| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 11 #include "media/audio/audio_util.h" | 11 #include "media/audio/audio_util.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "third_party/webrtc/voice_engine/main/interface/voe_audio_processing.h" | 13 #include "third_party/webrtc/voice_engine/main/interface/voe_audio_processing.h" |
| 14 #include "third_party/webrtc/voice_engine/main/interface/voe_base.h" | 14 #include "third_party/webrtc/voice_engine/main/interface/voe_base.h" |
| 15 #include "third_party/webrtc/voice_engine/main/interface/voe_external_media.h" | 15 #include "third_party/webrtc/voice_engine/main/interface/voe_external_media.h" |
| 16 #include "third_party/webrtc/voice_engine/main/interface/voe_file.h" | 16 #include "third_party/webrtc/voice_engine/main/interface/voe_file.h" |
| 17 #include "third_party/webrtc/voice_engine/main/interface/voe_network.h" | 17 #include "third_party/webrtc/voice_engine/main/interface/voe_network.h" |
| 18 | 18 |
| 19 using testing::_; | 19 using testing::_; |
| 20 using testing::AnyNumber; | 20 using testing::AnyNumber; |
| 21 using testing::InvokeWithoutArgs; | 21 using testing::InvokeWithoutArgs; |
| 22 using testing::Return; | 22 using testing::Return; |
| 23 using testing::StrEq; | 23 using testing::StrEq; |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 ACTION_P(QuitMessageLoop, loop_or_proxy) { | 27 ACTION_P(QuitMessageLoop, loop_or_proxy) { |
| 28 loop_or_proxy->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 28 loop_or_proxy->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 class AudioUtil : public AudioUtilInterface { | 31 class AudioUtil : public AudioUtilInterface { |
| 32 public: | 32 public: |
| 33 AudioUtil() {} | 33 AudioUtil() {} |
| 34 | 34 |
| 35 virtual double GetAudioHardwareSampleRate() OVERRIDE { | 35 virtual double GetAudioHardwareSampleRate() OVERRIDE { |
| 36 return media::GetAudioHardwareSampleRate(); | 36 return media::GetAudioHardwareSampleRate(); |
| 37 } | 37 } |
| 38 virtual double GetAudioInputHardwareSampleRate() OVERRIDE { | 38 virtual double GetAudioInputHardwareSampleRate() OVERRIDE { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 ScopedWebRTCPtr<webrtc::VoEFile> file(engine.get()); | 376 ScopedWebRTCPtr<webrtc::VoEFile> file(engine.get()); |
| 377 int duration = 0; | 377 int duration = 0; |
| 378 EXPECT_EQ(0, file->GetFileDuration(file_path.c_str(), duration, | 378 EXPECT_EQ(0, file->GetFileDuration(file_path.c_str(), duration, |
| 379 webrtc::kFileFormatPcm16kHzFile)); | 379 webrtc::kFileFormatPcm16kHzFile)); |
| 380 EXPECT_NE(0, duration); | 380 EXPECT_NE(0, duration); |
| 381 | 381 |
| 382 EXPECT_EQ(0, file->StartPlayingFileLocally(ch, file_path.c_str(), false, | 382 EXPECT_EQ(0, file->StartPlayingFileLocally(ch, file_path.c_str(), false, |
| 383 webrtc::kFileFormatPcm16kHzFile)); | 383 webrtc::kFileFormatPcm16kHzFile)); |
| 384 | 384 |
| 385 message_loop_.PostDelayedTask(FROM_HERE, | 385 message_loop_.PostDelayedTask(FROM_HERE, |
| 386 new MessageLoop::QuitTask(), | 386 MessageLoop::QuitClosure(), |
| 387 TestTimeouts::action_timeout_ms()); | 387 TestTimeouts::action_timeout_ms()); |
| 388 message_loop_.Run(); | 388 message_loop_.Run(); |
| 389 | 389 |
| 390 EXPECT_EQ(0, base->Terminate()); | 390 EXPECT_EQ(0, base->Terminate()); |
| 391 } | 391 } |
| 392 | 392 |
| 393 // Uses WebRtcAudioDeviceImpl to play out recorded audio in loopback. | 393 // Uses WebRtcAudioDeviceImpl to play out recorded audio in loopback. |
| 394 // An external transport implementation is utilized to feed back RTP packets | 394 // An external transport implementation is utilized to feed back RTP packets |
| 395 // which are recorded, encoded, packetized into RTP packets and finally | 395 // which are recorded, encoded, packetized into RTP packets and finally |
| 396 // "transmitted". The RTP packets are then fed back into the VoiceEngine | 396 // "transmitted". The RTP packets are then fed back into the VoiceEngine |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 435 |
| 436 ScopedWebRTCPtr<webrtc::VoENetwork> network(engine.get()); | 436 ScopedWebRTCPtr<webrtc::VoENetwork> network(engine.get()); |
| 437 scoped_ptr<WebRTCTransportImpl> transport( | 437 scoped_ptr<WebRTCTransportImpl> transport( |
| 438 new WebRTCTransportImpl(network.get())); | 438 new WebRTCTransportImpl(network.get())); |
| 439 EXPECT_EQ(0, network->RegisterExternalTransport(ch, *transport.get())); | 439 EXPECT_EQ(0, network->RegisterExternalTransport(ch, *transport.get())); |
| 440 EXPECT_EQ(0, base->StartPlayout(ch)); | 440 EXPECT_EQ(0, base->StartPlayout(ch)); |
| 441 EXPECT_EQ(0, base->StartSend(ch)); | 441 EXPECT_EQ(0, base->StartSend(ch)); |
| 442 | 442 |
| 443 LOG(INFO) << ">> You should now be able to hear yourself in loopback..."; | 443 LOG(INFO) << ">> You should now be able to hear yourself in loopback..."; |
| 444 message_loop_.PostDelayedTask(FROM_HERE, | 444 message_loop_.PostDelayedTask(FROM_HERE, |
| 445 new MessageLoop::QuitTask(), | 445 MessageLoop::QuitClosure(), |
| 446 TestTimeouts::action_timeout_ms()); | 446 TestTimeouts::action_timeout_ms()); |
| 447 message_loop_.Run(); | 447 message_loop_.Run(); |
| 448 | 448 |
| 449 EXPECT_EQ(0, base->StopSend(ch)); | 449 EXPECT_EQ(0, base->StopSend(ch)); |
| 450 EXPECT_EQ(0, base->StopPlayout(ch)); | 450 EXPECT_EQ(0, base->StopPlayout(ch)); |
| 451 | 451 |
| 452 EXPECT_EQ(0, base->DeleteChannel(ch)); | 452 EXPECT_EQ(0, base->DeleteChannel(ch)); |
| 453 EXPECT_EQ(0, base->Terminate()); | 453 EXPECT_EQ(0, base->Terminate()); |
| 454 } | 454 } |
| OLD | NEW |