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

Side by Side Diff: device/capture/video/linux/video_capture_device_factory_linux.cc

Issue 2214533002: move //media/capture to //device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 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 "device/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>
11 11
12 #include "base/files/file_enumerator.h" 12 #include "base/files/file_enumerator.h"
13 #include "base/files/scoped_file.h" 13 #include "base/files/scoped_file.h"
14 #include "base/posix/eintr_wrapper.h" 14 #include "base/posix/eintr_wrapper.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 17
18 #if defined(OS_OPENBSD) 18 #if defined(OS_OPENBSD)
19 #include <sys/videoio.h> 19 #include <sys/videoio.h>
20 #else 20 #else
21 #include <linux/videodev2.h> 21 #include <linux/videodev2.h>
22 #endif 22 #endif
23 23
24 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
25 #include "media/capture/video/linux/video_capture_device_chromeos.h" 25 #include "device/capture/video/linux/video_capture_device_chromeos.h"
26 #endif 26 #endif
27 #include "media/capture/video/linux/video_capture_device_linux.h" 27 #include "device/capture/video/linux/video_capture_device_linux.h"
28 28
29 namespace media { 29 namespace device {
30 30
31 // USB VID and PID are both 4 bytes long. 31 // USB VID and PID are both 4 bytes long.
32 static const size_t kVidPidSize = 4; 32 static const size_t kVidPidSize = 4;
33 33
34 // /sys/class/video4linux/video{N}/device is a symlink to the corresponding 34 // /sys/class/video4linux/video{N}/device is a symlink to the corresponding
35 // USB device info directory. 35 // USB device info directory.
36 static const char kVidPathTemplate[] = 36 static const char kVidPathTemplate[] =
37 "/sys/class/video4linux/%s/device/../idVendor"; 37 "/sys/class/video4linux/%s/device/../idVendor";
38 static const char kPidPathTemplate[] = 38 static const char kPidPathTemplate[] =
39 "/sys/class/video4linux/%s/device/../idProduct"; 39 "/sys/class/video4linux/%s/device/../idProduct";
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 media::VideoCaptureFormats* supported_formats) { 109 media::VideoCaptureFormats* supported_formats) {
110 v4l2_fmtdesc v4l2_format = {}; 110 v4l2_fmtdesc v4l2_format = {};
111 v4l2_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 111 v4l2_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
112 for (; HANDLE_EINTR(ioctl(fd, VIDIOC_ENUM_FMT, &v4l2_format)) == 0; 112 for (; HANDLE_EINTR(ioctl(fd, VIDIOC_ENUM_FMT, &v4l2_format)) == 0;
113 ++v4l2_format.index) { 113 ++v4l2_format.index) {
114 VideoCaptureFormat supported_format; 114 VideoCaptureFormat supported_format;
115 supported_format.pixel_format = 115 supported_format.pixel_format =
116 VideoCaptureDeviceLinux::V4l2FourCcToChromiumPixelFormat( 116 VideoCaptureDeviceLinux::V4l2FourCcToChromiumPixelFormat(
117 v4l2_format.pixelformat); 117 v4l2_format.pixelformat);
118 118
119 if (supported_format.pixel_format == PIXEL_FORMAT_UNKNOWN) 119 if (supported_format.pixel_format == media::PIXEL_FORMAT_UNKNOWN)
120 continue; 120 continue;
121 121
122 v4l2_frmsizeenum frame_size = {}; 122 v4l2_frmsizeenum frame_size = {};
123 frame_size.pixel_format = v4l2_format.pixelformat; 123 frame_size.pixel_format = v4l2_format.pixelformat;
124 for (; HANDLE_EINTR(ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frame_size)) == 0; 124 for (; HANDLE_EINTR(ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frame_size)) == 0;
125 ++frame_size.index) { 125 ++frame_size.index) {
126 if (frame_size.type == V4L2_FRMSIZE_TYPE_DISCRETE) { 126 if (frame_size.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
127 supported_format.frame_size.SetSize(frame_size.discrete.width, 127 supported_format.frame_size.SetSize(frame_size.discrete.width,
128 frame_size.discrete.height); 128 frame_size.discrete.height);
129 } else if (frame_size.type == V4L2_FRMSIZE_TYPE_STEPWISE || 129 } else if (frame_size.type == V4L2_FRMSIZE_TYPE_STEPWISE ||
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return usb_id; 250 return usb_id;
251 } 251 }
252 252
253 // static 253 // static
254 VideoCaptureDeviceFactory* 254 VideoCaptureDeviceFactory*
255 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( 255 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory(
256 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 256 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
257 return new VideoCaptureDeviceFactoryLinux(ui_task_runner); 257 return new VideoCaptureDeviceFactoryLinux(ui_task_runner);
258 } 258 }
259 259
260 } // namespace media 260 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698