Chromium Code Reviews| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 void VideoCaptureManager::AbortCaptureForDeviceError( | |
| 337 VideoCaptureController* controller, | |
| 338 VideoCaptureControllerID client_id, | |
| 339 VideoCaptureControllerEventHandler* client_handler) { | |
| 340 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 341 DCHECK(controller); | |
| 342 DCHECK(client_handler); | |
| 343 | |
| 344 DeviceEntry* entry = GetDeviceEntryForController(controller); | |
| 345 if (!entry) { | |
| 346 NOTREACHED(); | |
| 347 return; | |
| 348 } | |
| 349 | |
| 350 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator it; | |
|
mcasas
2014/04/24 11:09:47
nit: This data type std::map<media::VideoCaptureSe
jiayl
2014/04/24 18:11:13
Done.
| |
| 351 for (it = sessions_.begin(); it != sessions_.end(); ++it) { | |
| 352 if (it->second.type == entry->stream_type && | |
| 353 it->second.id == entry->id) | |
| 354 break; | |
| 355 } | |
| 356 | |
|
mcasas
2014/04/24 11:09:47
nit: no blank line?
jiayl
2014/04/24 18:11:13
Done.
| |
| 357 listener_->Aborted(it->second.type, it->first); | |
|
mcasas
2014/04/24 11:09:47
What happens if it->second.{id,type} has not been
jiayl
2014/04/24 18:11:13
Done.
| |
| 358 | |
| 359 StopCaptureForClient(controller, client_id, client_handler); | |
|
mcasas
2014/04/24 11:09:47
StopCaptureForClient() has overlapping boilerplate
jiayl
2014/04/24 18:11:13
Done.
| |
| 360 } | |
| 361 | |
| 336 bool VideoCaptureManager::GetDeviceSupportedFormats( | 362 bool VideoCaptureManager::GetDeviceSupportedFormats( |
| 337 media::VideoCaptureSessionId capture_session_id, | 363 media::VideoCaptureSessionId capture_session_id, |
| 338 media::VideoCaptureFormats* supported_formats) { | 364 media::VideoCaptureFormats* supported_formats) { |
| 339 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 365 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 340 DCHECK(supported_formats->empty()); | 366 DCHECK(supported_formats->empty()); |
| 341 | 367 |
| 342 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator it = | 368 std::map<media::VideoCaptureSessionId, MediaStreamDevice>::iterator it = |
| 343 sessions_.find(capture_session_id); | 369 sessions_.find(capture_session_id); |
| 344 if (it == sessions_.end()) | 370 if (it == sessions_.end()) |
| 345 return false; | 371 return false; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 if (device_info.type == device->stream_type && | 586 if (device_info.type == device->stream_type && |
| 561 device_info.id == device->id) { | 587 device_info.id == device->id) { |
| 562 return device; | 588 return device; |
| 563 } | 589 } |
| 564 } | 590 } |
| 565 return NULL; | 591 return NULL; |
| 566 } | 592 } |
| 567 | 593 |
| 568 VideoCaptureManager::DeviceEntry* | 594 VideoCaptureManager::DeviceEntry* |
| 569 VideoCaptureManager::GetDeviceEntryForController( | 595 VideoCaptureManager::GetDeviceEntryForController( |
| 570 const VideoCaptureController* controller) { | 596 const VideoCaptureController* controller) const { |
| 571 // Look up |controller| in |devices_|. | 597 // Look up |controller| in |devices_|. |
| 572 for (DeviceEntries::iterator it = devices_.begin(); | 598 for (DeviceEntries::const_iterator it = devices_.begin(); |
| 573 it != devices_.end(); ++it) { | 599 it != devices_.end(); ++it) { |
| 574 if ((*it)->video_capture_controller.get() == controller) { | 600 if ((*it)->video_capture_controller.get() == controller) { |
| 575 return *it; | 601 return *it; |
| 576 } | 602 } |
| 577 } | 603 } |
| 578 return NULL; | 604 return NULL; |
| 579 } | 605 } |
| 580 | 606 |
| 581 void VideoCaptureManager::DestroyDeviceEntryIfNoClients(DeviceEntry* entry) { | 607 void VideoCaptureManager::DestroyDeviceEntryIfNoClients(DeviceEntry* entry) { |
| 582 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 608 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( | 679 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( |
| 654 media::VideoCaptureSessionId session_id, | 680 media::VideoCaptureSessionId session_id, |
| 655 gfx::NativeViewId window_id) { | 681 gfx::NativeViewId window_id) { |
| 656 DCHECK(IsOnDeviceThread()); | 682 DCHECK(IsOnDeviceThread()); |
| 657 DCHECK(notification_window_ids_.find(session_id) == | 683 DCHECK(notification_window_ids_.find(session_id) == |
| 658 notification_window_ids_.end()); | 684 notification_window_ids_.end()); |
| 659 notification_window_ids_[session_id] = window_id; | 685 notification_window_ids_[session_id] = window_id; |
| 660 } | 686 } |
| 661 | 687 |
| 662 } // namespace content | 688 } // namespace content |
| OLD | NEW |