| OLD | NEW |
| 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> |
| 11 #include <sys/mman.h> | 11 #include <sys/mman.h> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/files/file_enumerator.h" | 15 #include "base/files/file_enumerator.h" |
| 16 #include "base/posix/eintr_wrapper.h" | 16 #include "base/posix/eintr_wrapper.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "media/base/bind_to_current_loop.h" | 19 #include "media/base/bind_to_current_loop.h" |
| 20 #include "media/capture/video/blob_utils.h" | 20 #include "media/capture/video/blob_utils.h" |
| 21 #include "media/capture/video/linux/video_capture_device_linux.h" | 21 #include "media/capture/video/linux/video_capture_device_linux.h" |
| 22 | 22 |
| 23 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) | 23 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) |
| 24 // 16 bit depth, Realsense F200. | 24 // 16 bit depth, Realsense F200. |
| 25 #define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') | 25 #define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') |
| 26 #endif |
| 27 |
| 28 // TODO(aleksandar.stojiljkovic): Wrap this with kernel version check once the |
| 29 // format is introduced to kernel. |
| 30 // See https://crbug.com/661877 |
| 31 #ifndef V4L2_PIX_FMT_INVZ |
| 26 // 16 bit depth, Realsense SR300. | 32 // 16 bit depth, Realsense SR300. |
| 27 #define V4L2_PIX_FMT_INVZ v4l2_fourcc('I', 'N', 'V', 'Z') | 33 #define V4L2_PIX_FMT_INVZ v4l2_fourcc('I', 'N', 'V', 'Z') |
| 28 #endif | 34 #endif |
| 29 | 35 |
| 30 namespace media { | 36 namespace media { |
| 31 | 37 |
| 32 // Desired number of video buffers to allocate. The actual number of allocated | 38 // Desired number of video buffers to allocate. The actual number of allocated |
| 33 // buffers by v4l2 driver can be higher or lower than this number. | 39 // buffers by v4l2 driver can be higher or lower than this number. |
| 34 // kNumVideoBuffers should not be too small, or Chrome may not return enough | 40 // kNumVideoBuffers should not be too small, or Chrome may not return enough |
| 35 // buffers back to driver in time. | 41 // buffers back to driver in time. |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace"; | 643 DLOG(ERROR) << "Error mmap()ing a V4L2 buffer into userspace"; |
| 638 return false; | 644 return false; |
| 639 } | 645 } |
| 640 start_ = static_cast<uint8_t*>(start); | 646 start_ = static_cast<uint8_t*>(start); |
| 641 length_ = buffer.length; | 647 length_ = buffer.length; |
| 642 payload_size_ = 0; | 648 payload_size_ = 0; |
| 643 return true; | 649 return true; |
| 644 } | 650 } |
| 645 | 651 |
| 646 } // namespace media | 652 } // namespace media |
| OLD | NEW |