taglist: add missing functions

Add missing and essential functions now that we can't directly use GstStructure
methods on the taglist anymore.
This commit is contained in:
Wim Taymans 2012-01-03 13:42:12 +01:00
parent 07952da04d
commit 713696d0c0
2 changed files with 60 additions and 0 deletions

View file

@ -759,6 +759,41 @@ gst_tag_list_new_from_string (const gchar * str)
return GST_TAG_LIST (gst_structure_from_string (str, NULL));
}
/**
* 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

View file

@ -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);