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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine_unittest.cc

Issue 1920123002: Cap the send bitrate for opus and iSAC before passing down to VoE. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Reverting patch set 3. Created 4 years, 8 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/media/engine/webrtcvoiceengine.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 (c) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 EXPECT_EQ(kTelephoneEventCodec.id, telephone_event.payload_type); 211 EXPECT_EQ(kTelephoneEventCodec.id, telephone_event.payload_type);
212 EXPECT_EQ(2, telephone_event.event_code); 212 EXPECT_EQ(2, telephone_event.event_code);
213 EXPECT_EQ(123, telephone_event.duration_ms); 213 EXPECT_EQ(123, telephone_event.duration_ms);
214 } 214 }
215 215
216 // Test that send bandwidth is set correctly. 216 // Test that send bandwidth is set correctly.
217 // |codec| is the codec under test. 217 // |codec| is the codec under test.
218 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth(). 218 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth().
219 // |expected_result| is the expected result from SetMaxSendBandwidth(). 219 // |expected_result| is the expected result from SetMaxSendBandwidth().
220 // |expected_bitrate| is the expected audio bitrate afterward. 220 // |expected_bitrate| is the expected audio bitrate afterward.
221 void TestSendBandwidth(const cricket::AudioCodec& codec, 221 void TestMaxSendBandwidth(const cricket::AudioCodec& codec,
222 int max_bitrate, 222 int max_bitrate,
223 bool expected_result, 223 bool expected_result,
224 int expected_bitrate) { 224 int expected_bitrate) {
225 cricket::AudioSendParameters parameters; 225 cricket::AudioSendParameters parameters;
226 parameters.codecs.push_back(codec); 226 parameters.codecs.push_back(codec);
227 parameters.max_bandwidth_bps = max_bitrate; 227 parameters.max_bandwidth_bps = max_bitrate;
228 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters)); 228 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters));
229 229
230 int channel_num = voe_.GetLastChannel(); 230 int channel_num = voe_.GetLastChannel();
231 webrtc::CodecInst temp_codec; 231 webrtc::CodecInst temp_codec;
232 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); 232 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec));
233 EXPECT_EQ(expected_bitrate, temp_codec.rate); 233 EXPECT_EQ(expected_bitrate, temp_codec.rate);
234 } 234 }
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 } 749 }
750 750
751 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { 751 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) {
752 EXPECT_TRUE(SetupSendStream()); 752 EXPECT_TRUE(SetupSendStream());
753 753
754 // Test that when autobw is enabled, bitrate is kept as the default 754 // Test that when autobw is enabled, bitrate is kept as the default
755 // value. autobw is enabled for the following tests because the target 755 // value. autobw is enabled for the following tests because the target
756 // bitrate is <= 0. 756 // bitrate is <= 0.
757 757
758 // ISAC, default bitrate == 32000. 758 // ISAC, default bitrate == 32000.
759 TestSendBandwidth(kIsacCodec, 0, true, 32000); 759 TestMaxSendBandwidth(kIsacCodec, 0, true, 32000);
760 760
761 // PCMU, default bitrate == 64000. 761 // PCMU, default bitrate == 64000.
762 TestSendBandwidth(kPcmuCodec, -1, true, 64000); 762 TestMaxSendBandwidth(kPcmuCodec, -1, true, 64000);
763 763
764 // opus, default bitrate == 64000. 764 // opus, default bitrate == 64000.
765 TestSendBandwidth(kOpusCodec, -1, true, 64000); 765 TestMaxSendBandwidth(kOpusCodec, -1, true, 64000);
766 } 766 }
767 767
768 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { 768 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) {
769 EXPECT_TRUE(SetupSendStream()); 769 EXPECT_TRUE(SetupSendStream());
770 770
771 // Test that the bitrate of a multi-rate codec is always the maximum. 771 // Test that the bitrate of a multi-rate codec is always the maximum.
772 772
773 // ISAC, default bitrate == 32000. 773 // ISAC, default bitrate == 32000.
774 TestSendBandwidth(kIsacCodec, 128000, true, 128000); 774 TestMaxSendBandwidth(kIsacCodec, 40000, true, 40000);
775 TestSendBandwidth(kIsacCodec, 16000, true, 16000); 775 TestMaxSendBandwidth(kIsacCodec, 16000, true, 16000);
776 // Rates above the max (56000) should be capped.
777 TestMaxSendBandwidth(kIsacCodec, 100000, true, 56000);
776 778
777 // opus, default bitrate == 64000. 779 // opus, default bitrate == 64000.
778 TestSendBandwidth(kOpusCodec, 96000, true, 96000); 780 TestMaxSendBandwidth(kOpusCodec, 96000, true, 96000);
779 TestSendBandwidth(kOpusCodec, 48000, true, 48000); 781 TestMaxSendBandwidth(kOpusCodec, 48000, true, 48000);
782 // Rates above the max (510000) should be capped.
783 TestMaxSendBandwidth(kOpusCodec, 600000, true, 510000);
780 } 784 }
781 785
782 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { 786 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) {
783 EXPECT_TRUE(SetupSendStream()); 787 EXPECT_TRUE(SetupSendStream());
784 788
785 // Test that we can only set a maximum bitrate for a fixed-rate codec 789 // Test that we can only set a maximum bitrate for a fixed-rate codec
786 // if it's bigger than the fixed rate. 790 // if it's bigger than the fixed rate.
787 791
788 // PCMU, fixed bitrate == 64000. 792 // PCMU, fixed bitrate == 64000.
789 TestSendBandwidth(kPcmuCodec, 0, true, 64000); 793 TestMaxSendBandwidth(kPcmuCodec, 0, true, 64000);
790 TestSendBandwidth(kPcmuCodec, 1, false, 64000); 794 TestMaxSendBandwidth(kPcmuCodec, 1, false, 64000);
791 TestSendBandwidth(kPcmuCodec, 128000, true, 64000); 795 TestMaxSendBandwidth(kPcmuCodec, 128000, true, 64000);
792 TestSendBandwidth(kPcmuCodec, 32000, false, 64000); 796 TestMaxSendBandwidth(kPcmuCodec, 32000, false, 64000);
793 TestSendBandwidth(kPcmuCodec, 64000, true, 64000); 797 TestMaxSendBandwidth(kPcmuCodec, 64000, true, 64000);
794 TestSendBandwidth(kPcmuCodec, 63999, false, 64000); 798 TestMaxSendBandwidth(kPcmuCodec, 63999, false, 64000);
795 TestSendBandwidth(kPcmuCodec, 64001, true, 64000); 799 TestMaxSendBandwidth(kPcmuCodec, 64001, true, 64000);
796 } 800 }
797 801
798 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { 802 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) {
799 EXPECT_TRUE(SetupChannel()); 803 EXPECT_TRUE(SetupChannel());
800 const int kDesiredBitrate = 128000; 804 const int kDesiredBitrate = 128000;
801 cricket::AudioSendParameters parameters; 805 cricket::AudioSendParameters parameters;
802 parameters.codecs = engine_->codecs(); 806 parameters.codecs = engine_->codecs();
803 parameters.max_bandwidth_bps = kDesiredBitrate; 807 parameters.max_bandwidth_bps = kDesiredBitrate;
804 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 808 EXPECT_TRUE(channel_->SetSendParameters(parameters));
805 809
(...skipping 2758 matching lines...) Expand 10 before | Expand all | Expand 10 after
3564 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { 3568 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
3565 cricket::WebRtcVoiceEngine engine(nullptr); 3569 cricket::WebRtcVoiceEngine engine(nullptr);
3566 std::unique_ptr<webrtc::Call> call( 3570 std::unique_ptr<webrtc::Call> call(
3567 webrtc::Call::Create(webrtc::Call::Config())); 3571 webrtc::Call::Create(webrtc::Call::Config()));
3568 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3572 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3569 cricket::AudioOptions(), call.get()); 3573 cricket::AudioOptions(), call.get());
3570 cricket::AudioRecvParameters parameters; 3574 cricket::AudioRecvParameters parameters;
3571 parameters.codecs = engine.codecs(); 3575 parameters.codecs = engine.codecs();
3572 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3576 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3573 } 3577 }
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698