[gst-cvs] gstreamer: gstcaps: New gst_caps_steal_structure() method

Edward Hervey bilboed at kemper.freedesktop.org
Mon Jun 14 04:16:54 PDT 2010


Module: gstreamer
Branch: master
Commit: 32adac81ee129bf90f3d9ee91b71ccc8c7ec649b
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=32adac81ee129bf90f3d9ee91b71ccc8c7ec649b

Author: Edward Hervey <bilboed at bilboed.com>
Date:   Mon Jun 14 11:39:40 2010 +0200

gstcaps: New gst_caps_steal_structure() method

This allows removing structures from caps without them being freed. Helpful when
plugins need to move around structures without having to do an expensive structure
copy.

API:gst_caps_steal_structure

https://bugzilla.gnome.org/show_bug.cgi?id=621527

---

 docs/gst/gstreamer-sections.txt |    1 +
 gst/gstcaps.c                   |   22 ++++++++++++++++++++++
 gst/gstcaps.h                   |    2 ++
 win32/common/libgstreamer.def   |    1 +
 4 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt
index 692106a..79f6064 100644
--- a/docs/gst/gstreamer-sections.txt
+++ b/docs/gst/gstreamer-sections.txt
@@ -288,6 +288,7 @@ gst_caps_append
 gst_caps_merge
 gst_caps_append_structure
 gst_caps_remove_structure
+gst_caps_steal_structure
 gst_caps_merge_structure
 gst_caps_get_size
 gst_caps_get_structure
diff --git a/gst/gstcaps.c b/gst/gstcaps.c
index 7f59aaf..ebc672c 100644
--- a/gst/gstcaps.c
+++ b/gst/gstcaps.c
@@ -529,6 +529,28 @@ gst_caps_remove_and_get_structure (GstCaps * caps, guint idx)
   return s;
 }
 
+/**
+ * gst_caps_steal_structure:
+ * @caps: the #GstCaps to retrieve from
+ * @idx: Index of the structure to retrieve
+ *
+ * Retrieves the stucture with the given index from the list of structures
+ * contained in @caps. The caller becomes the owner of the returned structure.
+ *
+ * Returns: a pointer to the #GstStructure corresponding to @index.
+ */
+GstStructure *
+gst_caps_steal_structure (GstCaps * caps, guint idx)
+{
+  g_return_val_if_fail (caps != NULL, NULL);
+  g_return_val_if_fail (IS_WRITABLE (caps), NULL);
+
+  if (G_UNLIKELY (idx >= caps->structs->len))
+    return NULL;
+
+  return gst_caps_remove_and_get_structure (caps, idx);
+}
+
 static gboolean
 gst_structure_is_equal_foreach (GQuark field_id, const GValue * val2,
     gpointer data)
diff --git a/gst/gstcaps.h b/gst/gstcaps.h
index 35a1fde..eca5f17 100644
--- a/gst/gstcaps.h
+++ b/gst/gstcaps.h
@@ -205,6 +205,8 @@ void              gst_caps_merge_structure         (GstCaps       *caps,
 guint             gst_caps_get_size                (const GstCaps *caps);
 GstStructure *    gst_caps_get_structure           (const GstCaps *caps,
                                                     guint          index);
+GstStructure *    gst_caps_steal_structure         (GstCaps *caps,
+                                                    guint          index);
 GstCaps *         gst_caps_copy_nth                (const GstCaps *caps, guint nth);
 void              gst_caps_truncate                (GstCaps       *caps);
 void              gst_caps_set_value               (GstCaps       *caps,
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index ad8d573..709f6ff 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -171,6 +171,7 @@ EXPORTS
 	gst_caps_new_full_valist
 	gst_caps_new_simple
 	gst_caps_normalize
+	gst_caps_steal_structure
 	gst_caps_ref
 	gst_caps_remove_structure
 	gst_caps_replace





More information about the Gstreamer-commits mailing list