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

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

Issue 1788583004: Enable setting the maximum bitrate limit in RtpSender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased on top of the latest master branch 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
« no previous file with comments | « webrtc/pc/channel.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 TransportChannel* rtp = channel1_->transport_channel(); 1762 TransportChannel* rtp = channel1_->transport_channel();
1763 EXPECT_FALSE(media_channel1_->ready_to_send()); 1763 EXPECT_FALSE(media_channel1_->ready_to_send());
1764 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel 1764 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel
1765 // should trigger the MediaChannel's OnReadyToSend. 1765 // should trigger the MediaChannel's OnReadyToSend.
1766 rtp->SignalReadyToSend(rtp); 1766 rtp->SignalReadyToSend(rtp);
1767 EXPECT_TRUE(media_channel1_->ready_to_send()); 1767 EXPECT_TRUE(media_channel1_->ready_to_send());
1768 channel1_->SetReadyToSend(false, false); 1768 channel1_->SetReadyToSend(false, false);
1769 EXPECT_FALSE(media_channel1_->ready_to_send()); 1769 EXPECT_FALSE(media_channel1_->ready_to_send());
1770 } 1770 }
1771 1771
1772 bool SetRemoteContentWithBitrateLimit(int remote_limit) {
1773 typename T::Content content;
1774 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1775 content.set_bandwidth(remote_limit);
1776 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL);
1777 }
1778
1779 webrtc::RtpParameters BitrateLimitedParameters(int limit) {
1780 webrtc::RtpParameters parameters;
1781 webrtc::RtpEncodingParameters encoding;
1782 encoding.max_bitrate_bps = limit;
1783 parameters.encodings.push_back(encoding);
1784 return parameters;
1785 }
1786
1787 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters,
1788 int expected_bitrate) {
1789 EXPECT_EQ(1UL, parameters.encodings.size());
1790 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps);
1791 }
1792
1793 void DefaultMaxBitrateIsUnlimited() {
1794 CreateChannels(0, 0);
1795 EXPECT_TRUE(
1796 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
1797 EXPECT_EQ(media_channel1_->max_bps(), -1);
1798 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1);
1799 }
1800
1801 void CanChangeMaxBitrate() {
1802 CreateChannels(0, 0);
1803 EXPECT_TRUE(
1804 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
1805
1806 EXPECT_TRUE(
1807 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000)));
1808 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), 1000);
1809 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), 1000);
1810 EXPECT_EQ(-1, media_channel1_->max_bps());
1811
1812 EXPECT_TRUE(
1813 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1)));
1814 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1);
1815 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1);
1816 EXPECT_EQ(-1, media_channel1_->max_bps());
1817 }
1818
1772 protected: 1819 protected:
1773 // TODO(pbos): Remove playout from all media channels and let renderers mute 1820 // TODO(pbos): Remove playout from all media channels and let renderers mute
1774 // themselves. 1821 // themselves.
1775 const bool verify_playout_; 1822 const bool verify_playout_;
1776 cricket::FakeTransportController transport_controller1_; 1823 cricket::FakeTransportController transport_controller1_;
1777 cricket::FakeTransportController transport_controller2_; 1824 cricket::FakeTransportController transport_controller2_;
1778 cricket::FakeMediaEngine media_engine_; 1825 cricket::FakeMediaEngine media_engine_;
1779 // The media channels are owned by the voice channel objects below. 1826 // The media channels are owned by the voice channel objects below.
1780 typename T::MediaChannel* media_channel1_; 1827 typename T::MediaChannel* media_channel1_;
1781 typename T::MediaChannel* media_channel2_; 1828 typename T::MediaChannel* media_channel2_;
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 } 2269 }
2223 2270
2224 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) { 2271 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) {
2225 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false); 2272 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
2226 } 2273 }
2227 2274
2228 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) { 2275 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) {
2229 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true); 2276 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
2230 } 2277 }
2231 2278
2279 TEST_F(VoiceChannelTest, GetRtpParametersIsNotImplemented) {
2280 // These tests verify that the Get/SetRtpParameters methods for VoiceChannel
2281 // always fail as they are not implemented.
2282 // TODO(skvlad): Replace with full tests when support for bitrate limiting
2283 // for audio RtpSenders is added.
2284 CreateChannels(0, 0);
2285 EXPECT_TRUE(
2286 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
2287 webrtc::RtpParameters voice_parameters = channel1_->GetRtpParameters(kSsrc1);
2288 EXPECT_EQ(0UL, voice_parameters.encodings.size());
2289 }
2290
2291 TEST_F(VoiceChannelTest, SetRtpParametersIsNotImplemented) {
2292 CreateChannels(0, 0);
2293 EXPECT_TRUE(
2294 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
2295 EXPECT_FALSE(
2296 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000)));
2297 }
2298
2232 // VideoChannelTest 2299 // VideoChannelTest
2233 TEST_F(VideoChannelTest, TestInit) { 2300 TEST_F(VideoChannelTest, TestInit) {
2234 Base::TestInit(); 2301 Base::TestInit();
2235 } 2302 }
2236 2303
2237 TEST_F(VideoChannelTest, TestSetContents) { 2304 TEST_F(VideoChannelTest, TestSetContents) {
2238 Base::TestSetContents(); 2305 Base::TestSetContents();
2239 } 2306 }
2240 2307
2241 TEST_F(VideoChannelTest, TestSetContentsNullOffer) { 2308 TEST_F(VideoChannelTest, TestSetContentsNullOffer) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 } 2517 }
2451 2518
2452 TEST_F(VideoChannelTest, TestOnReadyToSend) { 2519 TEST_F(VideoChannelTest, TestOnReadyToSend) {
2453 Base::TestOnReadyToSend(); 2520 Base::TestOnReadyToSend();
2454 } 2521 }
2455 2522
2456 TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) { 2523 TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) {
2457 Base::TestOnReadyToSendWithRtcpMux(); 2524 Base::TestOnReadyToSendWithRtcpMux();
2458 } 2525 }
2459 2526
2527 TEST_F(VideoChannelTest, DefaultMaxBitrateIsUnlimited) {
2528 Base::DefaultMaxBitrateIsUnlimited();
2529 }
2530
2531 TEST_F(VideoChannelTest, CanChangeMaxBitrate) {
2532 Base::CanChangeMaxBitrate();
2533 }
2534
2460 // DataChannelTest 2535 // DataChannelTest
2461 2536
2462 class DataChannelTest 2537 class DataChannelTest
2463 : public ChannelTest<DataTraits> { 2538 : public ChannelTest<DataTraits> {
2464 public: 2539 public:
2465 typedef ChannelTest<DataTraits> 2540 typedef ChannelTest<DataTraits>
2466 Base; 2541 Base;
2467 DataChannelTest() 2542 DataChannelTest()
2468 : Base(true, 2543 : Base(true,
2469 kDataPacket, 2544 kDataPacket,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 }; 2737 };
2663 rtc::Buffer payload(data, 3); 2738 rtc::Buffer payload(data, 3);
2664 cricket::SendDataResult result; 2739 cricket::SendDataResult result;
2665 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 2740 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
2666 EXPECT_EQ(params.ssrc, 2741 EXPECT_EQ(params.ssrc,
2667 media_channel1_->last_sent_data_params().ssrc); 2742 media_channel1_->last_sent_data_params().ssrc);
2668 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 2743 EXPECT_EQ("foo", media_channel1_->last_sent_data());
2669 } 2744 }
2670 2745
2671 // TODO(pthatcher): TestSetReceiver? 2746 // TODO(pthatcher): TestSetReceiver?
OLDNEW
« no previous file with comments | « webrtc/pc/channel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698