Commit a7420548 authored by wjia@chromium.org's avatar wjia@chromium.org

fix detection of video capture device on linux

MEM2MEM devices are registered with V4L2 as both V4L2_CAP_VIDEO_CAPTURE and V4L2_CAP_VIDEO_OUTPUT capabilities. Need to filter out those MEM2MEM devices when to enuemrate/open video capture devices.

BUG=139356
Review URL: https://chromiumcodereview.appspot.com/10824205

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150414 0039d316-1c4b-4281-b951-d872f2087c98
parent c28e705d
...@@ -85,10 +85,11 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) { ...@@ -85,10 +85,11 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
// Failed to open this device. // Failed to open this device.
continue; continue;
} }
// Test if this is a V4L2 device. // Test if this is a V4L2 capture device.
v4l2_capability cap; v4l2_capability cap;
if ((ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) && if ((ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) &&
(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) &&
!(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)) {
// This is a V4L2 video capture device // This is a V4L2 video capture device
name.device_name = StringPrintf("%s", cap.card); name.device_name = StringPrintf("%s", cap.card);
device_names->push_back(name); device_names->push_back(name);
...@@ -203,10 +204,11 @@ void VideoCaptureDeviceLinux::OnAllocate(int width, ...@@ -203,10 +204,11 @@ void VideoCaptureDeviceLinux::OnAllocate(int width,
return; return;
} }
// Test if this is a V4L2 device. // Test if this is a V4L2 capture device.
v4l2_capability cap; v4l2_capability cap;
if (!((ioctl(device_fd_, VIDIOC_QUERYCAP, &cap) == 0) && if (!((ioctl(device_fd_, VIDIOC_QUERYCAP, &cap) == 0) &&
(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))) { (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) &&
!(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT))) {
// This is not a V4L2 video capture device. // This is not a V4L2 video capture device.
close(device_fd_); close(device_fd_);
device_fd_ = -1; device_fd_ = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment