| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1842 EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1843 } | 1843 } |
| 1844 | 1844 |
| 1845 bool SetRemoteContentWithBitrateLimit(int remote_limit) { | 1845 bool SetRemoteContentWithBitrateLimit(int remote_limit) { |
| 1846 typename T::Content content; | 1846 typename T::Content content; |
| 1847 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 1847 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 1848 content.set_bandwidth(remote_limit); | 1848 content.set_bandwidth(remote_limit); |
| 1849 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); | 1849 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); |
| 1850 } | 1850 } |
| 1851 | 1851 |
| 1852 webrtc::RtpParameters BitrateLimitedParameters(int limit) { | 1852 webrtc::RtpParameters BitrateLimitedParameters(rtc::Optional<int> limit) { |
| 1853 webrtc::RtpParameters parameters; | 1853 webrtc::RtpParameters parameters; |
| 1854 webrtc::RtpEncodingParameters encoding; | 1854 webrtc::RtpEncodingParameters encoding; |
| 1855 encoding.max_bitrate_bps = limit; | 1855 encoding.max_bitrate_bps = limit; |
| 1856 parameters.encodings.push_back(encoding); | 1856 parameters.encodings.push_back(encoding); |
| 1857 return parameters; | 1857 return parameters; |
| 1858 } | 1858 } |
| 1859 | 1859 |
| 1860 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters, | 1860 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters, |
| 1861 int expected_bitrate) { | 1861 rtc::Optional<int> expected_bitrate) { |
| 1862 EXPECT_EQ(1UL, parameters.encodings.size()); | 1862 EXPECT_EQ(1UL, parameters.encodings.size()); |
| 1863 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps); | 1863 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps); |
| 1864 } | 1864 } |
| 1865 | 1865 |
| 1866 void DefaultMaxBitrateIsUnlimited() { | 1866 void DefaultMaxBitrateIsUnlimited() { |
| 1867 CreateChannels(0, 0); | 1867 CreateChannels(0, 0); |
| 1868 EXPECT_TRUE( | 1868 EXPECT_TRUE( |
| 1869 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); | 1869 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); |
| 1870 EXPECT_EQ(media_channel1_->max_bps(), -1); | 1870 EXPECT_EQ(rtc::Optional<int>(), media_channel1_->max_bps()); |
| 1871 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); | 1871 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), |
| 1872 rtc::Optional<int>()); |
| 1872 } | 1873 } |
| 1873 | 1874 |
| 1874 void CanChangeMaxBitrate() { | 1875 void CanChangeMaxBitrate() { |
| 1875 CreateChannels(0, 0); | 1876 CreateChannels(0, 0); |
| 1876 EXPECT_TRUE( | 1877 EXPECT_TRUE( |
| 1877 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); | 1878 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); |
| 1878 | 1879 |
| 1879 EXPECT_TRUE( | 1880 EXPECT_TRUE(channel1_->SetRtpParameters( |
| 1880 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000))); | 1881 kSsrc1, BitrateLimitedParameters(rtc::Optional<int>(1000)))); |
| 1881 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), 1000); | 1882 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), |
| 1882 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), 1000); | 1883 rtc::Optional<int>(1000)); |
| 1883 EXPECT_EQ(-1, media_channel1_->max_bps()); | 1884 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), |
| 1885 rtc::Optional<int>(1000)); |
| 1886 EXPECT_EQ(rtc::Optional<int>(), media_channel1_->max_bps()); |
| 1884 | 1887 |
| 1885 EXPECT_TRUE( | 1888 EXPECT_TRUE(channel1_->SetRtpParameters( |
| 1886 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1))); | 1889 kSsrc1, BitrateLimitedParameters(rtc::Optional<int>()))); |
| 1887 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1); | 1890 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), rtc::Optional<int>()); |
| 1888 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); | 1891 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), |
| 1889 EXPECT_EQ(-1, media_channel1_->max_bps()); | 1892 rtc::Optional<int>()); |
| 1893 EXPECT_EQ(rtc::Optional<int>(), media_channel1_->max_bps()); |
| 1890 } | 1894 } |
| 1891 | 1895 |
| 1892 protected: | 1896 protected: |
| 1893 // TODO(pbos): Remove playout from all media channels and let renderers mute | 1897 // TODO(pbos): Remove playout from all media channels and let renderers mute |
| 1894 // themselves. | 1898 // themselves. |
| 1895 const bool verify_playout_; | 1899 const bool verify_playout_; |
| 1896 cricket::FakeTransportController transport_controller1_; | 1900 cricket::FakeTransportController transport_controller1_; |
| 1897 cricket::FakeTransportController transport_controller2_; | 1901 cricket::FakeTransportController transport_controller2_; |
| 1898 cricket::FakeMediaEngine media_engine_; | 1902 cricket::FakeMediaEngine media_engine_; |
| 1899 // The media channels are owned by the voice channel objects below. | 1903 // The media channels are owned by the voice channel objects below. |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 EXPECT_TRUE( | 2366 EXPECT_TRUE( |
| 2363 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); | 2367 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); |
| 2364 webrtc::RtpParameters voice_parameters = channel1_->GetRtpParameters(kSsrc1); | 2368 webrtc::RtpParameters voice_parameters = channel1_->GetRtpParameters(kSsrc1); |
| 2365 EXPECT_EQ(0UL, voice_parameters.encodings.size()); | 2369 EXPECT_EQ(0UL, voice_parameters.encodings.size()); |
| 2366 } | 2370 } |
| 2367 | 2371 |
| 2368 TEST_F(VoiceChannelTest, SetRtpParametersIsNotImplemented) { | 2372 TEST_F(VoiceChannelTest, SetRtpParametersIsNotImplemented) { |
| 2369 CreateChannels(0, 0); | 2373 CreateChannels(0, 0); |
| 2370 EXPECT_TRUE( | 2374 EXPECT_TRUE( |
| 2371 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); | 2375 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); |
| 2372 EXPECT_FALSE( | 2376 EXPECT_FALSE(channel1_->SetRtpParameters( |
| 2373 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000))); | 2377 kSsrc1, BitrateLimitedParameters(rtc::Optional<int>(1000)))); |
| 2374 } | 2378 } |
| 2375 | 2379 |
| 2376 // VideoChannelTest | 2380 // VideoChannelTest |
| 2377 TEST_F(VideoChannelTest, TestInit) { | 2381 TEST_F(VideoChannelTest, TestInit) { |
| 2378 Base::TestInit(); | 2382 Base::TestInit(); |
| 2379 } | 2383 } |
| 2380 | 2384 |
| 2381 TEST_F(VideoChannelTest, TestSetContents) { | 2385 TEST_F(VideoChannelTest, TestSetContents) { |
| 2382 Base::TestSetContents(); | 2386 Base::TestSetContents(); |
| 2383 } | 2387 } |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2818 }; | 2822 }; |
| 2819 rtc::CopyOnWriteBuffer payload(data, 3); | 2823 rtc::CopyOnWriteBuffer payload(data, 3); |
| 2820 cricket::SendDataResult result; | 2824 cricket::SendDataResult result; |
| 2821 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); | 2825 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
| 2822 EXPECT_EQ(params.ssrc, | 2826 EXPECT_EQ(params.ssrc, |
| 2823 media_channel1_->last_sent_data_params().ssrc); | 2827 media_channel1_->last_sent_data_params().ssrc); |
| 2824 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 2828 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
| 2825 } | 2829 } |
| 2826 | 2830 |
| 2827 // TODO(pthatcher): TestSetReceiver? | 2831 // TODO(pthatcher): TestSetReceiver? |
| OLD | NEW |