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 "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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
11 #include "base/test/signaling_task.h" | 11 #include "base/test/signaling_task.h" |
12 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
13 #include "base/win/scoped_com_initializer.h" | 13 #include "base/win/scoped_com_initializer.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_renderer_host.h" | 15 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
16 #include "content/browser/renderer_host/media/media_stream_manager.h" | 16 #include "content/browser/renderer_host/media/media_stream_manager.h" |
17 #include "content/browser/renderer_host/media/mock_media_observer.h" | 17 #include "content/browser/renderer_host/media/mock_media_observer.h" |
18 #include "content/browser/resource_context.h" | 18 #include "content/browser/resource_context.h" |
19 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/common/content_paths.h" | 21 #include "content/public/common/content_paths.h" |
| 22 #include "content/renderer/media/audio_device.h" |
22 #include "content/renderer/media/webrtc_audio_device_impl.h" | 23 #include "content/renderer/media/webrtc_audio_device_impl.h" |
23 #include "content/renderer/render_process.h" | 24 #include "content/renderer/render_process.h" |
24 #include "content/renderer/render_thread_impl.h" | 25 #include "content/renderer/render_thread_impl.h" |
25 #include "content/test/test_browser_thread.h" | 26 #include "content/test/test_browser_thread.h" |
26 #include "net/url_request/url_request_test_util.h" | 27 #include "net/url_request/url_request_test_util.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
29 #include "third_party/webrtc/voice_engine/main/interface/voe_audio_processing.h" | 30 #include "third_party/webrtc/voice_engine/main/interface/voe_audio_processing.h" |
30 #include "third_party/webrtc/voice_engine/main/interface/voe_base.h" | 31 #include "third_party/webrtc/voice_engine/main/interface/voe_base.h" |
31 #include "third_party/webrtc/voice_engine/main/interface/voe_file.h" | 32 #include "third_party/webrtc/voice_engine/main/interface/voe_file.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 render_thread_ = new RenderThreadImpl(kThreadName); | 124 render_thread_ = new RenderThreadImpl(kThreadName); |
124 mock_process_->set_main_thread(render_thread_); | 125 mock_process_->set_main_thread(render_thread_); |
125 } | 126 } |
126 | 127 |
127 void WebRTCAudioDeviceTest::TearDown() { | 128 void WebRTCAudioDeviceTest::TearDown() { |
128 ChildProcess::current()->io_message_loop()->PostTask( | 129 ChildProcess::current()->io_message_loop()->PostTask( |
129 FROM_HERE, | 130 FROM_HERE, |
130 base::Bind(&SetupTask::UninitializeIOThread, new SetupTask(this))); | 131 base::Bind(&SetupTask::UninitializeIOThread, new SetupTask(this))); |
131 WaitForIOThreadCompletion(); | 132 WaitForIOThreadCompletion(); |
132 mock_process_.reset(); | 133 mock_process_.reset(); |
| 134 SetAudioUtilCallback(NULL); |
133 } | 135 } |
134 | 136 |
135 bool WebRTCAudioDeviceTest::Send(IPC::Message* message) { | 137 bool WebRTCAudioDeviceTest::Send(IPC::Message* message) { |
136 return channel_->Send(message); | 138 return channel_->Send(message); |
137 } | 139 } |
138 | 140 |
| 141 void WebRTCAudioDeviceTest::SetAudioUtilCallback(AudioUtilInterface* callback) { |
| 142 // Invalidate any potentially cached values since the new callback should |
| 143 // be used for those queries. |
| 144 AudioHardware::ResetCache(); |
| 145 audio_util_callback_ = callback; |
| 146 } |
| 147 |
139 void WebRTCAudioDeviceTest::InitializeIOThread(const char* thread_name) { | 148 void WebRTCAudioDeviceTest::InitializeIOThread(const char* thread_name) { |
140 // We initialize COM (STA) on our IO thread as is done in Chrome. | 149 // We initialize COM (STA) on our IO thread as is done in Chrome. |
141 // See BrowserProcessSubThread::Init. | 150 // See BrowserProcessSubThread::Init. |
142 initialize_com_.reset(new ScopedCOMInitializer()); | 151 initialize_com_.reset(new ScopedCOMInitializer()); |
143 | 152 |
144 // Set the current thread as the IO thread. | 153 // Set the current thread as the IO thread. |
145 io_thread_.reset(new content::TestBrowserThread(content::BrowserThread::IO, | 154 io_thread_.reset(new content::TestBrowserThread(content::BrowserThread::IO, |
146 MessageLoop::current())); | 155 MessageLoop::current())); |
147 test_request_context_ = new TestURLRequestContext(); | 156 test_request_context_ = new TestURLRequestContext(); |
148 resource_context_->set_request_context(test_request_context_.get()); | 157 resource_context_->set_request_context(test_request_context_.get()); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 WebRTCTransportImpl::~WebRTCTransportImpl() {} | 281 WebRTCTransportImpl::~WebRTCTransportImpl() {} |
273 | 282 |
274 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { | 283 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { |
275 return network_->ReceivedRTPPacket(channel, data, len); | 284 return network_->ReceivedRTPPacket(channel, data, len); |
276 } | 285 } |
277 | 286 |
278 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, | 287 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, |
279 int len) { | 288 int len) { |
280 return network_->ReceivedRTCPPacket(channel, data, len); | 289 return network_->ReceivedRTCPPacket(channel, data, len); |
281 } | 290 } |
OLD | NEW |