Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: webrtc/pc/channel_unittest.cc

Issue 1813763005: Updated structures and functions for setting the max bitrate limit to take rtc::Optional<int> Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More code review feedback Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 EXPECT_FALSE(media_channel1_->ready_to_send()); 1803 EXPECT_FALSE(media_channel1_->ready_to_send());
1804 } 1804 }
1805 1805
1806 bool SetRemoteContentWithBitrateLimit(int remote_limit) { 1806 bool SetRemoteContentWithBitrateLimit(int remote_limit) {
1807 typename T::Content content; 1807 typename T::Content content;
1808 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1808 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1809 content.set_bandwidth(remote_limit); 1809 content.set_bandwidth(remote_limit);
1810 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); 1810 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL);
1811 } 1811 }
1812 1812
1813 webrtc::RtpParameters BitrateLimitedParameters(int limit) { 1813 webrtc::RtpParameters BitrateLimitedParameters(rtc::Optional<int> limit) {
1814 webrtc::RtpParameters parameters; 1814 webrtc::RtpParameters parameters;
1815 webrtc::RtpEncodingParameters encoding; 1815 webrtc::RtpEncodingParameters encoding;
1816 encoding.max_bitrate_bps = limit; 1816 encoding.max_bitrate_bps = limit;
1817 parameters.encodings.push_back(encoding); 1817 parameters.encodings.push_back(encoding);
1818 return parameters; 1818 return parameters;
1819 } 1819 }
1820 1820
1821 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters, 1821 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters,
1822 int expected_bitrate) { 1822 rtc::Optional<int> expected_bitrate) {
1823 EXPECT_EQ(1UL, parameters.encodings.size()); 1823 EXPECT_EQ(1UL, parameters.encodings.size());
1824 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps); 1824 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps);
1825 } 1825 }
1826 1826
1827 void DefaultMaxBitrateIsUnlimited() { 1827 void DefaultMaxBitrateIsUnlimited() {
1828 CreateChannels(0, 0); 1828 CreateChannels(0, 0);
1829 EXPECT_TRUE( 1829 EXPECT_TRUE(
1830 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); 1830 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
1831 EXPECT_EQ(media_channel1_->max_bps(), -1); 1831 EXPECT_EQ(rtc::Optional<int>(), media_channel1_->max_bps());
1832 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); 1832 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1),
1833 rtc::Optional<int>());
1833 } 1834 }
1834 1835
1835 void CanChangeMaxBitrate() { 1836 void CanChangeMaxBitrate() {
1836 CreateChannels(0, 0); 1837 CreateChannels(0, 0);
1837 EXPECT_TRUE( 1838 EXPECT_TRUE(
1838 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); 1839 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
1839 1840
1840 EXPECT_TRUE( 1841 EXPECT_TRUE(channel1_->SetRtpParameters(
1841 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000))); 1842 kSsrc1, BitrateLimitedParameters(rtc::Optional<int>(1000))));
1842 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), 1000); 1843 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1),
1843 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), 1000); 1844 rtc::Optional<int>(1000));
1844 EXPECT_EQ(-1, media_channel1_->max_bps()); 1845 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1),
1846 rtc::Optional<int>(1000));
1847 EXPECT_EQ(rtc::Optional<int>(), media_channel1_->max_bps());
1845 1848
1846 EXPECT_TRUE( 1849 EXPECT_TRUE(channel1_->SetRtpParameters(
1847 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1))); 1850 kSsrc1, BitrateLimitedParameters(rtc::Optional<int>())));
1848 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1); 1851 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), rtc::Optional<int>());
1849 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); 1852 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1),
1850 EXPECT_EQ(-1, media_channel1_->max_bps()); 1853 rtc::Optional<int>());
1854 EXPECT_EQ(rtc::Optional<int>(), media_channel1_->max_bps());
1851 } 1855 }
1852 1856
1853 protected: 1857 protected:
1854 // TODO(pbos): Remove playout from all media channels and let renderers mute 1858 // TODO(pbos): Remove playout from all media channels and let renderers mute
1855 // themselves. 1859 // themselves.
1856 const bool verify_playout_; 1860 const bool verify_playout_;
1857 cricket::FakeTransportController transport_controller1_; 1861 cricket::FakeTransportController transport_controller1_;
1858 cricket::FakeTransportController transport_controller2_; 1862 cricket::FakeTransportController transport_controller2_;
1859 cricket::FakeMediaEngine media_engine_; 1863 cricket::FakeMediaEngine media_engine_;
1860 // The media channels are owned by the voice channel objects below. 1864 // The media channels are owned by the voice channel objects below.
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 EXPECT_TRUE( 2323 EXPECT_TRUE(
2320 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); 2324 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
2321 webrtc::RtpParameters voice_parameters = channel1_->GetRtpParameters(kSsrc1); 2325 webrtc::RtpParameters voice_parameters = channel1_->GetRtpParameters(kSsrc1);
2322 EXPECT_EQ(0UL, voice_parameters.encodings.size()); 2326 EXPECT_EQ(0UL, voice_parameters.encodings.size());
2323 } 2327 }
2324 2328
2325 TEST_F(VoiceChannelTest, SetRtpParametersIsNotImplemented) { 2329 TEST_F(VoiceChannelTest, SetRtpParametersIsNotImplemented) {
2326 CreateChannels(0, 0); 2330 CreateChannels(0, 0);
2327 EXPECT_TRUE( 2331 EXPECT_TRUE(
2328 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); 2332 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
2329 EXPECT_FALSE( 2333 EXPECT_FALSE(channel1_->SetRtpParameters(
2330 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000))); 2334 kSsrc1, BitrateLimitedParameters(rtc::Optional<int>(1000))));
2331 } 2335 }
2332 2336
2333 // VideoChannelTest 2337 // VideoChannelTest
2334 TEST_F(VideoChannelTest, TestInit) { 2338 TEST_F(VideoChannelTest, TestInit) {
2335 Base::TestInit(); 2339 Base::TestInit();
2336 } 2340 }
2337 2341
2338 TEST_F(VideoChannelTest, TestSetContents) { 2342 TEST_F(VideoChannelTest, TestSetContents) {
2339 Base::TestSetContents(); 2343 Base::TestSetContents();
2340 } 2344 }
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 }; 2775 };
2772 rtc::Buffer payload(data, 3); 2776 rtc::Buffer payload(data, 3);
2773 cricket::SendDataResult result; 2777 cricket::SendDataResult result;
2774 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 2778 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
2775 EXPECT_EQ(params.ssrc, 2779 EXPECT_EQ(params.ssrc,
2776 media_channel1_->last_sent_data_params().ssrc); 2780 media_channel1_->last_sent_data_params().ssrc);
2777 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 2781 EXPECT_EQ("foo", media_channel1_->last_sent_data());
2778 } 2782 }
2779 2783
2780 // TODO(pthatcher): TestSetReceiver? 2784 // TODO(pthatcher): TestSetReceiver?
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698