v4l2: Don't stop streaming when set_caps is called with unchanged caps
authorMichael Olbrich <m.olbrich@pengutronix.de>
Fri, 17 May 2013 08:16:48 +0000 (10:16 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 20 May 2013 09:13:18 +0000 (11:13 +0200)
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

sys/v4l2/gstv4l2object.c
sys/v4l2/gstv4l2object.h
sys/v4l2/gstv4l2sink.c
sys/v4l2/gstv4l2src.c

index 51b0a1c29a3ce472c4937cf9ec7f3b0c309e8e59..9e3212b78c4dbdacd07930269383909d8d533703 100644 (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)
 {
index 54703e95c6f963781e668e7e566ad877d55a1b31..af58b610aeddab1dc089ad8c9a96b9a265df3f34 100644 (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);
 
index dc36ff78b6998b2891b0231301d37e9edbd81073..b291aa8895a29f21c406f4ec40f7c24970dd2043 100644 (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;
 
index 28ab86aad866f75c841133fc66c5868a545514ed..9f5c92e23c0aa2d8158f5780370209b2826e06db 100644 (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;