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

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 88283002: Reland review 34393006: Refactor MediaStreamManager to not output real device id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years 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/browser/renderer_host/media/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/run_loop.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
16 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 17 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
17 #include "content/browser/renderer_host/media/device_request_message_filter.h" 18 #include "content/browser/renderer_host/media/device_request_message_filter.h"
18 #include "content/browser/renderer_host/media/media_stream_requester.h" 19 #include "content/browser/renderer_host/media/media_stream_requester.h"
19 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" 20 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
20 #include "content/browser/renderer_host/media/video_capture_manager.h" 21 #include "content/browser/renderer_host/media/video_capture_manager.h"
21 #include "content/browser/renderer_host/media/web_contents_capture_util.h" 22 #include "content/browser/renderer_host/media/web_contents_capture_util.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/content_browser_client.h" 24 #include "content/public/browser/content_browser_client.h"
24 #include "content/public/browser/media_device_id.h" 25 #include "content/public/browser/media_device_id.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return label; 57 return label;
57 } 58 }
58 59
59 // Helper to verify if a media stream type is part of options or not. 60 // Helper to verify if a media stream type is part of options or not.
60 static bool Requested(const MediaStreamRequest& request, 61 static bool Requested(const MediaStreamRequest& request,
61 MediaStreamType stream_type) { 62 MediaStreamType stream_type) {
62 return (request.audio_type == stream_type || 63 return (request.audio_type == stream_type ||
63 request.video_type == stream_type); 64 request.video_type == stream_type);
64 } 65 }
65 66
66 // TODO(xians): Merge DeviceRequest with MediaStreamRequest.
Jói 2013/11/27 13:52:00 Intentional?
perkj_chrome 2013/11/27 14:10:00 yes- it is a bad idea to merge theese. MediaStream
67 class MediaStreamManager::DeviceRequest { 67 class MediaStreamManager::DeviceRequest {
68 public: 68 public:
69 DeviceRequest(MediaStreamRequester* requester, 69 DeviceRequest(MediaStreamRequester* requester,
70 const MediaStreamRequest& request, 70 const MediaStreamRequest& request,
71 int requesting_process_id, 71 int requesting_process_id,
72 int requesting_view_id) 72 int requesting_view_id)
73 : requester(requester), 73 : requester(requester),
74 request(request), 74 request(request),
75 requesting_process_id(requesting_process_id), 75 requesting_process_id(requesting_process_id),
76 requesting_view_id(requesting_view_id), 76 requesting_view_id(requesting_view_id),
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 InitializeDeviceManagersOnIOThread(); 174 InitializeDeviceManagersOnIOThread();
175 } else { 175 } else {
176 BrowserThread::PostTask( 176 BrowserThread::PostTask(
177 BrowserThread::IO, FROM_HERE, 177 BrowserThread::IO, FROM_HERE,
178 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread, 178 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread,
179 base::Unretained(this))); 179 base::Unretained(this)));
180 } 180 }
181 } 181 }
182 182
183 MediaStreamManager::~MediaStreamManager() { 183 MediaStreamManager::~MediaStreamManager() {
184 DVLOG(1) << "~MediaStreamManager";
184 DCHECK(requests_.empty()); 185 DCHECK(requests_.empty());
185 DCHECK(!device_thread_.get()); 186 DCHECK(!device_thread_.get());
186 } 187 }
187 188
188 VideoCaptureManager* MediaStreamManager::video_capture_manager() { 189 VideoCaptureManager* MediaStreamManager::video_capture_manager() {
189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
190 DCHECK(video_capture_manager_.get()); 191 DCHECK(video_capture_manager_.get());
191 return video_capture_manager_.get(); 192 return video_capture_manager_.get();
192 } 193 }
193 194
194 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() { 195 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() {
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
196 DCHECK(audio_input_device_manager_.get()); 197 DCHECK(audio_input_device_manager_.get());
197 return audio_input_device_manager_.get(); 198 return audio_input_device_manager_.get();
198 } 199 }
199 200
200 std::string MediaStreamManager::MakeMediaAccessRequest( 201 std::string MediaStreamManager::MakeMediaAccessRequest(
201 int render_process_id, 202 int render_process_id,
202 int render_view_id, 203 int render_view_id,
203 int page_request_id, 204 int page_request_id,
204 const StreamOptions& options, 205 const StreamOptions& options,
205 const GURL& security_origin, 206 const GURL& security_origin,
206 const MediaRequestResponseCallback& callback) { 207 const MediaRequestResponseCallback& callback) {
207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
208 // Create a new request based on options. 209 // Create a new request based on options.
209 MediaStreamRequest stream_request( 210 MediaStreamRequest stream_request(
210 render_process_id, render_view_id, page_request_id, std::string(), 211 render_process_id, render_view_id, page_request_id,
211 security_origin, MEDIA_DEVICE_ACCESS, std::string(), std::string(), 212 security_origin, MEDIA_DEVICE_ACCESS, std::string(), std::string(),
212 options.audio_type, options.video_type); 213 options.audio_type, options.video_type);
213 DeviceRequest* request = new DeviceRequest(NULL, stream_request, 214 DeviceRequest* request = new DeviceRequest(NULL, stream_request,
214 render_process_id, render_view_id); 215 render_process_id, render_view_id);
215 const std::string& label = AddRequest(request); 216 const std::string& label = AddRequest(request);
216 217
217 request->callback = callback; 218 request->callback = callback;
218 219 // Post a task and handle the request asynchronously. The reason is that the
219 HandleRequest(label); 220 // requester won't have a label for the request until this function returns
220 221 // and thus can not handle a response. Using base::Unretained is safe since
222 // MediaStreamManager is deleted on the UI thread, after the IO thread has
223 // been stopped.
224 BrowserThread::PostTask(
225 BrowserThread::IO, FROM_HERE,
226 base::Bind(&MediaStreamManager::SetupRequest,
227 base::Unretained(this), label));
221 return label; 228 return label;
222 } 229 }
223 230
224 std::string MediaStreamManager::GenerateStream( 231 std::string MediaStreamManager::GenerateStream(
225 MediaStreamRequester* requester, 232 MediaStreamRequester* requester,
226 int render_process_id, 233 int render_process_id,
227 int render_view_id, 234 int render_view_id,
228 int page_request_id, 235 int page_request_id,
229 const StreamOptions& options, 236 const StreamOptions& options,
230 const GURL& security_origin) { 237 const GURL& security_origin) {
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
239 DVLOG(1) << "GenerateStream()";
232 if (CommandLine::ForCurrentProcess()->HasSwitch( 240 if (CommandLine::ForCurrentProcess()->HasSwitch(
233 switches::kUseFakeDeviceForMediaStream)) { 241 switches::kUseFakeDeviceForMediaStream)) {
234 UseFakeDevice(); 242 UseFakeDevice();
235 } 243 }
236 if (CommandLine::ForCurrentProcess()->HasSwitch( 244 if (CommandLine::ForCurrentProcess()->HasSwitch(
237 switches::kUseFakeUIForMediaStream)) { 245 switches::kUseFakeUIForMediaStream)) {
238 UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy>()); 246 UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy>());
239 } 247 }
240 248
241 int target_render_process_id = render_process_id;
242 int target_render_view_id = render_view_id;
243 std::string tab_capture_device_id;
244
245 // Customize options for a WebContents based capture.
246 if (options.audio_type == MEDIA_TAB_AUDIO_CAPTURE ||
247 options.video_type == MEDIA_TAB_VIDEO_CAPTURE) {
248 // TODO(justinlin): Can't plumb audio mirroring using stream type right
249 // now, so plumbing by device_id. Will revisit once it's refactored.
250 // http://crbug.com/163100
251 tab_capture_device_id =
252 WebContentsCaptureUtil::AppendWebContentsDeviceScheme(
253 !options.video_device_id.empty() ?
254 options.video_device_id : options.audio_device_id);
255
256 bool has_valid_device_id = WebContentsCaptureUtil::ExtractTabCaptureTarget(
257 tab_capture_device_id, &target_render_process_id,
258 &target_render_view_id);
259 if (!has_valid_device_id ||
260 (options.audio_type != MEDIA_TAB_AUDIO_CAPTURE &&
261 options.audio_type != MEDIA_NO_SERVICE) ||
262 (options.video_type != MEDIA_TAB_VIDEO_CAPTURE &&
263 options.video_type != MEDIA_NO_SERVICE)) {
264 LOG(ERROR) << "Invalid request.";
265 return std::string();
266 }
267 }
268
269 std::string translated_audio_device_id;
270 std::string translated_video_device_id;
271 if (options.audio_type == MEDIA_DEVICE_AUDIO_CAPTURE) {
272 bool found_match = TranslateGUIDToRawId(
273 MEDIA_DEVICE_AUDIO_CAPTURE, security_origin, options.audio_device_id,
274 &translated_audio_device_id);
275 DCHECK(found_match || translated_audio_device_id.empty());
276 }
277
278 if (options.video_type == MEDIA_DEVICE_VIDEO_CAPTURE) {
279 bool found_match = TranslateGUIDToRawId(
280 MEDIA_DEVICE_VIDEO_CAPTURE, security_origin, options.video_device_id,
281 &translated_video_device_id);
282 DCHECK(found_match || translated_video_device_id.empty());
283 }
284
285 if (options.video_type == MEDIA_DESKTOP_VIDEO_CAPTURE ||
286 options.audio_type == MEDIA_LOOPBACK_AUDIO_CAPTURE) {
287 // For screen capture we only support two valid combinations:
288 // (1) screen video capture only, or
289 // (2) screen video capture with loopback audio capture.
290 if (options.video_type != MEDIA_DESKTOP_VIDEO_CAPTURE ||
291 (options.audio_type != MEDIA_NO_SERVICE &&
292 options.audio_type != MEDIA_LOOPBACK_AUDIO_CAPTURE)) {
293 // TODO(sergeyu): Surface error message to the calling JS code.
294 LOG(ERROR) << "Invalid screen capture request.";
295 return std::string();
296 }
297 translated_video_device_id = options.video_device_id;
298 }
299
300 // Create a new request based on options. 249 // Create a new request based on options.
301 MediaStreamRequest stream_request( 250 MediaStreamRequest stream_request(
302 target_render_process_id, target_render_view_id, page_request_id, 251 render_process_id, render_view_id, page_request_id,
303 tab_capture_device_id, security_origin, MEDIA_GENERATE_STREAM, 252 security_origin, MEDIA_GENERATE_STREAM,
304 translated_audio_device_id, translated_video_device_id, 253 options.audio_device_id, options.video_device_id,
305 options.audio_type, options.video_type); 254 options.audio_type, options.video_type);
306 DeviceRequest* request = new DeviceRequest(requester, stream_request, 255 DeviceRequest* request = new DeviceRequest(requester, stream_request,
307 render_process_id, 256 render_process_id,
308 render_view_id); 257 render_view_id);
309 const std::string& label = AddRequest(request); 258 const std::string& label = AddRequest(request);
310 HandleRequest(label); 259
260 // Post a task and handle the request asynchronously. The reason is that the
261 // requester won't have a label for the request until this function returns
262 // and thus can not handle a response. Using base::Unretained is safe since
263 // MediaStreamManager is deleted on the UI thread, after the IO thread has
264 // been stopped.
265 BrowserThread::PostTask(
266 BrowserThread::IO, FROM_HERE,
267 base::Bind(&MediaStreamManager::SetupRequest,
268 base::Unretained(this), label));
311 return label; 269 return label;
312 } 270 }
313 271
314 void MediaStreamManager::CancelRequest(const std::string& label) { 272 void MediaStreamManager::CancelRequest(const std::string& label) {
315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
316 DVLOG(1) << "CancelRequest({label = " << label << "})"; 274 DVLOG(1) << "CancelRequest({label = " << label << "})";
317 DeviceRequests::iterator request_it = requests_.find(label); 275 DeviceRequest* request = FindRequest(label);
318 if (request_it == requests_.end()) { 276 if (!request) {
319 NOTREACHED(); 277 // The request does not exist.
278 LOG(ERROR) << "The request with label = " << label << " does not exist.";
320 return; 279 return;
321 } 280 }
322 scoped_ptr<DeviceRequest> request(request_it->second);
323 RemoveRequest(request_it);
324
325 if (request->request.request_type == MEDIA_ENUMERATE_DEVICES) { 281 if (request->request.request_type == MEDIA_ENUMERATE_DEVICES) {
282 DeleteRequest(label);
326 return; 283 return;
327 } 284 }
328 285
329 // This is a request for opening one or more devices. 286 // This is a request for opening one or more devices.
330 for (StreamDeviceInfoArray::iterator device_it = request->devices.begin(); 287 for (StreamDeviceInfoArray::iterator device_it = request->devices.begin();
331 device_it != request->devices.end(); ++device_it) { 288 device_it != request->devices.end(); ++device_it) {
289 MediaRequestState state = request->state(device_it->device.type);
332 // If we have not yet requested the device to be opened - just ignore it. 290 // If we have not yet requested the device to be opened - just ignore it.
333 if (request->state(device_it->device.type) != MEDIA_REQUEST_STATE_OPENING 291 if (state != MEDIA_REQUEST_STATE_OPENING &&
334 && 292 state != MEDIA_REQUEST_STATE_DONE) {
335 request->state(device_it->device.type) != MEDIA_REQUEST_STATE_DONE) {
336 continue; 293 continue;
337 } 294 }
338 // Stop the opening/opened devices of the requests. 295 // Stop the opening/opened devices of the requests.
339 CloseDevice(device_it->device.type, device_it->session_id); 296 CloseDevice(device_it->device.type, device_it->session_id);
340 } 297 }
341 298
342 // Cancel the request if still pending at UI side. 299 // Cancel the request if still pending at UI side.
343 request->SetState(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_CLOSING); 300 request->SetState(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_CLOSING);
301 DeleteRequest(label);
344 } 302 }
345 303
346 void MediaStreamManager::CancelAllRequests(int render_process_id) { 304 void MediaStreamManager::CancelAllRequests(int render_process_id) {
347 DeviceRequests::iterator request_it = requests_.begin(); 305 DeviceRequests::iterator request_it = requests_.begin();
348 while (request_it != requests_.end()) { 306 while (request_it != requests_.end()) {
349 if (request_it->second->requesting_process_id != render_process_id) { 307 if (request_it->second->requesting_process_id != render_process_id) {
350 ++request_it; 308 ++request_it;
351 continue; 309 continue;
352 } 310 }
353 311
354 std::string label = request_it->first; 312 std::string label = request_it->first;
355 ++request_it; 313 ++request_it;
356 CancelRequest(label); 314 CancelRequest(label);
357 } 315 }
358 } 316 }
359 317
360 void MediaStreamManager::StopStreamDevice(int render_process_id, 318 void MediaStreamManager::StopStreamDevice(int render_process_id,
361 int render_view_id, 319 int render_view_id,
362 const std::string& device_id) { 320 const std::string& device_id) {
363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
364 DVLOG(1) << "StopStreamDevice({render_view_id = " << render_view_id << "} " 322 DVLOG(1) << "StopStreamDevice({render_view_id = " << render_view_id << "} "
365 << ", {device_id = " << device_id << "})"; 323 << ", {device_id = " << device_id << "})";
366 324
367 // Find the first request for this |render_process_id| and |render_view_id|
Jói 2013/11/27 13:52:00 Intentional? I'm starting to wonder if you accide
perkj_chrome 2013/11/27 14:10:00 This was mistakenly removed in patch #2 - not the
368 // of type MEDIA_GENERATE_STREAM that has requested to use |device_id| and
369 // stop it.
370 for (DeviceRequests::iterator request_it = requests_.begin(); 325 for (DeviceRequests::iterator request_it = requests_.begin();
371 request_it != requests_.end(); ++request_it) { 326 request_it != requests_.end(); ++request_it) {
372 DeviceRequest* request = request_it->second; 327 DeviceRequest* request = request_it->second;
373 const MediaStreamRequest& ms_request = request->request; 328 const MediaStreamRequest& ms_request = request->request;
374 if (request->requesting_process_id != render_process_id || 329 if (request->requesting_process_id != render_process_id ||
375 request->requesting_view_id != render_view_id || 330 request->requesting_view_id != render_view_id ||
376 ms_request.request_type != MEDIA_GENERATE_STREAM) { 331 ms_request.request_type != MEDIA_GENERATE_STREAM) {
377 continue; 332 continue;
378 } 333 }
379 334
(...skipping 22 matching lines...) Expand all
402 device_it->session_id != session_id) { 357 device_it->session_id != session_id) {
403 ++device_it; 358 ++device_it;
404 continue; 359 continue;
405 } 360 }
406 if (request->state(type) == MEDIA_REQUEST_STATE_DONE) 361 if (request->state(type) == MEDIA_REQUEST_STATE_DONE)
407 CloseDevice(type, session_id); 362 CloseDevice(type, session_id);
408 device_it = devices->erase(device_it); 363 device_it = devices->erase(device_it);
409 } 364 }
410 // If this request doesn't have any active devices, remove the request. 365 // If this request doesn't have any active devices, remove the request.
411 if (devices->empty()) { 366 if (devices->empty()) {
412 DeviceRequests::iterator del_itor(request_it); 367 std::string label = request_it->first;
413 ++request_it; 368 ++request_it;
414 scoped_ptr<DeviceRequest> request(del_itor->second); 369 DeleteRequest(label);
415 RemoveRequest(del_itor);
416 } else { 370 } else {
417 ++request_it; 371 ++request_it;
418 } 372 }
419 } 373 }
420 } 374 }
421 375
422 void MediaStreamManager::CloseDevice(MediaStreamType type, int session_id) { 376 void MediaStreamManager::CloseDevice(MediaStreamType type, int session_id) {
423 DVLOG(1) << "CloseDevice(" 377 DVLOG(1) << "CloseDevice("
424 << "{type = " << type << "} " 378 << "{type = " << type << "} "
425 << "{session_id = " << session_id << "})"; 379 << "{session_id = " << session_id << "})";
(...skipping 29 matching lines...) Expand all
455 // starts monitoring devices. 409 // starts monitoring devices.
456 if (!requester) { 410 if (!requester) {
457 if (!monitoring_started_) 411 if (!monitoring_started_)
458 StartMonitoring(); 412 StartMonitoring();
459 413
460 return std::string(); 414 return std::string();
461 } 415 }
462 416
463 // Create a new request. 417 // Create a new request.
464 StreamOptions options; 418 StreamOptions options;
465 EnumerationCache* cache = NULL;
466 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) { 419 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) {
467 options.audio_type = type; 420 options.audio_type = type;
468 cache = &audio_enumeration_cache_;
469 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) { 421 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) {
470 options.video_type = type; 422 options.video_type = type;
471 cache = &video_enumeration_cache_;
472 } else { 423 } else {
473 NOTREACHED(); 424 NOTREACHED();
474 return std::string(); 425 return std::string();
475 } 426 }
476 427
477 MediaStreamRequest stream_request( 428 MediaStreamRequest stream_request(
478 render_process_id, render_view_id, page_request_id, std::string(), 429 render_process_id, render_view_id, page_request_id,
479 security_origin, MEDIA_ENUMERATE_DEVICES, std::string(), std::string(), 430 security_origin, MEDIA_ENUMERATE_DEVICES, std::string(), std::string(),
480 options.audio_type, options.video_type); 431 options.audio_type, options.video_type);
481 DeviceRequest* request = new DeviceRequest(requester, stream_request, 432 DeviceRequest* request = new DeviceRequest(requester, stream_request,
482 render_process_id, 433 render_process_id,
483 render_view_id); 434 render_view_id);
484 const std::string& label = AddRequest(request); 435 const std::string& label = AddRequest(request);
436 // Post a task and handle the request asynchronously. The reason is that the
437 // requester won't have a label for the request until this function returns
438 // and thus can not handle a response. Using base::Unretained is safe since
439 // MediaStreamManager is deleted on the UI thread, after the IO thread has
440 // been stopped.
441 BrowserThread::PostTask(
442 BrowserThread::IO, FROM_HERE,
443 base::Bind(&MediaStreamManager::DoEnumerateDevices,
444 base::Unretained(this), label));
445
446 return label;
447 }
448
449 void MediaStreamManager::DoEnumerateDevices(const std::string& label) {
450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
451 DeviceRequest* request = FindRequest(label);
452 if (!request)
453 return; // This can happen if the request has been canceled.
454
455 MediaStreamType type;
456 EnumerationCache* cache;
457 if (request->request.audio_type == MEDIA_DEVICE_AUDIO_CAPTURE) {
458 DCHECK_EQ(MEDIA_NO_SERVICE, request->request.video_type);
459 type = MEDIA_DEVICE_AUDIO_CAPTURE;
460 cache = &audio_enumeration_cache_;
461 } else {
462 DCHECK_EQ(MEDIA_DEVICE_VIDEO_CAPTURE, request->request.video_type);
463 type = MEDIA_DEVICE_VIDEO_CAPTURE;
464 cache = &video_enumeration_cache_;
465 }
485 466
486 if (cache->valid) { 467 if (cache->valid) {
487 // Cached device list of this type exists. Just send it out. 468 // Cached device list of this type exists. Just send it out.
488 request->SetState(type, MEDIA_REQUEST_STATE_REQUESTED); 469 request->SetState(type, MEDIA_REQUEST_STATE_REQUESTED);
489 470 request->devices = cache->devices;
490 // Need to post a task since the requester won't have label till 471 FinalizeEnumerateDevices(label, request);
491 // this function returns.
492 BrowserThread::PostTask(
493 BrowserThread::IO, FROM_HERE,
494 base::Bind(&MediaStreamManager::SendCachedDeviceList,
495 base::Unretained(this), cache, label));
496 } else { 472 } else {
497 StartEnumeration(request); 473 StartEnumeration(request);
498 } 474 }
499
500 DVLOG(1) << "Enumerate Devices ({label = " << label << "})"; 475 DVLOG(1) << "Enumerate Devices ({label = " << label << "})";
501 return label;
502 } 476 }
503 477
504 std::string MediaStreamManager::OpenDevice( 478 std::string MediaStreamManager::OpenDevice(
505 MediaStreamRequester* requester, 479 MediaStreamRequester* requester,
506 int render_process_id, 480 int render_process_id,
507 int render_view_id, 481 int render_view_id,
508 int page_request_id, 482 int page_request_id,
509 const std::string& device_id, 483 const std::string& device_id,
510 MediaStreamType type, 484 MediaStreamType type,
511 const GURL& security_origin) { 485 const GURL& security_origin) {
512 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 486 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
513 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || 487 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE ||
514 type == MEDIA_DEVICE_VIDEO_CAPTURE); 488 type == MEDIA_DEVICE_VIDEO_CAPTURE);
515 489
516 // Create a new request. 490 // Create a new request.
517 StreamOptions options; 491 StreamOptions options;
518 if (IsAudioMediaType(type)) { 492 if (IsAudioMediaType(type)) {
519 options.audio_type = type; 493 options.audio_type = type;
520 options.audio_device_id = device_id; 494 options.audio_device_id = device_id;
521 } else if (IsVideoMediaType(type)) { 495 } else if (IsVideoMediaType(type)) {
522 options.video_type = type; 496 options.video_type = type;
523 options.video_device_id = device_id; 497 options.video_device_id = device_id;
524 } else { 498 } else {
525 NOTREACHED(); 499 NOTREACHED();
526 return std::string(); 500 return std::string();
527 } 501 }
528 502
529 MediaStreamRequest stream_request( 503 MediaStreamRequest stream_request(
530 render_process_id, render_view_id, page_request_id, std::string(), 504 render_process_id, render_view_id, page_request_id,
531 security_origin, MEDIA_OPEN_DEVICE, options.audio_device_id, 505 security_origin, MEDIA_OPEN_DEVICE, options.audio_device_id,
532 options.video_device_id, options.audio_type, options.video_type); 506 options.video_device_id, options.audio_type, options.video_type);
533 DeviceRequest* request = new DeviceRequest(requester, stream_request, 507 DeviceRequest* request = new DeviceRequest(requester, stream_request,
534 render_process_id, 508 render_process_id,
535 render_view_id); 509 render_view_id);
536 const std::string& label = AddRequest(request); 510 const std::string& label = AddRequest(request);
537 StartEnumeration(request); 511 // Post a task and handle the request asynchronously. The reason is that the
512 // requester won't have a label for the request until this function returns
513 // and thus can not handle a response. Using base::Unretained is safe since
514 // MediaStreamManager is deleted on the UI thread, after the IO thread has
515 // been stopped.
516 BrowserThread::PostTask(
517 BrowserThread::IO, FROM_HERE,
518 base::Bind(&MediaStreamManager::SetupRequest,
519 base::Unretained(this), label));
538 520
539 DVLOG(1) << "OpenDevice ({label = " << label << "})"; 521 DVLOG(1) << "OpenDevice ({label = " << label << "})";
540 return label; 522 return label;
541 } 523 }
542 524
543 void MediaStreamManager::SendCachedDeviceList(
544 EnumerationCache* cache,
545 const std::string& label) {
546 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
547 if (cache->valid) {
548 DeviceRequests::iterator it = requests_.find(label);
549 if (it != requests_.end()) {
550 it->second->requester->DevicesEnumerated(label, cache->devices);
551 }
552 }
553 }
554
555 void MediaStreamManager::StopRemovedDevices( 525 void MediaStreamManager::StopRemovedDevices(
556 const StreamDeviceInfoArray& old_devices, 526 const StreamDeviceInfoArray& old_devices,
557 const StreamDeviceInfoArray& new_devices) { 527 const StreamDeviceInfoArray& new_devices) {
558 DVLOG(1) << "StopRemovedDevices(" 528 DVLOG(1) << "StopRemovedDevices("
559 << "{#old_devices = " << old_devices.size() << "} " 529 << "{#old_devices = " << old_devices.size() << "} "
560 << "{#new_devices = " << new_devices.size() << "})"; 530 << "{#new_devices = " << new_devices.size() << "})";
561 for (StreamDeviceInfoArray::const_iterator old_dev_it = old_devices.begin(); 531 for (StreamDeviceInfoArray::const_iterator old_dev_it = old_devices.begin();
562 old_dev_it != old_devices.end(); ++old_dev_it) { 532 old_dev_it != old_devices.end(); ++old_dev_it) {
563 bool device_found = false; 533 bool device_found = false;
564 for (StreamDeviceInfoArray::const_iterator new_dev_it = new_devices.begin(); 534 for (StreamDeviceInfoArray::const_iterator new_dev_it = new_devices.begin();
(...skipping 13 matching lines...) Expand all
578 } 548 }
579 549
580 void MediaStreamManager::StopRemovedDevice(const MediaStreamDevice& device) { 550 void MediaStreamManager::StopRemovedDevice(const MediaStreamDevice& device) {
581 std::vector<int> session_ids; 551 std::vector<int> session_ids;
582 for (DeviceRequests::const_iterator it = requests_.begin(); 552 for (DeviceRequests::const_iterator it = requests_.begin();
583 it != requests_.end() ; ++it) { 553 it != requests_.end() ; ++it) {
584 const DeviceRequest* request = it->second; 554 const DeviceRequest* request = it->second;
585 for (StreamDeviceInfoArray::const_iterator device_it = 555 for (StreamDeviceInfoArray::const_iterator device_it =
586 request->devices.begin(); 556 request->devices.begin();
587 device_it != request->devices.end(); ++device_it) { 557 device_it != request->devices.end(); ++device_it) {
588 if (device_it->device.IsEqual(device)) { 558 std::string source_id = content::GetHMACForMediaDeviceID(
559 request->request.security_origin,
560 device.id);
561 if (device_it->device.id == source_id &&
562 device_it->device.type == device.type) {
589 session_ids.push_back(device_it->session_id); 563 session_ids.push_back(device_it->session_id);
590 if (it->second->requester) { 564 if (it->second->requester) {
591 it->second->requester->DeviceStopped( 565 it->second->requester->DeviceStopped(
592 it->second->requesting_view_id, 566 it->second->requesting_view_id,
593 it->first, 567 it->first,
594 *device_it); 568 *device_it);
595 } 569 }
596 } 570 }
597 } 571 }
598 } 572 }
(...skipping 24 matching lines...) Expand all
623 void MediaStreamManager::StopMonitoring() { 597 void MediaStreamManager::StopMonitoring() {
624 DCHECK_EQ(base::MessageLoop::current(), io_loop_); 598 DCHECK_EQ(base::MessageLoop::current(), io_loop_);
625 if (monitoring_started_) { 599 if (monitoring_started_) {
626 base::SystemMonitor::Get()->RemoveDevicesChangedObserver(this); 600 base::SystemMonitor::Get()->RemoveDevicesChangedObserver(this);
627 monitoring_started_ = false; 601 monitoring_started_ = false;
628 ClearEnumerationCache(&audio_enumeration_cache_); 602 ClearEnumerationCache(&audio_enumeration_cache_);
629 ClearEnumerationCache(&video_enumeration_cache_); 603 ClearEnumerationCache(&video_enumeration_cache_);
630 } 604 }
631 } 605 }
632 606
633 bool MediaStreamManager::TranslateGUIDToRawId(MediaStreamType stream_type, 607 bool MediaStreamManager::TranslateRequestedSourceIdToDeviceId(
634 const GURL& security_origin, 608 MediaStreamRequest* request) {
635 const std::string& device_guid, 609 // If a specific device has been requested we need to find the real device id.
636 std::string* raw_device_id) { 610 if (request->audio_type == MEDIA_DEVICE_AUDIO_CAPTURE &&
611 !request->requested_audio_device_id.empty()) {
612 if (!TranslateSourceIdToDeviceId(MEDIA_DEVICE_AUDIO_CAPTURE,
613 request->security_origin,
614 request->requested_audio_device_id,
615 &request->requested_audio_device_id)) {
616 // TODO(perkj): gUM should support mandatory and optional constraints.
617 // Ie - if the sourceId is optional but it does not match - gUM should
618 // not fail. For now we treat sourceId as a mandatory constraint.
619 LOG(ERROR) << "Requested device does not exist.";
620 return false;
621 }
622 }
623
624 if (request->video_type == MEDIA_DEVICE_VIDEO_CAPTURE &&
625 !request->requested_video_device_id.empty()) {
626 if (!TranslateSourceIdToDeviceId(MEDIA_DEVICE_VIDEO_CAPTURE,
627 request->security_origin,
628 request->requested_video_device_id,
629 &request->requested_video_device_id)) {
630 // TODO(perkj): guM should support mandatory and optional constraints.
631 // Ie - if the sourceId is optional but it does not match - guM should
632 // not fail. For now we treat sourceId as a mandatory constraint.
633 LOG(ERROR) << "Requested device does not exist.";
634 return false;
635 }
636 }
637 DVLOG(3) << "Requested audio device " << request->requested_audio_device_id
638 << " video device " << request->requested_video_device_id;
639 return true;
640 }
641
642 void MediaStreamManager::TranslateDeviceIdToSourceId(
643 const MediaStreamRequest& request,
644 MediaStreamDevice* device) {
645 if (request.audio_type == MEDIA_DEVICE_AUDIO_CAPTURE ||
646 request.video_type == MEDIA_DEVICE_VIDEO_CAPTURE) {
647 device->id = content::GetHMACForMediaDeviceID(request.security_origin,
648 device->id);
649 }
650 }
651
652 bool MediaStreamManager::TranslateSourceIdToDeviceId(
653 MediaStreamType stream_type,
654 const GURL& security_origin,
655 const std::string& source_id,
656 std::string* device_id) {
637 DCHECK(stream_type == MEDIA_DEVICE_AUDIO_CAPTURE || 657 DCHECK(stream_type == MEDIA_DEVICE_AUDIO_CAPTURE ||
638 stream_type == MEDIA_DEVICE_VIDEO_CAPTURE); 658 stream_type == MEDIA_DEVICE_VIDEO_CAPTURE);
639 if (device_guid.empty()) 659 DCHECK(!source_id.empty());
640 return false;
641 660
642 EnumerationCache* cache = 661 EnumerationCache* cache =
643 stream_type == MEDIA_DEVICE_AUDIO_CAPTURE ? 662 stream_type == MEDIA_DEVICE_AUDIO_CAPTURE ?
644 &audio_enumeration_cache_ : &video_enumeration_cache_; 663 &audio_enumeration_cache_ : &video_enumeration_cache_;
645 664
646 // If device monitoring hasn't started, the |device_guid| is not valid. 665 // If device monitoring hasn't started, the |device_guid| is not valid.
647 if (!cache->valid) 666 if (!cache->valid)
648 return false; 667 return false;
649 668
650 for (StreamDeviceInfoArray::const_iterator it = cache->devices.begin(); 669 for (StreamDeviceInfoArray::const_iterator it = cache->devices.begin();
651 it != cache->devices.end(); 670 it != cache->devices.end();
652 ++it) { 671 ++it) {
653 if (content::DoesMediaDeviceIDMatchHMAC( 672 if (content::DoesMediaDeviceIDMatchHMAC(security_origin, source_id,
654 security_origin, device_guid, it->device.id)) { 673 it->device.id)) {
655 *raw_device_id = it->device.id; 674 *device_id = it->device.id;
656 return true; 675 return true;
657 } 676 }
658 } 677 }
659 return false; 678 return false;
660 } 679 }
661 680
662 void MediaStreamManager::ClearEnumerationCache(EnumerationCache* cache) { 681 void MediaStreamManager::ClearEnumerationCache(EnumerationCache* cache) {
663 DCHECK_EQ(base::MessageLoop::current(), io_loop_); 682 DCHECK_EQ(base::MessageLoop::current(), io_loop_);
664 cache->valid = false; 683 cache->valid = false;
665 } 684 }
(...skipping 27 matching lines...) Expand all
693 std::string unique_label; 712 std::string unique_label;
694 do { 713 do {
695 unique_label = RandomLabel(); 714 unique_label = RandomLabel();
696 } while (requests_.find(unique_label) != requests_.end()); 715 } while (requests_.find(unique_label) != requests_.end());
697 716
698 requests_.insert(std::make_pair(unique_label, request)); 717 requests_.insert(std::make_pair(unique_label, request));
699 718
700 return unique_label; 719 return unique_label;
701 } 720 }
702 721
703 void MediaStreamManager::RemoveRequest(DeviceRequests::iterator it) { 722 MediaStreamManager::DeviceRequest*
723 MediaStreamManager::FindRequest(const std::string& label) const {
724 DeviceRequests::const_iterator request_it = requests_.find(label);
725 return request_it == requests_.end() ? NULL : request_it->second;
726 }
727
728 void MediaStreamManager::DeleteRequest(const std::string& label) {
729 DeviceRequests::iterator it = requests_.find(label);
730 scoped_ptr<DeviceRequest> request(it->second);
704 requests_.erase(it); 731 requests_.erase(it);
705 } 732 }
706 733
707 void MediaStreamManager::PostRequestToUI(const std::string& label) { 734 void MediaStreamManager::PostRequestToUI(const std::string& label,
735 DeviceRequest* request) {
708 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
709 DeviceRequest* request = requests_[label]; 737 DVLOG(1) << "PostRequestToUI({label= " << label << "})";
738 // If a specific device has been requested we need to find the real device id.
739 if (!TranslateRequestedSourceIdToDeviceId(&request->request)) {
740 FinalizeRequestFailed(label, request);
741 return;
742 }
743
744 const MediaStreamType audio_type = request->request.audio_type;
745 const MediaStreamType video_type = request->request.video_type;
746
747 // Post the request to UI and set the state.
748 if (IsAudioMediaType(audio_type))
749 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
750 if (IsVideoMediaType(video_type))
751 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
710 752
711 if (use_fake_ui_) { 753 if (use_fake_ui_) {
712 if (!fake_ui_) 754 if (!fake_ui_)
713 fake_ui_.reset(new FakeMediaStreamUIProxy()); 755 fake_ui_.reset(new FakeMediaStreamUIProxy());
714 756
715 MediaStreamDevices devices; 757 MediaStreamDevices devices;
716 if (audio_enumeration_cache_.valid) { 758 if (audio_enumeration_cache_.valid) {
717 for (StreamDeviceInfoArray::const_iterator it = 759 for (StreamDeviceInfoArray::const_iterator it =
718 audio_enumeration_cache_.devices.begin(); 760 audio_enumeration_cache_.devices.begin();
719 it != audio_enumeration_cache_.devices.end(); ++it) { 761 it != audio_enumeration_cache_.devices.end(); ++it) {
(...skipping 14 matching lines...) Expand all
734 } else { 776 } else {
735 request->ui_proxy = MediaStreamUIProxy::Create(); 777 request->ui_proxy = MediaStreamUIProxy::Create();
736 } 778 }
737 779
738 request->ui_proxy->RequestAccess( 780 request->ui_proxy->RequestAccess(
739 request->request, 781 request->request,
740 base::Bind(&MediaStreamManager::HandleAccessRequestResponse, 782 base::Bind(&MediaStreamManager::HandleAccessRequestResponse,
741 base::Unretained(this), label)); 783 base::Unretained(this), label));
742 } 784 }
743 785
744 void MediaStreamManager::HandleRequest(const std::string& label) { 786 void MediaStreamManager::SetupRequest(const std::string& label) {
745 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 787 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
746 DeviceRequest* request = requests_[label]; 788 DeviceRequest* request = FindRequest(label);
789 if (!request) {
790 DVLOG(1) << "SetupRequest label " << label << " doesn't exist!!";
791 return; // This can happen if the request has been canceled.
792 }
793
794 if (!request->request.security_origin.is_valid()) {
795 LOG(ERROR) << "Invalid security origin. "
796 << request->request.security_origin;
797 FinalizeRequestFailed(label, request);
798 return;
799 }
747 800
748 const MediaStreamType audio_type = request->request.audio_type; 801 const MediaStreamType audio_type = request->request.audio_type;
749 const MediaStreamType video_type = request->request.video_type; 802 const MediaStreamType video_type = request->request.video_type;
750 803
751 bool is_web_contents_capture = 804 bool is_web_contents_capture =
752 audio_type == MEDIA_TAB_AUDIO_CAPTURE || 805 audio_type == MEDIA_TAB_AUDIO_CAPTURE ||
753 video_type == MEDIA_TAB_VIDEO_CAPTURE; 806 video_type == MEDIA_TAB_VIDEO_CAPTURE;
807 if (is_web_contents_capture && !SetupTabCaptureRequest(request)) {
808 FinalizeRequestFailed(label, request);
809 return;
810 }
754 811
755 bool is_screen_capture = 812 bool is_screen_capture =
756 video_type == MEDIA_DESKTOP_VIDEO_CAPTURE; 813 video_type == MEDIA_DESKTOP_VIDEO_CAPTURE;
814 if (is_screen_capture && !SetupScreenCaptureRequest(request)) {
815 FinalizeRequestFailed(label, request);
816 return;
817 }
757 818
758 if (!is_web_contents_capture && 819 if (!is_web_contents_capture &&
759 !is_screen_capture && 820 !is_screen_capture &&
760 ((IsAudioMediaType(audio_type) && !audio_enumeration_cache_.valid) || 821 ((IsAudioMediaType(audio_type) && !audio_enumeration_cache_.valid) ||
761 (IsVideoMediaType(video_type) && !video_enumeration_cache_.valid))) { 822 (IsVideoMediaType(video_type) && !video_enumeration_cache_.valid))) {
762 // Enumerate the devices if there is no valid device lists to be used. 823 // Enumerate the devices if there is no valid device lists to be used.
763 StartEnumeration(request); 824 StartEnumeration(request);
764 return; 825 return;
765 } 826 }
827 PostRequestToUI(label, request);
828 }
766 829
767 // No need to do new device enumerations, post the request to UI 830 bool MediaStreamManager::SetupTabCaptureRequest(DeviceRequest* request) {
768 // immediately. 831 DCHECK(request->request.audio_type == MEDIA_TAB_AUDIO_CAPTURE ||
769 if (IsAudioMediaType(audio_type)) 832 request->request.video_type == MEDIA_TAB_VIDEO_CAPTURE);
770 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
771 if (IsVideoMediaType(video_type))
772 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
773 833
774 PostRequestToUI(label); 834 MediaStreamRequest* ms_request = &request->request;
835 // Customize options for a WebContents based capture.
836 int target_render_process_id = 0;
837 int target_render_view_id = 0;
838
839 // TODO(justinlin): Can't plumb audio mirroring using stream type right
840 // now, so plumbing by device_id. Will revisit once it's refactored.
841 // http://crbug.com/163100
842 std::string tab_capture_device_id =
843 WebContentsCaptureUtil::AppendWebContentsDeviceScheme(
844 !ms_request->requested_video_device_id.empty() ?
845 ms_request->requested_video_device_id :
846 ms_request->requested_audio_device_id);
847
848 bool has_valid_device_id = WebContentsCaptureUtil::ExtractTabCaptureTarget(
849 tab_capture_device_id, &target_render_process_id,
850 &target_render_view_id);
851 if (!has_valid_device_id ||
852 (ms_request->audio_type != MEDIA_TAB_AUDIO_CAPTURE &&
853 ms_request->audio_type != MEDIA_NO_SERVICE) ||
854 (ms_request->video_type != MEDIA_TAB_VIDEO_CAPTURE &&
855 ms_request->video_type != MEDIA_NO_SERVICE)) {
856 return false;
857 }
858 ms_request->tab_capture_device_id = tab_capture_device_id;
859 ms_request->render_process_id = target_render_process_id;
860 ms_request->render_view_id = target_render_view_id;
861 DVLOG(3) << "SetupTabCaptureRequest "
862 << ", {tab_capture_device_id = " << tab_capture_device_id << "}"
863 << ", {target_render_process_id = " << target_render_process_id
864 << "}"
865 << ", {target_render_view_id = " << target_render_view_id << "}";
866 return true;
867 }
868
869 bool MediaStreamManager::SetupScreenCaptureRequest(DeviceRequest* request) {
870 DCHECK(request->request.audio_type == MEDIA_LOOPBACK_AUDIO_CAPTURE ||
871 request->request.video_type == MEDIA_DESKTOP_VIDEO_CAPTURE);
872 const MediaStreamRequest& ms_request = request->request;
873
874 // For screen capture we only support two valid combinations:
875 // (1) screen video capture only, or
876 // (2) screen video capture with loopback audio capture.
877 if (ms_request.video_type != MEDIA_DESKTOP_VIDEO_CAPTURE ||
878 (ms_request.audio_type != MEDIA_NO_SERVICE &&
879 ms_request.audio_type != MEDIA_LOOPBACK_AUDIO_CAPTURE)) {
880 // TODO(sergeyu): Surface error message to the calling JS code.
881 LOG(ERROR) << "Invalid screen capture request.";
882 return false;
883 }
884 return true;
885 }
886
887 StreamDeviceInfoArray MediaStreamManager::GetDevicesOpenedByRequest(
888 const std::string& label) const {
889 DeviceRequest* request = FindRequest(label);
890 if (!request)
891 return StreamDeviceInfoArray();
892 return request->devices;
775 } 893 }
776 894
777 bool MediaStreamManager::FindExistingRequestedDeviceInfo( 895 bool MediaStreamManager::FindExistingRequestedDeviceInfo(
778 int render_process_id, 896 int render_process_id,
779 int render_view_id, 897 int render_view_id,
898 const GURL& security_origin,
780 MediaStreamRequestType type, 899 MediaStreamRequestType type,
781 const std::string& device_id, 900 const std::string& device_id,
901 MediaStreamType device_type,
782 StreamDeviceInfo* device_info, 902 StreamDeviceInfo* device_info,
783 MediaRequestState* request_state) const { 903 MediaRequestState* request_state) const {
784 DCHECK(device_info); 904 DCHECK(device_info);
785 DCHECK(request_state); 905 DCHECK(request_state);
906
907 std::string source_id = content::GetHMACForMediaDeviceID(
908 security_origin,
909 device_id);
910
786 for (DeviceRequests::const_iterator it = requests_.begin(); 911 for (DeviceRequests::const_iterator it = requests_.begin();
787 it != requests_.end() ; ++it) { 912 it != requests_.end() ; ++it) {
788 const DeviceRequest* request = it->second; 913 const DeviceRequest* request = it->second;
789 if (request->requesting_process_id ==render_process_id && 914 if (request->requesting_process_id == render_process_id &&
790 request->requesting_view_id == render_view_id && 915 request->requesting_view_id == render_view_id &&
791 request->request.request_type == type) { 916 request->request.request_type == type) {
792 for (StreamDeviceInfoArray::const_iterator device_it = 917 for (StreamDeviceInfoArray::const_iterator device_it =
793 request->devices.begin(); 918 request->devices.begin();
794 device_it != request->devices.end(); ++device_it) { 919 device_it != request->devices.end(); ++device_it) {
795 if (device_it->device.id == device_id) { 920 if (device_it->device.id == source_id &&
921 device_it->device.type == device_type) {
796 *device_info = *device_it; 922 *device_info = *device_it;
797 *request_state = request->state(device_it->device.type); 923 *request_state = request->state(device_it->device.type);
798 return true; 924 return true;
799 } 925 }
800 } 926 }
801 } 927 }
802 } 928 }
803 return false; 929 return false;
804 } 930 }
805 931
932 void MediaStreamManager::FinalizeGenerateStream(const std::string& label,
933 DeviceRequest* request) {
934 DVLOG(1) << "FinalizeGenerateStream label " << label;
935 const StreamDeviceInfoArray& requested_devices = request->devices;
936
937 // Partition the array of devices into audio vs video.
938 StreamDeviceInfoArray audio_devices, video_devices;
939 for (StreamDeviceInfoArray::const_iterator device_it =
940 requested_devices.begin();
941 device_it != requested_devices.end(); ++device_it) {
942 if (IsAudioMediaType(device_it->device.type)) {
943 audio_devices.push_back(*device_it);
944 } else if (IsVideoMediaType(device_it->device.type)) {
945 video_devices.push_back(*device_it);
946 } else {
947 NOTREACHED();
948 }
949 }
950
951 request->requester->StreamGenerated(label, audio_devices, video_devices);
952 }
953
954 void MediaStreamManager::FinalizeRequestFailed(
955 const std::string& label,
956 DeviceRequest* request) {
957 if (request->requester)
958 request->requester->StreamGenerationFailed(label);
959
960 if (request->request.request_type == MEDIA_DEVICE_ACCESS &&
961 !request->callback.is_null()) {
962 request->callback.Run(MediaStreamDevices(), request->ui_proxy.Pass());
963 }
964
965 DeleteRequest(label);
966 }
967
968 void MediaStreamManager::FinalizeOpenDevice(const std::string& label,
969 DeviceRequest* request) {
970 const StreamDeviceInfoArray& requested_devices = request->devices;
971 request->requester->DeviceOpened(label, requested_devices.front());
972 }
973
974 void MediaStreamManager::FinalizeEnumerateDevices(const std::string& label,
975 DeviceRequest* request) {
976 for (StreamDeviceInfoArray::iterator it = request->devices.begin();
977 it != request->devices.end(); ++it) {
978 TranslateDeviceIdToSourceId(request->request, &it->device);
979 }
980 request->requester->DevicesEnumerated(label, request->devices);
981 }
982
983 void MediaStreamManager::FinalizeMediaAccessRequest(
984 const std::string& label,
985 DeviceRequest* request,
986 const MediaStreamDevices& devices) {
987 if (!request->callback.is_null())
988 request->callback.Run(devices, request->ui_proxy.Pass());
989
990 // Delete the request since it is done.
991 DeleteRequest(label);
992 }
993
806 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { 994 void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
807 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 995 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
808 if (device_thread_) 996 if (device_thread_)
809 return; 997 return;
810 998
811 device_thread_.reset(new base::Thread("MediaStreamDeviceThread")); 999 device_thread_.reset(new base::Thread("MediaStreamDeviceThread"));
812 #if defined(OS_WIN) 1000 #if defined(OS_WIN)
813 device_thread_->init_com_with_mta(true); 1001 device_thread_->init_com_with_mta(true);
814 #endif 1002 #endif
815 CHECK(device_thread_->Start()); 1003 CHECK(device_thread_->Start());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 request->SetState(device_it->device.type, MEDIA_REQUEST_STATE_DONE); 1039 request->SetState(device_it->device.type, MEDIA_REQUEST_STATE_DONE);
852 1040
853 if (IsAudioMediaType(device_it->device.type)) { 1041 if (IsAudioMediaType(device_it->device.type)) {
854 // Store the native audio parameters in the device struct. 1042 // Store the native audio parameters in the device struct.
855 // TODO(xians): Handle the tab capture sample rate/channel layout 1043 // TODO(xians): Handle the tab capture sample rate/channel layout
856 // in AudioInputDeviceManager::Open(). 1044 // in AudioInputDeviceManager::Open().
857 if (device_it->device.type != content::MEDIA_TAB_AUDIO_CAPTURE) { 1045 if (device_it->device.type != content::MEDIA_TAB_AUDIO_CAPTURE) {
858 const StreamDeviceInfo* info = 1046 const StreamDeviceInfo* info =
859 audio_input_device_manager_->GetOpenedDeviceInfoById( 1047 audio_input_device_manager_->GetOpenedDeviceInfoById(
860 device_it->session_id); 1048 device_it->session_id);
861 DCHECK_EQ(info->device.id, device_it->device.id);
862 device_it->device.input = info->device.input; 1049 device_it->device.input = info->device.input;
863 device_it->device.matched_output = info->device.matched_output; 1050 device_it->device.matched_output = info->device.matched_output;
864 } 1051 }
865 } 1052 }
866 if (RequestDone(*request)) 1053 if (RequestDone(*request))
867 HandleRequestDone(label, request); 1054 HandleRequestDone(label, request);
868 break; 1055 break;
869 } 1056 }
870 } 1057 }
871 } 1058 }
872 } 1059 }
873 1060
874 void MediaStreamManager::HandleRequestDone(const std::string& label, 1061 void MediaStreamManager::HandleRequestDone(const std::string& label,
875 DeviceRequest* request) { 1062 DeviceRequest* request) {
876 DCHECK(RequestDone(*request)); 1063 DCHECK(RequestDone(*request));
877 DVLOG(1) << "HandleRequestDone(" 1064 DVLOG(1) << "HandleRequestDone("
878 << ", {label = " << label << "})"; 1065 << ", {label = " << label << "})";
879 1066
880 const StreamDeviceInfoArray& requested_devices = request->devices;
881 switch (request->request.request_type) { 1067 switch (request->request.request_type) {
882 case MEDIA_OPEN_DEVICE: 1068 case MEDIA_OPEN_DEVICE:
883 request->requester->DeviceOpened(label, requested_devices.front()); 1069 FinalizeOpenDevice(label, request);
884 break; 1070 break;
885 case MEDIA_GENERATE_STREAM: { 1071 case MEDIA_GENERATE_STREAM: {
886 // Partition the array of devices into audio vs video. 1072 FinalizeGenerateStream(label, request);
887 StreamDeviceInfoArray audio_devices, video_devices;
888 for (StreamDeviceInfoArray::const_iterator device_it =
889 requested_devices.begin();
890 device_it != requested_devices.end(); ++device_it) {
891 if (IsAudioMediaType(device_it->device.type)) {
892 audio_devices.push_back(*device_it);
893 } else if (IsVideoMediaType(device_it->device.type)) {
894 video_devices.push_back(*device_it);
895 } else {
896 NOTREACHED();
897 }
898 }
899
900 request->requester->StreamGenerated(label, audio_devices, video_devices);
901 break; 1073 break;
902 } 1074 }
903 default: 1075 default:
904 NOTREACHED(); 1076 NOTREACHED();
905 break; 1077 break;
906 } 1078 }
907 1079
908 if (request->ui_proxy.get()) { 1080 if (request->ui_proxy.get()) {
909 request->ui_proxy->OnStarted( 1081 request->ui_proxy->OnStarted(
910 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser, 1082 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser,
(...skipping 22 matching lines...) Expand all
933 !std::equal(devices.begin(), devices.end(), cache->devices.begin(), 1105 !std::equal(devices.begin(), devices.end(), cache->devices.begin(),
934 StreamDeviceInfo::IsEqual)) { 1106 StreamDeviceInfo::IsEqual)) {
935 StopRemovedDevices(cache->devices, devices); 1107 StopRemovedDevices(cache->devices, devices);
936 cache->devices = devices; 1108 cache->devices = devices;
937 need_update_clients = true; 1109 need_update_clients = true;
938 1110
939 // The device might not be able to be enumerated when it is not warmed up, 1111 // The device might not be able to be enumerated when it is not warmed up,
940 // for example, when the machine just wakes up from sleep. We set the cache 1112 // for example, when the machine just wakes up from sleep. We set the cache
941 // to be invalid so that the next media request will trigger the 1113 // to be invalid so that the next media request will trigger the
942 // enumeration again. See issue/317673. 1114 // enumeration again. See issue/317673.
943 if (devices.size()) 1115 cache->valid = !devices.empty();
944 cache->valid = true;
945 else
946 cache->valid = false;
947 } 1116 }
948 1117
949 if (need_update_clients && monitoring_started_) 1118 if (need_update_clients && monitoring_started_)
950 NotifyDevicesChanged(stream_type, devices); 1119 NotifyDevicesChanged(stream_type, devices);
951 1120
952 // Publish the result for all requests waiting for device list(s). 1121 // Publish the result for all requests waiting for device list(s).
953 // Find the requests waiting for this device list, store their labels and 1122 // Find the requests waiting for this device list, store their labels and
954 // release the iterator before calling device settings. We might get a call 1123 // release the iterator before calling device settings. We might get a call
955 // back from device_settings that will need to iterate through devices. 1124 // back from device_settings that will need to iterate through devices.
956 std::list<std::string> label_list; 1125 std::list<std::string> label_list;
957 for (DeviceRequests::iterator it = requests_.begin(); it != requests_.end(); 1126 for (DeviceRequests::iterator it = requests_.begin(); it != requests_.end();
958 ++it) { 1127 ++it) {
959 if (it->second->state(stream_type) == MEDIA_REQUEST_STATE_REQUESTED && 1128 if (it->second->state(stream_type) == MEDIA_REQUEST_STATE_REQUESTED &&
960 Requested(it->second->request, stream_type)) { 1129 Requested(it->second->request, stream_type)) {
961 if (it->second->request.request_type != MEDIA_ENUMERATE_DEVICES) 1130 if (it->second->request.request_type != MEDIA_ENUMERATE_DEVICES)
962 it->second->SetState(stream_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); 1131 it->second->SetState(stream_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
963 label_list.push_back(it->first); 1132 label_list.push_back(it->first);
964 } 1133 }
965 } 1134 }
966 for (std::list<std::string>::iterator it = label_list.begin(); 1135 for (std::list<std::string>::iterator it = label_list.begin();
967 it != label_list.end(); ++it) { 1136 it != label_list.end(); ++it) {
968 DeviceRequest* request = requests_[*it]; 1137 DeviceRequest* request = FindRequest(*it);
969 switch (request->request.request_type) { 1138 switch (request->request.request_type) {
970 case MEDIA_ENUMERATE_DEVICES: 1139 case MEDIA_ENUMERATE_DEVICES:
971 if (need_update_clients && request->requester) 1140 if (need_update_clients && request->requester) {
972 request->requester->DevicesEnumerated(*it, devices); 1141 request->devices = devices;
1142 FinalizeEnumerateDevices(*it, request);
1143 }
973 break; 1144 break;
974 default: 1145 default:
975 if (request->state(request->request.audio_type) == 1146 if (request->state(request->request.audio_type) ==
976 MEDIA_REQUEST_STATE_REQUESTED || 1147 MEDIA_REQUEST_STATE_REQUESTED ||
977 request->state(request->request.video_type) == 1148 request->state(request->request.video_type) ==
978 MEDIA_REQUEST_STATE_REQUESTED) { 1149 MEDIA_REQUEST_STATE_REQUESTED) {
979 // We are doing enumeration for other type of media, wait until it is 1150 // We are doing enumeration for other type of media, wait until it is
980 // all done before posting the request to UI because UI needs 1151 // all done before posting the request to UI because UI needs
981 // the device lists to handle the request. 1152 // the device lists to handle the request.
982 break; 1153 break;
983 } 1154 }
984 1155
985 // Post the request to UI for permission approval. 1156 PostRequestToUI(*it, request);
986 PostRequestToUI(*it);
987 break; 1157 break;
988 } 1158 }
989 } 1159 }
990 label_list.clear(); 1160 label_list.clear();
991 --active_enumeration_ref_count_[stream_type]; 1161 --active_enumeration_ref_count_[stream_type];
992 DCHECK_GE(active_enumeration_ref_count_[stream_type], 0); 1162 DCHECK_GE(active_enumeration_ref_count_[stream_type], 0);
993 } 1163 }
994 1164
995 void MediaStreamManager::HandleAccessRequestResponse( 1165 void MediaStreamManager::HandleAccessRequestResponse(
996 const std::string& label, 1166 const std::string& label,
997 const MediaStreamDevices& devices) { 1167 const MediaStreamDevices& devices) {
998 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
999 DVLOG(1) << "HandleAccessRequestResponse(" 1169 DVLOG(1) << "HandleAccessRequestResponse("
1000 << ", {label = " << label << "})"; 1170 << ", {label = " << label << "})";
1001 1171
1002 DeviceRequests::iterator request_it = requests_.find(label); 1172 DeviceRequest* request = FindRequest(label);
1003 if (request_it == requests_.end()) { 1173 if (!request) {
1174 // The request has been canceled before the UI returned.
1175 return;
1176 }
1177
1178 if (request->request.request_type == MEDIA_DEVICE_ACCESS) {
1179 FinalizeMediaAccessRequest(label, request, devices);
1004 return; 1180 return;
1005 } 1181 }
1006 1182
1007 // Handle the case when the request was denied. 1183 // Handle the case when the request was denied.
1008 if (devices.empty()) { 1184 if (devices.empty()) {
1009 // Notify the users about the request result. 1185 FinalizeRequestFailed(label, request);
1010 scoped_ptr<DeviceRequest> request(request_it->second);
1011 if (request->requester)
1012 request->requester->StreamGenerationFailed(label);
1013
1014 if (request->request.request_type == MEDIA_DEVICE_ACCESS &&
1015 !request->callback.is_null()) {
1016 request->callback.Run(MediaStreamDevices(), request->ui_proxy.Pass());
1017 }
1018
1019 RemoveRequest(request_it);
1020 return;
1021 }
1022
1023 if (request_it->second->request.request_type == MEDIA_DEVICE_ACCESS) {
1024 scoped_ptr<DeviceRequest> request(request_it->second);
1025 if (!request->callback.is_null())
1026 request->callback.Run(devices, request->ui_proxy.Pass());
1027
1028 // Delete the request since it is done.
1029 RemoveRequest(request_it);
1030 return; 1186 return;
1031 } 1187 }
1032 1188
1033 // Process all newly-accepted devices for this request. 1189 // Process all newly-accepted devices for this request.
1034 DeviceRequest* request = request_it->second;
1035 bool found_audio = false; 1190 bool found_audio = false;
1036 bool found_video = false; 1191 bool found_video = false;
1037 for (MediaStreamDevices::const_iterator device_it = devices.begin(); 1192 for (MediaStreamDevices::const_iterator device_it = devices.begin();
1038 device_it != devices.end(); ++device_it) { 1193 device_it != devices.end(); ++device_it) {
1039 StreamDeviceInfo device_info; 1194 StreamDeviceInfo device_info;
1040 device_info.device = *device_it; 1195 device_info.device = *device_it;
1041 1196
1042 // TODO(justinlin): Nicer way to do this? 1197 // TODO(justinlin): Nicer way to do this?
1043 // Re-append the device's id since we lost it when posting request to UI. 1198 // Re-append the device's id since we lost it when posting request to UI.
1044 if (device_info.device.type == content::MEDIA_TAB_VIDEO_CAPTURE || 1199 if (device_info.device.type == content::MEDIA_TAB_VIDEO_CAPTURE ||
(...skipping 20 matching lines...) Expand all
1065 if (device_info.device.type == request->request.audio_type) { 1220 if (device_info.device.type == request->request.audio_type) {
1066 found_audio = true; 1221 found_audio = true;
1067 } else if (device_info.device.type == request->request.video_type) { 1222 } else if (device_info.device.type == request->request.video_type) {
1068 found_video = true; 1223 found_video = true;
1069 } 1224 }
1070 1225
1071 // If this is request for a new MediaStream, a device is only opened once 1226 // If this is request for a new MediaStream, a device is only opened once
1072 // per render view. This is so that the permission to use a device can be 1227 // per render view. This is so that the permission to use a device can be
1073 // revoked by a single call to StopStreamDevice regardless of how many 1228 // revoked by a single call to StopStreamDevice regardless of how many
1074 // MediaStreams it is being used in. 1229 // MediaStreams it is being used in.
1075
1076 if (request->request.request_type == MEDIA_GENERATE_STREAM) { 1230 if (request->request.request_type == MEDIA_GENERATE_STREAM) {
1077 MediaRequestState state; 1231 MediaRequestState state;
1078 if (FindExistingRequestedDeviceInfo(request->requesting_process_id, 1232 if (FindExistingRequestedDeviceInfo(request->requesting_process_id,
1079 request->requesting_view_id, 1233 request->requesting_view_id,
1234 request->request.security_origin,
1080 request->request.request_type, 1235 request->request.request_type,
1081 device_it->id, 1236 device_info.device.id,
1237 device_info.device.type,
1082 &device_info, 1238 &device_info,
1083 &state)) { 1239 &state)) {
1084 request->devices.push_back(device_info); 1240 request->devices.push_back(device_info);
1085 request->SetState(device_info.device.type, state); 1241 request->SetState(device_info.device.type, state);
1086 DVLOG(1) << "HandleAccessRequestResponse - device already opened " 1242 DVLOG(1) << "HandleAccessRequestResponse - device already opened "
1087 << ", {label = " << label << "}" 1243 << ", {label = " << label << "}"
1088 << ", device_id = " << device_it->id << "}"; 1244 << ", device_id = " << device_it->id << "}";
1089 continue; 1245 continue;
1090 } 1246 }
1091 } 1247 }
1092 device_info.session_id = 1248 device_info.session_id =
1093 GetDeviceManager(device_info.device.type)->Open(device_info); 1249 GetDeviceManager(device_info.device.type)->Open(device_info);
1250 TranslateDeviceIdToSourceId(request->request, &device_info.device);
1094 request->devices.push_back(device_info); 1251 request->devices.push_back(device_info);
1252
1095 request->SetState(device_info.device.type, MEDIA_REQUEST_STATE_OPENING); 1253 request->SetState(device_info.device.type, MEDIA_REQUEST_STATE_OPENING);
1096 DVLOG(1) << "HandleAccessRequestResponse - opening device " 1254 DVLOG(1) << "HandleAccessRequestResponse - opening device "
1097 << ", {label = " << label << "}" 1255 << ", {label = " << label << "}"
1098 << ", {device_id = " << device_it->id << "}" 1256 << ", {device_id = " << device_info.device.id << "}"
1099 << ", {session_id = " << device_info.session_id << "}"; 1257 << ", {session_id = " << device_info.session_id << "}";
1100 } 1258 }
1101 1259
1102 // Check whether we've received all stream types requested. 1260 // Check whether we've received all stream types requested.
1103 if (!found_audio && IsAudioMediaType(request->request.audio_type)) { 1261 if (!found_audio && IsAudioMediaType(request->request.audio_type)) {
1104 request->SetState(request->request.audio_type, MEDIA_REQUEST_STATE_ERROR); 1262 request->SetState(request->request.audio_type, MEDIA_REQUEST_STATE_ERROR);
1105 DVLOG(1) << "Set no audio found label " << label; 1263 DVLOG(1) << "Set no audio found label " << label;
1106 } 1264 }
1107 1265
1108 if (!found_video && IsVideoMediaType(request->request.video_type)) 1266 if (!found_video && IsVideoMediaType(request->request.video_type))
1109 request->SetState(request->request.video_type, MEDIA_REQUEST_STATE_ERROR); 1267 request->SetState(request->request.video_type, MEDIA_REQUEST_STATE_ERROR);
1110 1268
1111 if (RequestDone(*request)) 1269 if (RequestDone(*request))
1112 HandleRequestDone(label, request); 1270 HandleRequestDone(label, request);
1113 } 1271 }
1114 1272
1115 void MediaStreamManager::StopMediaStreamFromBrowser(const std::string& label) { 1273 void MediaStreamManager::StopMediaStreamFromBrowser(const std::string& label) {
1116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1117 1275
1118 DeviceRequests::iterator it = requests_.find(label); 1276 DeviceRequest* request = FindRequest(label);
1119 if (it == requests_.end()) 1277 if (!request)
1120 return; 1278 return;
1121 1279
1122 DeviceRequest* request = it->second;
1123 // Notify renderers that the devices in the stream will be stopped. 1280 // Notify renderers that the devices in the stream will be stopped.
1124 if (request->requester) { 1281 if (request->requester) {
1125 for (StreamDeviceInfoArray::iterator device_it = request->devices.begin(); 1282 for (StreamDeviceInfoArray::iterator device_it = request->devices.begin();
1126 device_it != request->devices.end(); ++device_it) { 1283 device_it != request->devices.end(); ++device_it) {
1127 request->requester->DeviceStopped(request->requesting_view_id, 1284 request->requester->DeviceStopped(request->requesting_view_id,
1128 label, 1285 label,
1129 *device_it); 1286 *device_it);
1130 } 1287 }
1131 } 1288 }
1132 1289
1133 CancelRequest(label); 1290 CancelRequest(label);
1134 } 1291 }
1135 1292
1136 void MediaStreamManager::UseFakeDevice() { 1293 void MediaStreamManager::UseFakeDevice() {
1137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1294 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1138 video_capture_manager()->UseFakeDevice(); 1295 video_capture_manager()->UseFakeDevice();
1139 audio_input_device_manager()->UseFakeDevice(); 1296 audio_input_device_manager()->UseFakeDevice();
1140 } 1297 }
1141 1298
1142 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { 1299 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) {
1143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1300 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1144 use_fake_ui_ = true; 1301 use_fake_ui_ = true;
1145 fake_ui_ = fake_ui.Pass(); 1302 fake_ui_ = fake_ui.Pass();
1146 } 1303 }
1147 1304
1148 void MediaStreamManager::WillDestroyCurrentMessageLoop() { 1305 void MediaStreamManager::WillDestroyCurrentMessageLoop() {
1306 DVLOG(3) << "MediaStreamManager::WillDestroyCurrentMessageLoop()";
1149 DCHECK_EQ(base::MessageLoop::current(), io_loop_); 1307 DCHECK_EQ(base::MessageLoop::current(), io_loop_);
1150 DCHECK(requests_.empty()); 1308 DCHECK(requests_.empty());
1151 if (device_thread_) { 1309 if (device_thread_) {
1152 StopMonitoring(); 1310 StopMonitoring();
1153 1311
1154 video_capture_manager_->Unregister(); 1312 video_capture_manager_->Unregister();
1155 audio_input_device_manager_->Unregister(); 1313 audio_input_device_manager_->Unregister();
1156 device_thread_.reset(); 1314 device_thread_.reset();
1157 } 1315 }
1158 1316
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 } 1398 }
1241 1399
1242 // Always do enumeration even though some enumeration is in progress, 1400 // Always do enumeration even though some enumeration is in progress,
1243 // because those enumeration commands could be sent before these devices 1401 // because those enumeration commands could be sent before these devices
1244 // change. 1402 // change.
1245 ++active_enumeration_ref_count_[stream_type]; 1403 ++active_enumeration_ref_count_[stream_type];
1246 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); 1404 GetDeviceManager(stream_type)->EnumerateDevices(stream_type);
1247 } 1405 }
1248 1406
1249 } // namespace content 1407 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698