Chromium Code Reviews| Index: media/capture/video/linux/v4l2_capture_delegate.cc |
| diff --git a/media/capture/video/linux/v4l2_capture_delegate.cc b/media/capture/video/linux/v4l2_capture_delegate.cc |
| index d846e416b5153c3b0ffa8d326b8ac83d49b5b0bc..9d0275e0f7a2fb8e2a1be358c62c0c7b3c94a990 100644 |
| --- a/media/capture/video/linux/v4l2_capture_delegate.cc |
| +++ b/media/capture/video/linux/v4l2_capture_delegate.cc |
| @@ -328,6 +328,86 @@ void V4L2CaptureDelegate::TakePhoto( |
| take_photo_callbacks_.push(std::move(callback)); |
| } |
| +void V4L2CaptureDelegate::GetPhotoCapabilities( |
| + VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) { |
| + DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); |
| + if (!device_fd_.is_valid() || !is_capturing_) |
| + return; |
|
chfremer
2016/09/23 21:18:29
This error case silently swallows the call and doe
mcasas
2016/09/23 22:10:57
The callback is not a simple thing, but a
ScopedR
chfremer
2016/09/23 22:48:56
Thanks. Now I remember you mentioned that to me be
|
| + |
| + mojom::PhotoCapabilitiesPtr photo_capabilities = |
| + mojom::PhotoCapabilities::New(); |
| + |
| + photo_capabilities->zoom = mojom::Range::New(); |
| + v4l2_queryctrl zoom_range = {}; |
| + zoom_range.id = V4L2_CID_ZOOM_ABSOLUTE; |
| + zoom_range.type = V4L2_CTRL_TYPE_INTEGER; |
| + if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QUERYCTRL, &zoom_range)) >= |
| + 0) { |
| + photo_capabilities->zoom->max = zoom_range.maximum * 100; |
| + photo_capabilities->zoom->min = zoom_range.minimum * 100; |
| + } |
| + v4l2_control zoom_current = {}; |
| + zoom_current.id = V4L2_CID_ZOOM_ABSOLUTE; |
| + if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_G_CTRL, &zoom_current)) >= 0) |
| + photo_capabilities->zoom->current = zoom_current.value * 100; |
| + |
| + photo_capabilities->focus_mode = mojom::MeteringMode::NONE; |
| + v4l2_control auto_focus_current = {}; |
| + auto_focus_current.id = V4L2_CID_FOCUS_AUTO; |
| + if (HANDLE_EINTR( |
| + ioctl(device_fd_.get(), VIDIOC_G_CTRL, &auto_focus_current)) >= 0) { |
| + photo_capabilities->focus_mode = auto_focus_current.value |
| + ? mojom::MeteringMode::CONTINUOUS |
| + : mojom::MeteringMode::MANUAL; |
| + } |
| + |
| + photo_capabilities->exposure_mode = mojom::MeteringMode::NONE; |
| + v4l2_control exposure_current = {}; |
| + exposure_current.id = V4L2_CID_EXPOSURE_AUTO; |
| + if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_G_CTRL, &exposure_current)) >= |
| + 0) { |
| + photo_capabilities->exposure_mode = |
| + exposure_current.value == V4L2_EXPOSURE_MANUAL |
| + ? mojom::MeteringMode::MANUAL |
| + : mojom::MeteringMode::CONTINUOUS; |
| + } |
| + |
| + photo_capabilities->white_balance_mode = mojom::MeteringMode::NONE; |
| + v4l2_control white_balance_current = {}; |
| + white_balance_current.id = V4L2_CID_AUTO_WHITE_BALANCE; |
| + if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_G_CTRL, |
| + &white_balance_current)) >= 0) { |
| + photo_capabilities->white_balance_mode = |
| + white_balance_current.value ? mojom::MeteringMode::CONTINUOUS |
| + : mojom::MeteringMode::MANUAL; |
| + } |
| + |
| + photo_capabilities->iso = mojom::Range::New(); |
| + photo_capabilities->height = mojom::Range::New(); |
| + photo_capabilities->width = mojom::Range::New(); |
| + photo_capabilities->exposure_compensation = mojom::Range::New(); |
| + photo_capabilities->fill_light_mode = mojom::FillLightMode::NONE; |
| + photo_capabilities->red_eye_reduction = false; |
|
chfremer
2016/09/23 21:18:29
Does the spec allow these "empty ranges" as way of
mcasas
2016/09/23 22:10:57
Yes, mojom::Range::New() essentially makes
all the
|
| + callback.Run(std::move(photo_capabilities)); |
| +} |
| + |
| +void V4L2CaptureDelegate::SetPhotoOptions( |
| + mojom::PhotoSettingsPtr settings, |
| + VideoCaptureDevice::SetPhotoOptionsCallback callback) { |
| + DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); |
| + if (!device_fd_.is_valid() || !is_capturing_) |
| + return; |
|
chfremer
2016/09/23 21:18:29
Same as above.
mcasas
2016/09/23 22:10:57
Acknowledged.
|
| + |
| + if (settings->has_zoom) { |
| + v4l2_control zoom_current = {}; |
| + zoom_current.id = V4L2_CID_ZOOM_ABSOLUTE; |
| + zoom_current.value = settings->zoom / 100; |
|
chfremer
2016/09/23 21:18:29
If the result of the division is a float, please w
mcasas
2016/09/23 22:10:57
Ridiculously enough, the setting (and the
underlyi
chfremer
2016/09/23 22:48:56
Seems I misinterpreted the value 100 by assuming t
mcasas
2016/09/23 23:16:26
|kZoomMultiplier| it is.
|
| + if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_S_CTRL, &zoom_current)) < 0) |
| + DPLOG(ERROR) << "Error setting zoom value to " << (settings->zoom / 100); |
| + } |
| + callback.Run(true); |
| +} |
| + |
| void V4L2CaptureDelegate::SetRotation(int rotation) { |
| DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); |
| DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0); |