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

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

Issue 11446042: Make sure that all OpenDevice requests are scrutinized against the audio and video policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT. Created 8 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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // Helper to verify if a media stream type is part of options or not. 57 // Helper to verify if a media stream type is part of options or not.
58 static bool Requested(const StreamOptions& options, 58 static bool Requested(const StreamOptions& options,
59 MediaStreamType stream_type) { 59 MediaStreamType stream_type) {
60 return (options.audio_type == stream_type || 60 return (options.audio_type == stream_type ||
61 options.video_type == stream_type); 61 options.video_type == stream_type);
62 } 62 }
63 63
64 // TODO(xians): Merge DeviceRequest with MediaStreamRequest. 64 // TODO(xians): Merge DeviceRequest with MediaStreamRequest.
65 class MediaStreamManager::DeviceRequest { 65 class MediaStreamManager::DeviceRequest {
66 public: 66 public:
67 enum RequestType {
68 DEVICE_ACCESS = 0,
69 GENERATE_STREAM,
70 ENUMERATE_DEVICES,
71 OPEN_DEVICE
72 };
73
74 DeviceRequest() 67 DeviceRequest()
75 : requester(NULL), 68 : requester(NULL),
76 type(GENERATE_STREAM), 69 type(MEDIA_GENERATE_STREAM),
77 render_process_id(-1), 70 render_process_id(-1),
78 render_view_id(-1), 71 render_view_id(-1),
79 state_(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_NOT_REQUESTED) { 72 state_(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_NOT_REQUESTED) {
80 } 73 }
81 74
82 DeviceRequest(MediaStreamRequester* requester, 75 DeviceRequest(MediaStreamRequester* requester,
83 const StreamOptions& request_options, 76 const StreamOptions& request_options,
84 RequestType request_type, 77 MediaStreamRequestType request_type,
85 int render_process_id, 78 int render_process_id,
86 int render_view_id, 79 int render_view_id,
87 const GURL& request_security_origin) 80 const GURL& request_security_origin)
88 : requester(requester), 81 : requester(requester),
89 options(request_options), 82 options(request_options),
90 type(request_type), 83 type(request_type),
91 render_process_id(render_process_id), 84 render_process_id(render_process_id),
92 render_view_id(render_view_id), 85 render_view_id(render_view_id),
93 security_origin(request_security_origin), 86 security_origin(request_security_origin),
94 state_(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_NOT_REQUESTED) { 87 state_(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_NOT_REQUESTED) {
(...skipping 27 matching lines...) Expand all
122 MediaStreamDevice( 115 MediaStreamDevice(
123 stream_type, device_id, device_id), new_state); 116 stream_type, device_id, device_id), new_state);
124 } 117 }
125 118
126 MediaRequestState state(MediaStreamType stream_type) const { 119 MediaRequestState state(MediaStreamType stream_type) const {
127 return state_[stream_type]; 120 return state_[stream_type];
128 } 121 }
129 122
130 MediaStreamRequester* requester; // Can be NULL. 123 MediaStreamRequester* requester; // Can be NULL.
131 StreamOptions options; 124 StreamOptions options;
132 RequestType type; 125 MediaStreamRequestType type;
133 int render_process_id; 126 int render_process_id;
134 int render_view_id; 127 int render_view_id;
135 GURL security_origin; 128 GURL security_origin;
136 std::string requested_device_id; 129 std::string requested_device_id;
137 StreamDeviceInfoArray devices; 130 StreamDeviceInfoArray devices;
138 131
139 // Callback to the requester which audio/video devices have been selected. 132 // Callback to the requester which audio/video devices have been selected.
140 // It can be null if the requester has no interest to know the result. 133 // It can be null if the requester has no interest to know the result.
141 // Currently it is only used by |DEVICE_ACCESS| type. 134 // Currently it is only used by |DEVICE_ACCESS| type.
142 MediaRequestResponseCallback callback; 135 MediaRequestResponseCallback callback;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 std::string MediaStreamManager::MakeMediaAccessRequest( 188 std::string MediaStreamManager::MakeMediaAccessRequest(
196 int render_process_id, 189 int render_process_id,
197 int render_view_id, 190 int render_view_id,
198 const StreamOptions& options, 191 const StreamOptions& options,
199 const GURL& security_origin, 192 const GURL& security_origin,
200 const MediaRequestResponseCallback& callback) { 193 const MediaRequestResponseCallback& callback) {
201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
202 // Create a new request based on options. 195 // Create a new request based on options.
203 DeviceRequest* request = new DeviceRequest(NULL, 196 DeviceRequest* request = new DeviceRequest(NULL,
204 options, 197 options,
205 DeviceRequest::DEVICE_ACCESS, 198 MEDIA_DEVICE_ACCESS,
206 render_process_id, 199 render_process_id,
207 render_view_id, 200 render_view_id,
208 security_origin); 201 security_origin);
209 const std::string& label = AddRequest(request); 202 const std::string& label = AddRequest(request);
210 StartEnumeration(request); 203 StartEnumeration(request);
211 204
212 request->callback = callback; 205 request->callback = callback;
213 206
214 PostRequestToUI(label); 207 PostRequestToUI(label);
215 208
216 return label; 209 return label;
217 } 210 }
218 211
219 std::string MediaStreamManager::GenerateStream( 212 std::string MediaStreamManager::GenerateStream(
220 MediaStreamRequester* requester, 213 MediaStreamRequester* requester,
221 int render_process_id, 214 int render_process_id,
222 int render_view_id, 215 int render_view_id,
223 const StreamOptions& options, 216 const StreamOptions& options,
224 const GURL& security_origin) { 217 const GURL& security_origin) {
225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
226 if (CommandLine::ForCurrentProcess()->HasSwitch( 219 if (CommandLine::ForCurrentProcess()->HasSwitch(
227 switches::kUseFakeDeviceForMediaStream)) { 220 switches::kUseFakeDeviceForMediaStream)) {
228 UseFakeDevice(); 221 UseFakeDevice();
229 } 222 }
230 223
231 // Create a new request based on options. 224 // Create a new request based on options.
232 DeviceRequest* request = new DeviceRequest(requester, options, 225 DeviceRequest* request = new DeviceRequest(requester, options,
233 DeviceRequest::GENERATE_STREAM, 226 MEDIA_GENERATE_STREAM,
234 render_process_id, 227 render_process_id,
235 render_view_id, 228 render_view_id,
236 security_origin); 229 security_origin);
237 const std::string& label = AddRequest(request); 230 const std::string& label = AddRequest(request);
238 StartEnumeration(request); 231 StartEnumeration(request);
239 232
240 // Get user confirmation to use capture devices. 233 // Get user confirmation to use capture devices.
241 PostRequestToUI(label); 234 PostRequestToUI(label);
242 235
243 return label; 236 return label;
(...skipping 18 matching lines...) Expand all
262 (options.audio_type != MEDIA_TAB_AUDIO_CAPTURE && 255 (options.audio_type != MEDIA_TAB_AUDIO_CAPTURE &&
263 options.audio_type != MEDIA_NO_SERVICE) || 256 options.audio_type != MEDIA_NO_SERVICE) ||
264 (options.video_type != MEDIA_TAB_VIDEO_CAPTURE && 257 (options.video_type != MEDIA_TAB_VIDEO_CAPTURE &&
265 options.video_type != MEDIA_NO_SERVICE)) { 258 options.video_type != MEDIA_NO_SERVICE)) {
266 LOG(ERROR) << "Invalid request or used tab capture outside extension API."; 259 LOG(ERROR) << "Invalid request or used tab capture outside extension API.";
267 return std::string(); 260 return std::string();
268 } 261 }
269 262
270 // Create a new request based on options. 263 // Create a new request based on options.
271 DeviceRequest* request = new DeviceRequest(requester, options, 264 DeviceRequest* request = new DeviceRequest(requester, options,
272 DeviceRequest::GENERATE_STREAM, 265 MEDIA_GENERATE_STREAM,
273 target_render_process_id, 266 target_render_process_id,
274 target_render_view_id, 267 target_render_view_id,
275 security_origin); 268 security_origin);
276 const std::string& label = AddRequest(request); 269 const std::string& label = AddRequest(request);
277 request->requested_device_id = device_id; 270 request->requested_device_id = device_id;
278 271
279 // Get user confirmation to use the capture device. 272 // Get user confirmation to use the capture device.
280 PostRequestToUI(label); 273 PostRequestToUI(label);
281 274
282 // TODO(miu): We should ask the device manager whether a device with id 275 // TODO(miu): We should ask the device manager whether a device with id
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 StopGeneratedStream(label); 330 StopGeneratedStream(label);
338 } 331 }
339 } 332 }
340 } 333 }
341 334
342 void MediaStreamManager::StopGeneratedStream(const std::string& label) { 335 void MediaStreamManager::StopGeneratedStream(const std::string& label) {
343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
344 // Find the request and close all open devices for the request. 337 // Find the request and close all open devices for the request.
345 DeviceRequests::iterator it = requests_.find(label); 338 DeviceRequests::iterator it = requests_.find(label);
346 if (it != requests_.end()) { 339 if (it != requests_.end()) {
347 if (it->second->type == DeviceRequest::ENUMERATE_DEVICES) { 340 if (it->second->type == MEDIA_ENUMERATE_DEVICES) {
348 StopEnumerateDevices(label); 341 StopEnumerateDevices(label);
349 return; 342 return;
350 } 343 }
351 344
352 scoped_ptr<DeviceRequest> request(it->second); 345 scoped_ptr<DeviceRequest> request(it->second);
353 requests_.erase(it); 346 requests_.erase(it);
354 for (StreamDeviceInfoArray::const_iterator device_it = 347 for (StreamDeviceInfoArray::const_iterator device_it =
355 request->devices.begin(); 348 request->devices.begin();
356 device_it != request->devices.end(); ++device_it) { 349 device_it != request->devices.end(); ++device_it) {
357 GetDeviceManager(device_it->stream_type)->Close(device_it->session_id); 350 GetDeviceManager(device_it->stream_type)->Close(device_it->session_id);
358 } 351 }
359 if (request->type == DeviceRequest::GENERATE_STREAM && 352 if (request->type == MEDIA_GENERATE_STREAM &&
360 RequestDone(*request)) { 353 RequestDone(*request)) {
361 // Notify observers that this device is being closed. 354 // Notify observers that this device is being closed.
362 for (int i = MEDIA_NO_SERVICE + 1; i != NUM_MEDIA_TYPES; ++i) { 355 for (int i = MEDIA_NO_SERVICE + 1; i != NUM_MEDIA_TYPES; ++i) {
363 if (request->state(static_cast<MediaStreamType>(i)) != 356 if (request->state(static_cast<MediaStreamType>(i)) !=
364 MEDIA_REQUEST_STATE_NOT_REQUESTED) { 357 MEDIA_REQUEST_STATE_NOT_REQUESTED) {
365 request->SetState(static_cast<MediaStreamType>(i), 358 request->SetState(static_cast<MediaStreamType>(i),
366 MEDIA_REQUEST_STATE_CLOSING); 359 MEDIA_REQUEST_STATE_CLOSING);
367 } 360 }
368 } 361 }
369 NotifyDevicesClosed(*request); 362 NotifyDevicesClosed(*request);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) { 396 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) {
404 options.video_type = type; 397 options.video_type = type;
405 cache = &video_enumeration_cache_; 398 cache = &video_enumeration_cache_;
406 } else { 399 } else {
407 NOTREACHED(); 400 NOTREACHED();
408 return std::string(); 401 return std::string();
409 } 402 }
410 403
411 DeviceRequest* request = new DeviceRequest(requester, 404 DeviceRequest* request = new DeviceRequest(requester,
412 options, 405 options,
413 DeviceRequest::ENUMERATE_DEVICES, 406 MEDIA_ENUMERATE_DEVICES,
414 render_process_id, 407 render_process_id,
415 render_view_id, 408 render_view_id,
416 security_origin); 409 security_origin);
417 const std::string& label = AddRequest(request); 410 const std::string& label = AddRequest(request);
418 411
419 if (cache->valid) { 412 if (cache->valid) {
420 // Cached device list of this type exists. Just send it out. 413 // Cached device list of this type exists. Just send it out.
421 request->SetState(type, MEDIA_REQUEST_STATE_REQUESTED); 414 request->SetState(type, MEDIA_REQUEST_STATE_REQUESTED);
422 415
423 // Need to post a task since the requester won't have label till 416 // Need to post a task since the requester won't have label till
424 // this function returns. 417 // this function returns.
425 BrowserThread::PostTask( 418 BrowserThread::PostTask(
426 BrowserThread::IO, FROM_HERE, 419 BrowserThread::IO, FROM_HERE,
427 base::Bind(&MediaStreamManager::SendCachedDeviceList, 420 base::Bind(&MediaStreamManager::SendCachedDeviceList,
428 base::Unretained(this), cache, label)); 421 base::Unretained(this), cache, label));
429 } else { 422 } else {
430 StartEnumeration(request); 423 StartEnumeration(request);
431 } 424 }
432 425
433 return label; 426 return label;
434 } 427 }
435 428
436 void MediaStreamManager::StopEnumerateDevices(const std::string& label) { 429 void MediaStreamManager::StopEnumerateDevices(const std::string& label) {
437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
438 431
439 DeviceRequests::iterator it = requests_.find(label); 432 DeviceRequests::iterator it = requests_.find(label);
440 if (it != requests_.end()) { 433 if (it != requests_.end()) {
441 DCHECK_EQ(it->second->type, DeviceRequest::ENUMERATE_DEVICES); 434 DCHECK_EQ(it->second->type, MEDIA_ENUMERATE_DEVICES);
442 // Delete the DeviceRequest. 435 // Delete the DeviceRequest.
443 scoped_ptr<DeviceRequest> request(it->second); 436 scoped_ptr<DeviceRequest> request(it->second);
444 requests_.erase(it); 437 requests_.erase(it);
445 } 438 }
446 } 439 }
447 440
448 std::string MediaStreamManager::OpenDevice( 441 std::string MediaStreamManager::OpenDevice(
449 MediaStreamRequester* requester, 442 MediaStreamRequester* requester,
450 int render_process_id, 443 int render_process_id,
451 int render_view_id, 444 int render_view_id,
(...skipping 10 matching lines...) Expand all
462 options.audio_type = type; 455 options.audio_type = type;
463 } else if (IsVideoMediaType(type)) { 456 } else if (IsVideoMediaType(type)) {
464 options.video_type = type; 457 options.video_type = type;
465 } else { 458 } else {
466 NOTREACHED(); 459 NOTREACHED();
467 return std::string(); 460 return std::string();
468 } 461 }
469 462
470 DeviceRequest* request = new DeviceRequest(requester, 463 DeviceRequest* request = new DeviceRequest(requester,
471 options, 464 options,
472 DeviceRequest::OPEN_DEVICE, 465 MEDIA_OPEN_DEVICE,
473 render_process_id, 466 render_process_id,
474 render_view_id, 467 render_view_id,
475 security_origin); 468 security_origin);
476 request->requested_device_id = device_id; 469 request->requested_device_id = device_id;
477 const std::string& label = AddRequest(request); 470 const std::string& label = AddRequest(request);
478 StartEnumeration(request); 471 StartEnumeration(request);
479 472
473 PostRequestToUI(label);
474
480 return label; 475 return label;
481 } 476 }
482 477
483 void MediaStreamManager::NotifyUIDevicesOpened( 478 void MediaStreamManager::NotifyUIDevicesOpened(
484 int render_process_id, 479 int render_process_id,
485 int render_view_id, 480 int render_view_id,
486 const MediaStreamDevices& devices) { 481 const MediaStreamDevices& devices) {
487 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 482 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
488 ui_controller_->NotifyUIIndicatorDevicesOpened(render_process_id, 483 ui_controller_->NotifyUIIndicatorDevicesOpened(render_process_id,
489 render_view_id, 484 render_view_id,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 585 }
591 586
592 void MediaStreamManager::PostRequestToUI(const std::string& label) { 587 void MediaStreamManager::PostRequestToUI(const std::string& label) {
593 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
594 DeviceRequest* request = requests_[label]; 589 DeviceRequest* request = requests_[label];
595 // Get user confirmation to use capture devices. 590 // Get user confirmation to use capture devices.
596 ui_controller_->MakeUIRequest(label, 591 ui_controller_->MakeUIRequest(label,
597 request->render_process_id, 592 request->render_process_id,
598 request->render_view_id, 593 request->render_view_id,
599 request->options, 594 request->options,
600 request->security_origin); 595 request->security_origin,
596 request->type);
601 } 597 }
602 598
603 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { 599 void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
604 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 600 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
605 if (device_thread_.get()) 601 if (device_thread_.get())
606 return; 602 return;
607 603
608 device_thread_.reset(new base::Thread("MediaStreamDeviceThread")); 604 device_thread_.reset(new base::Thread("MediaStreamDeviceThread"));
609 #if defined(OS_WIN) 605 #if defined(OS_WIN)
610 device_thread_->init_com_with_mta(true); 606 device_thread_->init_com_with_mta(true);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 } 664 }
669 665
670 request->SetState(stream_type, MEDIA_REQUEST_STATE_DONE); 666 request->SetState(stream_type, MEDIA_REQUEST_STATE_DONE);
671 667
672 if (!RequestDone(*request)) { 668 if (!RequestDone(*request)) {
673 // This stream_type is done, but not the other type. 669 // This stream_type is done, but not the other type.
674 return; 670 return;
675 } 671 }
676 672
677 switch (request->type) { 673 switch (request->type) {
678 case DeviceRequest::OPEN_DEVICE: 674 case MEDIA_OPEN_DEVICE:
679 request->requester->DeviceOpened(label, devices->front()); 675 request->requester->DeviceOpened(label, devices->front());
680 break; 676 break;
681 case DeviceRequest::GENERATE_STREAM: { 677 case MEDIA_GENERATE_STREAM: {
682 // Partition the array of devices into audio vs video. 678 // Partition the array of devices into audio vs video.
683 StreamDeviceInfoArray audio_devices, video_devices; 679 StreamDeviceInfoArray audio_devices, video_devices;
684 for (StreamDeviceInfoArray::const_iterator device_it = devices->begin(); 680 for (StreamDeviceInfoArray::const_iterator device_it = devices->begin();
685 device_it != devices->end(); ++device_it) { 681 device_it != devices->end(); ++device_it) {
686 if (IsAudioMediaType(device_it->stream_type)) { 682 if (IsAudioMediaType(device_it->stream_type)) {
687 audio_devices.push_back(*device_it); 683 audio_devices.push_back(*device_it);
688 } else if (IsVideoMediaType(device_it->stream_type)) { 684 } else if (IsVideoMediaType(device_it->stream_type)) {
689 video_devices.push_back(*device_it); 685 video_devices.push_back(*device_it);
690 } else { 686 } else {
691 NOTREACHED(); 687 NOTREACHED();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 // Publish the result for all requests waiting for device list(s). 727 // Publish the result for all requests waiting for device list(s).
732 // Find the requests waiting for this device list, store their labels and 728 // Find the requests waiting for this device list, store their labels and
733 // release the iterator before calling device settings. We might get a call 729 // release the iterator before calling device settings. We might get a call
734 // back from device_settings that will need to iterate through devices. 730 // back from device_settings that will need to iterate through devices.
735 std::list<std::string> label_list; 731 std::list<std::string> label_list;
736 for (DeviceRequests::iterator it = requests_.begin(); it != requests_.end(); 732 for (DeviceRequests::iterator it = requests_.begin(); it != requests_.end();
737 ++it) { 733 ++it) {
738 if (it->second->state(stream_type) == 734 if (it->second->state(stream_type) ==
739 MEDIA_REQUEST_STATE_REQUESTED && 735 MEDIA_REQUEST_STATE_REQUESTED &&
740 Requested(it->second->options, stream_type)) { 736 Requested(it->second->options, stream_type)) {
741 if (it->second->type != DeviceRequest::ENUMERATE_DEVICES) 737 if (it->second->type != MEDIA_ENUMERATE_DEVICES)
742 it->second->SetState(stream_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); 738 it->second->SetState(stream_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
743 label_list.push_back(it->first); 739 label_list.push_back(it->first);
744 } 740 }
745 } 741 }
746 for (std::list<std::string>::iterator it = label_list.begin(); 742 for (std::list<std::string>::iterator it = label_list.begin();
747 it != label_list.end(); ++it) { 743 it != label_list.end(); ++it) {
748 DeviceRequest* request = requests_[*it]; 744 DeviceRequest* request = requests_[*it];
749 switch (request->type) { 745 switch (request->type) {
750 case DeviceRequest::ENUMERATE_DEVICES: 746 case MEDIA_ENUMERATE_DEVICES:
751 if (need_update_clients && request->requester) 747 if (need_update_clients && request->requester)
752 request->requester->DevicesEnumerated(*it, devices); 748 request->requester->DevicesEnumerated(*it, devices);
753 break; 749 break;
754 case DeviceRequest::OPEN_DEVICE:
755 DCHECK(!request->requested_device_id.empty());
756 for (StreamDeviceInfoArray::const_iterator device_it = devices.begin();
757 device_it != devices.end(); ++device_it) {
758 if (request->requested_device_id == device_it->device_id) {
759 StreamDeviceInfo device = *device_it;
760 device.in_use = false;
761 device.session_id =
762 GetDeviceManager(device_it->stream_type)->Open(device);
763 request->SetState(device_it->stream_type,
764 MEDIA_REQUEST_STATE_OPENING);
765 request->devices.push_back(device);
766 break;
767 }
768 }
769 break;
770 default: 750 default:
771 ui_controller_->AddAvailableDevicesToRequest(*it, stream_type, 751 ui_controller_->AddAvailableDevicesToRequest(*it, stream_type,
772 devices); 752 devices);
773 break; 753 break;
774 } 754 }
775 } 755 }
776 label_list.clear(); 756 label_list.clear();
777 --active_enumeration_ref_count_[stream_type]; 757 --active_enumeration_ref_count_[stream_type];
778 DCHECK_GE(active_enumeration_ref_count_[stream_type], 0); 758 DCHECK_GE(active_enumeration_ref_count_[stream_type], 0);
779 } 759 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 814
835 void MediaStreamManager::DevicesAccepted(const std::string& label, 815 void MediaStreamManager::DevicesAccepted(const std::string& label,
836 const StreamDeviceInfoArray& devices) { 816 const StreamDeviceInfoArray& devices) {
837 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 817 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
838 DCHECK(!devices.empty()); 818 DCHECK(!devices.empty());
839 DeviceRequests::iterator request_it = requests_.find(label); 819 DeviceRequests::iterator request_it = requests_.find(label);
840 if (request_it == requests_.end()) { 820 if (request_it == requests_.end()) {
841 return; 821 return;
842 } 822 }
843 823
844 if (request_it->second->type == DeviceRequest::DEVICE_ACCESS) { 824 if (request_it->second->type == MEDIA_DEVICE_ACCESS) {
845 scoped_ptr<DeviceRequest> request(request_it->second); 825 scoped_ptr<DeviceRequest> request(request_it->second);
846 if (!request->callback.is_null()) { 826 if (!request->callback.is_null()) {
847 // Map the devices to MediaStreamDevices. 827 // Map the devices to MediaStreamDevices.
848 MediaStreamDevices selected_devices; 828 MediaStreamDevices selected_devices;
849 for (StreamDeviceInfoArray::const_iterator it = devices.begin(); 829 for (StreamDeviceInfoArray::const_iterator it = devices.begin();
850 it != devices.end(); ++it) { 830 it != devices.end(); ++it) {
851 selected_devices.push_back(MediaStreamDevice( 831 selected_devices.push_back(MediaStreamDevice(
852 it->stream_type, it->device_id, it->name)); 832 it->stream_type, it->device_id, it->name));
853 } 833 }
854 834
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 // Erase this request and report an error. 885 // Erase this request and report an error.
906 DeviceRequests::iterator it = requests_.find(label); 886 DeviceRequests::iterator it = requests_.find(label);
907 if (it == requests_.end()) 887 if (it == requests_.end())
908 return; 888 return;
909 889
910 // Notify the users about the request result. 890 // Notify the users about the request result.
911 scoped_ptr<DeviceRequest> request(it->second); 891 scoped_ptr<DeviceRequest> request(it->second);
912 if (request->requester) 892 if (request->requester)
913 request->requester->StreamGenerationFailed(label); 893 request->requester->StreamGenerationFailed(label);
914 894
915 if (request->type == DeviceRequest::DEVICE_ACCESS && 895 if (request->type == MEDIA_DEVICE_ACCESS &&
916 !request->callback.is_null()) { 896 !request->callback.is_null()) {
917 request->callback.Run(label, MediaStreamDevices()); 897 request->callback.Run(label, MediaStreamDevices());
918 } 898 }
919 899
920 requests_.erase(it); 900 requests_.erase(it);
921 } 901 }
922 902
923 void MediaStreamManager::UseFakeDevice() { 903 void MediaStreamManager::UseFakeDevice() {
924 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 904 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
925 video_capture_manager()->UseFakeDevice(); 905 video_capture_manager()->UseFakeDevice();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 } 1044 }
1065 1045
1066 // Always do enumeration even though some enumeration is in progress, 1046 // Always do enumeration even though some enumeration is in progress,
1067 // because those enumeration commands could be sent before these devices 1047 // because those enumeration commands could be sent before these devices
1068 // change. 1048 // change.
1069 ++active_enumeration_ref_count_[stream_type]; 1049 ++active_enumeration_ref_count_[stream_type];
1070 GetDeviceManager(stream_type)->EnumerateDevices(); 1050 GetDeviceManager(stream_type)->EnumerateDevices();
1071 } 1051 }
1072 1052
1073 } // namespace content 1053 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698