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

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

Issue 2482983002: MediaSettingsRange: s/long/double/ in MediaSettingsRange.idl and PhotoCapabilities.idl (Closed)
Patch Set: s/float/double/ in fake_video_capture_device.* Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/v4l2_capture_delegate.h" 5 #include "media/capture/video/linux/v4l2_capture_delegate.h"
6 6
7 #include <linux/version.h> 7 #include <linux/version.h>
8 #include <poll.h> 8 #include <poll.h>
9 #include <sys/fcntl.h> 9 #include <sys/fcntl.h>
10 #include <sys/ioctl.h> 10 #include <sys/ioctl.h>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // https://crbug.com/470717 45 // https://crbug.com/470717
46 const int kCaptureTimeoutMs = 1000; 46 const int kCaptureTimeoutMs = 1000;
47 // The number of continuous timeouts tolerated before treated as error. 47 // The number of continuous timeouts tolerated before treated as error.
48 const int kContinuousTimeoutLimit = 10; 48 const int kContinuousTimeoutLimit = 10;
49 // MJPEG is preferred if the requested width or height is larger than this. 49 // MJPEG is preferred if the requested width or height is larger than this.
50 const int kMjpegWidth = 640; 50 const int kMjpegWidth = 640;
51 const int kMjpegHeight = 480; 51 const int kMjpegHeight = 480;
52 // Typical framerate, in fps 52 // Typical framerate, in fps
53 const int kTypicalFramerate = 30; 53 const int kTypicalFramerate = 30;
54 54
55 // Constant used to multiply zoom values to avoid using floating point. Used to
56 // scale both the readings (min, max, current) and the value to set it to.
57 const int kZoomMultiplier = 100;
58
59 // V4L2 color formats supported by V4L2CaptureDelegate derived classes. 55 // V4L2 color formats supported by V4L2CaptureDelegate derived classes.
60 // This list is ordered by precedence of use -- but see caveats for MJPEG. 56 // This list is ordered by precedence of use -- but see caveats for MJPEG.
61 static struct { 57 static struct {
62 uint32_t fourcc; 58 uint32_t fourcc;
63 VideoPixelFormat pixel_format; 59 VideoPixelFormat pixel_format;
64 size_t num_planes; 60 size_t num_planes;
65 } const kSupportedFormatsAndPlanarity[] = { 61 } const kSupportedFormatsAndPlanarity[] = {
66 {V4L2_PIX_FMT_YUV420, PIXEL_FORMAT_I420, 1}, 62 {V4L2_PIX_FMT_YUV420, PIXEL_FORMAT_I420, 1},
67 {V4L2_PIX_FMT_Y16, PIXEL_FORMAT_Y16, 1}, 63 {V4L2_PIX_FMT_Y16, PIXEL_FORMAT_Y16, 1},
68 {V4L2_PIX_FMT_Z16, PIXEL_FORMAT_Y16, 1}, 64 {V4L2_PIX_FMT_Z16, PIXEL_FORMAT_Y16, 1},
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 void V4L2CaptureDelegate::SetPhotoOptions( 436 void V4L2CaptureDelegate::SetPhotoOptions(
441 mojom::PhotoSettingsPtr settings, 437 mojom::PhotoSettingsPtr settings,
442 VideoCaptureDevice::SetPhotoOptionsCallback callback) { 438 VideoCaptureDevice::SetPhotoOptionsCallback callback) {
443 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); 439 DCHECK(v4l2_task_runner_->BelongsToCurrentThread());
444 if (!device_fd_.is_valid() || !is_capturing_) 440 if (!device_fd_.is_valid() || !is_capturing_)
445 return; 441 return;
446 442
447 if (settings->has_zoom) { 443 if (settings->has_zoom) {
448 v4l2_control zoom_current = {}; 444 v4l2_control zoom_current = {};
449 zoom_current.id = V4L2_CID_ZOOM_ABSOLUTE; 445 zoom_current.id = V4L2_CID_ZOOM_ABSOLUTE;
450 zoom_current.value = settings->zoom / kZoomMultiplier; 446 zoom_current.value = settings->zoom;
451 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_S_CTRL, &zoom_current)) < 0) 447 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_S_CTRL, &zoom_current)) < 0)
452 DPLOG(ERROR) << "setting zoom to " << settings->zoom / kZoomMultiplier; 448 DPLOG(ERROR) << "setting zoom to " << settings->zoom;
453 } 449 }
454 450
455 if (settings->has_white_balance_mode && 451 if (settings->has_white_balance_mode &&
456 (settings->white_balance_mode == mojom::MeteringMode::CONTINUOUS || 452 (settings->white_balance_mode == mojom::MeteringMode::CONTINUOUS ||
457 settings->white_balance_mode == mojom::MeteringMode::MANUAL)) { 453 settings->white_balance_mode == mojom::MeteringMode::MANUAL)) {
458 v4l2_control white_balance_set = {}; 454 v4l2_control white_balance_set = {};
459 white_balance_set.id = V4L2_CID_AUTO_WHITE_BALANCE; 455 white_balance_set.id = V4L2_CID_AUTO_WHITE_BALANCE;
460 white_balance_set.value = 456 white_balance_set.value =
461 settings->white_balance_mode == mojom::MeteringMode::CONTINUOUS; 457 settings->white_balance_mode == mojom::MeteringMode::CONTINUOUS;
462 HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_S_CTRL, &white_balance_set)); 458 HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_S_CTRL, &white_balance_set));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace"; 646 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace";
651 return false; 647 return false;
652 } 648 }
653 start_ = static_cast<uint8_t*>(start); 649 start_ = static_cast<uint8_t*>(start);
654 length_ = buffer.length; 650 length_ = buffer.length;
655 payload_size_ = 0; 651 payload_size_ = 0;
656 return true; 652 return true;
657 } 653 }
658 654
659 } // namespace media 655 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/fake_video_capture_device_unittest.cc ('k') | media/mojo/interfaces/image_capture.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698