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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1567>
This commit is contained in:
Nicolas Dufresne 2022-01-26 10:06:50 -05:00 committed by GStreamer Marge Bot
parent d394b8b4bd
commit e2b2ff26c9

View file

@ -212,12 +212,8 @@ gst_v4l2_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps,
} }
} }
/* TODO Add renegotiation support */ gst_v4l2_object_stop (self->v4l2output);
g_return_val_if_fail (!GST_V4L2_IS_ACTIVE (self->v4l2output), FALSE); gst_v4l2_object_stop (self->v4l2capture);
g_return_val_if_fail (!GST_V4L2_IS_ACTIVE (self->v4l2capture), FALSE);
gst_caps_replace (&self->incaps, incaps);
gst_caps_replace (&self->outcaps, outcaps);
if (!gst_v4l2_object_set_format (self->v4l2output, incaps, &error)) if (!gst_v4l2_object_set_format (self->v4l2output, incaps, &error))
goto incaps_failed; 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)) if (!gst_v4l2_object_set_format (self->v4l2capture, outcaps, &error))
goto outcaps_failed; goto outcaps_failed;
gst_caps_replace (&self->incaps, incaps);
gst_caps_replace (&self->outcaps, outcaps);
/* FIXME implement fallback if crop not supported */ /* FIXME implement fallback if crop not supported */
if (!gst_v4l2_object_set_crop (self->v4l2output)) if (!gst_v4l2_object_set_crop (self->v4l2output))
goto failed; goto failed;