pads: Improve readability for gst_pad_fixate_caps()
authorStefan Kost <ensonic@users.sf.net>
Mon, 24 May 2010 14:25:52 +0000 (17:25 +0300)
committerStefan Kost <ensonic@users.sf.net>
Tue, 1 Jun 2010 19:30:37 +0000 (22:30 +0300)
Just truncate and then fixate. We check for empty caps in the begin and a
fixate-func that empties a caps would be broken. It also helps lazy caps impl.
in bug 618853 by avoiding the gst_caps_get_size().

gst/gstpad.c

index 956f00b..6df6a7f 100644 (file)
@@ -2416,13 +2416,16 @@ void
 gst_pad_fixate_caps (GstPad * pad, GstCaps * caps)
 {
   GstPadFixateCapsFunction fixatefunc;
-  guint len;
+  GstStructure *s;
 
   g_return_if_fail (GST_IS_PAD (pad));
   g_return_if_fail (caps != NULL);
   g_return_if_fail (!gst_caps_is_empty (caps));
+  /* FIXME-0.11: do not allow fixating any-caps
+   * g_return_if_fail (!gst_caps_is_any (caps));
+   */
 
-  if (gst_caps_is_fixed (caps))
+  if (gst_caps_is_fixed (caps) || gst_caps_is_any (caps))
     return;
 
   fixatefunc = GST_PAD_FIXATECAPSFUNC (pad);
@@ -2431,16 +2434,9 @@ gst_pad_fixate_caps (GstPad * pad, GstCaps * caps)
   }
 
   /* default fixation */
-  len = gst_caps_get_size (caps);
-  if (len > 0) {
-    GstStructure *s = gst_caps_get_structure (caps, 0);
-
-    gst_structure_foreach (s, gst_pad_default_fixate, s);
-  }
-
-  if (len > 1) {
-    gst_caps_truncate (caps);
-  }
+  gst_caps_truncate (caps);
+  s = gst_caps_get_structure (caps, 0);
+  gst_structure_foreach (s, gst_pad_default_fixate, s);
 }
 
 /* Default accept caps implementation just checks against