summaryrefslogtreecommitdiffstats
path: root/media/video
diff options
context:
space:
mode:
authormagjed <magjed@chromium.org>2014-09-09 05:08:06 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-09 12:10:01 +0000
commit7c653cbed4467e77e9df90e076e9d837887c67a7 (patch)
treeacd30efbfc59efc70ffcb67617c96af34140cbb0 /media/video
parentd79be4039cccd9fe0fa4f4798270df7f21ec57ef (diff)
downloadchromium_src-7c653cbed4467e77e9df90e076e9d837887c67a7.zip
chromium_src-7c653cbed4467e77e9df90e076e9d837887c67a7.tar.gz
chromium_src-7c653cbed4467e77e9df90e076e9d837887c67a7.tar.bz2
Linux video capture: handle devices that don't enumerate any frame rates
BUG=412284 TEST=Check output from DVLOG(1) << device.name() << " " << supported_format.ToString() in VideoCaptureDeviceFactoryLinux::GetDeviceSupportedFormats. For a Kinect Camera, it will now list: Microsoft Kinect Camera resolution: 640x480, fps: 0.000000, pixel format: UYUY Review URL: https://codereview.chromium.org/544033002 Cr-Commit-Position: refs/heads/master@{#293923}
Diffstat (limited to 'media/video')
-rw-r--r--media/video/capture/linux/video_capture_device_factory_linux.cc20
-rw-r--r--media/video/capture/linux/video_capture_device_linux.cc2
-rw-r--r--media/video/capture/linux/video_capture_device_linux.h2
3 files changed, 17 insertions, 7 deletions
diff --git a/media/video/capture/linux/video_capture_device_factory_linux.cc b/media/video/capture/linux/video_capture_device_factory_linux.cc
index 4cb0800..36d69d8 100644
--- a/media/video/capture/linux/video_capture_device_factory_linux.cc
+++ b/media/video/capture/linux/video_capture_device_factory_linux.cc
@@ -155,15 +155,14 @@ void VideoCaptureDeviceFactoryLinux::GetDeviceSupportedFormats(
frame_interval.pixel_format = pixel_format.pixelformat;
frame_interval.width = frame_size.discrete.width;
frame_interval.height = frame_size.discrete.height;
+ std::list<float> frame_rates;
while (HANDLE_EINTR(ioctl(
fd.get(), VIDIOC_ENUM_FRAMEINTERVALS, &frame_interval)) == 0) {
if (frame_interval.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
if (frame_interval.discrete.numerator != 0) {
- supported_format.frame_rate =
+ frame_rates.push_back(
static_cast<float>(frame_interval.discrete.denominator) /
- static_cast<float>(frame_interval.discrete.numerator);
- } else {
- supported_format.frame_rate = 0;
+ static_cast<float>(frame_interval.discrete.numerator));
}
} else if (frame_interval.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) {
// TODO(mcasas): see http://crbug.com/249953, support these devices.
@@ -174,9 +173,20 @@ void VideoCaptureDeviceFactoryLinux::GetDeviceSupportedFormats(
NOTIMPLEMENTED();
break;
}
+ ++frame_interval.index;
+ }
+
+ // Some devices, e.g. Kinect, do not enumerate any frame rates. For these
+ // devices, we do not want to lose all enumeration (pixel format and
+ // resolution), so we return a frame rate of zero instead.
+ if (frame_rates.empty())
+ frame_rates.push_back(0);
+
+ for (std::list<float>::iterator it = frame_rates.begin();
+ it != frame_rates.end(); ++it) {
+ supported_format.frame_rate = *it;
supported_formats->push_back(supported_format);
DVLOG(1) << device.name() << " " << supported_format.ToString();
- ++frame_interval.index;
}
++frame_size.index;
}
diff --git a/media/video/capture/linux/video_capture_device_linux.cc b/media/video/capture/linux/video_capture_device_linux.cc
index 0192daba..cee6dd0 100644
--- a/media/video/capture/linux/video_capture_device_linux.cc
+++ b/media/video/capture/linux/video_capture_device_linux.cc
@@ -204,7 +204,7 @@ void VideoCaptureDeviceLinux::SetRotationOnV4L2Thread(int rotation) {
void VideoCaptureDeviceLinux::OnAllocateAndStart(int width,
int height,
- int frame_rate,
+ float frame_rate,
scoped_ptr<Client> client) {
DCHECK_EQ(v4l2_thread_.message_loop(), base::MessageLoop::current());
diff --git a/media/video/capture/linux/video_capture_device_linux.h b/media/video/capture/linux/video_capture_device_linux.h
index 5415eb7..40017a8 100644
--- a/media/video/capture/linux/video_capture_device_linux.h
+++ b/media/video/capture/linux/video_capture_device_linux.h
@@ -59,7 +59,7 @@ class VideoCaptureDeviceLinux : public VideoCaptureDevice {
// Called on the v4l2_thread_.
void OnAllocateAndStart(int width,
int height,
- int frame_rate,
+ float frame_rate,
scoped_ptr<Client> client);
void OnStopAndDeAllocate();
void OnCaptureTask();