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
This commit is contained in:
Michael Olbrich 2013-05-17 10:16:48 +02:00 committed by Sebastian Dröge
parent f1f149b503
commit 00ffe41e6a
4 changed files with 25 additions and 0 deletions

View file

@ -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)
{

View file

@ -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);

View file

@ -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;

View file

@ -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;