[0.11] gstreamer: taglist: add missing functions

Wim Taymans wtay at kemper.freedesktop.org
Tue Jan 3 04:43:07 PST 2012


Module: gstreamer
Branch: 0.11
Commit: 713696d0c05886d6546b3d7a1941bfd69393508e
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=713696d0c05886d6546b3d7a1941bfd69393508e

Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Tue Jan  3 13:42:12 2012 +0100

taglist: add missing functions

Add missing and essential functions now that we can't directly use GstStructure
methods on the taglist anymore.

---

 gst/gsttaglist.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gst/gsttaglist.h |    6 ++++++
 2 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/gst/gsttaglist.c b/gst/gsttaglist.c
index 1287e93..ff5ee48 100644
--- a/gst/gsttaglist.c
+++ b/gst/gsttaglist.c
@@ -760,6 +760,41 @@ gst_tag_list_new_from_string (const gchar * str)
 }
 
 /**
+ * gst_tag_list_n_tags:
+ * @list: A #GstTagList.
+ *
+ * Get the number of tags in @list.
+ *
+ * Returns: The number of tags in @list.
+ */
+gint
+gst_tag_list_n_tags (const GstTagList * list)
+{
+  g_return_val_if_fail (list != NULL, 0);
+  g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
+
+  return gst_structure_n_fields ((GstStructure *) list);
+}
+
+/**
+ * gst_tag_list_nth_tag_name:
+ * @list: A #GstTagList.
+ * @index: the index
+ *
+ * Get the name of the tag in @list at @index.
+ *
+ * Returns: The name of the tag at @index.
+ */
+const gchar *
+gst_tag_list_nth_tag_name (const GstTagList * list, guint index)
+{
+  g_return_val_if_fail (list != NULL, 0);
+  g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
+
+  return gst_structure_nth_field_name ((GstStructure *) list, index);
+}
+
+/**
  * gst_tag_list_is_empty:
  * @list: A #GstTagList.
  *
@@ -1368,6 +1403,25 @@ gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
   return TRUE;
 }
 
+/**
+ * gst_tag_list_get_value:
+ * @list: list to get the tag from
+ * @tag: tag to read out
+ *
+ * Get the value for the given tag.
+ *
+ * Returns: The #GValue for @tag.
+ */
+const GValue *
+gst_tag_list_get_value (const GstTagList * list, const gchar * tag)
+{
+  g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
+  g_return_val_if_fail (tag != NULL, NULL);
+
+  return gst_structure_get_value ((GstStructure *) list, tag);
+}
+
+
 /* FIXME 0.11: this whole merge function business is overdesigned, and the
  * _get_foo() API is misleading as well - how many application developers will
  * expect gst_tag_list_get_string (list, GST_TAG_ARTIST, &val) might return a
diff --git a/gst/gsttaglist.h b/gst/gsttaglist.h
index ec1f7a2..c075978 100644
--- a/gst/gsttaglist.h
+++ b/gst/gsttaglist.h
@@ -208,6 +208,8 @@ GstTagList * gst_tag_list_new_from_string   (const gchar      * str) G_GNUC_MALL
 
 gboolean     gst_is_tag_list                (gconstpointer p);
 GstTagList * gst_tag_list_copy              (const GstTagList * list) G_GNUC_MALLOC;
+gint         gst_tag_list_n_tags            (const GstTagList * list);
+const gchar* gst_tag_list_nth_tag_name      (const GstTagList * list, guint index);
 gboolean     gst_tag_list_is_empty          (const GstTagList * list);
 gboolean     gst_tag_list_is_equal          (const GstTagList * list1,
                                              const GstTagList * list2);
@@ -255,6 +257,10 @@ gboolean     gst_tag_list_copy_value        (GValue           * dest,
                                              const gchar      * tag);
 
 /* simplifications (FIXME: do we want them?) */
+const GValue *
+             gst_tag_list_get_value         (const GstTagList * list,
+                                             const gchar      * tag);
+
 gboolean     gst_tag_list_get_boolean       (const GstTagList * list,
                                              const gchar      * tag,
                                              gboolean         * value);



More information about the gstreamer-commits mailing list