caps: add fixate function
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 15 Aug 2011 12:40:38 +0000 (14:40 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 15 Aug 2011 12:40:38 +0000 (14:40 +0200)
Add a fixate function and use it in gstpad.c

gst/gstcaps.c
gst/gstcaps.h
gst/gstpad.c
gst/gststructure.c

index 6bf86cd..53d974a 100644 (file)
@@ -1776,6 +1776,28 @@ gst_caps_do_simplify (GstCaps * caps)
   return TRUE;
 }
 
+/**
+ * gst_caps_fixate:
+ * @caps: a #GstCaps to fixate
+ *
+ * Modifies the given @caps inplace into a representation with only fixed
+ * values. First the caps will be truncated and then the first structure will be
+ * fixated with gst_structure_fixate(). @caps should be writable.
+ */
+void
+gst_caps_fixate (GstCaps * caps)
+{
+  GstStructure *s;
+
+  g_return_if_fail (GST_IS_CAPS (caps));
+  g_return_if_fail (IS_WRITABLE (caps));
+
+  /* default fixation */
+  gst_caps_truncate (caps);
+  s = gst_caps_get_structure (caps, 0);
+  gst_structure_fixate (s);
+}
+
 /* utility */
 
 /**
index bd8f8f8..b5c8a3e 100644 (file)
@@ -406,6 +406,8 @@ GstCaps *         gst_caps_union                   (const GstCaps *caps1,
 GstCaps *         gst_caps_normalize               (const GstCaps *caps);
 gboolean          gst_caps_do_simplify             (GstCaps       *caps);
 
+void              gst_caps_fixate                  (GstCaps       *caps);
+
 /* utility */
 gchar *           gst_caps_to_string               (const GstCaps *caps);
 GstCaps *         gst_caps_from_string             (const gchar   *string);
index 4cfcea8..e08e396 100644 (file)
@@ -2491,12 +2491,8 @@ no_peer:
 static void
 gst_pad_default_fixate (GstPad * pad, GstCaps * caps)
 {
-  GstStructure *s;
-
   /* default fixation */
-  gst_caps_truncate (caps);
-  s = gst_caps_get_structure (caps, 0);
-  gst_structure_fixate (s);
+  gst_caps_fixate (caps);
 }
 
 /**
index b04236e..34cf806 100644 (file)
@@ -3215,5 +3215,7 @@ default_fixate (GQuark field_id, const GValue * value, gpointer data)
 void
 gst_structure_fixate (GstStructure * structure)
 {
+  g_return_if_fail (GST_IS_STRUCTURE (structure));
+
   gst_structure_foreach (structure, default_fixate, structure);
 }