Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/capture/video/linux/video_capture_device_factory_linux.h" | 5 #include "media/capture/video/linux/video_capture_device_factory_linux.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <sys/ioctl.h> | 10 #include <sys/ioctl.h> |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE, | 221 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE, |
| 222 VideoCaptureTransportType::OTHER_TRANSPORT, | 222 VideoCaptureTransportType::OTHER_TRANSPORT, |
| 223 g_camera_facing_helper.Get().GetCameraFacing(unique_id, model_id)); | 223 g_camera_facing_helper.Get().GetCameraFacing(unique_id, model_id)); |
| 224 #else | 224 #else |
| 225 device_descriptors->emplace_back( | 225 device_descriptors->emplace_back( |
| 226 reinterpret_cast<char*>(cap.card), unique_id, model_id, | 226 reinterpret_cast<char*>(cap.card), unique_id, model_id, |
| 227 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE); | 227 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE); |
| 228 #endif | 228 #endif |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 // Since JS doesn't have API to get camera facing, we sort the list to make | |
| 232 // apps can use the front camera by default. | |
| 233 // TODO(henryhsu): remove this after JS API completed (crbug.com/543997). | |
| 234 std::sort(device_descriptors->begin(), device_descriptors->end()); | |
|
Guido Urdaneta
2017/01/24 10:42:07
Is this sorting relevant only for linux, or should
henryhsu
2017/01/25 03:28:18
This is for chromebook
| |
| 231 } | 235 } |
| 232 | 236 |
| 233 void VideoCaptureDeviceFactoryLinux::GetSupportedFormats( | 237 void VideoCaptureDeviceFactoryLinux::GetSupportedFormats( |
| 234 const VideoCaptureDeviceDescriptor& device, | 238 const VideoCaptureDeviceDescriptor& device, |
| 235 VideoCaptureFormats* supported_formats) { | 239 VideoCaptureFormats* supported_formats) { |
| 236 DCHECK(thread_checker_.CalledOnValidThread()); | 240 DCHECK(thread_checker_.CalledOnValidThread()); |
| 237 if (device.device_id.empty()) | 241 if (device.device_id.empty()) |
| 238 return; | 242 return; |
| 239 base::ScopedFD fd(HANDLE_EINTR(open(device.device_id.c_str(), O_RDONLY))); | 243 base::ScopedFD fd(HANDLE_EINTR(open(device.device_id.c_str(), O_RDONLY))); |
| 240 if (!fd.is_valid()) // Failed to open this device. | 244 if (!fd.is_valid()) // Failed to open this device. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 269 } | 273 } |
| 270 | 274 |
| 271 // static | 275 // static |
| 272 VideoCaptureDeviceFactory* | 276 VideoCaptureDeviceFactory* |
| 273 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( | 277 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( |
| 274 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 278 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 275 return new VideoCaptureDeviceFactoryLinux(ui_task_runner); | 279 return new VideoCaptureDeviceFactoryLinux(ui_task_runner); |
| 276 } | 280 } |
| 277 | 281 |
| 278 } // namespace media | 282 } // namespace media |
| OLD | NEW |