| 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/webrtc_audio_device_impl.h" | 7 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 8 #include "content/test/webrtc_audio_device_test.h" | 8 #include "content/test/webrtc_audio_device_test.h" |
| 9 #include "media/audio/audio_util.h" | 9 #include "media/audio/audio_util.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 int channels_; | 110 int channels_; |
| 111 DISALLOW_COPY_AND_ASSIGN(WebRTCMediaProcessImpl); | 111 DISALLOW_COPY_AND_ASSIGN(WebRTCMediaProcessImpl); |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 } // end namespace | 114 } // end namespace |
| 115 | 115 |
| 116 // Basic test that instantiates and initializes an instance of | 116 // Basic test that instantiates and initializes an instance of |
| 117 // WebRtcAudioDeviceImpl. | 117 // WebRtcAudioDeviceImpl. |
| 118 TEST_F(WebRTCAudioDeviceTest, Construct) { | 118 TEST_F(WebRTCAudioDeviceTest, Construct) { |
| 119 AudioUtilNoHardware audio_util(48000.0, 48000.0); | 119 AudioUtilNoHardware audio_util(48000.0, 48000.0); |
| 120 set_audio_util_callback(&audio_util); | 120 SetAudioUtilCallback(&audio_util); |
| 121 scoped_refptr<WebRtcAudioDeviceImpl> audio_device( | 121 scoped_refptr<WebRtcAudioDeviceImpl> audio_device( |
| 122 new WebRtcAudioDeviceImpl()); | 122 new WebRtcAudioDeviceImpl()); |
| 123 audio_device->SetSessionId(1); | 123 audio_device->SetSessionId(1); |
| 124 | 124 |
| 125 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); | 125 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); |
| 126 ASSERT_TRUE(engine.valid()); | 126 ASSERT_TRUE(engine.valid()); |
| 127 | 127 |
| 128 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); | 128 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); |
| 129 int err = base->Init(audio_device); | 129 int err = base->Init(audio_device); |
| 130 EXPECT_EQ(0, err); | 130 EXPECT_EQ(0, err); |
| 131 EXPECT_EQ(0, base->Terminate()); | 131 EXPECT_EQ(0, base->Terminate()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Verify that a call to webrtc::VoEBase::StartPlayout() starts audio output | 134 // Verify that a call to webrtc::VoEBase::StartPlayout() starts audio output |
| 135 // with the correct set of parameters. A WebRtcAudioDeviceImpl instance will | 135 // with the correct set of parameters. A WebRtcAudioDeviceImpl instance will |
| 136 // be utilized to implement the actual audio path. The test registers a | 136 // be utilized to implement the actual audio path. The test registers a |
| 137 // webrtc::VoEExternalMedia implementation to hijack the output audio and | 137 // webrtc::VoEExternalMedia implementation to hijack the output audio and |
| 138 // verify that streaming starts correctly. | 138 // verify that streaming starts correctly. |
| 139 // Disabled when running headless since the bots don't have the required config. | 139 // Disabled when running headless since the bots don't have the required config. |
| 140 TEST_F(WebRTCAudioDeviceTest, StartPlayout) { | 140 TEST_F(WebRTCAudioDeviceTest, StartPlayout) { |
| 141 if (IsRunningHeadless()) | 141 if (IsRunningHeadless()) |
| 142 return; | 142 return; |
| 143 | 143 |
| 144 AudioUtil audio_util; | 144 AudioUtil audio_util; |
| 145 set_audio_util_callback(&audio_util); | 145 SetAudioUtilCallback(&audio_util); |
| 146 | 146 |
| 147 EXPECT_CALL(media_observer(), | 147 EXPECT_CALL(media_observer(), |
| 148 OnSetAudioStreamStatus(_, 1, StrEq("created"))).Times(1); | 148 OnSetAudioStreamStatus(_, 1, StrEq("created"))).Times(1); |
| 149 EXPECT_CALL(media_observer(), | 149 EXPECT_CALL(media_observer(), |
| 150 OnSetAudioStreamPlaying(_, 1, true)).Times(1); | 150 OnSetAudioStreamPlaying(_, 1, true)).Times(1); |
| 151 EXPECT_CALL(media_observer(), | 151 EXPECT_CALL(media_observer(), |
| 152 OnSetAudioStreamStatus(_, 1, StrEq("closed"))).Times(1); | 152 OnSetAudioStreamStatus(_, 1, StrEq("closed"))).Times(1); |
| 153 EXPECT_CALL(media_observer(), | 153 EXPECT_CALL(media_observer(), |
| 154 OnDeleteAudioStream(_, 1)).Times(1); | 154 OnDeleteAudioStream(_, 1)).Times(1); |
| 155 | 155 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // verify that streaming starts correctly. An external transport implementation | 204 // verify that streaming starts correctly. An external transport implementation |
| 205 // is also required to ensure that "sending" can start without actually trying | 205 // is also required to ensure that "sending" can start without actually trying |
| 206 // to send encoded packets to the network. Our main interest here is to ensure | 206 // to send encoded packets to the network. Our main interest here is to ensure |
| 207 // that the audio capturing starts as it should. | 207 // that the audio capturing starts as it should. |
| 208 // Disabled when running headless since the bots don't have the required config. | 208 // Disabled when running headless since the bots don't have the required config. |
| 209 TEST_F(WebRTCAudioDeviceTest, StartRecording) { | 209 TEST_F(WebRTCAudioDeviceTest, StartRecording) { |
| 210 if (IsRunningHeadless()) | 210 if (IsRunningHeadless()) |
| 211 return; | 211 return; |
| 212 | 212 |
| 213 AudioUtil audio_util; | 213 AudioUtil audio_util; |
| 214 set_audio_util_callback(&audio_util); | 214 SetAudioUtilCallback(&audio_util); |
| 215 | 215 |
| 216 // TODO(tommi): extend MediaObserver and MockMediaObserver with support | 216 // TODO(tommi): extend MediaObserver and MockMediaObserver with support |
| 217 // for new interfaces, like OnSetAudioStreamRecording(). When done, add | 217 // for new interfaces, like OnSetAudioStreamRecording(). When done, add |
| 218 // EXPECT_CALL() macros here. | 218 // EXPECT_CALL() macros here. |
| 219 | 219 |
| 220 scoped_refptr<WebRtcAudioDeviceImpl> audio_device( | 220 scoped_refptr<WebRtcAudioDeviceImpl> audio_device( |
| 221 new WebRtcAudioDeviceImpl()); | 221 new WebRtcAudioDeviceImpl()); |
| 222 audio_device->SetSessionId(1); | 222 audio_device->SetSessionId(1); |
| 223 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); | 223 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); |
| 224 ASSERT_TRUE(engine.valid()); | 224 ASSERT_TRUE(engine.valid()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // Uses WebRtcAudioDeviceImpl to play a local wave file. | 271 // Uses WebRtcAudioDeviceImpl to play a local wave file. |
| 272 // Disabled when running headless since the bots don't have the required config. | 272 // Disabled when running headless since the bots don't have the required config. |
| 273 TEST_F(WebRTCAudioDeviceTest, PlayLocalFile) { | 273 TEST_F(WebRTCAudioDeviceTest, PlayLocalFile) { |
| 274 if (IsRunningHeadless()) | 274 if (IsRunningHeadless()) |
| 275 return; | 275 return; |
| 276 | 276 |
| 277 std::string file_path( | 277 std::string file_path( |
| 278 GetTestDataPath(FILE_PATH_LITERAL("speechmusic_mono_16kHz.pcm"))); | 278 GetTestDataPath(FILE_PATH_LITERAL("speechmusic_mono_16kHz.pcm"))); |
| 279 | 279 |
| 280 AudioUtil audio_util; | 280 AudioUtil audio_util; |
| 281 set_audio_util_callback(&audio_util); | 281 SetAudioUtilCallback(&audio_util); |
| 282 | 282 |
| 283 EXPECT_CALL(media_observer(), | 283 EXPECT_CALL(media_observer(), |
| 284 OnSetAudioStreamStatus(_, 1, StrEq("created"))).Times(1); | 284 OnSetAudioStreamStatus(_, 1, StrEq("created"))).Times(1); |
| 285 EXPECT_CALL(media_observer(), | 285 EXPECT_CALL(media_observer(), |
| 286 OnSetAudioStreamPlaying(_, 1, true)).Times(1); | 286 OnSetAudioStreamPlaying(_, 1, true)).Times(1); |
| 287 EXPECT_CALL(media_observer(), | 287 EXPECT_CALL(media_observer(), |
| 288 OnSetAudioStreamStatus(_, 1, StrEq("closed"))).Times(1); | 288 OnSetAudioStreamStatus(_, 1, StrEq("closed"))).Times(1); |
| 289 EXPECT_CALL(media_observer(), | 289 EXPECT_CALL(media_observer(), |
| 290 OnDeleteAudioStream(_, 1)).Times(1); | 290 OnDeleteAudioStream(_, 1)).Times(1); |
| 291 | 291 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 // "transmitted". The RTP packets are then fed back into the VoiceEngine | 328 // "transmitted". The RTP packets are then fed back into the VoiceEngine |
| 329 // where they are decoded and played out on the default audio output device. | 329 // where they are decoded and played out on the default audio output device. |
| 330 // Disabled when running headless since the bots don't have the required config. | 330 // Disabled when running headless since the bots don't have the required config. |
| 331 // TODO(henrika): improve quality by using a wideband codec, enabling noise- | 331 // TODO(henrika): improve quality by using a wideband codec, enabling noise- |
| 332 // suppressions and perhaps also the digital AGC. | 332 // suppressions and perhaps also the digital AGC. |
| 333 TEST_F(WebRTCAudioDeviceTest, FullDuplexAudio) { | 333 TEST_F(WebRTCAudioDeviceTest, FullDuplexAudio) { |
| 334 if (IsRunningHeadless()) | 334 if (IsRunningHeadless()) |
| 335 return; | 335 return; |
| 336 | 336 |
| 337 AudioUtil audio_util; | 337 AudioUtil audio_util; |
| 338 set_audio_util_callback(&audio_util); | 338 SetAudioUtilCallback(&audio_util); |
| 339 | 339 |
| 340 scoped_refptr<WebRtcAudioDeviceImpl> audio_device( | 340 scoped_refptr<WebRtcAudioDeviceImpl> audio_device( |
| 341 new WebRtcAudioDeviceImpl()); | 341 new WebRtcAudioDeviceImpl()); |
| 342 audio_device->SetSessionId(1); | 342 audio_device->SetSessionId(1); |
| 343 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); | 343 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); |
| 344 ASSERT_TRUE(engine.valid()); | 344 ASSERT_TRUE(engine.valid()); |
| 345 | 345 |
| 346 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); | 346 ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get()); |
| 347 ASSERT_TRUE(base.valid()); | 347 ASSERT_TRUE(base.valid()); |
| 348 int err = base->Init(audio_device); | 348 int err = base->Init(audio_device); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 363 new MessageLoop::QuitTask(), | 363 new MessageLoop::QuitTask(), |
| 364 TestTimeouts::action_timeout_ms()); | 364 TestTimeouts::action_timeout_ms()); |
| 365 message_loop_.Run(); | 365 message_loop_.Run(); |
| 366 | 366 |
| 367 EXPECT_EQ(0, base->StopSend(ch)); | 367 EXPECT_EQ(0, base->StopSend(ch)); |
| 368 EXPECT_EQ(0, base->StopPlayout(ch)); | 368 EXPECT_EQ(0, base->StopPlayout(ch)); |
| 369 | 369 |
| 370 EXPECT_EQ(0, base->DeleteChannel(ch)); | 370 EXPECT_EQ(0, base->DeleteChannel(ch)); |
| 371 EXPECT_EQ(0, base->Terminate()); | 371 EXPECT_EQ(0, base->Terminate()); |
| 372 } | 372 } |
| OLD | NEW |