summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2013-05-17 10:16:48 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2013-09-13 16:29:47 +0200
commitf953d545c14638486c28c451bb82f80620856cee (patch)
tree52f87bd93c02c461c69b945a571fb4f5d7ec08fc
parenta1d12258c964a9e65293f8c7468428fa8de9a8f2 (diff)
downloadgst-plugins-good-f953d545c14638486c28c451bb82f80620856cee.tar.gz
gst-plugins-good-f953d545c14638486c28c451bb82f80620856cee.tar.xz
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
-rw-r--r--sys/v4l2/gstv4l2object.c15
-rw-r--r--sys/v4l2/gstv4l2object.h2
-rw-r--r--sys/v4l2/gstv4l2sink.c4
-rw-r--r--sys/v4l2/gstv4l2src.c4
4 files changed, 25 insertions, 0 deletions
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c
index c06e073b1..b46b7e9aa 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -2489,6 +2489,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)
{
GST_LOG_OBJECT (v4l2object->element, "flush poll");
diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h
index 2cc7cd289..3abb19365 100644
--- a/sys/v4l2/gstv4l2object.h
+++ b/sys/v4l2/gstv4l2object.h
@@ -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);
diff --git a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c
index 115f0578e..dbc41a7ca 100644
--- a/sys/v4l2/gstv4l2sink.c
+++ b/sys/v4l2/gstv4l2sink.c
@@ -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;
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index e3e1e9d90..cbd673a47 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -498,6 +498,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;