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 "content/test/webrtc_audio_device_test.h" | 5 #include "content/test/webrtc_audio_device_test.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
| 14 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" | 14 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
| 15 #include "content/browser/renderer_host/media/audio_mirroring_manager.h" | 15 #include "content/browser/renderer_host/media/audio_mirroring_manager.h" |
| 16 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 16 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 17 #include "content/browser/renderer_host/media/media_stream_manager.h" | 17 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 18 #include "content/browser/renderer_host/media/mock_media_observer.h" | 18 #include "content/browser/renderer_host/media/mock_media_observer.h" |
| 19 #include "content/common/media/media_param_traits.h" | |
|
DaleCurtis
2013/03/07 02:41:39
??
Chris Rogers
2013/03/09 01:37:50
I found that it was necessary to include this for
| |
| 19 #include "content/common/view_messages.h" | 20 #include "content/common/view_messages.h" |
| 20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/common/content_paths.h" | 22 #include "content/public/common/content_paths.h" |
| 22 #include "content/public/test/mock_resource_context.h" | 23 #include "content/public/test/mock_resource_context.h" |
| 23 #include "content/public/test/test_browser_thread.h" | 24 #include "content/public/test/test_browser_thread.h" |
| 24 #include "content/renderer/media/audio_input_message_filter.h" | 25 #include "content/renderer/media/audio_input_message_filter.h" |
| 25 #include "content/renderer/media/audio_message_filter.h" | 26 #include "content/renderer/media/audio_message_filter.h" |
| 26 #include "content/renderer/media/webrtc_audio_device_impl.h" | 27 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 27 #include "content/renderer/render_process.h" | 28 #include "content/renderer/render_process.h" |
| 28 #include "content/renderer/render_thread_impl.h" | 29 #include "content/renderer/render_thread_impl.h" |
| 29 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 30 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
| 31 #include "media/audio/audio_parameters.h" | |
| 30 #include "media/base/audio_hardware_config.h" | 32 #include "media/base/audio_hardware_config.h" |
| 31 #include "net/url_request/url_request_test_util.h" | 33 #include "net/url_request/url_request_test_util.h" |
| 32 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "third_party/webrtc/voice_engine/include/voe_audio_processing.h" | 36 #include "third_party/webrtc/voice_engine/include/voe_audio_processing.h" |
| 35 #include "third_party/webrtc/voice_engine/include/voe_base.h" | 37 #include "third_party/webrtc/voice_engine/include/voe_base.h" |
| 36 #include "third_party/webrtc/voice_engine/include/voe_file.h" | 38 #include "third_party/webrtc/voice_engine/include/voe_file.h" |
| 37 #include "third_party/webrtc/voice_engine/include/voe_network.h" | 39 #include "third_party/webrtc/voice_engine/include/voe_network.h" |
| 38 | 40 |
| 39 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 40 #include "base/win/scoped_com_initializer.h" | 42 #include "base/win/scoped_com_initializer.h" |
| 41 #endif | 43 #endif |
| 42 | 44 |
| 45 using media::AudioParameters; | |
| 46 using media::ChannelLayout; | |
| 43 using testing::_; | 47 using testing::_; |
| 44 using testing::InvokeWithoutArgs; | 48 using testing::InvokeWithoutArgs; |
| 45 using testing::Return; | 49 using testing::Return; |
| 46 using testing::StrEq; | 50 using testing::StrEq; |
| 47 | 51 |
| 48 namespace content { | 52 namespace content { |
| 49 | 53 |
| 50 // This class is a mock of the child process singleton which is needed | 54 // This class is a mock of the child process singleton which is needed |
| 51 // to be able to create a RenderThread object. | 55 // to be able to create a RenderThread object. |
| 52 class WebRTCMockRenderProcess : public RenderProcess { | 56 class WebRTCMockRenderProcess : public RenderProcess { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 audio_render_host_->OnChannelClosing(); | 259 audio_render_host_->OnChannelClosing(); |
| 256 audio_render_host_->OnFilterRemoved(); | 260 audio_render_host_->OnFilterRemoved(); |
| 257 audio_input_renderer_host_->OnChannelClosing(); | 261 audio_input_renderer_host_->OnChannelClosing(); |
| 258 audio_input_renderer_host_->OnFilterRemoved(); | 262 audio_input_renderer_host_->OnFilterRemoved(); |
| 259 channel_.reset(); | 263 channel_.reset(); |
| 260 audio_render_host_ = NULL; | 264 audio_render_host_ = NULL; |
| 261 audio_input_renderer_host_ = NULL; | 265 audio_input_renderer_host_ = NULL; |
| 262 } | 266 } |
| 263 | 267 |
| 264 void WebRTCAudioDeviceTest::OnGetAudioHardwareConfig( | 268 void WebRTCAudioDeviceTest::OnGetAudioHardwareConfig( |
| 265 int* output_buffer_size, int* output_sample_rate, int* input_sample_rate, | 269 AudioParameters* input_params, AudioParameters* output_params) { |
| 266 media::ChannelLayout* input_channel_layout) { | |
| 267 ASSERT_TRUE(audio_hardware_config_); | 270 ASSERT_TRUE(audio_hardware_config_); |
| 268 | 271 |
| 269 *output_buffer_size = audio_hardware_config_->GetOutputBufferSize(); | 272 int output_buffer_size = audio_hardware_config_->GetOutputBufferSize(); |
| 270 *output_sample_rate = audio_hardware_config_->GetOutputSampleRate(); | 273 int output_sample_rate = audio_hardware_config_->GetOutputSampleRate(); |
| 274 ChannelLayout output_channels_layout = | |
|
DaleCurtis
2013/03/07 02:41:39
Seems AudioHardwareConfig should offer to return A
| |
| 275 audio_hardware_config_->GetOutputChannelLayout(); | |
| 271 | 276 |
| 272 // TODO(henrika): add support for all available input devices. | 277 // TODO(henrika): add support for all available input devices. |
| 273 *input_sample_rate = audio_hardware_config_->GetInputSampleRate(); | 278 int input_sample_rate = audio_hardware_config_->GetInputSampleRate(); |
| 274 *input_channel_layout = audio_hardware_config_->GetInputChannelLayout(); | 279 ChannelLayout input_channel_layout = |
| 280 audio_hardware_config_->GetInputChannelLayout(); | |
| 281 | |
| 282 *input_params = AudioParameters( | |
| 283 AudioParameters::AUDIO_PCM_LOW_LATENCY, | |
| 284 input_channel_layout, | |
| 285 input_sample_rate, | |
| 286 16, | |
| 287 output_buffer_size); | |
| 288 | |
| 289 *output_params = AudioParameters( | |
| 290 AudioParameters::AUDIO_PCM_LOW_LATENCY, | |
| 291 output_channels_layout, | |
| 292 output_sample_rate, | |
| 293 16, | |
| 294 output_buffer_size); | |
| 275 } | 295 } |
| 276 | 296 |
| 277 // IPC::Listener implementation. | 297 // IPC::Listener implementation. |
| 278 bool WebRTCAudioDeviceTest::OnMessageReceived(const IPC::Message& message) { | 298 bool WebRTCAudioDeviceTest::OnMessageReceived(const IPC::Message& message) { |
| 279 if (render_thread_) { | 299 if (render_thread_) { |
| 280 IPC::ChannelProxy::MessageFilter* filter = | 300 IPC::ChannelProxy::MessageFilter* filter = |
| 281 render_thread_->audio_input_message_filter(); | 301 render_thread_->audio_input_message_filter(); |
| 282 if (filter->OnMessageReceived(message)) | 302 if (filter->OnMessageReceived(message)) |
| 283 return true; | 303 return true; |
| 284 | 304 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { | 379 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { |
| 360 return network_->ReceivedRTPPacket(channel, data, len); | 380 return network_->ReceivedRTPPacket(channel, data, len); |
| 361 } | 381 } |
| 362 | 382 |
| 363 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, | 383 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, |
| 364 int len) { | 384 int len) { |
| 365 return network_->ReceivedRTCPPacket(channel, data, len); | 385 return network_->ReceivedRTCPPacket(channel, data, len); |
| 366 } | 386 } |
| 367 | 387 |
| 368 } // namespace content | 388 } // namespace content |
| OLD | NEW |