| 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 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 | 1018 |
| 1019 // Walk the |devices_info_cache_| and produce a | 1019 // Walk the |devices_info_cache_| and produce a |
| 1020 // media::VideoCaptureDeviceDescriptors for return purposes. | 1020 // media::VideoCaptureDeviceDescriptors for return purposes. |
| 1021 media::VideoCaptureDeviceDescriptors devices; | 1021 media::VideoCaptureDeviceDescriptors devices; |
| 1022 std::vector<std::tuple<media::VideoCaptureDeviceDescriptor, | 1022 std::vector<std::tuple<media::VideoCaptureDeviceDescriptor, |
| 1023 media::VideoCaptureFormats>> | 1023 media::VideoCaptureFormats>> |
| 1024 descriptors_and_formats; | 1024 descriptors_and_formats; |
| 1025 for (const auto& it : devices_info_cache_) { | 1025 for (const auto& it : devices_info_cache_) { |
| 1026 devices.emplace_back(it.descriptor); | 1026 devices.emplace_back(it.descriptor); |
| 1027 descriptors_and_formats.emplace_back(it.descriptor, it.supported_formats); | 1027 descriptors_and_formats.emplace_back(it.descriptor, it.supported_formats); |
| 1028 } |
| 1029 |
| 1030 if (!descriptors_and_formats.empty()) { |
| 1028 MediaInternals::GetInstance()->UpdateVideoCaptureDeviceCapabilities( | 1031 MediaInternals::GetInstance()->UpdateVideoCaptureDeviceCapabilities( |
| 1029 descriptors_and_formats); | 1032 descriptors_and_formats); |
| 1030 } | 1033 } |
| 1031 | 1034 |
| 1032 client_callback.Run(devices); | 1035 client_callback.Run(devices); |
| 1033 } | 1036 } |
| 1034 | 1037 |
| 1035 bool VideoCaptureManager::IsOnDeviceThread() const { | 1038 bool VideoCaptureManager::IsOnDeviceThread() const { |
| 1036 return device_task_runner_->BelongsToCurrentThread(); | 1039 return device_task_runner_->BelongsToCurrentThread(); |
| 1037 } | 1040 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 VideoCaptureDevice::TakePhotoCallback callback, | 1223 VideoCaptureDevice::TakePhotoCallback callback, |
| 1221 VideoCaptureDevice* device) { | 1224 VideoCaptureDevice* device) { |
| 1222 // Unretained() is safe to use here because |device| would be null if it | 1225 // Unretained() is safe to use here because |device| would be null if it |
| 1223 // was scheduled for shutdown and destruction, and because this task is | 1226 // was scheduled for shutdown and destruction, and because this task is |
| 1224 // guaranteed to run before the task that destroys the |device|. | 1227 // guaranteed to run before the task that destroys the |device|. |
| 1225 device_task_runner_->PostTask( | 1228 device_task_runner_->PostTask( |
| 1226 FROM_HERE, base::Bind(&VideoCaptureDevice::TakePhoto, | 1229 FROM_HERE, base::Bind(&VideoCaptureDevice::TakePhoto, |
| 1227 base::Unretained(device), base::Passed(&callback))); | 1230 base::Unretained(device), base::Passed(&callback))); |
| 1228 } | 1231 } |
| 1229 | 1232 |
| 1233 base::Optional<CameraCalibration> VideoCaptureManager::GetCameraCalibration( |
| 1234 const std::string& device_id) { |
| 1235 VideoCaptureManager::DeviceInfo* info = GetDeviceInfoById(device_id); |
| 1236 if (!info) |
| 1237 return base::Optional<CameraCalibration>(); |
| 1238 return info->descriptor.camera_calibration; |
| 1239 } |
| 1240 |
| 1230 #if defined(OS_ANDROID) | 1241 #if defined(OS_ANDROID) |
| 1231 void VideoCaptureManager::OnApplicationStateChange( | 1242 void VideoCaptureManager::OnApplicationStateChange( |
| 1232 base::android::ApplicationState state) { | 1243 base::android::ApplicationState state) { |
| 1233 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1244 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1234 | 1245 |
| 1235 // Only release/resume devices when the Application state changes from | 1246 // Only release/resume devices when the Application state changes from |
| 1236 // RUNNING->STOPPED->RUNNING. | 1247 // RUNNING->STOPPED->RUNNING. |
| 1237 if (state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES && | 1248 if (state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES && |
| 1238 !application_state_has_running_activities_) { | 1249 !application_state_has_running_activities_) { |
| 1239 ResumeDevices(); | 1250 ResumeDevices(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 if (!device_in_queue) { | 1289 if (!device_in_queue) { |
| 1279 // Session ID is only valid for Screen capture. So we can fake it to | 1290 // Session ID is only valid for Screen capture. So we can fake it to |
| 1280 // resume video capture devices here. | 1291 // resume video capture devices here. |
| 1281 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); | 1292 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); |
| 1282 } | 1293 } |
| 1283 } | 1294 } |
| 1284 } | 1295 } |
| 1285 #endif // defined(OS_ANDROID) | 1296 #endif // defined(OS_ANDROID) |
| 1286 | 1297 |
| 1287 } // namespace content | 1298 } // namespace content |
| OLD | NEW |