| OLD | NEW |
| 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" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 artificial_device_source_for_testing_(DISABLED) { | 101 artificial_device_source_for_testing_(DISABLED) { |
| 102 } | 102 } |
| 103 | 103 |
| 104 VideoCaptureManager::~VideoCaptureManager() { | 104 VideoCaptureManager::~VideoCaptureManager() { |
| 105 DCHECK(devices_.empty()); | 105 DCHECK(devices_.empty()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void VideoCaptureManager::Register( | 108 void VideoCaptureManager::Register( |
| 109 MediaStreamProviderListener* listener, | 109 MediaStreamProviderListener* listener, |
| 110 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { | 110 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { |
| 111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 111 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 112 DCHECK(!listener_); | 112 DCHECK(!listener_); |
| 113 DCHECK(!device_task_runner_.get()); | 113 DCHECK(!device_task_runner_.get()); |
| 114 listener_ = listener; | 114 listener_ = listener; |
| 115 device_task_runner_ = device_task_runner; | 115 device_task_runner_ = device_task_runner; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void VideoCaptureManager::Unregister() { | 118 void VideoCaptureManager::Unregister() { |
| 119 DCHECK(listener_); | 119 DCHECK(listener_); |
| 120 listener_ = NULL; | 120 listener_ = NULL; |
| 121 } | 121 } |
| 122 | 122 |
| 123 void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) { | 123 void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) { |
| 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 124 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 125 DVLOG(1) << "VideoCaptureManager::EnumerateDevices, type " << stream_type; | 125 DVLOG(1) << "VideoCaptureManager::EnumerateDevices, type " << stream_type; |
| 126 DCHECK(listener_); | 126 DCHECK(listener_); |
| 127 base::PostTaskAndReplyWithResult( | 127 base::PostTaskAndReplyWithResult( |
| 128 device_task_runner_, FROM_HERE, | 128 device_task_runner_, FROM_HERE, |
| 129 base::Bind(&VideoCaptureManager::GetAvailableDevicesInfoOnDeviceThread, | 129 base::Bind(&VideoCaptureManager::GetAvailableDevicesInfoOnDeviceThread, |
| 130 this, stream_type, devices_info_cache_), | 130 this, stream_type, devices_info_cache_), |
| 131 base::Bind(&VideoCaptureManager::OnDevicesInfoEnumerated, this, | 131 base::Bind(&VideoCaptureManager::OnDevicesInfoEnumerated, this, |
| 132 stream_type)); | 132 stream_type)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 int VideoCaptureManager::Open(const StreamDeviceInfo& device_info) { | 135 int VideoCaptureManager::Open(const StreamDeviceInfo& device_info) { |
| 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 136 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 137 DCHECK(listener_); | 137 DCHECK(listener_); |
| 138 | 138 |
| 139 // Generate a new id for the session being opened. | 139 // Generate a new id for the session being opened. |
| 140 const media::VideoCaptureSessionId capture_session_id = | 140 const media::VideoCaptureSessionId capture_session_id = |
| 141 new_capture_session_id_++; | 141 new_capture_session_id_++; |
| 142 | 142 |
| 143 DCHECK(sessions_.find(capture_session_id) == sessions_.end()); | 143 DCHECK(sessions_.find(capture_session_id) == sessions_.end()); |
| 144 DVLOG(1) << "VideoCaptureManager::Open, id " << capture_session_id; | 144 DVLOG(1) << "VideoCaptureManager::Open, id " << capture_session_id; |
| 145 | 145 |
| 146 // We just save the stream info for processing later. | 146 // We just save the stream info for processing later. |
| 147 sessions_[capture_session_id] = device_info.device; | 147 sessions_[capture_session_id] = device_info.device; |
| 148 | 148 |
| 149 // Notify our listener asynchronously; this ensures that we return | 149 // Notify our listener asynchronously; this ensures that we return |
| 150 // |capture_session_id| to the caller of this function before using that same | 150 // |capture_session_id| to the caller of this function before using that same |
| 151 // id in a listener event. | 151 // id in a listener event. |
| 152 base::MessageLoop::current()->PostTask(FROM_HERE, | 152 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 153 base::Bind(&VideoCaptureManager::OnOpened, this, | 153 base::Bind(&VideoCaptureManager::OnOpened, this, |
| 154 device_info.device.type, capture_session_id)); | 154 device_info.device.type, capture_session_id)); |
| 155 return capture_session_id; | 155 return capture_session_id; |
| 156 } | 156 } |
| 157 | 157 |
| 158 void VideoCaptureManager::Close(int capture_session_id) { | 158 void VideoCaptureManager::Close(int capture_session_id) { |
| 159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 159 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 160 DCHECK(listener_); | 160 DCHECK(listener_); |
| 161 DVLOG(1) << "VideoCaptureManager::Close, id " << capture_session_id; | 161 DVLOG(1) << "VideoCaptureManager::Close, id " << capture_session_id; |
| 162 | 162 |
| 163 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator | 163 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator |
| 164 session_it = sessions_.find(capture_session_id); | 164 session_it = sessions_.find(capture_session_id); |
| 165 if (session_it == sessions_.end()) { | 165 if (session_it == sessions_.end()) { |
| 166 NOTREACHED(); | 166 NOTREACHED(); |
| 167 return; | 167 return; |
| 168 } | 168 } |
| 169 | 169 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 entry->video_capture_device = video_capture_device.Pass(); | 268 entry->video_capture_device = video_capture_device.Pass(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void VideoCaptureManager::StartCaptureForClient( | 271 void VideoCaptureManager::StartCaptureForClient( |
| 272 media::VideoCaptureSessionId session_id, | 272 media::VideoCaptureSessionId session_id, |
| 273 const media::VideoCaptureParams& params, | 273 const media::VideoCaptureParams& params, |
| 274 base::ProcessHandle client_render_process, | 274 base::ProcessHandle client_render_process, |
| 275 VideoCaptureControllerID client_id, | 275 VideoCaptureControllerID client_id, |
| 276 VideoCaptureControllerEventHandler* client_handler, | 276 VideoCaptureControllerEventHandler* client_handler, |
| 277 const DoneCB& done_cb) { | 277 const DoneCB& done_cb) { |
| 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 278 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 279 DVLOG(1) << "VideoCaptureManager::StartCaptureForClient, " | 279 DVLOG(1) << "VideoCaptureManager::StartCaptureForClient, " |
| 280 << params.requested_format.frame_size.ToString() << ", " | 280 << params.requested_format.frame_size.ToString() << ", " |
| 281 << params.requested_format.frame_rate << ", #" << session_id << ")"; | 281 << params.requested_format.frame_rate << ", #" << session_id << ")"; |
| 282 | 282 |
| 283 DeviceEntry* entry = GetOrCreateDeviceEntry(session_id); | 283 DeviceEntry* entry = GetOrCreateDeviceEntry(session_id); |
| 284 if (!entry) { | 284 if (!entry) { |
| 285 done_cb.Run(base::WeakPtr<VideoCaptureController>()); | 285 done_cb.Run(base::WeakPtr<VideoCaptureController>()); |
| 286 return; | 286 return; |
| 287 } | 287 } |
| 288 | 288 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 306 // Run the callback first, as AddClient() may trigger OnFrameInfo(). | 306 // Run the callback first, as AddClient() may trigger OnFrameInfo(). |
| 307 done_cb.Run(entry->video_capture_controller->GetWeakPtr()); | 307 done_cb.Run(entry->video_capture_controller->GetWeakPtr()); |
| 308 entry->video_capture_controller->AddClient( | 308 entry->video_capture_controller->AddClient( |
| 309 client_id, client_handler, client_render_process, session_id, params); | 309 client_id, client_handler, client_render_process, session_id, params); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void VideoCaptureManager::StopCaptureForClient( | 312 void VideoCaptureManager::StopCaptureForClient( |
| 313 VideoCaptureController* controller, | 313 VideoCaptureController* controller, |
| 314 VideoCaptureControllerID client_id, | 314 VideoCaptureControllerID client_id, |
| 315 VideoCaptureControllerEventHandler* client_handler) { | 315 VideoCaptureControllerEventHandler* client_handler) { |
| 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 316 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 317 DCHECK(controller); | 317 DCHECK(controller); |
| 318 DCHECK(client_handler); | 318 DCHECK(client_handler); |
| 319 | 319 |
| 320 DeviceEntry* entry = GetDeviceEntryForController(controller); | 320 DeviceEntry* entry = GetDeviceEntryForController(controller); |
| 321 if (!entry) { | 321 if (!entry) { |
| 322 NOTREACHED(); | 322 NOTREACHED(); |
| 323 return; | 323 return; |
| 324 } | 324 } |
| 325 | 325 |
| 326 // Detach client from controller. | 326 // Detach client from controller. |
| 327 media::VideoCaptureSessionId session_id = | 327 media::VideoCaptureSessionId session_id = |
| 328 controller->RemoveClient(client_id, client_handler); | 328 controller->RemoveClient(client_id, client_handler); |
| 329 DVLOG(1) << "VideoCaptureManager::StopCaptureForClient, session_id = " | 329 DVLOG(1) << "VideoCaptureManager::StopCaptureForClient, session_id = " |
| 330 << session_id; | 330 << session_id; |
| 331 | 331 |
| 332 // If controller has no more clients, delete controller and device. | 332 // If controller has no more clients, delete controller and device. |
| 333 DestroyDeviceEntryIfNoClients(entry); | 333 DestroyDeviceEntryIfNoClients(entry); |
| 334 } | 334 } |
| 335 | 335 |
| 336 bool VideoCaptureManager::GetDeviceSupportedFormats( | 336 bool VideoCaptureManager::GetDeviceSupportedFormats( |
| 337 media::VideoCaptureSessionId capture_session_id, | 337 media::VideoCaptureSessionId capture_session_id, |
| 338 media::VideoCaptureFormats* supported_formats) { | 338 media::VideoCaptureFormats* supported_formats) { |
| 339 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 339 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 340 DCHECK(supported_formats->empty()); | 340 DCHECK(supported_formats->empty()); |
| 341 | 341 |
| 342 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator it = | 342 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator it = |
| 343 sessions_.find(capture_session_id); | 343 sessions_.find(capture_session_id); |
| 344 if (it == sessions_.end()) | 344 if (it == sessions_.end()) |
| 345 return false; | 345 return false; |
| 346 DVLOG(1) << "GetDeviceSupportedFormats for device: " << it->second.name; | 346 DVLOG(1) << "GetDeviceSupportedFormats for device: " << it->second.name; |
| 347 | 347 |
| 348 // Return all available formats of the device, regardless its started state. | 348 // Return all available formats of the device, regardless its started state. |
| 349 DeviceInfo* existing_device = | 349 DeviceInfo* existing_device = |
| 350 FindDeviceInfoById(it->second.id, devices_info_cache_); | 350 FindDeviceInfoById(it->second.id, devices_info_cache_); |
| 351 if (existing_device) | 351 if (existing_device) |
| 352 *supported_formats = existing_device->supported_formats; | 352 *supported_formats = existing_device->supported_formats; |
| 353 return true; | 353 return true; |
| 354 } | 354 } |
| 355 | 355 |
| 356 bool VideoCaptureManager::GetDeviceFormatsInUse( | 356 bool VideoCaptureManager::GetDeviceFormatsInUse( |
| 357 media::VideoCaptureSessionId capture_session_id, | 357 media::VideoCaptureSessionId capture_session_id, |
| 358 media::VideoCaptureFormats* formats_in_use) { | 358 media::VideoCaptureFormats* formats_in_use) { |
| 359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 359 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 360 DCHECK(formats_in_use->empty()); | 360 DCHECK(formats_in_use->empty()); |
| 361 | 361 |
| 362 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator it = | 362 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator it = |
| 363 sessions_.find(capture_session_id); | 363 sessions_.find(capture_session_id); |
| 364 if (it == sessions_.end()) | 364 if (it == sessions_.end()) |
| 365 return false; | 365 return false; |
| 366 DVLOG(1) << "GetDeviceFormatsInUse for device: " << it->second.name; | 366 DVLOG(1) << "GetDeviceFormatsInUse for device: " << it->second.name; |
| 367 | 367 |
| 368 // Return the currently in-use format(s) of the device, if it's started. | 368 // Return the currently in-use format(s) of the device, if it's started. |
| 369 DeviceEntry* device_in_use = | 369 DeviceEntry* device_in_use = |
| 370 GetDeviceEntryForMediaStreamDevice(it->second); | 370 GetDeviceEntryForMediaStreamDevice(it->second); |
| 371 if (device_in_use) { | 371 if (device_in_use) { |
| 372 // Currently only one format-in-use is supported at the VCC level. | 372 // Currently only one format-in-use is supported at the VCC level. |
| 373 formats_in_use->push_back( | 373 formats_in_use->push_back( |
| 374 device_in_use->video_capture_controller->GetVideoCaptureFormat()); | 374 device_in_use->video_capture_controller->GetVideoCaptureFormat()); |
| 375 } | 375 } |
| 376 return true; | 376 return true; |
| 377 } | 377 } |
| 378 | 378 |
| 379 void VideoCaptureManager::SetDesktopCaptureWindowId( | 379 void VideoCaptureManager::SetDesktopCaptureWindowId( |
| 380 media::VideoCaptureSessionId session_id, | 380 media::VideoCaptureSessionId session_id, |
| 381 gfx::NativeViewId window_id) { | 381 gfx::NativeViewId window_id) { |
| 382 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 382 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 383 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator | 383 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator |
| 384 session_it = sessions_.find(session_id); | 384 session_it = sessions_.find(session_id); |
| 385 if (session_it == sessions_.end()) { | 385 if (session_it == sessions_.end()) { |
| 386 device_task_runner_->PostTask( | 386 device_task_runner_->PostTask( |
| 387 FROM_HERE, | 387 FROM_HERE, |
| 388 base::Bind( | 388 base::Bind( |
| 389 &VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread, | 389 &VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread, |
| 390 this, | 390 this, |
| 391 session_id, | 391 session_id, |
| 392 window_id)); | 392 window_id)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 418 DCHECK(IsOnDeviceThread()); | 418 DCHECK(IsOnDeviceThread()); |
| 419 if (entry->video_capture_device) { | 419 if (entry->video_capture_device) { |
| 420 entry->video_capture_device->StopAndDeAllocate(); | 420 entry->video_capture_device->StopAndDeAllocate(); |
| 421 } | 421 } |
| 422 entry->video_capture_device.reset(); | 422 entry->video_capture_device.reset(); |
| 423 } | 423 } |
| 424 | 424 |
| 425 void VideoCaptureManager::OnOpened( | 425 void VideoCaptureManager::OnOpened( |
| 426 MediaStreamType stream_type, | 426 MediaStreamType stream_type, |
| 427 media::VideoCaptureSessionId capture_session_id) { | 427 media::VideoCaptureSessionId capture_session_id) { |
| 428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 428 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 429 if (!listener_) { | 429 if (!listener_) { |
| 430 // Listener has been removed. | 430 // Listener has been removed. |
| 431 return; | 431 return; |
| 432 } | 432 } |
| 433 listener_->Opened(stream_type, capture_session_id); | 433 listener_->Opened(stream_type, capture_session_id); |
| 434 } | 434 } |
| 435 | 435 |
| 436 void VideoCaptureManager::OnClosed( | 436 void VideoCaptureManager::OnClosed( |
| 437 MediaStreamType stream_type, | 437 MediaStreamType stream_type, |
| 438 media::VideoCaptureSessionId capture_session_id) { | 438 media::VideoCaptureSessionId capture_session_id) { |
| 439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 439 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 440 if (!listener_) { | 440 if (!listener_) { |
| 441 // Listener has been removed. | 441 // Listener has been removed. |
| 442 return; | 442 return; |
| 443 } | 443 } |
| 444 listener_->Closed(stream_type, capture_session_id); | 444 listener_->Closed(stream_type, capture_session_id); |
| 445 } | 445 } |
| 446 | 446 |
| 447 void VideoCaptureManager::OnDevicesInfoEnumerated( | 447 void VideoCaptureManager::OnDevicesInfoEnumerated( |
| 448 MediaStreamType stream_type, | 448 MediaStreamType stream_type, |
| 449 const DeviceInfos& new_devices_info_cache) { | 449 const DeviceInfos& new_devices_info_cache) { |
| 450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 450 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 451 | 451 |
| 452 if (!listener_) { | 452 if (!listener_) { |
| 453 // Listener has been removed. | 453 // Listener has been removed. |
| 454 return; | 454 return; |
| 455 } | 455 } |
| 456 devices_info_cache_ = new_devices_info_cache; | 456 devices_info_cache_ = new_devices_info_cache; |
| 457 | 457 |
| 458 // Walk the |devices_info_cache_| and transform from VCD::Name to | 458 // Walk the |devices_info_cache_| and transform from VCD::Name to |
| 459 // StreamDeviceInfo for return purposes. | 459 // StreamDeviceInfo for return purposes. |
| 460 StreamDeviceInfoArray devices; | 460 StreamDeviceInfoArray devices; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 545 } |
| 546 ConsolidateCaptureFormats(&device_info.supported_formats); | 546 ConsolidateCaptureFormats(&device_info.supported_formats); |
| 547 new_devices_info_cache.push_back(device_info); | 547 new_devices_info_cache.push_back(device_info); |
| 548 } | 548 } |
| 549 return new_devices_info_cache; | 549 return new_devices_info_cache; |
| 550 } | 550 } |
| 551 | 551 |
| 552 VideoCaptureManager::DeviceEntry* | 552 VideoCaptureManager::DeviceEntry* |
| 553 VideoCaptureManager::GetDeviceEntryForMediaStreamDevice( | 553 VideoCaptureManager::GetDeviceEntryForMediaStreamDevice( |
| 554 const MediaStreamDevice& device_info) { | 554 const MediaStreamDevice& device_info) { |
| 555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 555 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 556 | 556 |
| 557 for (DeviceEntries::iterator it = devices_.begin(); | 557 for (DeviceEntries::iterator it = devices_.begin(); |
| 558 it != devices_.end(); ++it) { | 558 it != devices_.end(); ++it) { |
| 559 DeviceEntry* device = *it; | 559 DeviceEntry* device = *it; |
| 560 if (device_info.type == device->stream_type && | 560 if (device_info.type == device->stream_type && |
| 561 device_info.id == device->id) { | 561 device_info.id == device->id) { |
| 562 return device; | 562 return device; |
| 563 } | 563 } |
| 564 } | 564 } |
| 565 return NULL; | 565 return NULL; |
| 566 } | 566 } |
| 567 | 567 |
| 568 VideoCaptureManager::DeviceEntry* | 568 VideoCaptureManager::DeviceEntry* |
| 569 VideoCaptureManager::GetDeviceEntryForController( | 569 VideoCaptureManager::GetDeviceEntryForController( |
| 570 const VideoCaptureController* controller) { | 570 const VideoCaptureController* controller) { |
| 571 // Look up |controller| in |devices_|. | 571 // Look up |controller| in |devices_|. |
| 572 for (DeviceEntries::iterator it = devices_.begin(); | 572 for (DeviceEntries::iterator it = devices_.begin(); |
| 573 it != devices_.end(); ++it) { | 573 it != devices_.end(); ++it) { |
| 574 if ((*it)->video_capture_controller.get() == controller) { | 574 if ((*it)->video_capture_controller.get() == controller) { |
| 575 return *it; | 575 return *it; |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 return NULL; | 578 return NULL; |
| 579 } | 579 } |
| 580 | 580 |
| 581 void VideoCaptureManager::DestroyDeviceEntryIfNoClients(DeviceEntry* entry) { | 581 void VideoCaptureManager::DestroyDeviceEntryIfNoClients(DeviceEntry* entry) { |
| 582 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 582 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 583 // Removal of the last client stops the device. | 583 // Removal of the last client stops the device. |
| 584 if (entry->video_capture_controller->GetClientCount() == 0) { | 584 if (entry->video_capture_controller->GetClientCount() == 0) { |
| 585 DVLOG(1) << "VideoCaptureManager stopping device (type = " | 585 DVLOG(1) << "VideoCaptureManager stopping device (type = " |
| 586 << entry->stream_type << ", id = " << entry->id << ")"; | 586 << entry->stream_type << ", id = " << entry->id << ")"; |
| 587 | 587 |
| 588 // The DeviceEntry is removed from |devices_| immediately. The controller is | 588 // The DeviceEntry is removed from |devices_| immediately. The controller is |
| 589 // deleted immediately, and the device is freed asynchronously. After this | 589 // deleted immediately, and the device is freed asynchronously. After this |
| 590 // point, subsequent requests to open this same device ID will create a new | 590 // point, subsequent requests to open this same device ID will create a new |
| 591 // DeviceEntry, VideoCaptureController, and VideoCaptureDevice. | 591 // DeviceEntry, VideoCaptureController, and VideoCaptureDevice. |
| 592 devices_.erase(entry); | 592 devices_.erase(entry); |
| 593 entry->video_capture_controller.reset(); | 593 entry->video_capture_controller.reset(); |
| 594 device_task_runner_->PostTask( | 594 device_task_runner_->PostTask( |
| 595 FROM_HERE, | 595 FROM_HERE, |
| 596 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this, | 596 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this, |
| 597 base::Owned(entry))); | 597 base::Owned(entry))); |
| 598 } | 598 } |
| 599 } | 599 } |
| 600 | 600 |
| 601 VideoCaptureManager::DeviceEntry* VideoCaptureManager::GetOrCreateDeviceEntry( | 601 VideoCaptureManager::DeviceEntry* VideoCaptureManager::GetOrCreateDeviceEntry( |
| 602 media::VideoCaptureSessionId capture_session_id) { | 602 media::VideoCaptureSessionId capture_session_id) { |
| 603 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 603 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 604 | 604 |
| 605 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator | 605 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator |
| 606 session_it = sessions_.find(capture_session_id); | 606 session_it = sessions_.find(capture_session_id); |
| 607 if (session_it == sessions_.end()) { | 607 if (session_it == sessions_.end()) { |
| 608 return NULL; | 608 return NULL; |
| 609 } | 609 } |
| 610 const MediaStreamDevice& device_info = session_it->second; | 610 const MediaStreamDevice& device_info = session_it->second; |
| 611 | 611 |
| 612 // Check if another session has already opened this device. If so, just | 612 // Check if another session has already opened this device. If so, just |
| 613 // use that opened device. | 613 // use that opened device. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( | 653 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( |
| 654 media::VideoCaptureSessionId session_id, | 654 media::VideoCaptureSessionId session_id, |
| 655 gfx::NativeViewId window_id) { | 655 gfx::NativeViewId window_id) { |
| 656 DCHECK(IsOnDeviceThread()); | 656 DCHECK(IsOnDeviceThread()); |
| 657 DCHECK(notification_window_ids_.find(session_id) == | 657 DCHECK(notification_window_ids_.find(session_id) == |
| 658 notification_window_ids_.end()); | 658 notification_window_ids_.end()); |
| 659 notification_window_ids_[session_id] = window_id; | 659 notification_window_ids_[session_id] = window_id; |
| 660 } | 660 } |
| 661 | 661 |
| 662 } // namespace content | 662 } // namespace content |
| OLD | NEW |