Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: content/test/webrtc_audio_device_test.cc

Issue 10662049: Move the device enumerate/open/close work to device thread from IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small changes to fix the trybots' failure Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/win/scoped_com_initializer.h" 14 #include "base/win/scoped_com_initializer.h"
15 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
15 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" 16 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
16 #include "content/browser/renderer_host/media/audio_renderer_host.h" 17 #include "content/browser/renderer_host/media/audio_renderer_host.h"
17 #include "content/browser/renderer_host/media/media_stream_manager.h" 18 #include "content/browser/renderer_host/media/media_stream_manager.h"
18 #include "content/browser/renderer_host/media/mock_media_observer.h" 19 #include "content/browser/renderer_host/media/mock_media_observer.h"
20 #include "content/browser/renderer_host/media/video_capture_manager.h"
19 #include "content/common/view_messages.h" 21 #include "content/common/view_messages.h"
20 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
21 #include "content/public/common/content_paths.h" 23 #include "content/public/common/content_paths.h"
22 #include "content/public/test/mock_resource_context.h" 24 #include "content/public/test/mock_resource_context.h"
23 #include "content/public/test/test_browser_thread.h" 25 #include "content/public/test/test_browser_thread.h"
24 #include "content/renderer/media/audio_device_factory.h" 26 #include "content/renderer/media/audio_device_factory.h"
25 #include "content/renderer/media/audio_hardware.h" 27 #include "content/renderer/media/audio_hardware.h"
26 #include "content/renderer/media/audio_message_filter.h" 28 #include "content/renderer/media/audio_message_filter.h"
27 #include "content/renderer/media/webrtc_audio_device_impl.h" 29 #include "content/renderer/media/webrtc_audio_device_impl.h"
28 #include "content/renderer/render_process.h" 30 #include "content/renderer/render_process.h"
(...skipping 14 matching lines...) Expand all
43 using testing::StrEq; 45 using testing::StrEq;
44 46
45 // This class is a mock of the child process singleton which is needed 47 // This class is a mock of the child process singleton which is needed
46 // to be able to create a RenderThread object. 48 // to be able to create a RenderThread object.
47 class WebRTCMockRenderProcess : public RenderProcess { 49 class WebRTCMockRenderProcess : public RenderProcess {
48 public: 50 public:
49 WebRTCMockRenderProcess() {} 51 WebRTCMockRenderProcess() {}
50 virtual ~WebRTCMockRenderProcess() {} 52 virtual ~WebRTCMockRenderProcess() {}
51 53
52 // RenderProcess implementation. 54 // RenderProcess implementation.
53 virtual skia::PlatformCanvas* GetDrawingCanvas(TransportDIB** memory, 55 virtual skia::PlatformCanvas* GetDrawingCanvas(
54 const gfx::Rect& rect) { 56 TransportDIB** memory, const gfx::Rect& rect) OVERRIDE {
55 return NULL; 57 return NULL;
56 } 58 }
57 virtual void ReleaseTransportDIB(TransportDIB* memory) {} 59 virtual void ReleaseTransportDIB(TransportDIB* memory) OVERRIDE {}
58 virtual bool UseInProcessPlugins() const { return false; } 60 virtual bool UseInProcessPlugins() const OVERRIDE { return false; }
59 virtual void AddBindings(int bindings) {} 61 virtual void AddBindings(int bindings) OVERRIDE {}
60 virtual int GetEnabledBindings() const { return 0; } 62 virtual int GetEnabledBindings() const { return 0; }
61 virtual bool HasInitializedMediaLibrary() const { return false; } 63 virtual bool HasInitializedMediaLibrary() const { return false; }
62 64
63 private: 65 private:
64 DISALLOW_COPY_AND_ASSIGN(WebRTCMockRenderProcess); 66 DISALLOW_COPY_AND_ASSIGN(WebRTCMockRenderProcess);
65 }; 67 };
66 68
67 // Utility scoped class to replace the global content client's renderer for the 69 // Utility scoped class to replace the global content client's renderer for the
68 // duration of the test. 70 // duration of the test.
69 class ReplaceContentClientRenderer { 71 class ReplaceContentClientRenderer {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // We initialize COM (STA) on our IO thread as is done in Chrome. 192 // We initialize COM (STA) on our IO thread as is done in Chrome.
191 // See BrowserProcessSubThread::Init. 193 // See BrowserProcessSubThread::Init.
192 initialize_com_.reset(new ScopedCOMInitializer()); 194 initialize_com_.reset(new ScopedCOMInitializer());
193 195
194 // Set the current thread as the IO thread. 196 // Set the current thread as the IO thread.
195 io_thread_.reset(new content::TestBrowserThread(content::BrowserThread::IO, 197 io_thread_.reset(new content::TestBrowserThread(content::BrowserThread::IO,
196 MessageLoop::current())); 198 MessageLoop::current()));
197 199
198 audio_manager_.reset(media::AudioManager::Create()); 200 audio_manager_.reset(media::AudioManager::Create());
199 201
202 scoped_refptr<media_stream::AudioInputDeviceManager>
203 audio_input_device_manager(new media_stream::AudioInputDeviceManager(
204 audio_manager_.get()));
205 scoped_refptr<media_stream::VideoCaptureManager> video_capture_manager(
206 new media_stream::VideoCaptureManager());
207 media_stream_manager_.reset(new media_stream::MediaStreamManager(
208 audio_input_device_manager, video_capture_manager));
209
200 // Populate our resource context. 210 // Populate our resource context.
201 test_request_context_.reset(new TestURLRequestContext()); 211 test_request_context_.reset(new TestURLRequestContext());
202 MockResourceContext* resource_context = 212 MockResourceContext* resource_context =
203 static_cast<MockResourceContext*>(resource_context_.get()); 213 static_cast<MockResourceContext*>(resource_context_.get());
204 resource_context->set_request_context(test_request_context_.get()); 214 resource_context->set_request_context(test_request_context_.get());
205 media_observer_.reset(new MockMediaObserver()); 215 media_observer_.reset(new MockMediaObserver());
206 216
207 has_input_devices_ = audio_manager_->HasAudioInputDevices(); 217 has_input_devices_ = audio_manager_->HasAudioInputDevices();
208 has_output_devices_ = audio_manager_->HasAudioOutputDevices(); 218 has_output_devices_ = audio_manager_->HasAudioOutputDevices();
209 219
210 // Create an IPC channel that handles incoming messages on the IO thread. 220 // Create an IPC channel that handles incoming messages on the IO thread.
211 CreateChannel(thread_name); 221 CreateChannel(thread_name);
212 } 222 }
213 223
214 void WebRTCAudioDeviceTest::UninitializeIOThread() { 224 void WebRTCAudioDeviceTest::UninitializeIOThread() {
215 resource_context_.reset(); 225 resource_context_.reset();
216 226
227 media_stream_manager_.reset();
217 audio_manager_.reset(); 228 audio_manager_.reset();
218 test_request_context_.reset(); 229 test_request_context_.reset();
219 initialize_com_.reset(); 230 initialize_com_.reset();
220 } 231 }
221 232
222 void WebRTCAudioDeviceTest::CreateChannel(const char* name) { 233 void WebRTCAudioDeviceTest::CreateChannel(const char* name) {
223 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 234 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
224 audio_render_host_ = new AudioRendererHost( 235 audio_render_host_ = new AudioRendererHost(
225 audio_manager_.get(), media_observer_.get()); 236 audio_manager_.get(), media_observer_.get());
226 audio_render_host_->OnChannelConnected(base::GetCurrentProcId()); 237 audio_render_host_->OnChannelConnected(base::GetCurrentProcId());
227 238
228 audio_input_renderer_host_ = new AudioInputRendererHost( 239 audio_input_renderer_host_ = new AudioInputRendererHost(
229 resource_context_.get(), audio_manager_.get()); 240 audio_manager_.get(), media_stream_manager_.get());
230 audio_input_renderer_host_->OnChannelConnected(base::GetCurrentProcId()); 241 audio_input_renderer_host_->OnChannelConnected(base::GetCurrentProcId());
231 242
232 channel_.reset(new IPC::Channel(name, IPC::Channel::MODE_SERVER, this)); 243 channel_.reset(new IPC::Channel(name, IPC::Channel::MODE_SERVER, this));
233 ASSERT_TRUE(channel_->Connect()); 244 ASSERT_TRUE(channel_->Connect());
234 245
235 audio_render_host_->OnFilterAdded(channel_.get()); 246 audio_render_host_->OnFilterAdded(channel_.get());
236 audio_input_renderer_host_->OnFilterAdded(channel_.get()); 247 audio_input_renderer_host_->OnFilterAdded(channel_.get());
237 } 248 }
238 249
239 void WebRTCAudioDeviceTest::DestroyChannel() { 250 void WebRTCAudioDeviceTest::DestroyChannel() {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 WebRTCTransportImpl::~WebRTCTransportImpl() {} 367 WebRTCTransportImpl::~WebRTCTransportImpl() {}
357 368
358 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { 369 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) {
359 return network_->ReceivedRTPPacket(channel, data, len); 370 return network_->ReceivedRTPPacket(channel, data, len);
360 } 371 }
361 372
362 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, 373 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data,
363 int len) { 374 int len) {
364 return network_->ReceivedRTCPPacket(channel, data, len); 375 return network_->ReceivedRTCPPacket(channel, data, len);
365 } 376 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | media/video/capture/win/video_capture_device_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698