Chromium Code Reviews| 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/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" |
| 11 #include "content/test/webrtc_audio_device_test.h" | 11 #include "content/test/webrtc_audio_device_test.h" |
| 12 #include "media/audio/audio_manager_base.h" | 12 #include "media/audio/audio_manager_base.h" |
| 13 #include "media/base/audio_hardware_config.h" | 13 #include "media/base/audio_hardware_config.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "third_party/webrtc/voice_engine/include/voe_audio_processing.h" | 15 #include "third_party/webrtc/voice_engine/include/voe_audio_processing.h" |
| 16 #include "third_party/webrtc/voice_engine/include/voe_base.h" | 16 #include "third_party/webrtc/voice_engine/include/voe_base.h" |
| 17 #include "third_party/webrtc/voice_engine/include/voe_external_media.h" | 17 #include "third_party/webrtc/voice_engine/include/voe_external_media.h" |
| 18 #include "third_party/webrtc/voice_engine/include/voe_file.h" | 18 #include "third_party/webrtc/voice_engine/include/voe_file.h" |
| 19 #include "third_party/webrtc/voice_engine/include/voe_network.h" | 19 #include "third_party/webrtc/voice_engine/include/voe_network.h" |
| 20 | 20 |
| 21 using media::AudioParameters; | |
| 21 using testing::_; | 22 using testing::_; |
| 22 using testing::AnyNumber; | 23 using testing::AnyNumber; |
| 23 using testing::InvokeWithoutArgs; | 24 using testing::InvokeWithoutArgs; |
| 24 using testing::Return; | 25 using testing::Return; |
| 25 using testing::StrEq; | 26 using testing::StrEq; |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 const int kRenderViewId = 1; | 32 const int kRenderViewId = 1; |
| 32 | 33 |
| 33 scoped_ptr<media::AudioHardwareConfig> CreateRealHardwareConfig( | 34 scoped_ptr<media::AudioHardwareConfig> CreateRealHardwareConfig( |
| 34 media::AudioManager* manager) { | 35 media::AudioManager* manager) { |
| 35 const media::AudioParameters output_parameters = | 36 const AudioParameters output_parameters = |
| 36 manager->GetDefaultOutputStreamParameters(); | 37 manager->GetDefaultOutputStreamParameters(); |
| 37 const media::AudioParameters input_parameters = | 38 const AudioParameters input_parameters = |
| 38 manager->GetInputStreamParameters( | 39 manager->GetInputStreamParameters( |
| 39 media::AudioManagerBase::kDefaultDeviceId); | 40 media::AudioManagerBase::kDefaultDeviceId); |
| 40 return make_scoped_ptr(new media::AudioHardwareConfig( | 41 return make_scoped_ptr(new media::AudioHardwareConfig( |
| 41 output_parameters.frames_per_buffer(), output_parameters.sample_rate(), | 42 input_parameters, output_parameters)); |
| 42 input_parameters.sample_rate(), input_parameters.channel_layout())); | |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Return true if at least one element in the array matches |value|. | 45 // Return true if at least one element in the array matches |value|. |
| 46 bool FindElementInArray(const int* array, int size, int value) { | 46 bool FindElementInArray(const int* array, int size, int value) { |
| 47 return (std::find(&array[0], &array[0] + size, value) != &array[size]); | 47 return (std::find(&array[0], &array[0] + size, value) != &array[size]); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // This method returns false if a non-supported rate is detected on the | 50 // This method returns false if a non-supported rate is detected on the |
| 51 // input or output side. | 51 // input or output side. |
| 52 // TODO(henrika): add support for automatic fallback to Windows Wave audio | 52 // TODO(henrika): add support for automatic fallback to Windows Wave audio |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 int invalid_rates[] = {-1, 0, 8000, 11025, 22050, 32000, 192000}; | 211 int invalid_rates[] = {-1, 0, 8000, 11025, 22050, 32000, 192000}; |
| 212 for (size_t i = 0; i < arraysize(invalid_rates); ++i) { | 212 for (size_t i = 0; i < arraysize(invalid_rates); ++i) { |
| 213 EXPECT_FALSE(FindElementInArray(valid_rates, arraysize(valid_rates), | 213 EXPECT_FALSE(FindElementInArray(valid_rates, arraysize(valid_rates), |
| 214 invalid_rates[i])); | 214 invalid_rates[i])); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 // Basic test that instantiates and initializes an instance of | 218 // Basic test that instantiates and initializes an instance of |
| 219 // WebRtcAudioDeviceImpl. | 219 // WebRtcAudioDeviceImpl. |
| 220 TEST_F(WebRTCAudioDeviceTest, Construct) { | 220 TEST_F(WebRTCAudioDeviceTest, Construct) { |
| 221 media::AudioHardwareConfig audio_config( | 221 AudioParameters input_params( |
| 222 480, 48000, 48000, media::CHANNEL_LAYOUT_MONO); | 222 AudioParameters::AUDIO_PCM_LOW_LATENCY, |
|
DaleCurtis
2013/03/07 02:41:39
4 space.
Chris Rogers
2013/03/09 01:37:50
Done.
| |
| 223 media::CHANNEL_LAYOUT_MONO, | |
| 224 48000, | |
| 225 16, | |
| 226 480); | |
| 227 | |
| 228 AudioParameters output_params( | |
| 229 AudioParameters::AUDIO_PCM_LOW_LATENCY, | |
|
DaleCurtis
2013/03/07 02:41:39
4 space.
Chris Rogers
2013/03/09 01:37:50
Done.
| |
| 230 media::CHANNEL_LAYOUT_STEREO, | |
| 231 48000, | |
| 232 16, | |
| 233 480); | |
| 234 | |
| 235 media::AudioHardwareConfig audio_config(input_params, output_params); | |
| 223 SetAudioHardwareConfig(&audio_config); | 236 SetAudioHardwareConfig(&audio_config); |
| 224 | 237 |
| 225 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 238 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| 226 new WebRtcAudioDeviceImpl()); | 239 new WebRtcAudioDeviceImpl()); |
| 227 | 240 |
| 228 // The capturer is not created until after the WebRtcAudioDeviceImpl has | 241 // The capturer is not created until after the WebRtcAudioDeviceImpl has |
| 229 // been initialized. | 242 // been initialized. |
| 230 EXPECT_FALSE(InitializeCapturer(webrtc_audio_device.get())); | 243 EXPECT_FALSE(InitializeCapturer(webrtc_audio_device.get())); |
| 231 | 244 |
| 232 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); | 245 WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create()); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 | 572 |
| 560 renderer->Stop(); | 573 renderer->Stop(); |
| 561 EXPECT_EQ(0, base->StopSend(ch)); | 574 EXPECT_EQ(0, base->StopSend(ch)); |
| 562 EXPECT_EQ(0, base->StopPlayout(ch)); | 575 EXPECT_EQ(0, base->StopPlayout(ch)); |
| 563 | 576 |
| 564 EXPECT_EQ(0, base->DeleteChannel(ch)); | 577 EXPECT_EQ(0, base->DeleteChannel(ch)); |
| 565 EXPECT_EQ(0, base->Terminate()); | 578 EXPECT_EQ(0, base->Terminate()); |
| 566 } | 579 } |
| 567 | 580 |
| 568 } // namespace content | 581 } // namespace content |
| OLD | NEW |