Index: content/common/gpu/media/v4l2_device.cc |
diff --git a/content/common/gpu/media/v4l2_device.cc b/content/common/gpu/media/v4l2_device.cc |
index 7629bac5e19109bc35c7eb065b72950a5b4582e0..8ff28659f9dfc9a639b6d787b0d4c39321632bb1 100644 |
--- a/content/common/gpu/media/v4l2_device.cc |
+++ b/content/common/gpu/media/v4l2_device.cc |
@@ -197,4 +197,36 @@ gfx::Size V4L2Device::CodedSizeFromV4L2Format(struct v4l2_format format) { |
return coded_size; |
} |
+// static |
+gfx::Size V4L2Device::GetMaxSupportedResolution( |
+ const scoped_refptr<V4L2Device>& device, |
+ unsigned int pixelformat) { |
+ gfx::Size max_resolution; |
+ v4l2_frmsizeenum frame_size; |
+ memset(&frame_size, 0, sizeof(frame_size)); |
+ frame_size.pixel_format = pixelformat; |
+ for (; device->Ioctl(VIDIOC_ENUM_FRAMESIZES, &frame_size) == 0; |
+ ++frame_size.index) { |
+ if (frame_size.type == V4L2_FRMIVAL_TYPE_DISCRETE) { |
+ if (frame_size.discrete.width > |
+ static_cast<unsigned int>(max_resolution.width()) && |
+ frame_size.discrete.height > |
+ static_cast<unsigned int>(max_resolution.height())) { |
+ max_resolution.SetSize(frame_size.discrete.width, |
+ frame_size.discrete.height); |
+ } |
+ } else if (frame_size.type == V4L2_FRMIVAL_TYPE_STEPWISE || |
+ frame_size.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) { |
+ max_resolution.SetSize(frame_size.stepwise.max_width, |
+ frame_size.stepwise.max_height); |
+ } |
+ } |
+ if (max_resolution.IsEmpty()) { |
+ LOG(ERROR) << "GetMaxSupportedResolution failed for format " |
+ << std::hex << pixelformat; |
+ max_resolution.SetSize(1920, 1088); |
+ } |
+ return max_resolution; |
+} |
+ |
} // namespace content |