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

Side by Side Diff: content/renderer/media/webrtc_audio_device_unittest.cc

Issue 9702019: Adds Analog Gain Control (AGC) to the WebRTC client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/environment.h" 5 #include "base/environment.h"
6 #include "base/test/test_timeouts.h" 6 #include "base/test/test_timeouts.h"
7 #include "content/renderer/media/audio_hardware.h" 7 #include "content/renderer/media/audio_hardware.h"
8 #include "content/renderer/media/webrtc_audio_device_impl.h" 8 #include "content/renderer/media/webrtc_audio_device_impl.h"
9 #include "content/test/webrtc_audio_device_test.h" 9 #include "content/test/webrtc_audio_device_test.h"
10 #include "media/audio/audio_manager.h" 10 #include "media/audio/audio_manager.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); 430 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get());
431 ASSERT_TRUE(base.valid()); 431 ASSERT_TRUE(base.valid());
432 int err = base->Init(audio_device); 432 int err = base->Init(audio_device);
433 ASSERT_EQ(0, err); 433 ASSERT_EQ(0, err);
434 434
435 int ch = base->CreateChannel(); 435 int ch = base->CreateChannel();
436 EXPECT_NE(-1, ch); 436 EXPECT_NE(-1, ch);
437 EXPECT_EQ(0, base->StartPlayout(ch)); 437 EXPECT_EQ(0, base->StartPlayout(ch));
438 438
439 ScopedWebRTCPtr<webrtc::VoEFile> file(engine.get()); 439 ScopedWebRTCPtr<webrtc::VoEFile> file(engine.get());
440 ASSERT_TRUE(file.valid());
440 int duration = 0; 441 int duration = 0;
441 EXPECT_EQ(0, file->GetFileDuration(file_path.c_str(), duration, 442 EXPECT_EQ(0, file->GetFileDuration(file_path.c_str(), duration,
442 webrtc::kFileFormatPcm16kHzFile)); 443 webrtc::kFileFormatPcm16kHzFile));
443 EXPECT_NE(0, duration); 444 EXPECT_NE(0, duration);
444 445
445 EXPECT_EQ(0, file->StartPlayingFileLocally(ch, file_path.c_str(), false, 446 EXPECT_EQ(0, file->StartPlayingFileLocally(ch, file_path.c_str(), false,
446 webrtc::kFileFormatPcm16kHzFile)); 447 webrtc::kFileFormatPcm16kHzFile));
447 448
448 // Play 2 seconds worth of audio and then quit. 449 // Play 2 seconds worth of audio and then quit.
449 message_loop_.PostDelayedTask(FROM_HERE, 450 message_loop_.PostDelayedTask(FROM_HERE,
450 MessageLoop::QuitClosure(), 451 MessageLoop::QuitClosure(),
451 base::TimeDelta::FromSeconds(2)); 452 base::TimeDelta::FromSeconds(2));
452 message_loop_.Run(); 453 message_loop_.Run();
453 454
454 455
455 EXPECT_EQ(0, base->StopSend(ch)); 456 EXPECT_EQ(0, base->StopSend(ch));
456 EXPECT_EQ(0, base->StopPlayout(ch)); 457 EXPECT_EQ(0, base->StopPlayout(ch));
457 EXPECT_EQ(0, base->DeleteChannel(ch)); 458 EXPECT_EQ(0, base->DeleteChannel(ch));
458 EXPECT_EQ(0, base->Terminate()); 459 EXPECT_EQ(0, base->Terminate());
459 } 460 }
460 461
461 // Uses WebRtcAudioDeviceImpl to play out recorded audio in loopback. 462 // Uses WebRtcAudioDeviceImpl to play out recorded audio in loopback.
462 // An external transport implementation is utilized to feed back RTP packets 463 // An external transport implementation is utilized to feed back RTP packets
463 // which are recorded, encoded, packetized into RTP packets and finally 464 // which are recorded, encoded, packetized into RTP packets and finally
464 // "transmitted". The RTP packets are then fed back into the VoiceEngine 465 // "transmitted". The RTP packets are then fed back into the VoiceEngine
465 // where they are decoded and played out on the default audio output device. 466 // where they are decoded and played out on the default audio output device.
466 // Disabled when running headless since the bots don't have the required config. 467 // Disabled when running headless since the bots don't have the required config.
467 // TODO(henrika): improve quality by using a wideband codec, enabling noise- 468 // TODO(henrika): improve quality by using a wideband codec, enabling noise-
468 // suppressions and perhaps also the digital AGC. 469 // suppressions etc.
469 TEST_F(WebRTCAudioDeviceTest, FullDuplexAudio) { 470 TEST_F(WebRTCAudioDeviceTest, FullDuplexAudioWithAGC) {
470 if (IsRunningHeadless()) 471 if (IsRunningHeadless())
471 return; 472 return;
472 473
473 AudioUtil audio_util; 474 AudioUtil audio_util;
474 SetAudioUtilCallback(&audio_util); 475 SetAudioUtilCallback(&audio_util);
475 476
476 if (!HardwareSampleRatesAreValid()) 477 if (!HardwareSampleRatesAreValid())
477 return; 478 return;
478 479
479 EXPECT_CALL(media_observer(), 480 EXPECT_CALL(media_observer(),
480 OnSetAudioStreamStatus(_, 1, StrEq("created"))); 481 OnSetAudioStreamStatus(_, 1, StrEq("created")));
481 EXPECT_CALL(media_observer(), 482 EXPECT_CALL(media_observer(),
482 OnSetAudioStreamPlaying(_, 1, true)); 483 OnSetAudioStreamPlaying(_, 1, true));
483 EXPECT_CALL(media_observer(), 484 EXPECT_CALL(media_observer(),
484 OnSetAudioStreamStatus(_, 1, StrEq("closed"))); 485 OnSetAudioStreamStatus(_, 1, StrEq("closed")));
485 EXPECT_CALL(media_observer(), 486 EXPECT_CALL(media_observer(),
486 OnDeleteAudioStream(_, 1)).Times(AnyNumber()); 487 OnDeleteAudioStream(_, 1)).Times(AnyNumber());
487 488
488 scoped_refptr<WebRtcAudioDeviceImpl> audio_device( 489 scoped_refptr<WebRtcAudioDeviceImpl> audio_device(
489 new WebRtcAudioDeviceImpl()); 490 new WebRtcAudioDeviceImpl());
490 audio_device->SetSessionId(1); 491 audio_device->SetSessionId(1);
491 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); 492 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create());
492 ASSERT_TRUE(engine.valid()); 493 ASSERT_TRUE(engine.valid());
493 494
494 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); 495 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get());
495 ASSERT_TRUE(base.valid()); 496 ASSERT_TRUE(base.valid());
496 int err = base->Init(audio_device); 497 int err = base->Init(audio_device);
497 ASSERT_EQ(0, err); 498 ASSERT_EQ(0, err);
498 499
500 ScopedWebRTCPtr<webrtc::VoEAudioProcessing> audio_processing(engine.get());
501 ASSERT_TRUE(audio_processing.valid());
502 bool enabled = false;
503 webrtc::AgcModes agc_mode = webrtc::kAgcDefault;
504 EXPECT_EQ(0, audio_processing->GetAgcStatus(enabled, agc_mode));
505 EXPECT_TRUE(enabled);
506 EXPECT_EQ(agc_mode, webrtc::kAgcAdaptiveAnalog);
507
499 int ch = base->CreateChannel(); 508 int ch = base->CreateChannel();
500 EXPECT_NE(-1, ch); 509 EXPECT_NE(-1, ch);
501 510
502 ScopedWebRTCPtr<webrtc::VoENetwork> network(engine.get()); 511 ScopedWebRTCPtr<webrtc::VoENetwork> network(engine.get());
512 ASSERT_TRUE(network.valid());
503 scoped_ptr<WebRTCTransportImpl> transport( 513 scoped_ptr<WebRTCTransportImpl> transport(
504 new WebRTCTransportImpl(network.get())); 514 new WebRTCTransportImpl(network.get()));
505 EXPECT_EQ(0, network->RegisterExternalTransport(ch, *transport.get())); 515 EXPECT_EQ(0, network->RegisterExternalTransport(ch, *transport.get()));
506 EXPECT_EQ(0, base->StartPlayout(ch)); 516 EXPECT_EQ(0, base->StartPlayout(ch));
507 EXPECT_EQ(0, base->StartSend(ch)); 517 EXPECT_EQ(0, base->StartSend(ch));
508 518
509 LOG(INFO) << ">> You should now be able to hear yourself in loopback..."; 519 LOG(INFO) << ">> You should now be able to hear yourself in loopback...";
510 message_loop_.PostDelayedTask(FROM_HERE, 520 message_loop_.PostDelayedTask(FROM_HERE,
511 MessageLoop::QuitClosure(), 521 MessageLoop::QuitClosure(),
512 TestTimeouts::action_timeout()); 522 TestTimeouts::action_timeout());
513 message_loop_.Run(); 523 message_loop_.Run();
514 524
515 EXPECT_EQ(0, base->StopSend(ch)); 525 EXPECT_EQ(0, base->StopSend(ch));
516 EXPECT_EQ(0, base->StopPlayout(ch)); 526 EXPECT_EQ(0, base->StopPlayout(ch));
517 527
518 EXPECT_EQ(0, base->DeleteChannel(ch)); 528 EXPECT_EQ(0, base->DeleteChannel(ch));
519 EXPECT_EQ(0, base->Terminate()); 529 EXPECT_EQ(0, base->Terminate());
520 } 530 }
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_device_impl.cc ('k') | content/renderer/pepper/pepper_platform_audio_input_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698