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

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

Issue 2397573006: Using AudioOption to enable audio network adaptor. (Closed)
Patch Set: fixing some problems Created 4 years, 1 month 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
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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 284
285 int GetCodecBitrate(int32_t ssrc) { 285 int GetCodecBitrate(int32_t ssrc) {
286 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.rate; 286 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.rate;
287 } 287 }
288 288
289 int GetCodecPacSize(int32_t ssrc) { 289 int GetCodecPacSize(int32_t ssrc) {
290 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.pacsize; 290 return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.pacsize;
291 } 291 }
292 292
293 const rtc::Optional<std::string>& GetAudioNetworkAdaptorConfig(int32_t ssrc) {
294 return GetSendStreamConfig(ssrc).audio_network_adaptor_config;
295 }
296
293 void SetAndExpectMaxBitrate(const cricket::AudioCodec& codec, 297 void SetAndExpectMaxBitrate(const cricket::AudioCodec& codec,
294 int global_max, 298 int global_max,
295 int stream_max, 299 int stream_max,
296 bool expected_result, 300 bool expected_result,
297 int expected_codec_bitrate) { 301 int expected_codec_bitrate) {
298 // Clear the bitrate limit from the previous test case. 302 // Clear the bitrate limit from the previous test case.
299 EXPECT_TRUE(SetMaxBitrateForStream(kSsrc1, -1)); 303 EXPECT_TRUE(SetMaxBitrateForStream(kSsrc1, -1));
300 304
301 // Attempt to set the requested bitrate limits. 305 // Attempt to set the requested bitrate limits.
302 EXPECT_TRUE(SetGlobalMaxBitrate(codec, global_max)); 306 EXPECT_TRUE(SetGlobalMaxBitrate(codec, global_max));
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { 2331 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) {
2328 EXPECT_TRUE(SetupSendStream()); 2332 EXPECT_TRUE(SetupSendStream());
2329 EXPECT_CALL(adm_, SetRecordingSampleRate(48000)).WillOnce(Return(0)); 2333 EXPECT_CALL(adm_, SetRecordingSampleRate(48000)).WillOnce(Return(0));
2330 EXPECT_CALL(adm_, SetPlayoutSampleRate(44100)).WillOnce(Return(0)); 2334 EXPECT_CALL(adm_, SetPlayoutSampleRate(44100)).WillOnce(Return(0));
2331 send_parameters_.options.recording_sample_rate = 2335 send_parameters_.options.recording_sample_rate =
2332 rtc::Optional<uint32_t>(48000); 2336 rtc::Optional<uint32_t>(48000);
2333 send_parameters_.options.playout_sample_rate = rtc::Optional<uint32_t>(44100); 2337 send_parameters_.options.playout_sample_rate = rtc::Optional<uint32_t>(44100);
2334 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2338 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2335 } 2339 }
2336 2340
2341 TEST_F(WebRtcVoiceEngineTestFake, SetAudioNetworkAdaptorViaOptions) {
2342 EXPECT_TRUE(SetupSendStream());
2343 send_parameters_.options.audio_network_adaptor = rtc::Optional<bool>(true);
2344 send_parameters_.options.audio_network_adaptor_config =
2345 rtc::Optional<std::string>("1234");
2346 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2347 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config,
2348 GetAudioNetworkAdaptorConfig(kSsrc1));
2349 }
2350
2351 TEST_F(WebRtcVoiceEngineTestFake, AudioSendResetAudioNetworkAdaptor) {
2352 EXPECT_TRUE(SetupSendStream());
2353 send_parameters_.options.audio_network_adaptor = rtc::Optional<bool>(true);
2354 send_parameters_.options.audio_network_adaptor_config =
2355 rtc::Optional<std::string>("1234");
2356 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2357 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config,
2358 GetAudioNetworkAdaptorConfig(kSsrc1));
2359 const int initial_num = call_.GetNumCreatedSendStreams();
2360 cricket::AudioOptions options;
2361 options.audio_network_adaptor = rtc::Optional<bool>(false);
2362 EXPECT_TRUE(channel_->SetAudioSend(kSsrc1, true, &options, nullptr));
2363 // AudioSendStream expected to be recreated.
2364 EXPECT_EQ(initial_num + 1, call_.GetNumCreatedSendStreams());
2365 EXPECT_EQ(rtc::Optional<std::string>(), GetAudioNetworkAdaptorConfig(kSsrc1));
2366 }
2367
2368 TEST_F(WebRtcVoiceEngineTestFake, AudioNetworkAdaptorNotGetOverridden) {
2369 EXPECT_TRUE(SetupSendStream());
2370 send_parameters_.options.audio_network_adaptor = rtc::Optional<bool>(true);
2371 send_parameters_.options.audio_network_adaptor_config =
2372 rtc::Optional<std::string>("1234");
2373 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2374 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config,
2375 GetAudioNetworkAdaptorConfig(kSsrc1));
2376 const int initial_num = call_.GetNumCreatedSendStreams();
2377 cricket::AudioOptions options;
2378 options.audio_network_adaptor = rtc::Optional<bool>();
2379 // Unvalued |options.audio_network_adaptor|.should not reset audio network
2380 // adaptor.
2381 EXPECT_TRUE(channel_->SetAudioSend(kSsrc1, true, &options, nullptr));
2382 // AudioSendStream not expected to be recreated.
2383 EXPECT_EQ(initial_num, call_.GetNumCreatedSendStreams());
2384 EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config,
2385 GetAudioNetworkAdaptorConfig(kSsrc1));
2386 }
2387
2337 // Test that we can set the outgoing SSRC properly. 2388 // Test that we can set the outgoing SSRC properly.
2338 // SSRC is set in SetupSendStream() by calling AddSendStream. 2389 // SSRC is set in SetupSendStream() by calling AddSendStream.
2339 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { 2390 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) {
2340 EXPECT_TRUE(SetupSendStream()); 2391 EXPECT_TRUE(SetupSendStream());
2341 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); 2392 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1));
2342 } 2393 }
2343 2394
2344 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { 2395 TEST_F(WebRtcVoiceEngineTestFake, GetStats) {
2345 // Setup. We need send codec to be set to get all stats. 2396 // Setup. We need send codec to be set to get all stats.
2346 EXPECT_TRUE(SetupSendStream()); 2397 EXPECT_TRUE(SetupSendStream());
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); 3470 nullptr, webrtc::CreateBuiltinAudioDecoderFactory());
3420 webrtc::RtcEventLogNullImpl event_log; 3471 webrtc::RtcEventLogNullImpl event_log;
3421 std::unique_ptr<webrtc::Call> call( 3472 std::unique_ptr<webrtc::Call> call(
3422 webrtc::Call::Create(webrtc::Call::Config(&event_log))); 3473 webrtc::Call::Create(webrtc::Call::Config(&event_log)));
3423 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3474 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3424 cricket::AudioOptions(), call.get()); 3475 cricket::AudioOptions(), call.get());
3425 cricket::AudioRecvParameters parameters; 3476 cricket::AudioRecvParameters parameters;
3426 parameters.codecs = engine.recv_codecs(); 3477 parameters.codecs = engine.recv_codecs();
3427 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3478 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3428 } 3479 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698