OLD | NEW |
---|---|
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 parameters.codecs.push_back(codec); | 193 parameters.codecs.push_back(codec); |
194 parameters.max_bandwidth_bps = max_bitrate; | 194 parameters.max_bandwidth_bps = max_bitrate; |
195 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters)); | 195 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters)); |
196 | 196 |
197 int channel_num = voe_.GetLastChannel(); | 197 int channel_num = voe_.GetLastChannel(); |
198 webrtc::CodecInst temp_codec; | 198 webrtc::CodecInst temp_codec; |
199 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); | 199 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); |
200 EXPECT_EQ(expected_bitrate, temp_codec.rate); | 200 EXPECT_EQ(expected_bitrate, temp_codec.rate); |
201 } | 201 } |
202 | 202 |
203 void TestSendStreamBitrate(const cricket::AudioCodec& codec, | |
204 int max_bitrate_global, | |
205 int max_bitrate_ssrc, | |
206 bool expected_result, | |
207 int expected_bitrate) { | |
208 // clear the bitrate limit from the previous test case | |
209 webrtc::RTCRtpParameters rtp_parameters = | |
210 channel_->GetRtpParameters(kSsrc1); | |
211 EXPECT_EQ(1UL, rtp_parameters.encodings.size()); | |
212 rtp_parameters.encodings[0].max_bitrate_bps = -1; | |
213 EXPECT_TRUE(channel_->SetRtpParameters(kSsrc1, rtp_parameters)); | |
214 | |
215 // Attempt to set the requested bitrate limits | |
216 cricket::AudioSendParameters send_parameters; | |
217 send_parameters.codecs.push_back(codec); | |
218 send_parameters.max_bandwidth_bps = max_bitrate_global; | |
219 EXPECT_TRUE(channel_->SetSendParameters(send_parameters)); | |
220 | |
221 rtp_parameters.encodings[0].max_bitrate_bps = max_bitrate_ssrc; | |
222 EXPECT_EQ(expected_result, | |
223 channel_->SetRtpParameters(kSsrc1, rtp_parameters)); | |
224 | |
225 // Verify that reading back the parameters gives results | |
226 // consistent with the Set() result | |
227 webrtc::RTCRtpParameters resulting_parameters = | |
228 channel_->GetRtpParameters(kSsrc1); | |
229 EXPECT_EQ(1UL, resulting_parameters.encodings.size()); | |
230 EXPECT_EQ(expected_result ? max_bitrate_ssrc : -1, | |
231 resulting_parameters.encodings[0].max_bitrate_bps); | |
232 | |
233 // Verify that the codec settings have the expected bitrate | |
234 int channel_num = voe_.GetLastChannel(); | |
235 webrtc::CodecInst temp_codec; | |
236 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); | |
237 EXPECT_EQ(expected_bitrate, temp_codec.rate); | |
238 } | |
239 | |
203 void TestSetSendRtpHeaderExtensions(const std::string& ext) { | 240 void TestSetSendRtpHeaderExtensions(const std::string& ext) { |
204 EXPECT_TRUE(SetupEngineWithSendStream()); | 241 EXPECT_TRUE(SetupEngineWithSendStream()); |
205 | 242 |
206 // Ensure extensions are off by default. | 243 // Ensure extensions are off by default. |
207 EXPECT_EQ(0u, GetSendStreamConfig(kSsrc1).rtp.extensions.size()); | 244 EXPECT_EQ(0u, GetSendStreamConfig(kSsrc1).rtp.extensions.size()); |
208 | 245 |
209 // Ensure unknown extensions won't cause an error. | 246 // Ensure unknown extensions won't cause an error. |
210 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( | 247 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
211 "urn:ietf:params:unknownextention", 1)); | 248 "urn:ietf:params:unknownextention", 1)); |
212 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 249 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 799 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
763 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 800 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
764 EXPECT_EQ(64000, codec.rate); | 801 EXPECT_EQ(64000, codec.rate); |
765 | 802 |
766 send_parameters_.max_bandwidth_bps = 128; | 803 send_parameters_.max_bandwidth_bps = 128; |
767 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); | 804 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); |
768 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 805 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
769 EXPECT_EQ(64000, codec.rate); | 806 EXPECT_EQ(64000, codec.rate); |
770 } | 807 } |
771 | 808 |
809 // Test that the per-stream bitrate limit and the global | |
810 // bitrate limit both apply | |
811 TEST_F(WebRtcVoiceEngineTestFake, SetMaxBitratePerStream) { | |
812 EXPECT_TRUE(SetupEngineWithSendStream()); | |
813 | |
814 // opus, default bitrate == 64000. | |
815 TestSendStreamBitrate(kOpusCodec, 0, 0, true, 64000); | |
816 TestSendStreamBitrate(kOpusCodec, 48000, 0, true, 48000); | |
817 TestSendStreamBitrate(kOpusCodec, 48000, 64000, true, 48000); | |
818 TestSendStreamBitrate(kOpusCodec, 64000, 48000, true, 48000); | |
819 | |
820 // CBR codecs allow both maximums to exceed the bitrate | |
821 TestSendStreamBitrate(kPcmuCodec, 0, 0, true, 64000); | |
822 TestSendStreamBitrate(kPcmuCodec, 64001, 0, true, 64000); | |
823 TestSendStreamBitrate(kPcmuCodec, 0, 64001, true, 64000); | |
824 TestSendStreamBitrate(kPcmuCodec, 64001, 64001, true, 64000); | |
825 | |
826 // CBR codecs don't allow per stream maximums to be too low | |
827 TestSendStreamBitrate(kPcmuCodec, 0, 63999, false, 64000); | |
828 TestSendStreamBitrate(kPcmuCodec, 64001, 63999, false, 64000); | |
829 } | |
830 | |
831 TEST_F(WebRtcVoiceEngineTestFake, CannotSetMaxBitrateForNonexistentStream) { | |
832 EXPECT_TRUE(SetupEngine()); | |
833 webrtc::RTCRtpParameters nonexistent_parameters = | |
834 channel_->GetRtpParameters(kSsrc1); | |
835 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); | |
836 | |
837 nonexistent_parameters.encodings.push_back( | |
838 webrtc::RTCRtpEncodingParameters()); | |
839 EXPECT_FALSE(channel_->SetRtpParameters(kSsrc1, nonexistent_parameters)); | |
840 } | |
841 | |
842 TEST_F(WebRtcVoiceEngineTestFake, | |
843 CannotSetRtpParametersWithIncorrectNumberOfEncodings) { | |
Taylor Brandstetter
2016/03/12 01:57:06
If you add a TODO comment for the other "Incorrect
skvlad
2016/03/15 21:18:18
Done.
| |
844 EXPECT_TRUE(SetupEngineWithSendStream()); | |
845 // no encodings - should fail | |
846 webrtc::RTCRtpParameters parameters; | |
847 EXPECT_FALSE(channel_->SetRtpParameters(kSsrc1, parameters)); | |
848 // one encoding - expected to succeed | |
849 parameters.encodings.push_back(webrtc::RTCRtpEncodingParameters()); | |
850 EXPECT_TRUE(channel_->SetRtpParameters(kSsrc1, parameters)); | |
851 // two encodings - too many | |
852 parameters.encodings.push_back(webrtc::RTCRtpEncodingParameters()); | |
853 EXPECT_FALSE(channel_->SetRtpParameters(kSsrc1, parameters)); | |
854 } | |
855 | |
772 // Test that we apply codecs properly. | 856 // Test that we apply codecs properly. |
773 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { | 857 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { |
774 EXPECT_TRUE(SetupEngineWithSendStream()); | 858 EXPECT_TRUE(SetupEngineWithSendStream()); |
775 cricket::AudioSendParameters parameters; | 859 cricket::AudioSendParameters parameters; |
776 parameters.codecs.push_back(kIsacCodec); | 860 parameters.codecs.push_back(kIsacCodec); |
777 parameters.codecs.push_back(kPcmuCodec); | 861 parameters.codecs.push_back(kPcmuCodec); |
778 parameters.codecs.push_back(kRedCodec); | 862 parameters.codecs.push_back(kRedCodec); |
779 parameters.codecs[0].id = 96; | 863 parameters.codecs[0].id = 96; |
780 parameters.codecs[0].bitrate = 48000; | 864 parameters.codecs[0].bitrate = 48000; |
781 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 865 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
(...skipping 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3292 cricket::WebRtcVoiceEngine engine; | 3376 cricket::WebRtcVoiceEngine engine; |
3293 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3377 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
3294 std::unique_ptr<webrtc::Call> call( | 3378 std::unique_ptr<webrtc::Call> call( |
3295 webrtc::Call::Create(webrtc::Call::Config())); | 3379 webrtc::Call::Create(webrtc::Call::Config())); |
3296 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3380 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
3297 cricket::AudioOptions(), call.get()); | 3381 cricket::AudioOptions(), call.get()); |
3298 cricket::AudioRecvParameters parameters; | 3382 cricket::AudioRecvParameters parameters; |
3299 parameters.codecs = engine.codecs(); | 3383 parameters.codecs = engine.codecs(); |
3300 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3384 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3301 } | 3385 } |
OLD | NEW |