| OLD | NEW |
| 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" |
| 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 static const int kRenderViewId = -2; |
| 28 |
| 27 ACTION_P(QuitMessageLoop, loop_or_proxy) { | 29 ACTION_P(QuitMessageLoop, loop_or_proxy) { |
| 28 loop_or_proxy->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 30 loop_or_proxy->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 29 } | 31 } |
| 30 | 32 |
| 31 class AudioUtil : public AudioUtilInterface { | 33 class AudioUtil : public AudioUtilInterface { |
| 32 public: | 34 public: |
| 33 AudioUtil() {} | 35 AudioUtil() {} |
| 34 | 36 |
| 35 virtual int GetAudioHardwareSampleRate() OVERRIDE { | 37 virtual int GetAudioHardwareSampleRate() OVERRIDE { |
| 36 return media::GetAudioHardwareSampleRate(); | 38 return media::GetAudioHardwareSampleRate(); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 return; | 260 return; |
| 259 } | 261 } |
| 260 | 262 |
| 261 AudioUtil audio_util; | 263 AudioUtil audio_util; |
| 262 SetAudioUtilCallback(&audio_util); | 264 SetAudioUtilCallback(&audio_util); |
| 263 | 265 |
| 264 if (!HardwareSampleRatesAreValid()) | 266 if (!HardwareSampleRatesAreValid()) |
| 265 return; | 267 return; |
| 266 | 268 |
| 267 EXPECT_CALL(media_observer(), | 269 EXPECT_CALL(media_observer(), |
| 268 OnSetAudioStreamStatus(_, 1, StrEq("created"))).Times(1); | 270 OnSetAudioStreamStatus(_, kRenderViewId, |
| 271 1, StrEq("created"))).Times(1); |
| 269 EXPECT_CALL(media_observer(), | 272 EXPECT_CALL(media_observer(), |
| 270 OnSetAudioStreamPlaying(_, 1, true)).Times(1); | 273 OnSetAudioStreamPlaying(_, kRenderViewId, 1, true)).Times(1); |
| 271 EXPECT_CALL(media_observer(), | 274 EXPECT_CALL(media_observer(), |
| 272 OnSetAudioStreamStatus(_, 1, StrEq("closed"))).Times(1); | 275 OnSetAudioStreamStatus(_, kRenderViewId, |
| 276 1, StrEq("closed"))).Times(1); |
| 273 EXPECT_CALL(media_observer(), | 277 EXPECT_CALL(media_observer(), |
| 274 OnDeleteAudioStream(_, 1)).Times(AnyNumber()); | 278 OnDeleteAudioStream(_, kRenderViewId, 1)).Times(AnyNumber()); |
| 275 | 279 |
| 276 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 280 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| 277 new WebRtcAudioDeviceImpl(0)); | 281 new WebRtcAudioDeviceImpl(0)); |
| 278 webrtc_audio_device->SetSessionId(1); | 282 webrtc_audio_device->SetSessionId(1); |
| 279 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); | 283 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); |
| 280 ASSERT_TRUE(engine.valid()); | 284 ASSERT_TRUE(engine.valid()); |
| 281 | 285 |
| 282 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); | 286 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); |
| 283 ASSERT_TRUE(base.valid()); | 287 ASSERT_TRUE(base.valid()); |
| 284 int err = base->Init(webrtc_audio_device); | 288 int err = base->Init(webrtc_audio_device); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 std::string file_path( | 406 std::string file_path( |
| 403 GetTestDataPath(FILE_PATH_LITERAL("speechmusic_mono_16kHz.pcm"))); | 407 GetTestDataPath(FILE_PATH_LITERAL("speechmusic_mono_16kHz.pcm"))); |
| 404 | 408 |
| 405 AudioUtil audio_util; | 409 AudioUtil audio_util; |
| 406 SetAudioUtilCallback(&audio_util); | 410 SetAudioUtilCallback(&audio_util); |
| 407 | 411 |
| 408 if (!HardwareSampleRatesAreValid()) | 412 if (!HardwareSampleRatesAreValid()) |
| 409 return; | 413 return; |
| 410 | 414 |
| 411 EXPECT_CALL(media_observer(), | 415 EXPECT_CALL(media_observer(), |
| 412 OnSetAudioStreamStatus(_, 1, StrEq("created"))).Times(1); | 416 OnSetAudioStreamStatus( _, kRenderViewId, |
| 417 1, StrEq("created"))).Times(1); |
| 413 EXPECT_CALL(media_observer(), | 418 EXPECT_CALL(media_observer(), |
| 414 OnSetAudioStreamPlaying(_, 1, true)).Times(1); | 419 OnSetAudioStreamPlaying(_, kRenderViewId, |
| 420 1, true)).Times(1); |
| 415 EXPECT_CALL(media_observer(), | 421 EXPECT_CALL(media_observer(), |
| 416 OnSetAudioStreamStatus(_, 1, StrEq("closed"))).Times(1); | 422 OnSetAudioStreamStatus(_, kRenderViewId, |
| 423 1, StrEq("closed"))).Times(1); |
| 417 EXPECT_CALL(media_observer(), | 424 EXPECT_CALL(media_observer(), |
| 418 OnDeleteAudioStream(_, 1)).Times(AnyNumber()); | 425 OnDeleteAudioStream(_, kRenderViewId, 1)).Times(AnyNumber()); |
| 419 | 426 |
| 420 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 427 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| 421 new WebRtcAudioDeviceImpl(0)); | 428 new WebRtcAudioDeviceImpl(0)); |
| 422 webrtc_audio_device->SetSessionId(1); | 429 webrtc_audio_device->SetSessionId(1); |
| 423 | 430 |
| 424 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); | 431 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); |
| 425 ASSERT_TRUE(engine.valid()); | 432 ASSERT_TRUE(engine.valid()); |
| 426 | 433 |
| 427 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); | 434 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); |
| 428 ASSERT_TRUE(base.valid()); | 435 ASSERT_TRUE(base.valid()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 return; | 477 return; |
| 471 } | 478 } |
| 472 | 479 |
| 473 AudioUtil audio_util; | 480 AudioUtil audio_util; |
| 474 SetAudioUtilCallback(&audio_util); | 481 SetAudioUtilCallback(&audio_util); |
| 475 | 482 |
| 476 if (!HardwareSampleRatesAreValid()) | 483 if (!HardwareSampleRatesAreValid()) |
| 477 return; | 484 return; |
| 478 | 485 |
| 479 EXPECT_CALL(media_observer(), | 486 EXPECT_CALL(media_observer(), |
| 480 OnSetAudioStreamStatus(_, 1, StrEq("created"))); | 487 OnSetAudioStreamStatus(_, kRenderViewId, 1, StrEq("created"))); |
| 481 EXPECT_CALL(media_observer(), | 488 EXPECT_CALL(media_observer(), |
| 482 OnSetAudioStreamPlaying(_, 1, true)); | 489 OnSetAudioStreamPlaying(_, kRenderViewId, 1, true)); |
| 483 EXPECT_CALL(media_observer(), | 490 EXPECT_CALL(media_observer(), |
| 484 OnSetAudioStreamStatus(_, 1, StrEq("closed"))); | 491 OnSetAudioStreamStatus(_, kRenderViewId, 1, StrEq("closed"))); |
| 485 EXPECT_CALL(media_observer(), | 492 EXPECT_CALL(media_observer(), |
| 486 OnDeleteAudioStream(_, 1)).Times(AnyNumber()); | 493 OnDeleteAudioStream(_, kRenderViewId, 1)).Times(AnyNumber()); |
| 487 | 494 |
| 488 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 495 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| 489 new WebRtcAudioDeviceImpl(0)); | 496 new WebRtcAudioDeviceImpl(0)); |
| 490 webrtc_audio_device->SetSessionId(1); | 497 webrtc_audio_device->SetSessionId(1); |
| 491 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); | 498 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); |
| 492 ASSERT_TRUE(engine.valid()); | 499 ASSERT_TRUE(engine.valid()); |
| 493 | 500 |
| 494 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); | 501 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); |
| 495 ASSERT_TRUE(base.valid()); | 502 ASSERT_TRUE(base.valid()); |
| 496 int err = base->Init(webrtc_audio_device); | 503 int err = base->Init(webrtc_audio_device); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 520 MessageLoop::QuitClosure(), | 527 MessageLoop::QuitClosure(), |
| 521 TestTimeouts::action_timeout()); | 528 TestTimeouts::action_timeout()); |
| 522 message_loop_.Run(); | 529 message_loop_.Run(); |
| 523 | 530 |
| 524 EXPECT_EQ(0, base->StopSend(ch)); | 531 EXPECT_EQ(0, base->StopSend(ch)); |
| 525 EXPECT_EQ(0, base->StopPlayout(ch)); | 532 EXPECT_EQ(0, base->StopPlayout(ch)); |
| 526 | 533 |
| 527 EXPECT_EQ(0, base->DeleteChannel(ch)); | 534 EXPECT_EQ(0, base->DeleteChannel(ch)); |
| 528 EXPECT_EQ(0, base->Terminate()); | 535 EXPECT_EQ(0, base->Terminate()); |
| 529 } | 536 } |
| OLD | NEW |