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

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

Issue 10786029: Delete MediaStreamManager in the same way as AudioManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: put Stop() in the dtor. 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
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // This part sets up a RenderThread environment to ensure that 126 // This part sets up a RenderThread environment to ensure that
127 // RenderThread::current() (<=> TLS pointer) is valid. 127 // RenderThread::current() (<=> TLS pointer) is valid.
128 // Main parts are inspired by the RenderViewFakeResourcesTest. 128 // Main parts are inspired by the RenderViewFakeResourcesTest.
129 // Note that, the IPC part is not utilized in this test. 129 // Note that, the IPC part is not utilized in this test.
130 saved_content_renderer_.reset( 130 saved_content_renderer_.reset(
131 new ReplaceContentClientRenderer(&content_renderer_client_)); 131 new ReplaceContentClientRenderer(&content_renderer_client_));
132 mock_process_.reset(new WebRTCMockRenderProcess()); 132 mock_process_.reset(new WebRTCMockRenderProcess());
133 ui_thread_.reset(new content::TestBrowserThread(content::BrowserThread::UI, 133 ui_thread_.reset(new content::TestBrowserThread(content::BrowserThread::UI,
134 MessageLoop::current())); 134 MessageLoop::current()));
135 135
136 // Create our own AudioManager and MediaStreamManager.
137 audio_manager_.reset(media::AudioManager::Create());
138
139 scoped_refptr<media_stream::AudioInputDeviceManager>
140 audio_input_device_manager(new media_stream::AudioInputDeviceManager(
141 audio_manager_.get()));
142 scoped_refptr<media_stream::VideoCaptureManager> video_capture_manager(
143 new media_stream::VideoCaptureManager());
144 media_stream_manager_.reset(new media_stream::MediaStreamManager(
145 audio_input_device_manager, video_capture_manager));
146
136 // Construct the resource context on the UI thread. 147 // Construct the resource context on the UI thread.
137 resource_context_.reset(new MockResourceContext); 148 resource_context_.reset(new MockResourceContext);
138 149
139 static const char kThreadName[] = "RenderThread"; 150 static const char kThreadName[] = "RenderThread";
140 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, 151 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE,
141 base::Bind(&WebRTCAudioDeviceTest::InitializeIOThread, 152 base::Bind(&WebRTCAudioDeviceTest::InitializeIOThread,
142 base::Unretained(this), kThreadName)); 153 base::Unretained(this), kThreadName));
143 WaitForIOThreadCompletion(); 154 WaitForIOThreadCompletion();
144 155
145 sandbox_was_enabled_ = 156 sandbox_was_enabled_ =
(...skipping 20 matching lines...) Expand all
166 // the IO thread to actually delete the AudioEntry for the audio stream. Only 177 // the IO thread to actually delete the AudioEntry for the audio stream. Only
167 // then is the reference to the audio manager released, so we wait for the 178 // then is the reference to the audio manager released, so we wait for the
168 // whole thing to be torn down before we finally uninitialize the io thread. 179 // whole thing to be torn down before we finally uninitialize the io thread.
169 WaitForAudioManagerCompletion(); 180 WaitForAudioManagerCompletion();
170 181
171 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, 182 ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE,
172 base::Bind(&WebRTCAudioDeviceTest::UninitializeIOThread, 183 base::Bind(&WebRTCAudioDeviceTest::UninitializeIOThread,
173 base::Unretained((this)))); 184 base::Unretained((this))));
174 WaitForIOThreadCompletion(); 185 WaitForIOThreadCompletion();
175 mock_process_.reset(); 186 mock_process_.reset();
187 media_stream_manager_.reset();
188 audio_manager_.reset();
176 RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting( 189 RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting(
177 sandbox_was_enabled_); 190 sandbox_was_enabled_);
178 } 191 }
179 192
180 bool WebRTCAudioDeviceTest::Send(IPC::Message* message) { 193 bool WebRTCAudioDeviceTest::Send(IPC::Message* message) {
181 return channel_->Send(message); 194 return channel_->Send(message);
182 } 195 }
183 196
184 void WebRTCAudioDeviceTest::SetAudioUtilCallback(AudioUtilInterface* callback) { 197 void WebRTCAudioDeviceTest::SetAudioUtilCallback(AudioUtilInterface* callback) {
185 // Invalidate any potentially cached values since the new callback should 198 // Invalidate any potentially cached values since the new callback should
186 // be used for those queries. 199 // be used for those queries.
187 audio_hardware::ResetCache(); 200 audio_hardware::ResetCache();
188 audio_util_callback_ = callback; 201 audio_util_callback_ = callback;
189 } 202 }
190 203
191 void WebRTCAudioDeviceTest::InitializeIOThread(const char* thread_name) { 204 void WebRTCAudioDeviceTest::InitializeIOThread(const char* thread_name) {
192 // We initialize COM (STA) on our IO thread as is done in Chrome. 205 // We initialize COM (STA) on our IO thread as is done in Chrome.
193 // See BrowserProcessSubThread::Init. 206 // See BrowserProcessSubThread::Init.
194 initialize_com_.reset(new ScopedCOMInitializer()); 207 initialize_com_.reset(new ScopedCOMInitializer());
195 208
196 // Set the current thread as the IO thread. 209 // Set the current thread as the IO thread.
197 io_thread_.reset(new content::TestBrowserThread(content::BrowserThread::IO, 210 io_thread_.reset(new content::TestBrowserThread(content::BrowserThread::IO,
198 MessageLoop::current())); 211 MessageLoop::current()));
199 212
200 audio_manager_.reset(media::AudioManager::Create());
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
210 // Populate our resource context. 213 // Populate our resource context.
211 test_request_context_.reset(new TestURLRequestContext()); 214 test_request_context_.reset(new TestURLRequestContext());
212 MockResourceContext* resource_context = 215 MockResourceContext* resource_context =
213 static_cast<MockResourceContext*>(resource_context_.get()); 216 static_cast<MockResourceContext*>(resource_context_.get());
214 resource_context->set_request_context(test_request_context_.get()); 217 resource_context->set_request_context(test_request_context_.get());
215 media_observer_.reset(new MockMediaObserver()); 218 media_observer_.reset(new MockMediaObserver());
216 219
217 has_input_devices_ = audio_manager_->HasAudioInputDevices(); 220 has_input_devices_ = audio_manager_->HasAudioInputDevices();
218 has_output_devices_ = audio_manager_->HasAudioOutputDevices(); 221 has_output_devices_ = audio_manager_->HasAudioOutputDevices();
219 222
220 // Create an IPC channel that handles incoming messages on the IO thread. 223 // Create an IPC channel that handles incoming messages on the IO thread.
221 CreateChannel(thread_name); 224 CreateChannel(thread_name);
222 } 225 }
223 226
224 void WebRTCAudioDeviceTest::UninitializeIOThread() { 227 void WebRTCAudioDeviceTest::UninitializeIOThread() {
225 resource_context_.reset(); 228 resource_context_.reset();
226 229
227 media_stream_manager_.reset();
228 audio_manager_.reset();
229 test_request_context_.reset(); 230 test_request_context_.reset();
230 initialize_com_.reset(); 231 initialize_com_.reset();
231 } 232 }
232 233
233 void WebRTCAudioDeviceTest::CreateChannel(const char* name) { 234 void WebRTCAudioDeviceTest::CreateChannel(const char* name) {
234 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 235 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
235 audio_render_host_ = new AudioRendererHost( 236 audio_render_host_ = new AudioRendererHost(
236 audio_manager_.get(), media_observer_.get()); 237 audio_manager_.get(), media_observer_.get());
237 audio_render_host_->OnChannelConnected(base::GetCurrentProcId()); 238 audio_render_host_->OnChannelConnected(base::GetCurrentProcId());
238 239
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 WebRTCTransportImpl::~WebRTCTransportImpl() {} 367 WebRTCTransportImpl::~WebRTCTransportImpl() {}
367 368
368 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) { 369 int WebRTCTransportImpl::SendPacket(int channel, const void* data, int len) {
369 return network_->ReceivedRTPPacket(channel, data, len); 370 return network_->ReceivedRTPPacket(channel, data, len);
370 } 371 }
371 372
372 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data, 373 int WebRTCTransportImpl::SendRTCPPacket(int channel, const void* data,
373 int len) { 374 int len) {
374 return network_->ReceivedRTCPPacket(channel, data, len); 375 return network_->ReceivedRTCPPacket(channel, data, len);
375 } 376 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698