From b750fb2d5b0b49d3356be39de1455873b07a5cc5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 10 Feb 2021 15:49:03 -0500 Subject: [PATCH] v4l2src: Force renegotiation on resolution change As mandated by the specification, make sure to cycle through streamoff / streamon regardless if the caps have changed or not. Part-of: --- sys/v4l2/gstv4l2src.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index b23cd75c6e..5c3888a709 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -903,7 +903,21 @@ gst_v4l2src_create (GstPushSrc * src, GstBuffer ** buf) if (G_UNLIKELY (ret != GST_FLOW_OK)) { if (ret == GST_V4L2_FLOW_RESOLUTION_CHANGE) { GST_INFO_OBJECT (v4l2src, "Resolution change detected."); - gst_base_src_negotiate (GST_BASE_SRC (src)); + + /* It is required to always cycle through streamoff, we also need to + * streamoff in order to allow locking a new DV_TIMING which will + * influence the output of TRY_FMT */ + gst_v4l2src_stop (GST_BASE_SRC (src)); + + /* Force renegotiation */ + v4l2src->renegotiation_adjust = v4l2src->offset + 1; + v4l2src->pending_set_fmt = TRUE; + + if (!gst_base_src_negotiate (GST_BASE_SRC (src))) { + ret = GST_FLOW_NOT_NEGOTIATED; + goto error; + } + continue; } goto alloc_failed;