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

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: solve unit test 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
326 // TODO(leozwang): Because ExternalMediaProcessing is disabled in webrtc,
327 // disable this unit test on Android for now.
328 #if !defined(OS_ANDROID)
tommi (sloooow) - chröme 2013/02/11 09:52:58 Instead of this, can you use the MAYBE_ approach a
leozwang1 2013/02/11 18:03:43 Done.
325 TEST_F(WebRTCAudioDeviceTest, StartRecording) { 329 TEST_F(WebRTCAudioDeviceTest, StartRecording) {
326 if (!has_input_devices_ || !has_output_devices_) { 330 if (!has_input_devices_ || !has_output_devices_) {
327 LOG(WARNING) << "Missing audio devices."; 331 LOG(WARNING) << "Missing audio devices.";
328 return; 332 return;
329 } 333 }
330 334
331 scoped_ptr<media::AudioHardwareConfig> config = CreateRealHardwareConfig(); 335 scoped_ptr<media::AudioHardwareConfig> config = CreateRealHardwareConfig();
332 SetAudioHardwareConfig(config.get()); 336 SetAudioHardwareConfig(config.get());
333 337
334 if (!HardwareSampleRatesAreValid()) 338 if (!HardwareSampleRatesAreValid())
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 EXPECT_EQ(80, media_process->packet_size()); 385 EXPECT_EQ(80, media_process->packet_size());
382 EXPECT_EQ(8000, media_process->sample_rate()); 386 EXPECT_EQ(8000, media_process->sample_rate());
383 387
384 EXPECT_EQ(0, external_media->DeRegisterExternalMediaProcessing( 388 EXPECT_EQ(0, external_media->DeRegisterExternalMediaProcessing(
385 ch, webrtc::kRecordingPerChannel)); 389 ch, webrtc::kRecordingPerChannel));
386 EXPECT_EQ(0, base->StopSend(ch)); 390 EXPECT_EQ(0, base->StopSend(ch));
387 391
388 EXPECT_EQ(0, base->DeleteChannel(ch)); 392 EXPECT_EQ(0, base->DeleteChannel(ch));
389 EXPECT_EQ(0, base->Terminate()); 393 EXPECT_EQ(0, base->Terminate());
390 } 394 }
395 #endif
391 396
392 // Uses WebRtcAudioDeviceImpl to play a local wave file. 397 // Uses WebRtcAudioDeviceImpl to play a local wave file.
393 // Disabled when running headless since the bots don't have the required config. 398 // Disabled when running headless since the bots don't have the required config.
394 // Flaky, http://crbug.com/167298 . 399 // Flaky, http://crbug.com/167298 .
395 TEST_F(WebRTCAudioDeviceTest, DISABLED_PlayLocalFile) { 400 TEST_F(WebRTCAudioDeviceTest, DISABLED_PlayLocalFile) {
396 if (!has_output_devices_) { 401 if (!has_output_devices_) {
397 LOG(WARNING) << "No output device detected."; 402 LOG(WARNING) << "No output device detected.";
398 return; 403 return;
399 } 404 }
400 405
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 503
499 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); 504 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get());
500 ASSERT_TRUE(base.valid()); 505 ASSERT_TRUE(base.valid());
501 int err = base->Init(webrtc_audio_device); 506 int err = base->Init(webrtc_audio_device);
502 ASSERT_EQ(0, err); 507 ASSERT_EQ(0, err);
503 508
504 EXPECT_TRUE(InitializeCapturer(webrtc_audio_device.get())); 509 EXPECT_TRUE(InitializeCapturer(webrtc_audio_device.get()));
505 510
506 ScopedWebRTCPtr<webrtc::VoEAudioProcessing> audio_processing(engine.get()); 511 ScopedWebRTCPtr<webrtc::VoEAudioProcessing> audio_processing(engine.get());
507 ASSERT_TRUE(audio_processing.valid()); 512 ASSERT_TRUE(audio_processing.valid());
513 #if defined(OS_ANDROID)
514 // On Android, by default AGC is off.
515 bool enabled = true;
516 webrtc::AgcModes agc_mode = webrtc::kAgcDefault;
517 EXPECT_EQ(0, audio_processing->GetAgcStatus(enabled, agc_mode));
518 EXPECT_FALSE(enabled);
519 #else
508 bool enabled = false; 520 bool enabled = false;
509 webrtc::AgcModes agc_mode = webrtc::kAgcDefault; 521 webrtc::AgcModes agc_mode = webrtc::kAgcDefault;
510 EXPECT_EQ(0, audio_processing->GetAgcStatus(enabled, agc_mode)); 522 EXPECT_EQ(0, audio_processing->GetAgcStatus(enabled, agc_mode));
511 EXPECT_TRUE(enabled); 523 EXPECT_TRUE(enabled);
512 EXPECT_EQ(agc_mode, webrtc::kAgcAdaptiveAnalog); 524 EXPECT_EQ(agc_mode, webrtc::kAgcAdaptiveAnalog);
525 #endif
513 526
514 int ch = base->CreateChannel(); 527 int ch = base->CreateChannel();
515 EXPECT_NE(-1, ch); 528 EXPECT_NE(-1, ch);
516 529
517 ScopedWebRTCPtr<webrtc::VoENetwork> network(engine.get()); 530 ScopedWebRTCPtr<webrtc::VoENetwork> network(engine.get());
518 ASSERT_TRUE(network.valid()); 531 ASSERT_TRUE(network.valid());
519 scoped_ptr<WebRTCTransportImpl> transport( 532 scoped_ptr<WebRTCTransportImpl> transport(
520 new WebRTCTransportImpl(network.get())); 533 new WebRTCTransportImpl(network.get()));
521 EXPECT_EQ(0, network->RegisterExternalTransport(ch, *transport.get())); 534 EXPECT_EQ(0, network->RegisterExternalTransport(ch, *transport.get()));
522 EXPECT_EQ(0, base->StartPlayout(ch)); 535 EXPECT_EQ(0, base->StartPlayout(ch));
523 EXPECT_EQ(0, base->StartSend(ch)); 536 EXPECT_EQ(0, base->StartSend(ch));
524 renderer->Play(); 537 renderer->Play();
525 538
526 LOG(INFO) << ">> You should now be able to hear yourself in loopback..."; 539 LOG(INFO) << ">> You should now be able to hear yourself in loopback...";
527 message_loop_.PostDelayedTask(FROM_HERE, 540 message_loop_.PostDelayedTask(FROM_HERE,
528 MessageLoop::QuitClosure(), 541 MessageLoop::QuitClosure(),
529 base::TimeDelta::FromSeconds(2)); 542 base::TimeDelta::FromSeconds(2));
530 message_loop_.Run(); 543 message_loop_.Run();
531 544
532 renderer->Stop(); 545 renderer->Stop();
533 EXPECT_EQ(0, base->StopSend(ch)); 546 EXPECT_EQ(0, base->StopSend(ch));
534 EXPECT_EQ(0, base->StopPlayout(ch)); 547 EXPECT_EQ(0, base->StopPlayout(ch));
535 548
536 EXPECT_EQ(0, base->DeleteChannel(ch)); 549 EXPECT_EQ(0, base->DeleteChannel(ch));
537 EXPECT_EQ(0, base->Terminate()); 550 EXPECT_EQ(0, base->Terminate());
538 } 551 }
539 552
540 } // namespace content 553 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698