v4l2transform: Handle caps changes
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 26 Jan 2022 15:06:50 +0000 (10:06 -0500)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sun, 20 Feb 2022 22:32:55 +0000 (22:32 +0000)
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1567>

subprojects/gst-plugins-good/sys/v4l2/gstv4l2transform.c

index edb3203..17cce7a 100644 (file)
@@ -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;