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 VideoCaptureDevice::TakePhotoCallback& photo_callback) { | 845 media::ScopedResultCallback<VideoCaptureDevice::TakePhotoCallback> |
| 846 callback) { |
846 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 847 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
847 SessionMap::const_iterator session_it = sessions_.find(session_id); | 848 SessionMap::const_iterator session_it = sessions_.find(session_id); |
848 if (session_it == sessions_.end()) | 849 if (session_it == sessions_.end()) |
849 return false; | 850 return; |
850 | 851 |
851 DeviceEntry* const device_info = | 852 DeviceEntry* const device_info = |
852 GetDeviceEntryForMediaStreamDevice(session_it->second); | 853 GetDeviceEntryForMediaStreamDevice(session_it->second); |
853 if (!device_info) | 854 if (!device_info) |
854 return false; | 855 return; |
855 device_task_runner_->PostTask( | 856 device_task_runner_->PostTask( |
856 FROM_HERE, | 857 FROM_HERE, |
857 base::Bind(&VideoCaptureManager::DoTakePhotoOnDeviceThread, this, | 858 base::Bind(&VideoCaptureDevice::TakePhoto, |
858 device_info->video_capture_device(), photo_callback)); | 859 base::Unretained(device_info->video_capture_device()), |
859 return true; | 860 base::Passed(&callback))); |
860 } | |
861 | |
862 void VideoCaptureManager::DoTakePhotoOnDeviceThread( | |
863 media::VideoCaptureDevice* device, | |
864 const 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 } | 861 } |
874 | 862 |
875 void VideoCaptureManager::DoStopDeviceOnDeviceThread( | 863 void VideoCaptureManager::DoStopDeviceOnDeviceThread( |
876 std::unique_ptr<VideoCaptureDevice> device) { | 864 std::unique_ptr<VideoCaptureDevice> device) { |
877 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StopDeviceTime"); | 865 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StopDeviceTime"); |
878 DCHECK(IsOnDeviceThread()); | 866 DCHECK(IsOnDeviceThread()); |
879 device->StopAndDeAllocate(); | 867 device->StopAndDeAllocate(); |
880 DVLOG(3) << "DoStopDeviceOnDeviceThread"; | 868 DVLOG(3) << "DoStopDeviceOnDeviceThread"; |
881 } | 869 } |
882 | 870 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 continue; | 1115 continue; |
1128 | 1116 |
1129 // Session ID is only valid for Screen capture. So we can fake it to resume | 1117 // Session ID is only valid for Screen capture. So we can fake it to resume |
1130 // video capture devices here. | 1118 // video capture devices here. |
1131 QueueStartDevice(kFakeSessionId, entry, entry->parameters); | 1119 QueueStartDevice(kFakeSessionId, entry, entry->parameters); |
1132 } | 1120 } |
1133 } | 1121 } |
1134 #endif // defined(OS_ANDROID) | 1122 #endif // defined(OS_ANDROID) |
1135 | 1123 |
1136 } // namespace content | 1124 } // namespace content |
OLD | NEW |