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

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

Issue 2364543002: Revert of Image Capture Linux/CrOs: wire some capabilities set/get (Closed)
Patch Set: Created 4 years, 2 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 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 <poll.h> 7 #include <poll.h>
8 #include <sys/fcntl.h> 8 #include <sys/fcntl.h>
9 #include <sys/ioctl.h> 9 #include <sys/ioctl.h>
10 #include <sys/mman.h> 10 #include <sys/mman.h>
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 is_capturing_ = false; 321 is_capturing_ = false;
322 client_.reset(); 322 client_.reset();
323 } 323 }
324 324
325 void V4L2CaptureDelegate::TakePhoto( 325 void V4L2CaptureDelegate::TakePhoto(
326 VideoCaptureDevice::TakePhotoCallback callback) { 326 VideoCaptureDevice::TakePhotoCallback callback) {
327 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); 327 DCHECK(v4l2_task_runner_->BelongsToCurrentThread());
328 take_photo_callbacks_.push(std::move(callback)); 328 take_photo_callbacks_.push(std::move(callback));
329 } 329 }
330 330
331 void V4L2CaptureDelegate::GetPhotoCapabilities(
332 VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) {
333 DCHECK(v4l2_task_runner_->BelongsToCurrentThread());
334
335 mojom::PhotoCapabilitiesPtr photo_capabilities =
336 mojom::PhotoCapabilities::New();
337
338 photo_capabilities->zoom = mojom::Range::New();
339 v4l2_queryctrl zoom_range = {};
340 zoom_range.id = V4L2_CID_ZOOM_ABSOLUTE;
341 zoom_range.type = V4L2_CTRL_TYPE_INTEGER;
342 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_QUERYCTRL, &zoom_range)) >=
343 0) {
344 photo_capabilities->zoom->max = zoom_range.maximum * 100;
345 photo_capabilities->zoom->min = zoom_range.minimum * 100;
346 }
347 v4l2_control zoom_current = {};
348 zoom_current.id = V4L2_CID_ZOOM_ABSOLUTE;
349 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_G_CTRL, &zoom_current)) >= 0)
350 photo_capabilities->zoom->current = zoom_current.value * 100;
351
352 photo_capabilities->focus_mode = mojom::MeteringMode::NONE;
353 v4l2_control auto_focus_current = {};
354 auto_focus_current.id = V4L2_CID_FOCUS_AUTO;
355 if (HANDLE_EINTR(
356 ioctl(device_fd_.get(), VIDIOC_G_CTRL, &auto_focus_current)) >= 0) {
357 photo_capabilities->focus_mode = auto_focus_current.value
358 ? mojom::MeteringMode::CONTINUOUS
359 : mojom::MeteringMode::MANUAL;
360 }
361
362 photo_capabilities->exposure_mode = mojom::MeteringMode::NONE;
363 v4l2_control exposure_current = {};
364 exposure_current.id = V4L2_CID_EXPOSURE_AUTO;
365 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_G_CTRL, &exposure_current)) >=
366 0) {
367 photo_capabilities->exposure_mode =
368 exposure_current.value == V4L2_EXPOSURE_MANUAL
369 ? mojom::MeteringMode::MANUAL
370 : mojom::MeteringMode::CONTINUOUS;
371 }
372
373 photo_capabilities->white_balance_mode = mojom::MeteringMode::NONE;
374 v4l2_control white_balance_current = {};
375 white_balance_current.id = V4L2_CID_AUTO_WHITE_BALANCE;
376 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_G_CTRL,
377 &white_balance_current)) >= 0) {
378 photo_capabilities->white_balance_mode =
379 white_balance_current.value ? mojom::MeteringMode::CONTINUOUS
380 : mojom::MeteringMode::MANUAL;
381 }
382
383 photo_capabilities->iso = mojom::Range::New();
384 photo_capabilities->height = mojom::Range::New();
385 photo_capabilities->width = mojom::Range::New();
386 photo_capabilities->exposure_compensation = mojom::Range::New();
387 photo_capabilities->fill_light_mode = mojom::FillLightMode::NONE;
388 photo_capabilities->red_eye_reduction = false;
389 callback.Run(std::move(photo_capabilities));
390 }
391
392 void V4L2CaptureDelegate::SetPhotoOptions(
393 mojom::PhotoSettingsPtr settings,
394 VideoCaptureDevice::SetPhotoOptionsCallback callback) {
395 if (settings->has_zoom) {
396 v4l2_control zoom_current = {};
397 zoom_current.id = V4L2_CID_ZOOM_ABSOLUTE;
398 zoom_current.value = settings->zoom / 100;
399 if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_S_CTRL, &zoom_current)) < 0)
400 DLOG(ERROR) << "Error setting zoom value to " << (settings->zoom / 100);
401 }
402 callback.Run(true);
403 }
404
405 void V4L2CaptureDelegate::SetRotation(int rotation) { 331 void V4L2CaptureDelegate::SetRotation(int rotation) {
406 DCHECK(v4l2_task_runner_->BelongsToCurrentThread()); 332 DCHECK(v4l2_task_runner_->BelongsToCurrentThread());
407 DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0); 333 DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0);
408 rotation_ = rotation; 334 rotation_ = rotation;
409 } 335 }
410 336
411 V4L2CaptureDelegate::~V4L2CaptureDelegate() {} 337 V4L2CaptureDelegate::~V4L2CaptureDelegate() {}
412 338
413 bool V4L2CaptureDelegate::MapAndQueueBuffer(int index) { 339 bool V4L2CaptureDelegate::MapAndQueueBuffer(int index) {
414 v4l2_buffer buffer; 340 v4l2_buffer buffer;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace"; 456 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace";
531 return false; 457 return false;
532 } 458 }
533 start_ = static_cast<uint8_t*>(start); 459 start_ = static_cast<uint8_t*>(start);
534 length_ = buffer.length; 460 length_ = buffer.length;
535 payload_size_ = 0; 461 payload_size_ = 0;
536 return true; 462 return true;
537 } 463 }
538 464
539 } // namespace media 465 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/linux/v4l2_capture_delegate.h ('k') | media/capture/video/linux/video_capture_device_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698