From e2b2ff26c99723cbbe7129412cc707d0de6d78dd Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 26 Jan 2022 10:06:50 -0500 Subject: [PATCH] v4l2transform: Handle caps changes As this element is single threaded, we only need to stop the objects to allow changing the format again. Fixes assertion notably on shutdown and on some other situation where the format may be set twice without actually activating the element. Part-of: --- .../gst-plugins-good/sys/v4l2/gstv4l2transform.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2transform.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2transform.c index edb3203630..17cce7a591 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2transform.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2transform.c @@ -212,12 +212,8 @@ gst_v4l2_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps, } } - /* TODO Add renegotiation support */ - g_return_val_if_fail (!GST_V4L2_IS_ACTIVE (self->v4l2output), FALSE); - g_return_val_if_fail (!GST_V4L2_IS_ACTIVE (self->v4l2capture), FALSE); - - gst_caps_replace (&self->incaps, incaps); - gst_caps_replace (&self->outcaps, outcaps); + gst_v4l2_object_stop (self->v4l2output); + gst_v4l2_object_stop (self->v4l2capture); if (!gst_v4l2_object_set_format (self->v4l2output, incaps, &error)) goto incaps_failed; @@ -225,6 +221,9 @@ gst_v4l2_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps, if (!gst_v4l2_object_set_format (self->v4l2capture, outcaps, &error)) goto outcaps_failed; + gst_caps_replace (&self->incaps, incaps); + gst_caps_replace (&self->outcaps, outcaps); + /* FIXME implement fallback if crop not supported */ if (!gst_v4l2_object_set_crop (self->v4l2output)) goto failed;