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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 } | 313 } |
314 | 314 |
315 int GetCodecBitrate(int32_t ssrc) { | 315 int GetCodecBitrate(int32_t ssrc) { |
316 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.rate; | 316 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.rate; |
317 } | 317 } |
318 | 318 |
319 int GetCodecPacSize(int32_t ssrc) { | 319 int GetCodecPacSize(int32_t ssrc) { |
320 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.pacsize; | 320 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.pacsize; |
321 } | 321 } |
322 | 322 |
323 const rtc::Optional<std::string>& GetAudioNetworkAdaptorConfig(int32_t ssrc) { | |
324 return GetSendStreamConfig(ssrc).audio_network_adaptor_config; | |
325 } | |
326 | |
323 void SetAndExpectMaxBitrate(const cricket::AudioCodec& codec, | 327 void SetAndExpectMaxBitrate(const cricket::AudioCodec& codec, |
324 int global_max, | 328 int global_max, |
325 int stream_max, | 329 int stream_max, |
326 bool expected_result, | 330 bool expected_result, |
327 int expected_codec_bitrate) { | 331 int expected_codec_bitrate) { |
328 // Clear the bitrate limit from the previous test case. | 332 // Clear the bitrate limit from the previous test case. |
329 EXPECT_TRUE(SetMaxBitrateForStream(kSsrc1, -1)); | 333 EXPECT_TRUE(SetMaxBitrateForStream(kSsrc1, -1)); |
330 | 334 |
331 // Attempt to set the requested bitrate limits. | 335 // Attempt to set the requested bitrate limits. |
332 SetGlobalMaxBitrate(codec, global_max); | 336 SetGlobalMaxBitrate(codec, global_max); |
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2360 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { | 2364 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { |
2361 EXPECT_TRUE(SetupSendStream()); | 2365 EXPECT_TRUE(SetupSendStream()); |
2362 EXPECT_CALL(adm_, SetRecordingSampleRate(48000)).WillOnce(Return(0)); | 2366 EXPECT_CALL(adm_, SetRecordingSampleRate(48000)).WillOnce(Return(0)); |
2363 EXPECT_CALL(adm_, SetPlayoutSampleRate(44100)).WillOnce(Return(0)); | 2367 EXPECT_CALL(adm_, SetPlayoutSampleRate(44100)).WillOnce(Return(0)); |
2364 send_parameters_.options.recording_sample_rate = | 2368 send_parameters_.options.recording_sample_rate = |
2365 rtc::Optional<uint32_t>(48000); | 2369 rtc::Optional<uint32_t>(48000); |
2366 send_parameters_.options.playout_sample_rate = rtc::Optional<uint32_t>(44100); | 2370 send_parameters_.options.playout_sample_rate = rtc::Optional<uint32_t>(44100); |
2367 SetSendParameters(send_parameters_); | 2371 SetSendParameters(send_parameters_); |
2368 } | 2372 } |
2369 | 2373 |
2374 TEST_F(WebRtcVoiceEngineTestFake, SetAudioNetworkAdaptorViaOptions) { | |
2375 EXPECT_TRUE(SetupSendStream()); | |
2376 send_parameters_.options.audio_network_adaptor = rtc::Optional<bool>(true); | |
2377 send_parameters_.options.audio_network_adaptor_config = | |
2378 rtc::Optional<std::string>("1234"); | |
2379 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
the sun
2016/10/28 18:21:52
You may need to use the test utility "SetSendParam
minyue-webrtc
2016/10/28 18:41:57
I see, SetSendParameters is recently added. Will d
| |
2380 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config, | |
2381 GetAudioNetworkAdaptorConfig(kSsrc1)); | |
2382 } | |
2383 | |
2384 TEST_F(WebRtcVoiceEngineTestFake, AudioSendResetAudioNetworkAdaptor) { | |
2385 EXPECT_TRUE(SetupSendStream()); | |
2386 send_parameters_.options.audio_network_adaptor = rtc::Optional<bool>(true); | |
2387 send_parameters_.options.audio_network_adaptor_config = | |
2388 rtc::Optional<std::string>("1234"); | |
2389 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
2390 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config, | |
2391 GetAudioNetworkAdaptorConfig(kSsrc1)); | |
2392 const int initial_num = call_.GetNumCreatedSendStreams(); | |
2393 cricket::AudioOptions options; | |
2394 options.audio_network_adaptor = rtc::Optional<bool>(false); | |
2395 EXPECT_TRUE(channel_->SetAudioSend(kSsrc1, true, &options, nullptr)); | |
the sun
2016/10/28 18:21:52
There's a utility for SetAudioSend as well
minyue-webrtc
2016/10/28 18:41:57
will do
| |
2396 // AudioSendStream expected to be recreated. | |
2397 EXPECT_EQ(initial_num + 1, call_.GetNumCreatedSendStreams()); | |
2398 EXPECT_EQ(rtc::Optional<std::string>(), GetAudioNetworkAdaptorConfig(kSsrc1)); | |
2399 } | |
2400 | |
2401 TEST_F(WebRtcVoiceEngineTestFake, AudioNetworkAdaptorNotGetOverridden) { | |
2402 EXPECT_TRUE(SetupSendStream()); | |
2403 send_parameters_.options.audio_network_adaptor = rtc::Optional<bool>(true); | |
2404 send_parameters_.options.audio_network_adaptor_config = | |
2405 rtc::Optional<std::string>("1234"); | |
2406 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
2407 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config, | |
2408 GetAudioNetworkAdaptorConfig(kSsrc1)); | |
2409 const int initial_num = call_.GetNumCreatedSendStreams(); | |
2410 cricket::AudioOptions options; | |
2411 options.audio_network_adaptor = rtc::Optional<bool>(); | |
2412 // Unvalued |options.audio_network_adaptor|.should not reset audio network | |
2413 // adaptor. | |
2414 EXPECT_TRUE(channel_->SetAudioSend(kSsrc1, true, &options, nullptr)); | |
2415 // AudioSendStream not expected to be recreated. | |
2416 EXPECT_EQ(initial_num, call_.GetNumCreatedSendStreams()); | |
2417 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config, | |
2418 GetAudioNetworkAdaptorConfig(kSsrc1)); | |
2419 } | |
2420 | |
2370 // Test that we can set the outgoing SSRC properly. | 2421 // Test that we can set the outgoing SSRC properly. |
2371 // SSRC is set in SetupSendStream() by calling AddSendStream. | 2422 // SSRC is set in SetupSendStream() by calling AddSendStream. |
2372 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { | 2423 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { |
2373 EXPECT_TRUE(SetupSendStream()); | 2424 EXPECT_TRUE(SetupSendStream()); |
2374 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); | 2425 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); |
2375 } | 2426 } |
2376 | 2427 |
2377 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { | 2428 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { |
2378 // Setup. We need send codec to be set to get all stats. | 2429 // Setup. We need send codec to be set to get all stats. |
2379 EXPECT_TRUE(SetupSendStream()); | 2430 EXPECT_TRUE(SetupSendStream()); |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3461 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); | 3512 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); |
3462 webrtc::RtcEventLogNullImpl event_log; | 3513 webrtc::RtcEventLogNullImpl event_log; |
3463 std::unique_ptr<webrtc::Call> call( | 3514 std::unique_ptr<webrtc::Call> call( |
3464 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3515 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
3465 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3516 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
3466 cricket::AudioOptions(), call.get()); | 3517 cricket::AudioOptions(), call.get()); |
3467 cricket::AudioRecvParameters parameters; | 3518 cricket::AudioRecvParameters parameters; |
3468 parameters.codecs = engine.recv_codecs(); | 3519 parameters.codecs = engine.recv_codecs(); |
3469 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3520 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3470 } | 3521 } |
OLD | NEW |