| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <fcntl.h> | 5 #include <fcntl.h> |
| 6 #include <linux/videodev2.h> | 6 #include <linux/videodev2.h> |
| 7 #include <poll.h> | 7 #include <poll.h> |
| 8 #include <sys/eventfd.h> | 8 #include <sys/eventfd.h> |
| 9 #include <sys/ioctl.h> | 9 #include <sys/ioctl.h> |
| 10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 visible_size_ = input_visible_size; | 113 visible_size_ = input_visible_size; |
| 114 | 114 |
| 115 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); | 115 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); |
| 116 client_ = client_ptr_factory_->GetWeakPtr(); | 116 client_ = client_ptr_factory_->GetWeakPtr(); |
| 117 | 117 |
| 118 DCHECK(child_task_runner_->BelongsToCurrentThread()); | 118 DCHECK(child_task_runner_->BelongsToCurrentThread()); |
| 119 DCHECK_EQ(encoder_state_, kUninitialized); | 119 DCHECK_EQ(encoder_state_, kUninitialized); |
| 120 | 120 |
| 121 struct v4l2_capability caps; | 121 struct v4l2_capability caps; |
| 122 memset(&caps, 0, sizeof(caps)); | 122 memset(&caps, 0, sizeof(caps)); |
| 123 const __u32 kCapsRequired = V4L2_CAP_VIDEO_CAPTURE_MPLANE | | 123 const __u32 kCapsRequired = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; |
| 124 V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_STREAMING; | |
| 125 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYCAP, &caps); | 124 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYCAP, &caps); |
| 126 if ((caps.capabilities & kCapsRequired) != kCapsRequired) { | 125 if ((caps.capabilities & kCapsRequired) != kCapsRequired) { |
| 127 LOG(ERROR) << "Initialize(): ioctl() failed: VIDIOC_QUERYCAP: " | 126 // This cap combination is deprecated, but some older drivers may still be |
| 128 "caps check failed: 0x" << std::hex << caps.capabilities; | 127 // returning it. |
| 129 return false; | 128 const __u32 kCapsRequiredCompat = V4L2_CAP_VIDEO_CAPTURE_MPLANE | |
| 129 V4L2_CAP_VIDEO_OUTPUT_MPLANE | |
| 130 V4L2_CAP_STREAMING; |
| 131 if ((caps.capabilities & kCapsRequiredCompat) != kCapsRequiredCompat) { |
| 132 LOG(ERROR) << "Initialize(): ioctl() failed: VIDIOC_QUERYCAP: " |
| 133 "caps check failed: 0x" << std::hex << caps.capabilities; |
| 134 return false; |
| 135 } |
| 130 } | 136 } |
| 131 | 137 |
| 132 if (!SetFormats(input_format, output_profile)) { | 138 if (!SetFormats(input_format, output_profile)) { |
| 133 LOG(ERROR) << "Failed setting up formats"; | 139 LOG(ERROR) << "Failed setting up formats"; |
| 134 return false; | 140 return false; |
| 135 } | 141 } |
| 136 | 142 |
| 137 if (input_format != device_input_format_) { | 143 if (input_format != device_input_format_) { |
| 138 DVLOG(1) << "Input format not supported by the HW, will convert to " | 144 DVLOG(1) << "Input format not supported by the HW, will convert to " |
| 139 << media::VideoPixelFormatToString(device_input_format_); | 145 << media::VideoPixelFormatToString(device_input_format_); |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 reqbufs.count = 0; | 1163 reqbufs.count = 0; |
| 1158 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 1164 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| 1159 reqbufs.memory = V4L2_MEMORY_MMAP; | 1165 reqbufs.memory = V4L2_MEMORY_MMAP; |
| 1160 IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs); | 1166 IOCTL_OR_LOG_ERROR(VIDIOC_REQBUFS, &reqbufs); |
| 1161 | 1167 |
| 1162 output_buffer_map_.clear(); | 1168 output_buffer_map_.clear(); |
| 1163 free_output_buffers_.clear(); | 1169 free_output_buffers_.clear(); |
| 1164 } | 1170 } |
| 1165 | 1171 |
| 1166 } // namespace content | 1172 } // namespace content |
| OLD | NEW |