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

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

Issue 544033002: Linux video capture: handle devices that don't enumerate any frame rates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed type of frame_rate from int to float Created 6 years, 3 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
« no previous file with comments | « no previous file | media/video/capture/linux/video_capture_device_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // TODO(mcasas): see http://crbug.com/249953, support these devices. 148 // TODO(mcasas): see http://crbug.com/249953, support these devices.
149 NOTIMPLEMENTED(); 149 NOTIMPLEMENTED();
150 } else if (frame_size.type == V4L2_FRMSIZE_TYPE_CONTINUOUS) { 150 } else if (frame_size.type == V4L2_FRMSIZE_TYPE_CONTINUOUS) {
151 // TODO(mcasas): see http://crbug.com/249953, support these devices. 151 // TODO(mcasas): see http://crbug.com/249953, support these devices.
152 NOTIMPLEMENTED(); 152 NOTIMPLEMENTED();
153 } 153 }
154 v4l2_frmivalenum frame_interval = {}; 154 v4l2_frmivalenum frame_interval = {};
155 frame_interval.pixel_format = pixel_format.pixelformat; 155 frame_interval.pixel_format = pixel_format.pixelformat;
156 frame_interval.width = frame_size.discrete.width; 156 frame_interval.width = frame_size.discrete.width;
157 frame_interval.height = frame_size.discrete.height; 157 frame_interval.height = frame_size.discrete.height;
158 std::list<float> frame_rates;
158 while (HANDLE_EINTR(ioctl( 159 while (HANDLE_EINTR(ioctl(
159 fd.get(), VIDIOC_ENUM_FRAMEINTERVALS, &frame_interval)) == 0) { 160 fd.get(), VIDIOC_ENUM_FRAMEINTERVALS, &frame_interval)) == 0) {
160 if (frame_interval.type == V4L2_FRMIVAL_TYPE_DISCRETE) { 161 if (frame_interval.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
161 if (frame_interval.discrete.numerator != 0) { 162 if (frame_interval.discrete.numerator != 0) {
162 supported_format.frame_rate = 163 frame_rates.push_back(
163 static_cast<float>(frame_interval.discrete.denominator) / 164 static_cast<float>(frame_interval.discrete.denominator) /
164 static_cast<float>(frame_interval.discrete.numerator); 165 static_cast<float>(frame_interval.discrete.numerator));
165 } else {
166 supported_format.frame_rate = 0;
167 } 166 }
168 } else if (frame_interval.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) { 167 } else if (frame_interval.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) {
169 // TODO(mcasas): see http://crbug.com/249953, support these devices. 168 // TODO(mcasas): see http://crbug.com/249953, support these devices.
170 NOTIMPLEMENTED(); 169 NOTIMPLEMENTED();
171 break; 170 break;
172 } else if (frame_interval.type == V4L2_FRMIVAL_TYPE_STEPWISE) { 171 } else if (frame_interval.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
173 // TODO(mcasas): see http://crbug.com/249953, support these devices. 172 // TODO(mcasas): see http://crbug.com/249953, support these devices.
174 NOTIMPLEMENTED(); 173 NOTIMPLEMENTED();
175 break; 174 break;
176 } 175 }
176 ++frame_interval.index;
177 }
178
179 // Some devices, e.g. Kinect, do not enumerate any frame rates. For these
180 // devices, we do not want to lose all enumeration (pixel format and
181 // resolution), so we return a frame rate of zero instead.
182 if (frame_rates.empty())
183 frame_rates.push_back(0);
184
185 for (std::list<float>::iterator it = frame_rates.begin();
186 it != frame_rates.end(); ++it) {
187 supported_format.frame_rate = *it;
177 supported_formats->push_back(supported_format); 188 supported_formats->push_back(supported_format);
178 DVLOG(1) << device.name() << " " << supported_format.ToString(); 189 DVLOG(1) << device.name() << " " << supported_format.ToString();
179 ++frame_interval.index;
180 } 190 }
181 ++frame_size.index; 191 ++frame_size.index;
182 } 192 }
183 ++pixel_format.index; 193 ++pixel_format.index;
184 } 194 }
185 return; 195 return;
186 } 196 }
187 197
188 } // namespace media 198 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/video/capture/linux/video_capture_device_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698