From 85b53bb65d129fc8142b8862ba8b59f594a44e88 Mon Sep 17 00:00:00 2001 From: Hou Qi Date: Tue, 10 May 2022 16:20:46 +0800 Subject: [PATCH] v4l2: set default resolution if caps has no such information Output may attemp to set the width and height to zero values if caps has no such information, which will cause capture get invalid dimensions. Then decoder reports negotiation failure. So need to set default resolution if caps has no such information. Real values can be set again until source change event is signaled. Part-of: --- subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c index b948e16..c0834a8 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c @@ -54,6 +54,8 @@ GST_DEBUG_CATEGORY_EXTERN (v4l2_debug); #define DEFAULT_PROP_IO_MODE GST_V4L2_IO_AUTO #define ENCODED_BUFFER_SIZE (2 * 1024 * 1024) +#define GST_V4L2_DEFAULT_WIDTH 320 +#define GST_V4L2_DEFAULT_HEIGHT 240 enum { @@ -3563,6 +3565,11 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps, pixelformat = fmtdesc->pixelformat; width = GST_VIDEO_INFO_WIDTH (&info); height = GST_VIDEO_INFO_FIELD_HEIGHT (&info); + /* if caps has no width and height info, use default value */ + if (V4L2_TYPE_IS_OUTPUT (v4l2object->type) && width == 0 && height == 0) { + width = GST_V4L2_DEFAULT_WIDTH; + height = GST_V4L2_DEFAULT_HEIGHT; + } fps_n = GST_VIDEO_INFO_FPS_N (&info); fps_d = GST_VIDEO_INFO_FPS_D (&info); -- 2.7.4