Commit 00ffe41e authored by Michael Olbrich's avatar Michael Olbrich Committed by Sebastian Dröge

v4l2: Don't stop streaming when set_caps is called with unchanged caps

This can happen if other parts of the pipeline are reconfigured.
Stop streaming even for a short amount of time can be quite visible, so it
should be avoided if possible.

https://bugzilla.gnome.org/show_bug.cgi?id=700503
parent f1f149b5
......@@ -2482,6 +2482,21 @@ pool_failed:
}
}
gboolean
gst_v4l2_object_caps_equal (GstV4l2Object * v4l2object, GstCaps * caps)
{
GstStructure *s;
GstCaps *oldcaps;
if (!v4l2object->pool)
return FALSE;
s = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (v4l2object->pool));
gst_buffer_pool_config_get_params (s, &oldcaps, NULL, NULL, NULL);
return oldcaps && gst_caps_is_equal (caps, oldcaps);
}
gboolean
gst_v4l2_object_unlock (GstV4l2Object * v4l2object)
{
......
......@@ -227,6 +227,8 @@ GstStructure* gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc);
gboolean gst_v4l2_object_set_format (GstV4l2Object *v4l2object, GstCaps * caps);
gboolean gst_v4l2_object_caps_equal (GstV4l2Object * v4l2object, GstCaps * caps);
gboolean gst_v4l2_object_unlock (GstV4l2Object *v4l2object);
gboolean gst_v4l2_object_unlock_stop (GstV4l2Object *v4l2object);
......
......@@ -574,6 +574,10 @@ gst_v4l2sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
return FALSE;
}
/* make sure the caps changed before doing anything */
if (gst_v4l2_object_caps_equal (obj, caps))
return TRUE;
if (!gst_v4l2_object_stop (obj))
goto stop_failed;
......
......@@ -494,6 +494,10 @@ gst_v4l2src_set_caps (GstBaseSrc * src, GstCaps * caps)
v4l2src = GST_V4L2SRC (src);
obj = v4l2src->v4l2object;
/* make sure the caps changed before doing anything */
if (gst_v4l2_object_caps_equal (obj, caps))
return TRUE;
/* make sure we stop capturing and dealloc buffers */
if (!gst_v4l2_object_stop (obj))
return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment