v4l2transform: Check if caps have changes before asserting
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 15 Apr 2014 20:43:15 +0000 (16:43 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 8 May 2014 19:56:36 +0000 (15:56 -0400)
In set_caps, now checks if caps actually changed and succeed if they didn't
change.

sys/v4l2/gstv4l2transform.c
sys/v4l2/gstv4l2transform.h

index eba63341bd4edb71642f15f4e527cc26331b029a..e6124dd4ea49d0c1d70cd09f32a77e9b61b37eb2 100644 (file)
@@ -188,7 +188,9 @@ gst_v4l2_transform_stop (GstBaseTransform * trans)
   gst_v4l2_object_close (self->v4l2output);
   gst_v4l2_object_close (self->v4l2capture);
   gst_caps_replace (&self->probed_srccaps, NULL);
-  gst_caps_replace (&self->probed_sinkcaps, NULL);
+  gst_caps_replace (&self->probed_srccaps, NULL);
+  gst_caps_replace (&self->incaps, NULL);
+  gst_caps_replace (&self->outcaps, NULL);
 
   return TRUE;
 }
@@ -199,10 +201,21 @@ gst_v4l2_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps,
 {
   GstV4l2Transform *self = GST_V4L2_TRANSFORM (trans);
 
+  if (self->incaps && self->outcaps) {
+    if (gst_caps_is_equal (incaps, self->incaps) &&
+        gst_caps_is_equal (outcaps, self->outcaps)) {
+      GST_DEBUG_OBJECT (trans, "Caps did not changed");
+      return TRUE;
+    }
+  }
+
   /* TODO Add renegotiation support */
   g_return_val_if_fail (!GST_V4L2_IS_ACTIVE (self->v4l2output), FALSE);
   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))
     goto incaps_failed;
 
index 6c26a9c1dbca4291cb0227ab10844c554fad90a9..13d56c3d7cad9145057940a68c42c81cf8928269 100644 (file)
@@ -59,6 +59,10 @@ struct _GstV4l2Transform
   /* pads */
   GstCaps *probed_srccaps;
   GstCaps *probed_sinkcaps;
+
+  /* Selected caps */
+  GstCaps *incaps;
+  GstCaps *outcaps;
 };
 
 struct _GstV4l2TransformClass