| 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/video/capture/linux/video_capture_device_factory_linux.h" | 5 #include "media/video/capture/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 #if defined(OS_OPENBSD) | 9 #if defined(OS_OPENBSD) |
| 10 #include <sys/videoio.h> | 10 #include <sys/videoio.h> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 while (HANDLE_EINTR(ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc)) == 0) { | 37 while (HANDLE_EINTR(ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc)) == 0) { |
| 38 if (std::find(usable_fourccs.begin(), usable_fourccs.end(), | 38 if (std::find(usable_fourccs.begin(), usable_fourccs.end(), |
| 39 fmtdesc.pixelformat) != usable_fourccs.end()) | 39 fmtdesc.pixelformat) != usable_fourccs.end()) |
| 40 return true; | 40 return true; |
| 41 | 41 |
| 42 fmtdesc.index++; | 42 fmtdesc.index++; |
| 43 } | 43 } |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 | 46 |
| 47 VideoCaptureDeviceFactoryLinux::VideoCaptureDeviceFactoryLinux( |
| 48 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) |
| 49 : ui_task_runner_(ui_task_runner) { |
| 50 } |
| 51 |
| 52 VideoCaptureDeviceFactoryLinux::~VideoCaptureDeviceFactoryLinux() { |
| 53 } |
| 54 |
| 47 scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactoryLinux::Create( | 55 scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactoryLinux::Create( |
| 48 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | |
| 49 const VideoCaptureDevice::Name& device_name) { | 56 const VideoCaptureDevice::Name& device_name) { |
| 50 DCHECK(thread_checker_.CalledOnValidThread()); | 57 DCHECK(thread_checker_.CalledOnValidThread()); |
| 51 #if defined(OS_CHROMEOS) | 58 #if defined(OS_CHROMEOS) |
| 52 VideoCaptureDeviceChromeOS* self = | 59 VideoCaptureDeviceChromeOS* self = |
| 53 new VideoCaptureDeviceChromeOS(ui_task_runner, device_name); | 60 new VideoCaptureDeviceChromeOS(ui_task_runner_, device_name); |
| 54 #else | 61 #else |
| 55 VideoCaptureDeviceLinux* self = new VideoCaptureDeviceLinux(device_name); | 62 VideoCaptureDeviceLinux* self = new VideoCaptureDeviceLinux(device_name); |
| 56 #endif | 63 #endif |
| 57 if (!self) | 64 if (!self) |
| 58 return scoped_ptr<VideoCaptureDevice>(); | 65 return scoped_ptr<VideoCaptureDevice>(); |
| 59 // Test opening the device driver. This is to make sure it is available. | 66 // Test opening the device driver. This is to make sure it is available. |
| 60 // We will reopen it again in our worker thread when someone | 67 // We will reopen it again in our worker thread when someone |
| 61 // allocates the camera. | 68 // allocates the camera. |
| 62 base::ScopedFD fd(HANDLE_EINTR(open(device_name.id().c_str(), O_RDONLY))); | 69 base::ScopedFD fd(HANDLE_EINTR(open(device_name.id().c_str(), O_RDONLY))); |
| 63 if (!fd.is_valid()) { | 70 if (!fd.is_valid()) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 ++frame_interval.index; | 178 ++frame_interval.index; |
| 172 } | 179 } |
| 173 ++frame_size.index; | 180 ++frame_size.index; |
| 174 } | 181 } |
| 175 ++pixel_format.index; | 182 ++pixel_format.index; |
| 176 } | 183 } |
| 177 return; | 184 return; |
| 178 } | 185 } |
| 179 | 186 |
| 180 } // namespace media | 187 } // namespace media |
| OLD | NEW |