Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 2606983002: Media Capture Depth Stream Extensions API: focal length and depth range. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 bool VideoCaptureManager::GetCameraCalibration(
1234 const std::string& device_id,
1235 MediaStreamDevice::CameraCalibration* calibration) {
1236 VideoCaptureManager::DeviceInfo* info = GetDeviceInfoById(device_id);
1237 if (!info || !info->descriptor.camera_calibration)
1238 return false;
1239 calibration->valid = true;
1240 calibration->focal_length_x =
1241 info->descriptor.camera_calibration->focal_length_x;
1242 calibration->focal_length_y =
1243 info->descriptor.camera_calibration->focal_length_y;
1244 calibration->depth_near = info->descriptor.camera_calibration->depth_near;
1245 calibration->depth_far = info->descriptor.camera_calibration->depth_far;
1246 return true;
1247 }
1248
1230 #if defined(OS_ANDROID) 1249 #if defined(OS_ANDROID)
1231 void VideoCaptureManager::OnApplicationStateChange( 1250 void VideoCaptureManager::OnApplicationStateChange(
1232 base::android::ApplicationState state) { 1251 base::android::ApplicationState state) {
1233 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1252 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1234 1253
1235 // Only release/resume devices when the Application state changes from 1254 // Only release/resume devices when the Application state changes from
1236 // RUNNING->STOPPED->RUNNING. 1255 // RUNNING->STOPPED->RUNNING.
1237 if (state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES && 1256 if (state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES &&
1238 !application_state_has_running_activities_) { 1257 !application_state_has_running_activities_) {
1239 ResumeDevices(); 1258 ResumeDevices();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 if (!device_in_queue) { 1297 if (!device_in_queue) {
1279 // Session ID is only valid for Screen capture. So we can fake it to 1298 // Session ID is only valid for Screen capture. So we can fake it to
1280 // resume video capture devices here. 1299 // resume video capture devices here.
1281 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); 1300 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters);
1282 } 1301 }
1283 } 1302 }
1284 } 1303 }
1285 #endif // defined(OS_ANDROID) 1304 #endif // defined(OS_ANDROID)
1286 1305
1287 } // namespace content 1306 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698