mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-04 22:48:54 +00:00
taglist: add gst_tag_list_peek_string_index to avoid a copy
Adds a variation of the _get_string_index function that doesn't copy the string. API: gst_tag_list_peek_string_index https://bugzilla.gnome.org/show_bug.cgi?id=621896
This commit is contained in:
parent
e1573f194c
commit
9ee11a2af4
4 changed files with 44 additions and 0 deletions
|
@ -2255,6 +2255,7 @@ gst_tag_list_get_double
|
|||
gst_tag_list_get_double_index
|
||||
gst_tag_list_get_string
|
||||
gst_tag_list_get_string_index
|
||||
gst_tag_list_peek_string_index
|
||||
gst_tag_list_get_pointer
|
||||
gst_tag_list_get_pointer_index
|
||||
gst_tag_list_get_date
|
||||
|
|
|
@ -1601,6 +1601,44 @@ TAG_MERGE_FUNCS (pointer, gpointer, (*value != NULL))
|
|||
*/
|
||||
TAG_MERGE_FUNCS (string, gchar *, (*value != NULL && **value != '\0'))
|
||||
|
||||
/*
|
||||
*FIXME 0.11: Instead of _peek (non-copy) and _get (copy), we could have
|
||||
* _get (non-copy) and _dup (copy) for strings, seems more
|
||||
* widely used
|
||||
*/
|
||||
/**
|
||||
* gst_tag_list_peek_string_index:
|
||||
* @list: a #GstTagList to get the tag from
|
||||
* @tag: tag to read out
|
||||
* @index: number of entry to read out
|
||||
* @value: location for the result
|
||||
*
|
||||
* Peeks at the value that is at the given index for the given tag in the given
|
||||
* list.
|
||||
*
|
||||
* The resulting string in @value will be in UTF-8 encoding and doesn't need
|
||||
* to be freed by the caller. The returned string is also guaranteed to
|
||||
* be non-NULL and non-empty.
|
||||
*
|
||||
* Returns: TRUE, if a value was set, FALSE if the tag didn't exist in the
|
||||
* given list.
|
||||
*/
|
||||
gboolean
|
||||
gst_tag_list_peek_string_index (const GstTagList * list,
|
||||
const gchar * tag, guint index, const gchar ** value)
|
||||
{
|
||||
const GValue *v;
|
||||
|
||||
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
||||
g_return_val_if_fail (tag != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
|
||||
return FALSE;
|
||||
*value = g_value_get_string (v);
|
||||
return *value != NULL && **value != '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_tag_list_get_date:
|
||||
* @list: a #GstTagList to get the tag from
|
||||
|
|
|
@ -345,6 +345,10 @@ gboolean gst_tag_list_get_string_index (const GstTagList * list,
|
|||
const gchar * tag,
|
||||
guint index,
|
||||
gchar ** value);
|
||||
gboolean gst_tag_list_peek_string_index (const GstTagList * list,
|
||||
const gchar * tag,
|
||||
guint index,
|
||||
const gchar ** value);
|
||||
gboolean gst_tag_list_get_pointer (const GstTagList * list,
|
||||
const gchar * tag,
|
||||
gpointer * value);
|
||||
|
|
|
@ -991,6 +991,7 @@ EXPORTS
|
|||
gst_tag_list_new
|
||||
gst_tag_list_new_full
|
||||
gst_tag_list_new_full_valist
|
||||
gst_tag_list_peek_string_index
|
||||
gst_tag_list_remove_tag
|
||||
gst_tag_merge_mode_get_type
|
||||
gst_tag_merge_strings_with_comma
|
||||
|
|
Loading…
Reference in a new issue