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 "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 Loading... | |
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(); | |
187 ++it) { | |
perkj_chrome
2014/09/05 12:04:58
nit, fits on line above.
magjed_chromium
2014/09/09 09:10:06
Done. FYI, clang-format wants "++it" on a separate
| |
188 supported_format.frame_rate = *it; | |
177 supported_formats->push_back(supported_format); | 189 supported_formats->push_back(supported_format); |
178 DVLOG(1) << device.name() << " " << supported_format.ToString(); | 190 DVLOG(1) << device.name() << " " << supported_format.ToString(); |
179 ++frame_interval.index; | |
180 } | 191 } |
181 ++frame_size.index; | 192 ++frame_size.index; |
182 } | 193 } |
183 ++pixel_format.index; | 194 ++pixel_format.index; |
184 } | 195 } |
185 return; | 196 return; |
186 } | 197 } |
187 | 198 |
188 } // namespace media | 199 } // namespace media |
OLD | NEW |