| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 device_task_runner_->PostTask( | 833 device_task_runner_->PostTask( |
| 834 FROM_HERE, | 834 FROM_HERE, |
| 835 base::Bind(&VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread, | 835 base::Bind(&VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread, |
| 836 this, | 836 this, |
| 837 existing_device->video_capture_device(), | 837 existing_device->video_capture_device(), |
| 838 window_id_it->second)); | 838 window_id_it->second)); |
| 839 | 839 |
| 840 notification_window_ids_.erase(window_id_it); | 840 notification_window_ids_.erase(window_id_it); |
| 841 } | 841 } |
| 842 | 842 |
| 843 bool VideoCaptureManager::TakePhoto( | 843 void VideoCaptureManager::TakePhoto( |
| 844 int session_id, | 844 int session_id, |
| 845 const media::VideoCaptureDevice::TakePhotoCallback& photo_callback) { | 845 media::ScopedCallback<media::VideoCaptureDevice::TakePhotoCallback> cb) { |
| 846 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 846 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 847 SessionMap::const_iterator session_it = sessions_.find(session_id); | 847 SessionMap::const_iterator session_it = sessions_.find(session_id); |
| 848 if (session_it == sessions_.end()) | 848 if (session_it == sessions_.end()) |
| 849 return false; | 849 return; |
| 850 | 850 |
| 851 DeviceEntry* const device_info = | 851 DeviceEntry* const device_info = |
| 852 GetDeviceEntryForMediaStreamDevice(session_it->second); | 852 GetDeviceEntryForMediaStreamDevice(session_it->second); |
| 853 if (!device_info) | 853 if (!device_info) |
| 854 return false; | 854 return; |
| 855 device_task_runner_->PostTask( | 855 device_task_runner_->PostTask( |
| 856 FROM_HERE, | 856 FROM_HERE, |
| 857 base::Bind(&VideoCaptureManager::DoTakePhotoOnDeviceThread, this, | 857 base::Bind(&media::VideoCaptureDevice::TakePhoto, |
| 858 device_info->video_capture_device(), photo_callback)); | 858 base::Unretained(device_info->video_capture_device()), |
| 859 return true; | 859 base::Passed(std::move(cb)))); |
| 860 } | |
| 861 | |
| 862 void VideoCaptureManager::DoTakePhotoOnDeviceThread( | |
| 863 media::VideoCaptureDevice* device, | |
| 864 const media::VideoCaptureDevice::TakePhotoCallback& photo_callback) { | |
| 865 DCHECK(IsOnDeviceThread()); | |
| 866 if (device->TakePhoto(photo_callback)) | |
| 867 return; | |
| 868 | |
| 869 // TakePhoto() failed synchronously: Make sure |photo_callback| is Run(). | |
| 870 std::unique_ptr<std::vector<uint8_t>> empty_vector( | |
| 871 new std::vector<uint8_t>()); | |
| 872 photo_callback.Run("", std::move(empty_vector)); | |
| 873 } | 860 } |
| 874 | 861 |
| 875 void VideoCaptureManager::DoStopDeviceOnDeviceThread( | 862 void VideoCaptureManager::DoStopDeviceOnDeviceThread( |
| 876 std::unique_ptr<media::VideoCaptureDevice> device) { | 863 std::unique_ptr<media::VideoCaptureDevice> device) { |
| 877 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StopDeviceTime"); | 864 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StopDeviceTime"); |
| 878 DCHECK(IsOnDeviceThread()); | 865 DCHECK(IsOnDeviceThread()); |
| 879 device->StopAndDeAllocate(); | 866 device->StopAndDeAllocate(); |
| 880 DVLOG(3) << "DoStopDeviceOnDeviceThread"; | 867 DVLOG(3) << "DoStopDeviceOnDeviceThread"; |
| 881 } | 868 } |
| 882 | 869 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 continue; | 1114 continue; |
| 1128 | 1115 |
| 1129 // Session ID is only valid for Screen capture. So we can fake it to resume | 1116 // Session ID is only valid for Screen capture. So we can fake it to resume |
| 1130 // video capture devices here. | 1117 // video capture devices here. |
| 1131 QueueStartDevice(kFakeSessionId, entry, entry->parameters); | 1118 QueueStartDevice(kFakeSessionId, entry, entry->parameters); |
| 1132 } | 1119 } |
| 1133 } | 1120 } |
| 1134 #endif // defined(OS_ANDROID) | 1121 #endif // defined(OS_ANDROID) |
| 1135 | 1122 |
| 1136 } // namespace content | 1123 } // namespace content |
| OLD | NEW |