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" | |
20 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/common/content_paths.h" | 21 #include "content/public/common/content_paths.h" |
23 #include "content/public/test/mock_resource_context.h" | 22 #include "content/public/test/mock_resource_context.h" |
24 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
25 #include "content/renderer/media/audio_input_message_filter.h" | 24 #include "content/renderer/media/audio_input_message_filter.h" |
26 #include "content/renderer/media/audio_message_filter.h" | 25 #include "content/renderer/media/audio_message_filter.h" |
27 #include "content/renderer/media/webrtc_audio_device_impl.h" | 26 #include "content/renderer/media/webrtc_audio_device_impl.h" |
28 #include "content/renderer/render_process.h" | 27 #include "content/renderer/render_process.h" |
29 #include "content/renderer/render_thread_impl.h" | 28 #include "content/renderer/render_thread_impl.h" |
30 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 29 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
31 #include "media/audio/audio_parameters.h" | |
32 #include "media/base/audio_hardware_config.h" | 30 #include "media/base/audio_hardware_config.h" |
33 #include "net/url_request/url_request_test_util.h" | 31 #include "net/url_request/url_request_test_util.h" |
34 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
36 #include "third_party/webrtc/voice_engine/include/voe_audio_processing.h" | 34 #include "third_party/webrtc/voice_engine/include/voe_audio_processing.h" |
37 #include "third_party/webrtc/voice_engine/include/voe_base.h" | 35 #include "third_party/webrtc/voice_engine/include/voe_base.h" |
38 #include "third_party/webrtc/voice_engine/include/voe_file.h" | 36 #include "third_party/webrtc/voice_engine/include/voe_file.h" |
39 #include "third_party/webrtc/voice_engine/include/voe_network.h" | 37 #include "third_party/webrtc/voice_engine/include/voe_network.h" |
40 | 38 |
41 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
42 #include "base/win/scoped_com_initializer.h" | 40 #include "base/win/scoped_com_initializer.h" |
43 #endif | 41 #endif |
44 | 42 |
45 using media::AudioParameters; | |
46 using media::ChannelLayout; | |
47 using testing::_; | 43 using testing::_; |
48 using testing::InvokeWithoutArgs; | 44 using testing::InvokeWithoutArgs; |
49 using testing::Return; | 45 using testing::Return; |
50 using testing::StrEq; | 46 using testing::StrEq; |
51 | 47 |
52 namespace content { | 48 namespace content { |
53 | 49 |
54 // This class is a mock of the child process singleton which is needed | 50 // This class is a mock of the child process singleton which is needed |
55 // to be able to create a RenderThread object. | 51 // to be able to create a RenderThread object. |
56 class WebRTCMockRenderProcess : public RenderProcess { | 52 class WebRTCMockRenderProcess : public RenderProcess { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 audio_render_host_->OnChannelClosing(); | 255 audio_render_host_->OnChannelClosing(); |
260 audio_render_host_->OnFilterRemoved(); | 256 audio_render_host_->OnFilterRemoved(); |
261 audio_input_renderer_host_->OnChannelClosing(); | 257 audio_input_renderer_host_->OnChannelClosing(); |
262 audio_input_renderer_host_->OnFilterRemoved(); | 258 audio_input_renderer_host_->OnFilterRemoved(); |
263 channel_.reset(); | 259 channel_.reset(); |
264 audio_render_host_ = NULL; | 260 audio_render_host_ = NULL; |
265 audio_input_renderer_host_ = NULL; | 261 audio_input_renderer_host_ = NULL; |
266 } | 262 } |
267 | 263 |
268 void WebRTCAudioDeviceTest::OnGetAudioHardwareConfig( | 264 void WebRTCAudioDeviceTest::OnGetAudioHardwareConfig( |
269 AudioParameters* input_params, AudioParameters* output_params) { | 265 int* output_buffer_size, int* output_sample_rate, int* input_sample_rate, |
| 266 media::ChannelLayout* input_channel_layout) { |
270 ASSERT_TRUE(audio_hardware_config_); | 267 ASSERT_TRUE(audio_hardware_config_); |
271 *input_params = audio_hardware_config_->GetInputConfig(); | 268 |
272 *output_params = audio_hardware_config_->GetOutputConfig(); | 269 *output_buffer_size = audio_hardware_config_->GetOutputBufferSize(); |
| 270 *output_sample_rate = audio_hardware_config_->GetOutputSampleRate(); |
| 271 |
| 272 // TODO(henrika): add support for all available input devices. |
| 273 *input_sample_rate = audio_hardware_config_->GetInputSampleRate(); |
| 274 *input_channel_layout = audio_hardware_config_->GetInputChannelLayout(); |
273 } | 275 } |
274 | 276 |
275 // IPC::Listener implementation. | 277 // IPC::Listener implementation. |
276 bool WebRTCAudioDeviceTest::OnMessageReceived(const IPC::Message& message) { | 278 bool WebRTCAudioDeviceTest::OnMessageReceived(const IPC::Message& message) { |
277 if (render_thread_) { | 279 if (render_thread_) { |
278 IPC::ChannelProxy::MessageFilter* filter = | 280 IPC::ChannelProxy::MessageFilter* filter = |
279 render_thread_->audio_input_message_filter(); | 281 render_thread_->audio_input_message_filter(); |
280 if (filter->OnMessageReceived(message)) | 282 if (filter->OnMessageReceived(message)) |
281 return true; | 283 return true; |
282 | 284 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { | 359 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { |
358 return network_->ReceivedRTPPacket(channel, data, len); | 360 return network_->ReceivedRTPPacket(channel, data, len); |
359 } | 361 } |
360 | 362 |
361 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, | 363 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, |
362 int len) { | 364 int len) { |
363 return network_->ReceivedRTCPPacket(channel, data, len); | 365 return network_->ReceivedRTCPPacket(channel, data, len); |
364 } | 366 } |
365 | 367 |
366 } // namespace content | 368 } // namespace content |
OLD | NEW |