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

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

Issue 1124723006: VideoCaptureDeviceLinux: Add support for SPLANE+DMABUF V4L2 type capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 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 "media/video/capture/linux/video_capture_device_factory_linux.h" 5 #include "media/video/capture/linux/video_capture_device_factory_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #if defined(OS_OPENBSD) 9 #if defined(OS_OPENBSD)
10 #include <sys/videoio.h> 10 #include <sys/videoio.h>
11 #else 11 #else
12 #include <linux/videodev2.h> 12 #include <linux/videodev2.h>
13 #endif 13 #endif
14 #include <linux/version.h>
14 #include <sys/ioctl.h> 15 #include <sys/ioctl.h>
15 16
16 #include "base/files/file_enumerator.h" 17 #include "base/files/file_enumerator.h"
17 #include "base/files/scoped_file.h" 18 #include "base/files/scoped_file.h"
18 #include "base/posix/eintr_wrapper.h" 19 #include "base/posix/eintr_wrapper.h"
19 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 //#include "content/common/gpu/gpu_memory_buffer_factory.h"
emircan 2015/05/06 03:06:26 Can be erased.
mcasas 2015/05/06 21:44:42 Done.
20 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
21 #include "media/video/capture/linux/video_capture_device_chromeos.h" 23 #include "media/video/capture/linux/video_capture_device_chromeos.h"
22 #endif 24 #endif
23 #include "media/video/capture/linux/video_capture_device_linux.h" 25 #include "media/video/capture/linux/video_capture_device_linux.h"
24 26
25 namespace media { 27 namespace media {
26 28
27 static bool HasUsableFormats(int fd, uint32 capabilities) { 29 static bool HasUsableFormats(int fd, uint32 capabilities) {
28 const std::list<uint32_t>& usable_fourccs = 30 const std::list<uint32_t>& usable_fourccs =
29 VideoCaptureDeviceLinux::GetListOfUsableFourCCs(false); 31 VideoCaptureDeviceLinux::GetListOfUsableFourCCs(false);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // supported capture format. Devices that have capture and output 178 // supported capture format. Devices that have capture and output
177 // capabilities at the same time are memory-to-memory and are skipped, see 179 // capabilities at the same time are memory-to-memory and are skipped, see
178 // http://crbug.com/139356. 180 // http://crbug.com/139356.
179 v4l2_capability cap; 181 v4l2_capability cap;
180 if ((HANDLE_EINTR(ioctl(fd.get(), VIDIOC_QUERYCAP, &cap)) == 0) && 182 if ((HANDLE_EINTR(ioctl(fd.get(), VIDIOC_QUERYCAP, &cap)) == 0) &&
181 ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE || 183 ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE ||
182 cap.capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) && 184 cap.capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) &&
183 !(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) && 185 !(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) &&
184 !(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT_MPLANE)) && 186 !(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT_MPLANE)) &&
185 HasUsableFormats(fd.get(), cap.capabilities)) { 187 HasUsableFormats(fd.get(), cap.capabilities)) {
186 device_names->push_back(VideoCaptureDevice::Name( 188 VideoCaptureDevice::Name::CaptureApiType api_type =
187 base::StringPrintf("%s", cap.card), unique_id,
188 (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE) 189 (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE)
189 ? VideoCaptureDevice::Name::V4L2_MULTI_PLANE 190 ? VideoCaptureDevice::Name::V4L2_MULTI_PLANE
190 : VideoCaptureDevice::Name::V4L2_SINGLE_PLANE)); 191 : VideoCaptureDevice::Name::V4L2_SINGLE_PLANE;
192 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
193 // For SPLANE API, check if we support Dma-Buf based capture.
194 if (api_type == VideoCaptureDevice::Name::V4L2_SINGLE_PLANE) {
195 v4l2_requestbuffers r_buffer = {};
196 r_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
197 r_buffer.memory = V4L2_MEMORY_DMABUF;
198 r_buffer.count = 1u;
199 if (HANDLE_EINTR(ioctl(fd.get(), VIDIOC_REQBUFS, &r_buffer)) >= 0)
200 api_type = VideoCaptureDevice::Name::V4L2_SINGLE_PLANE_DMABUF;
201 }
emircan 2015/05/06 03:06:26 I think, we should also check if the usable "fourc
mcasas 2015/05/06 21:44:42 We still need to figure out indeed where to check
202 #endif
203 device_names->push_back(VideoCaptureDevice::Name(
204 base::StringPrintf("%s", cap.card), unique_id, api_type));
191 } 205 }
192 } 206 }
193 } 207 }
194 208
195 void VideoCaptureDeviceFactoryLinux::GetDeviceSupportedFormats( 209 void VideoCaptureDeviceFactoryLinux::GetDeviceSupportedFormats(
196 const VideoCaptureDevice::Name& device, 210 const VideoCaptureDevice::Name& device,
197 VideoCaptureFormats* supported_formats) { 211 VideoCaptureFormats* supported_formats) {
198 DCHECK(thread_checker_.CalledOnValidThread()); 212 DCHECK(thread_checker_.CalledOnValidThread());
199 if (device.id().empty()) 213 if (device.id().empty())
200 return; 214 return;
(...skipping 14 matching lines...) Expand all
215 } 229 }
216 230
217 // static 231 // static
218 VideoCaptureDeviceFactory* 232 VideoCaptureDeviceFactory*
219 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( 233 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory(
220 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 234 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
221 return new VideoCaptureDeviceFactoryLinux(ui_task_runner); 235 return new VideoCaptureDeviceFactoryLinux(ui_task_runner);
222 } 236 }
223 237
224 } // namespace media 238 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/linux/v4l2_capture_delegate.cc ('k') | media/video/capture/video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698