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

Side by Side Diff: media/video/capture/linux/video_capture_device_linux.cc

Issue 539443003: Add support for pixel format UYVY in Linux video capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/video/capture/linux/video_capture_device_linux.h" 5 #include "media/video/capture/linux/video_capture_device_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 25 matching lines...) Expand all
36 enum { kCaptureSelectWaitMs = 10 }; 36 enum { kCaptureSelectWaitMs = 10 };
37 // MJPEG is preferred if the width or height is larger than this. 37 // MJPEG is preferred if the width or height is larger than this.
38 enum { kMjpegWidth = 640 }; 38 enum { kMjpegWidth = 640 };
39 enum { kMjpegHeight = 480 }; 39 enum { kMjpegHeight = 480 };
40 // Typical framerate, in fps 40 // Typical framerate, in fps
41 enum { kTypicalFramerate = 30 }; 41 enum { kTypicalFramerate = 30 };
42 42
43 // V4L2 color formats VideoCaptureDeviceLinux support. 43 // V4L2 color formats VideoCaptureDeviceLinux support.
44 static const int32 kV4l2RawFmts[] = { 44 static const int32 kV4l2RawFmts[] = {
45 V4L2_PIX_FMT_YUV420, 45 V4L2_PIX_FMT_YUV420,
46 V4L2_PIX_FMT_YUYV 46 V4L2_PIX_FMT_YUYV,
47 V4L2_PIX_FMT_UYVY
47 }; 48 };
48 49
49 // USB VID and PID are both 4 bytes long. 50 // USB VID and PID are both 4 bytes long.
50 static const size_t kVidPidSize = 4; 51 static const size_t kVidPidSize = 4;
51 52
52 // /sys/class/video4linux/video{N}/device is a symlink to the corresponding 53 // /sys/class/video4linux/video{N}/device is a symlink to the corresponding
53 // USB device info directory. 54 // USB device info directory.
54 static const char kVidPathTemplate[] = 55 static const char kVidPathTemplate[] =
55 "/sys/class/video4linux/%s/device/../idVendor"; 56 "/sys/class/video4linux/%s/device/../idVendor";
56 static const char kPidPathTemplate[] = 57 static const char kPidPathTemplate[] =
(...skipping 18 matching lines...) Expand all
75 VideoPixelFormat VideoCaptureDeviceLinux::V4l2ColorToVideoCaptureColorFormat( 76 VideoPixelFormat VideoCaptureDeviceLinux::V4l2ColorToVideoCaptureColorFormat(
76 int32 v4l2_fourcc) { 77 int32 v4l2_fourcc) {
77 VideoPixelFormat result = PIXEL_FORMAT_UNKNOWN; 78 VideoPixelFormat result = PIXEL_FORMAT_UNKNOWN;
78 switch (v4l2_fourcc) { 79 switch (v4l2_fourcc) {
79 case V4L2_PIX_FMT_YUV420: 80 case V4L2_PIX_FMT_YUV420:
80 result = PIXEL_FORMAT_I420; 81 result = PIXEL_FORMAT_I420;
81 break; 82 break;
82 case V4L2_PIX_FMT_YUYV: 83 case V4L2_PIX_FMT_YUYV:
83 result = PIXEL_FORMAT_YUY2; 84 result = PIXEL_FORMAT_YUY2;
84 break; 85 break;
86 case V4L2_PIX_FMT_UYVY:
87 result = PIXEL_FORMAT_UYVY;
88 break;
85 case V4L2_PIX_FMT_MJPEG: 89 case V4L2_PIX_FMT_MJPEG:
86 case V4L2_PIX_FMT_JPEG: 90 case V4L2_PIX_FMT_JPEG:
87 result = PIXEL_FORMAT_MJPEG; 91 result = PIXEL_FORMAT_MJPEG;
88 break; 92 break;
89 default: 93 default:
90 DVLOG(1) << "Unsupported pixel format " << std::hex << v4l2_fourcc; 94 DVLOG(1) << "Unsupported pixel format " << std::hex << v4l2_fourcc;
91 } 95 }
92 return result; 96 return result;
93 } 97 }
94 98
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 506
503 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) { 507 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) {
504 DCHECK(!v4l2_thread_.IsRunning() || 508 DCHECK(!v4l2_thread_.IsRunning() ||
505 v4l2_thread_.message_loop() == base::MessageLoop::current()); 509 v4l2_thread_.message_loop() == base::MessageLoop::current());
506 DVLOG(1) << reason; 510 DVLOG(1) << reason;
507 state_ = kError; 511 state_ = kError;
508 client_->OnError(reason); 512 client_->OnError(reason);
509 } 513 }
510 514
511 } // namespace media 515 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698