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

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

Issue 12218036: Enable audio capture on Android (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: fix unit test name because of switching terminals Created 7 years, 10 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
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/webrtc_audio_capturer.h" 7 #include "content/renderer/media/webrtc_audio_capturer.h"
8 #include "content/renderer/media/webrtc_audio_device_impl.h" 8 #include "content/renderer/media/webrtc_audio_device_impl.h"
9 #include "content/renderer/media/webrtc_audio_renderer.h" 9 #include "content/renderer/media/webrtc_audio_renderer.h"
10 #include "content/renderer/render_thread_impl.h" 10 #include "content/renderer/render_thread_impl.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 // Verify that a call to webrtc::VoEBase::StartRecording() starts audio input 316 // Verify that a call to webrtc::VoEBase::StartRecording() starts audio input
317 // with the correct set of parameters. A WebRtcAudioDeviceImpl instance will 317 // with the correct set of parameters. A WebRtcAudioDeviceImpl instance will
318 // be utilized to implement the actual audio path. The test registers a 318 // be utilized to implement the actual audio path. The test registers a
319 // webrtc::VoEExternalMedia implementation to hijack the input audio and 319 // webrtc::VoEExternalMedia implementation to hijack the input audio and
320 // verify that streaming starts correctly. An external transport implementation 320 // verify that streaming starts correctly. An external transport implementation
321 // is also required to ensure that "sending" can start without actually trying 321 // is also required to ensure that "sending" can start without actually trying
322 // to send encoded packets to the network. Our main interest here is to ensure 322 // to send encoded packets to the network. Our main interest here is to ensure
323 // that the audio capturing starts as it should. 323 // that the audio capturing starts as it should.
324 // Disabled when running headless since the bots don't have the required config. 324 // Disabled when running headless since the bots don't have the required config.
325 TEST_F(WebRTCAudioDeviceTest, StartRecording) { 325
326 // TODO(leozwang): Because ExternalMediaProcessing is disabled in webrtc,
327 // disable this unit test on Android for now.
tommi (sloooow) - chröme 2013/02/11 22:59:11 thanks
328 #if defined(OS_ANDROID)
329 #define MAYBE_StartRecording DISABLED_StartRecording
330 #else
331 #define MAYBE_StartRecording StartRecording
332 #endif
333 TEST_F(WebRTCAudioDeviceTest, MAYBE_StartRecording) {
326 if (!has_input_devices_ || !has_output_devices_) { 334 if (!has_input_devices_ || !has_output_devices_) {
327 LOG(WARNING) << "Missing audio devices."; 335 LOG(WARNING) << "Missing audio devices.";
328 return; 336 return;
329 } 337 }
330 338
331 scoped_ptr<media::AudioHardwareConfig> config = CreateRealHardwareConfig(); 339 scoped_ptr<media::AudioHardwareConfig> config = CreateRealHardwareConfig();
332 SetAudioHardwareConfig(config.get()); 340 SetAudioHardwareConfig(config.get());
333 341
334 if (!HardwareSampleRatesAreValid()) 342 if (!HardwareSampleRatesAreValid())
335 return; 343 return;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 506
499 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); 507 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get());
500 ASSERT_TRUE(base.valid()); 508 ASSERT_TRUE(base.valid());
501 int err = base->Init(webrtc_audio_device); 509 int err = base->Init(webrtc_audio_device);
502 ASSERT_EQ(0, err); 510 ASSERT_EQ(0, err);
503 511
504 EXPECT_TRUE(InitializeCapturer(webrtc_audio_device.get())); 512 EXPECT_TRUE(InitializeCapturer(webrtc_audio_device.get()));
505 513
506 ScopedWebRTCPtr<webrtc::VoEAudioProcessing> audio_processing(engine.get()); 514 ScopedWebRTCPtr<webrtc::VoEAudioProcessing> audio_processing(engine.get());
507 ASSERT_TRUE(audio_processing.valid()); 515 ASSERT_TRUE(audio_processing.valid());
516 #if defined(OS_ANDROID)
517 // On Android, by default AGC is off.
518 bool enabled = true;
519 webrtc::AgcModes agc_mode = webrtc::kAgcDefault;
520 EXPECT_EQ(0, audio_processing->GetAgcStatus(enabled, agc_mode));
521 EXPECT_FALSE(enabled);
522 #else
508 bool enabled = false; 523 bool enabled = false;
509 webrtc::AgcModes agc_mode = webrtc::kAgcDefault; 524 webrtc::AgcModes agc_mode = webrtc::kAgcDefault;
510 EXPECT_EQ(0, audio_processing->GetAgcStatus(enabled, agc_mode)); 525 EXPECT_EQ(0, audio_processing->GetAgcStatus(enabled, agc_mode));
511 EXPECT_TRUE(enabled); 526 EXPECT_TRUE(enabled);
512 EXPECT_EQ(agc_mode, webrtc::kAgcAdaptiveAnalog); 527 EXPECT_EQ(agc_mode, webrtc::kAgcAdaptiveAnalog);
528 #endif
513 529
514 int ch = base->CreateChannel(); 530 int ch = base->CreateChannel();
515 EXPECT_NE(-1, ch); 531 EXPECT_NE(-1, ch);
516 532
517 ScopedWebRTCPtr<webrtc::VoENetwork> network(engine.get()); 533 ScopedWebRTCPtr<webrtc::VoENetwork> network(engine.get());
518 ASSERT_TRUE(network.valid()); 534 ASSERT_TRUE(network.valid());
519 scoped_ptr<WebRTCTransportImpl> transport( 535 scoped_ptr<WebRTCTransportImpl> transport(
520 new WebRTCTransportImpl(network.get())); 536 new WebRTCTransportImpl(network.get()));
521 EXPECT_EQ(0, network->RegisterExternalTransport(ch, *transport.get())); 537 EXPECT_EQ(0, network->RegisterExternalTransport(ch, *transport.get()));
522 EXPECT_EQ(0, base->StartPlayout(ch)); 538 EXPECT_EQ(0, base->StartPlayout(ch));
523 EXPECT_EQ(0, base->StartSend(ch)); 539 EXPECT_EQ(0, base->StartSend(ch));
524 renderer->Play(); 540 renderer->Play();
525 541
526 LOG(INFO) << ">> You should now be able to hear yourself in loopback..."; 542 LOG(INFO) << ">> You should now be able to hear yourself in loopback...";
527 message_loop_.PostDelayedTask(FROM_HERE, 543 message_loop_.PostDelayedTask(FROM_HERE,
528 MessageLoop::QuitClosure(), 544 MessageLoop::QuitClosure(),
529 base::TimeDelta::FromSeconds(2)); 545 base::TimeDelta::FromSeconds(2));
530 message_loop_.Run(); 546 message_loop_.Run();
531 547
532 renderer->Stop(); 548 renderer->Stop();
533 EXPECT_EQ(0, base->StopSend(ch)); 549 EXPECT_EQ(0, base->StopSend(ch));
534 EXPECT_EQ(0, base->StopPlayout(ch)); 550 EXPECT_EQ(0, base->StopPlayout(ch));
535 551
536 EXPECT_EQ(0, base->DeleteChannel(ch)); 552 EXPECT_EQ(0, base->DeleteChannel(ch));
537 EXPECT_EQ(0, base->Terminate()); 553 EXPECT_EQ(0, base->Terminate());
538 } 554 }
539 555
540 } // namespace content 556 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_capturer.cc ('k') | content/renderer/media/webrtc_audio_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698