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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 channel_->SetSend(enable); | 202 channel_->SetSend(enable); |
203 } | 203 } |
204 | 204 |
205 void SetSendParameters(const cricket::AudioSendParameters& params) { | 205 void SetSendParameters(const cricket::AudioSendParameters& params) { |
206 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 206 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
207 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 207 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
208 ASSERT_TRUE(channel_); | 208 ASSERT_TRUE(channel_); |
209 EXPECT_TRUE(channel_->SetSendParameters(params)); | 209 EXPECT_TRUE(channel_->SetSendParameters(params)); |
210 } | 210 } |
211 | 211 |
212 void SetAudioSend(uint32_t ssrc, bool enable, cricket::AudioSource* source) { | 212 void SetAudioSend(uint32_t ssrc, bool enable, cricket::AudioSource* source, |
| 213 const cricket::AudioOptions* options = nullptr) { |
213 EXPECT_CALL(apm_, set_output_will_be_muted(!enable)); | 214 EXPECT_CALL(apm_, set_output_will_be_muted(!enable)); |
214 ASSERT_TRUE(channel_); | 215 ASSERT_TRUE(channel_); |
215 EXPECT_TRUE(channel_->SetAudioSend(ssrc, enable, nullptr, source)); | 216 if (enable && options) { |
| 217 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
| 218 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
| 219 } |
| 220 EXPECT_TRUE(channel_->SetAudioSend(ssrc, enable, options, source)); |
216 } | 221 } |
217 | 222 |
218 void TestInsertDtmf(uint32_t ssrc, bool caller) { | 223 void TestInsertDtmf(uint32_t ssrc, bool caller) { |
219 EXPECT_TRUE(SetupChannel()); | 224 EXPECT_TRUE(SetupChannel()); |
220 if (caller) { | 225 if (caller) { |
221 // If this is a caller, local description will be applied and add the | 226 // If this is a caller, local description will be applied and add the |
222 // send stream. | 227 // send stream. |
223 EXPECT_TRUE(channel_->AddSendStream( | 228 EXPECT_TRUE(channel_->AddSendStream( |
224 cricket::StreamParams::CreateLegacy(kSsrc1))); | 229 cricket::StreamParams::CreateLegacy(kSsrc1))); |
225 } | 230 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 } | 318 } |
314 | 319 |
315 int GetCodecBitrate(int32_t ssrc) { | 320 int GetCodecBitrate(int32_t ssrc) { |
316 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.rate; | 321 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.rate; |
317 } | 322 } |
318 | 323 |
319 int GetCodecPacSize(int32_t ssrc) { | 324 int GetCodecPacSize(int32_t ssrc) { |
320 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.pacsize; | 325 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.pacsize; |
321 } | 326 } |
322 | 327 |
| 328 const rtc::Optional<std::string>& GetAudioNetworkAdaptorConfig(int32_t ssrc) { |
| 329 return GetSendStreamConfig(ssrc).audio_network_adaptor_config; |
| 330 } |
| 331 |
323 void SetAndExpectMaxBitrate(const cricket::AudioCodec& codec, | 332 void SetAndExpectMaxBitrate(const cricket::AudioCodec& codec, |
324 int global_max, | 333 int global_max, |
325 int stream_max, | 334 int stream_max, |
326 bool expected_result, | 335 bool expected_result, |
327 int expected_codec_bitrate) { | 336 int expected_codec_bitrate) { |
328 // Clear the bitrate limit from the previous test case. | 337 // Clear the bitrate limit from the previous test case. |
329 EXPECT_TRUE(SetMaxBitrateForStream(kSsrc1, -1)); | 338 EXPECT_TRUE(SetMaxBitrateForStream(kSsrc1, -1)); |
330 | 339 |
331 // Attempt to set the requested bitrate limits. | 340 // Attempt to set the requested bitrate limits. |
332 SetGlobalMaxBitrate(codec, global_max); | 341 SetGlobalMaxBitrate(codec, global_max); |
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2360 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { | 2369 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { |
2361 EXPECT_TRUE(SetupSendStream()); | 2370 EXPECT_TRUE(SetupSendStream()); |
2362 EXPECT_CALL(adm_, SetRecordingSampleRate(48000)).WillOnce(Return(0)); | 2371 EXPECT_CALL(adm_, SetRecordingSampleRate(48000)).WillOnce(Return(0)); |
2363 EXPECT_CALL(adm_, SetPlayoutSampleRate(44100)).WillOnce(Return(0)); | 2372 EXPECT_CALL(adm_, SetPlayoutSampleRate(44100)).WillOnce(Return(0)); |
2364 send_parameters_.options.recording_sample_rate = | 2373 send_parameters_.options.recording_sample_rate = |
2365 rtc::Optional<uint32_t>(48000); | 2374 rtc::Optional<uint32_t>(48000); |
2366 send_parameters_.options.playout_sample_rate = rtc::Optional<uint32_t>(44100); | 2375 send_parameters_.options.playout_sample_rate = rtc::Optional<uint32_t>(44100); |
2367 SetSendParameters(send_parameters_); | 2376 SetSendParameters(send_parameters_); |
2368 } | 2377 } |
2369 | 2378 |
| 2379 TEST_F(WebRtcVoiceEngineTestFake, SetAudioNetworkAdaptorViaOptions) { |
| 2380 EXPECT_TRUE(SetupSendStream()); |
| 2381 send_parameters_.options.audio_network_adaptor = rtc::Optional<bool>(true); |
| 2382 send_parameters_.options.audio_network_adaptor_config = |
| 2383 rtc::Optional<std::string>("1234"); |
| 2384 SetSendParameters(send_parameters_); |
| 2385 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config, |
| 2386 GetAudioNetworkAdaptorConfig(kSsrc1)); |
| 2387 } |
| 2388 |
| 2389 TEST_F(WebRtcVoiceEngineTestFake, AudioSendResetAudioNetworkAdaptor) { |
| 2390 EXPECT_TRUE(SetupSendStream()); |
| 2391 send_parameters_.options.audio_network_adaptor = rtc::Optional<bool>(true); |
| 2392 send_parameters_.options.audio_network_adaptor_config = |
| 2393 rtc::Optional<std::string>("1234"); |
| 2394 SetSendParameters(send_parameters_); |
| 2395 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config, |
| 2396 GetAudioNetworkAdaptorConfig(kSsrc1)); |
| 2397 const int initial_num = call_.GetNumCreatedSendStreams(); |
| 2398 cricket::AudioOptions options; |
| 2399 options.audio_network_adaptor = rtc::Optional<bool>(false); |
| 2400 SetAudioSend(kSsrc1, true, nullptr, &options); |
| 2401 // AudioSendStream expected to be recreated. |
| 2402 EXPECT_EQ(initial_num + 1, call_.GetNumCreatedSendStreams()); |
| 2403 EXPECT_EQ(rtc::Optional<std::string>(), GetAudioNetworkAdaptorConfig(kSsrc1)); |
| 2404 } |
| 2405 |
| 2406 TEST_F(WebRtcVoiceEngineTestFake, AudioNetworkAdaptorNotGetOverridden) { |
| 2407 EXPECT_TRUE(SetupSendStream()); |
| 2408 send_parameters_.options.audio_network_adaptor = rtc::Optional<bool>(true); |
| 2409 send_parameters_.options.audio_network_adaptor_config = |
| 2410 rtc::Optional<std::string>("1234"); |
| 2411 SetSendParameters(send_parameters_); |
| 2412 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config, |
| 2413 GetAudioNetworkAdaptorConfig(kSsrc1)); |
| 2414 const int initial_num = call_.GetNumCreatedSendStreams(); |
| 2415 cricket::AudioOptions options; |
| 2416 options.audio_network_adaptor = rtc::Optional<bool>(); |
| 2417 // Unvalued |options.audio_network_adaptor|.should not reset audio network |
| 2418 // adaptor. |
| 2419 SetAudioSend(kSsrc1, true, nullptr, &options); |
| 2420 // AudioSendStream not expected to be recreated. |
| 2421 EXPECT_EQ(initial_num, call_.GetNumCreatedSendStreams()); |
| 2422 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config, |
| 2423 GetAudioNetworkAdaptorConfig(kSsrc1)); |
| 2424 } |
| 2425 |
2370 // Test that we can set the outgoing SSRC properly. | 2426 // Test that we can set the outgoing SSRC properly. |
2371 // SSRC is set in SetupSendStream() by calling AddSendStream. | 2427 // SSRC is set in SetupSendStream() by calling AddSendStream. |
2372 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { | 2428 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { |
2373 EXPECT_TRUE(SetupSendStream()); | 2429 EXPECT_TRUE(SetupSendStream()); |
2374 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); | 2430 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); |
2375 } | 2431 } |
2376 | 2432 |
2377 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { | 2433 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { |
2378 // Setup. We need send codec to be set to get all stats. | 2434 // Setup. We need send codec to be set to get all stats. |
2379 EXPECT_TRUE(SetupSendStream()); | 2435 EXPECT_TRUE(SetupSendStream()); |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3461 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); | 3517 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); |
3462 webrtc::RtcEventLogNullImpl event_log; | 3518 webrtc::RtcEventLogNullImpl event_log; |
3463 std::unique_ptr<webrtc::Call> call( | 3519 std::unique_ptr<webrtc::Call> call( |
3464 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3520 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
3465 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3521 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
3466 cricket::AudioOptions(), call.get()); | 3522 cricket::AudioOptions(), call.get()); |
3467 cricket::AudioRecvParameters parameters; | 3523 cricket::AudioRecvParameters parameters; |
3468 parameters.codecs = engine.recv_codecs(); | 3524 parameters.codecs = engine.recv_codecs(); |
3469 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3525 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3470 } | 3526 } |
OLD | NEW |