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

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

Issue 74703002: RELAND 29423003: Added video capture capabilities retrieval and caching to VideoCaptureManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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/video_capture_manager.h" 5 #include "content/browser/renderer_host/media/video_capture_manager.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/task_runner_util.h"
14 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
15 #include "content/browser/renderer_host/media/video_capture_controller.h" 16 #include "content/browser/renderer_host/media/video_capture_controller.h"
16 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" 17 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h"
17 #include "content/browser/renderer_host/media/web_contents_video_capture_device. h" 18 #include "content/browser/renderer_host/media/web_contents_video_capture_device. h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 #include "content/public/common/desktop_media_id.h" 21 #include "content/public/common/desktop_media_id.h"
21 #include "content/public/common/media_stream_request.h" 22 #include "content/public/common/media_stream_request.h"
22 #include "media/base/scoped_histogram_timer.h" 23 #include "media/base/scoped_histogram_timer.h"
23 #include "media/video/capture/fake_video_capture_device.h" 24 #include "media/video/capture/fake_video_capture_device.h"
24 #include "media/video/capture/video_capture_device.h" 25 #include "media/video/capture/video_capture_device.h"
25 26
26 #if defined(ENABLE_SCREEN_CAPTURE) 27 #if defined(ENABLE_SCREEN_CAPTURE)
27 #include "content/browser/renderer_host/media/desktop_capture_device.h" 28 #include "content/browser/renderer_host/media/desktop_capture_device.h"
28 #endif 29 #endif
29 30
30 namespace content { 31 namespace content {
31 32
32 VideoCaptureManager::DeviceEntry::DeviceEntry( 33 VideoCaptureManager::DeviceEntry::DeviceEntry(
33 MediaStreamType stream_type, 34 MediaStreamType stream_type,
34 const std::string& id, 35 const std::string& id,
35 scoped_ptr<VideoCaptureController> controller) 36 scoped_ptr<VideoCaptureController> controller)
36 : stream_type(stream_type), 37 : stream_type(stream_type),
37 id(id), 38 id(id),
38 video_capture_controller(controller.Pass()) {} 39 video_capture_controller(controller.Pass()) {}
39 40
40 VideoCaptureManager::DeviceEntry::~DeviceEntry() {} 41 VideoCaptureManager::DeviceEntry::~DeviceEntry() {}
41 42
43 VideoCaptureManager::DeviceInfo::DeviceInfo() {}
44
45 VideoCaptureManager::DeviceInfo::DeviceInfo(
46 const media::VideoCaptureDevice::Name& name,
47 const media::VideoCaptureCapabilities& capabilities)
48 : name(name),
49 capabilities(capabilities) {}
50
51 VideoCaptureManager::DeviceInfo::~DeviceInfo() {}
52
42 VideoCaptureManager::VideoCaptureManager() 53 VideoCaptureManager::VideoCaptureManager()
43 : listener_(NULL), 54 : listener_(NULL),
44 new_capture_session_id_(1), 55 new_capture_session_id_(1),
45 use_fake_device_(false) { 56 use_fake_device_(false) {
46 } 57 }
47 58
48 VideoCaptureManager::~VideoCaptureManager() { 59 VideoCaptureManager::~VideoCaptureManager() {
49 DCHECK(devices_.empty()); 60 DCHECK(devices_.empty());
50 } 61 }
51 62
52 void VideoCaptureManager::Register(MediaStreamProviderListener* listener, 63 void VideoCaptureManager::Register(MediaStreamProviderListener* listener,
53 base::MessageLoopProxy* device_thread_loop) { 64 base::MessageLoopProxy* device_thread_loop) {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
55 DCHECK(!listener_); 66 DCHECK(!listener_);
56 DCHECK(!device_loop_.get()); 67 DCHECK(!device_loop_.get());
57 listener_ = listener; 68 listener_ = listener;
58 device_loop_ = device_thread_loop; 69 device_loop_ = device_thread_loop;
59 } 70 }
60 71
61 void VideoCaptureManager::Unregister() { 72 void VideoCaptureManager::Unregister() {
62 DCHECK(listener_); 73 DCHECK(listener_);
63 listener_ = NULL; 74 listener_ = NULL;
64 } 75 }
65 76
66 void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) { 77 void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) {
67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
68 DVLOG(1) << "VideoCaptureManager::EnumerateDevices, type " << stream_type; 79 DVLOG(1) << "VideoCaptureManager::EnumerateDevices, type " << stream_type;
69 DCHECK(listener_); 80 DCHECK(listener_);
81
70 base::PostTaskAndReplyWithResult( 82 base::PostTaskAndReplyWithResult(
71 device_loop_, FROM_HERE, 83 device_loop_,
72 base::Bind(&VideoCaptureManager::GetAvailableDevicesOnDeviceThread, this, 84 FROM_HERE,
73 stream_type), 85 base::Bind(&VideoCaptureManager::
74 base::Bind(&VideoCaptureManager::OnDevicesEnumerated, this, stream_type)); 86 GetAvailableDevicesAndCapabilitiesOnDeviceThread,
87 this,
88 stream_type,
89 devices_info_cache_),
90 base::Bind(&VideoCaptureManager::OnDeviceNamesAndCapabilitiesEnumerated,
91 this,
92 stream_type));
75 } 93 }
76 94
77 int VideoCaptureManager::Open(const StreamDeviceInfo& device_info) { 95 int VideoCaptureManager::Open(const StreamDeviceInfo& device_info) {
78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
79 DCHECK(listener_); 97 DCHECK(listener_);
80 98
81 // Generate a new id for the session being opened. 99 // Generate a new id for the session being opened.
82 const int capture_session_id = new_capture_session_id_++; 100 const int capture_session_id = new_capture_session_id_++;
83 101
84 DCHECK(sessions_.find(capture_session_id) == sessions_.end()); 102 DCHECK(sessions_.find(capture_session_id) == sessions_.end());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 scoped_ptr<media::VideoCaptureDevice::Client> device_client) { 155 scoped_ptr<media::VideoCaptureDevice::Client> device_client) {
138 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); 156 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime");
139 DCHECK(IsOnDeviceThread()); 157 DCHECK(IsOnDeviceThread());
140 158
141 scoped_ptr<media::VideoCaptureDevice> video_capture_device; 159 scoped_ptr<media::VideoCaptureDevice> video_capture_device;
142 switch (entry->stream_type) { 160 switch (entry->stream_type) {
143 case MEDIA_DEVICE_VIDEO_CAPTURE: { 161 case MEDIA_DEVICE_VIDEO_CAPTURE: {
144 // We look up the device id from the renderer in our local enumeration 162 // We look up the device id from the renderer in our local enumeration
145 // since the renderer does not have all the information that might be 163 // since the renderer does not have all the information that might be
146 // held in the browser-side VideoCaptureDevice::Name structure. 164 // held in the browser-side VideoCaptureDevice::Name structure.
147 media::VideoCaptureDevice::Name* found = 165 DeviceInfo* found = FindDeviceInfoById(entry->id, devices_info_cache_);
148 video_capture_devices_.FindById(entry->id);
149 if (found) { 166 if (found) {
150 video_capture_device.reset(use_fake_device_ ? 167 video_capture_device.reset(use_fake_device_ ?
151 media::FakeVideoCaptureDevice::Create(*found) : 168 media::FakeVideoCaptureDevice::Create(found->name) :
152 media::VideoCaptureDevice::Create(*found)); 169 media::VideoCaptureDevice::Create(found->name));
153 } 170 }
154 break; 171 break;
155 } 172 }
156 case MEDIA_TAB_VIDEO_CAPTURE: { 173 case MEDIA_TAB_VIDEO_CAPTURE: {
157 video_capture_device.reset( 174 video_capture_device.reset(
158 WebContentsVideoCaptureDevice::Create(entry->id)); 175 WebContentsVideoCaptureDevice::Create(entry->id));
159 break; 176 break;
160 } 177 }
161 case MEDIA_DESKTOP_VIDEO_CAPTURE: { 178 case MEDIA_DESKTOP_VIDEO_CAPTURE: {
162 #if defined(ENABLE_SCREEN_CAPTURE) 179 #if defined(ENABLE_SCREEN_CAPTURE)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 228
212 media::VideoCaptureCapability params_as_capability; 229 media::VideoCaptureCapability params_as_capability;
213 params_as_capability.width = params.requested_format.width; 230 params_as_capability.width = params.requested_format.width;
214 params_as_capability.height = params.requested_format.height; 231 params_as_capability.height = params.requested_format.height;
215 params_as_capability.frame_rate = params.requested_format.frame_rate; 232 params_as_capability.frame_rate = params.requested_format.frame_rate;
216 params_as_capability.frame_size_type = 233 params_as_capability.frame_size_type =
217 params.requested_format.frame_size_type; 234 params.requested_format.frame_size_type;
218 235
219 device_loop_->PostTask(FROM_HERE, base::Bind( 236 device_loop_->PostTask(FROM_HERE, base::Bind(
220 &VideoCaptureManager::DoStartDeviceOnDeviceThread, this, 237 &VideoCaptureManager::DoStartDeviceOnDeviceThread, this,
221 entry, params_as_capability, 238 entry,
239 params_as_capability,
222 base::Passed(entry->video_capture_controller->NewDeviceClient()))); 240 base::Passed(entry->video_capture_controller->NewDeviceClient())));
223 } 241 }
224 // Run the callback first, as AddClient() may trigger OnFrameInfo(). 242 // Run the callback first, as AddClient() may trigger OnFrameInfo().
225 done_cb.Run(entry->video_capture_controller->GetWeakPtr()); 243 done_cb.Run(entry->video_capture_controller->GetWeakPtr());
226 entry->video_capture_controller->AddClient(client_id, 244 entry->video_capture_controller->AddClient(client_id,
227 client_handler, 245 client_handler,
228 client_render_process, 246 client_render_process,
229 params); 247 params);
230 } 248 }
231 249
(...skipping 13 matching lines...) Expand all
245 263
246 // Detach client from controller. 264 // Detach client from controller.
247 int session_id = controller->RemoveClient(client_id, client_handler); 265 int session_id = controller->RemoveClient(client_id, client_handler);
248 DVLOG(1) << "VideoCaptureManager::StopCaptureForClient, session_id = " 266 DVLOG(1) << "VideoCaptureManager::StopCaptureForClient, session_id = "
249 << session_id; 267 << session_id;
250 268
251 // If controller has no more clients, delete controller and device. 269 // If controller has no more clients, delete controller and device.
252 DestroyDeviceEntryIfNoClients(entry); 270 DestroyDeviceEntryIfNoClients(entry);
253 } 271 }
254 272
273 void VideoCaptureManager::GetDeviceCapabilities(
274 int capture_session_id,
275 media::VideoCaptureCapabilities* capabilities) {
276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
277 capabilities->clear();
278
279 std::map<int, MediaStreamDevice>::iterator it =
280 sessions_.find(capture_session_id);
281 DCHECK(it != sessions_.end());
282 DVLOG(1) << "GetDeviceCapabilities for device: " << it->second.name;
283
284 DeviceInfo* device_in_use =
285 FindDeviceInfoById(it->second.id, devices_info_cache_);
286 DCHECK(device_in_use);
287 if (device_in_use) {
288 DeviceEntry* const existing_device =
289 GetDeviceEntryForMediaStreamDevice(it->second);
290 if (!existing_device) {
291 // If the device is not in use, just return all its cached capabilities.
292 *capabilities = device_in_use->capabilities;
293 return;
294 }
295 // Otherwise, get the video capture parameters in use from the controller
296 // associated to the device.
297 media::VideoCaptureFormat format =
298 existing_device->video_capture_controller->GetVideoCaptureFormat();
299 media::VideoCaptureCapability current_format(format.width,
300 format.height,
301 format.frame_rate,
302 media::PIXEL_FORMAT_I420,
303 format.frame_size_type);
304 capabilities->push_back(current_format);
305 }
306 }
307
255 void VideoCaptureManager::DoStopDeviceOnDeviceThread(DeviceEntry* entry) { 308 void VideoCaptureManager::DoStopDeviceOnDeviceThread(DeviceEntry* entry) {
256 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StopDeviceTime"); 309 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StopDeviceTime");
257 DCHECK(IsOnDeviceThread()); 310 DCHECK(IsOnDeviceThread());
258 if (entry->video_capture_device) { 311 if (entry->video_capture_device) {
259 entry->video_capture_device->StopAndDeAllocate(); 312 entry->video_capture_device->StopAndDeAllocate();
260 } 313 }
261 entry->video_capture_device.reset(); 314 entry->video_capture_device.reset();
262 } 315 }
263 316
264 void VideoCaptureManager::OnOpened(MediaStreamType stream_type, 317 void VideoCaptureManager::OnOpened(MediaStreamType stream_type,
265 int capture_session_id) { 318 int capture_session_id) {
266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
267 if (!listener_) { 320 if (!listener_) {
268 // Listener has been removed. 321 // Listener has been removed.
269 return; 322 return;
270 } 323 }
271 listener_->Opened(stream_type, capture_session_id); 324 listener_->Opened(stream_type, capture_session_id);
272 } 325 }
273 326
274 void VideoCaptureManager::OnClosed(MediaStreamType stream_type, 327 void VideoCaptureManager::OnClosed(MediaStreamType stream_type,
275 int capture_session_id) { 328 int capture_session_id) {
276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
277 if (!listener_) { 330 if (!listener_) {
278 // Listener has been removed. 331 // Listener has been removed.
279 return; 332 return;
280 } 333 }
281 listener_->Closed(stream_type, capture_session_id); 334 listener_->Closed(stream_type, capture_session_id);
282 } 335 }
283 336
284 void VideoCaptureManager::OnDevicesEnumerated( 337 void VideoCaptureManager::OnDeviceNamesAndCapabilitiesEnumerated(
285 MediaStreamType stream_type, 338 MediaStreamType stream_type,
286 const media::VideoCaptureDevice::Names& device_names) { 339 const DevicesInfo& new_devices_info_cache) {
287 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
288 341 DVLOG(1) << "OnDeviceNameAndCapabilitiesEnumerated, #new devices: "
289 if (!listener_) { 342 << new_devices_info_cache.size();
290 // Listener has been removed. 343 if (!listener_) { // Listener has been removed.
291 return; 344 return;
292 } 345 }
346 devices_info_cache_ = new_devices_info_cache;
293 347
294 // Transform from VCD::Name to StreamDeviceInfo. 348 // Walk the |devices_info_cache_| and transform from VCD::Name to
349 // StreamDeviceInfo for return purposes.
295 StreamDeviceInfoArray devices; 350 StreamDeviceInfoArray devices;
296 for (media::VideoCaptureDevice::Names::const_iterator it = 351 for (DevicesInfo::const_iterator it = devices_info_cache_.begin();
297 device_names.begin(); it != device_names.end(); ++it) { 352 it != devices_info_cache_.end();
353 ++it) {
298 devices.push_back(StreamDeviceInfo( 354 devices.push_back(StreamDeviceInfo(
299 stream_type, it->GetNameAndModel(), it->id())); 355 stream_type, it->name.GetNameAndModel(), it->name.id()));
300 } 356 }
301
302 listener_->DevicesEnumerated(stream_type, devices); 357 listener_->DevicesEnumerated(stream_type, devices);
303 } 358 }
304 359
305 bool VideoCaptureManager::IsOnDeviceThread() const { 360 bool VideoCaptureManager::IsOnDeviceThread() const {
306 return device_loop_->BelongsToCurrentThread(); 361 return device_loop_->BelongsToCurrentThread();
307 } 362 }
308 363
309 media::VideoCaptureDevice::Names 364 VideoCaptureManager::DevicesInfo
310 VideoCaptureManager::GetAvailableDevicesOnDeviceThread( 365 VideoCaptureManager::GetAvailableDevicesAndCapabilitiesOnDeviceThread(
311 MediaStreamType stream_type) { 366 MediaStreamType stream_type,
367 const DevicesInfo& old_device_info_cache) {
312 SCOPED_UMA_HISTOGRAM_TIMER( 368 SCOPED_UMA_HISTOGRAM_TIMER(
313 "Media.VideoCaptureManager.GetAvailableDevicesTime"); 369 "Media.VideoCaptureManager."
370 "GetAvailableDevicesAndCapabilitiesOnDeviceThreadTime");
314 DCHECK(IsOnDeviceThread()); 371 DCHECK(IsOnDeviceThread());
315 media::VideoCaptureDevice::Names result; 372 media::VideoCaptureDevice::Names names_snapshot;
316
317 switch (stream_type) { 373 switch (stream_type) {
318 case MEDIA_DEVICE_VIDEO_CAPTURE: 374 case MEDIA_DEVICE_VIDEO_CAPTURE:
319 // Cache the latest enumeration of video capture devices. 375 if (!use_fake_device_)
320 // We'll refer to this list again in OnOpen to avoid having to 376 media::VideoCaptureDevice::GetDeviceNames(&names_snapshot);
321 // enumerate the devices again. 377 else
322 if (!use_fake_device_) { 378 media::FakeVideoCaptureDevice::GetDeviceNames(&names_snapshot);
323 media::VideoCaptureDevice::GetDeviceNames(&result);
324 } else {
325 media::FakeVideoCaptureDevice::GetDeviceNames(&result);
326 }
327
328 // TODO(nick): The correctness of device start depends on this cache being
329 // maintained, but it seems a little odd to keep a cache here. Can we
330 // eliminate it?
331 video_capture_devices_ = result;
332 break; 379 break;
333
334 case MEDIA_DESKTOP_VIDEO_CAPTURE: 380 case MEDIA_DESKTOP_VIDEO_CAPTURE:
335 // Do nothing. 381 // Do nothing.
336 break; 382 break;
337
338 default: 383 default:
339 NOTREACHED(); 384 NOTREACHED();
340 break; 385 break;
341 } 386 }
342 return result; 387
388 // Construct |new_devices_info_cache| with the cached devices that are still
389 // present in the system, and remove their names from |names_snapshot|, so we
390 // keep there the truly new devices.
391 DevicesInfo new_devices_info_cache;
392 for (DevicesInfo::const_iterator it_device_info =
393 old_device_info_cache.begin();
394 it_device_info != old_device_info_cache.end();
395 ++it_device_info) {
396 media::VideoCaptureDevice::Names::iterator it;
397 for (it = names_snapshot.begin(); it != names_snapshot.end(); ++it) {
398 if (it_device_info->name.id() == it->id()) {
399 new_devices_info_cache.push_back(*it_device_info);
400 names_snapshot.erase(it);
401 break;
402 }
403 }
404 }
405
406 // Need to get the capabilities for the truly new devices in |names_snapshot|.
407 for (media::VideoCaptureDevice::Names::const_iterator it =
408 names_snapshot.begin();
409 it != names_snapshot.end();
410 ++it) {
411 media::VideoCaptureCapabilities capabilities;
412 DeviceInfo device_info(*it, media::VideoCaptureCapabilities());
413 if (!use_fake_device_) {
414 media::VideoCaptureDevice::GetDeviceSupportedFormats(
415 *it, &(device_info.capabilities));
416 } else {
417 media::FakeVideoCaptureDevice::GetDeviceSupportedFormats(
418 *it, &(device_info.capabilities));
419 }
420 new_devices_info_cache.push_back(device_info);
421 }
422 return new_devices_info_cache;
343 } 423 }
344 424
345 VideoCaptureManager::DeviceEntry* 425 VideoCaptureManager::DeviceEntry*
346 VideoCaptureManager::GetDeviceEntryForMediaStreamDevice( 426 VideoCaptureManager::GetDeviceEntryForMediaStreamDevice(
347 const MediaStreamDevice& device_info) { 427 const MediaStreamDevice& device_info) {
348 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
349 429
350 for (DeviceEntries::iterator it = devices_.begin(); 430 for (DeviceEntries::iterator it = devices_.begin();
351 it != devices_.end(); ++it) { 431 it != devices_.end(); ++it) {
352 DeviceEntry* device = *it; 432 DeviceEntry* device = *it;
(...skipping 26 matching lines...) Expand all
379 << entry->stream_type << ", id = " << entry->id << ")"; 459 << entry->stream_type << ", id = " << entry->id << ")";
380 460
381 // The DeviceEntry is removed from |devices_| immediately. The controller is 461 // The DeviceEntry is removed from |devices_| immediately. The controller is
382 // deleted immediately, and the device is freed asynchronously. After this 462 // deleted immediately, and the device is freed asynchronously. After this
383 // point, subsequent requests to open this same device ID will create a new 463 // point, subsequent requests to open this same device ID will create a new
384 // DeviceEntry, VideoCaptureController, and VideoCaptureDevice. 464 // DeviceEntry, VideoCaptureController, and VideoCaptureDevice.
385 devices_.erase(entry); 465 devices_.erase(entry);
386 entry->video_capture_controller.reset(); 466 entry->video_capture_controller.reset();
387 device_loop_->PostTask( 467 device_loop_->PostTask(
388 FROM_HERE, 468 FROM_HERE,
389 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this, 469 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread,
470 this,
390 base::Owned(entry))); 471 base::Owned(entry)));
391 } 472 }
392 } 473 }
393 474
394 VideoCaptureManager::DeviceEntry* VideoCaptureManager::GetOrCreateDeviceEntry( 475 VideoCaptureManager::DeviceEntry* VideoCaptureManager::GetOrCreateDeviceEntry(
395 int capture_session_id) { 476 int capture_session_id) {
396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 477 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
397 478
398 std::map<int, MediaStreamDevice>::iterator session_it = 479 std::map<int, MediaStreamDevice>::iterator session_it =
399 sessions_.find(capture_session_id); 480 sessions_.find(capture_session_id);
(...skipping 13 matching lines...) Expand all
413 494
414 scoped_ptr<VideoCaptureController> video_capture_controller( 495 scoped_ptr<VideoCaptureController> video_capture_controller(
415 new VideoCaptureController()); 496 new VideoCaptureController());
416 DeviceEntry* new_device = new DeviceEntry(device_info.type, 497 DeviceEntry* new_device = new DeviceEntry(device_info.type,
417 device_info.id, 498 device_info.id,
418 video_capture_controller.Pass()); 499 video_capture_controller.Pass());
419 devices_.insert(new_device); 500 devices_.insert(new_device);
420 return new_device; 501 return new_device;
421 } 502 }
422 503
504 VideoCaptureManager::DeviceInfo* VideoCaptureManager::FindDeviceInfoById(
505 const std::string& id,
506 DevicesInfo& device_vector) {
507 for (DevicesInfo::iterator it = device_vector.begin();
508 it != device_vector.end(); ++it) {
509 if (it->name.id() == id)
510 return &(*it);
511 }
512 return NULL;
513 }
514
423 } // namespace content 515 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698