2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
4 * gsttag.c: tag support (aka metadata)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
26 #include "gst_private.h"
27 #include "gst-i18n-lib.h"
32 #include <gobject/gvaluecollector.h>
35 #define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL)
38 GType type; /* type the data is in */
40 gchar * nick; /* translated name */
41 gchar * blurb; /* translated description of type */
43 GstTagMergeFunc merge_func; /* functions to merge the values */
44 GstTagFlag flag; /* type of tag */
47 #define TAGLIST "taglist"
48 static GQuark gst_tag_list_quark;
49 static GMutex *__tag_mutex;
50 static GHashTable *__tags;
51 #define TAG_LOCK g_mutex_lock (__tag_mutex)
52 #define TAG_UNLOCK g_mutex_unlock (__tag_mutex)
55 gst_tag_list_get_type (void)
57 static GType _gst_tag_list_type;
59 if (_gst_tag_list_type == 0) {
60 _gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
61 (GBoxedCopyFunc) gst_tag_list_copy,
62 (GBoxedFreeFunc) gst_tag_list_free);
65 g_value_register_transform_func(_gst_tag_list_type, G_TYPE_STRING,
66 _gst_structure_transform_to_string);
70 return _gst_tag_list_type;
74 _gst_tag_initialize (void)
76 gst_tag_list_quark = g_quark_from_static_string (TAGLIST);
77 __tag_mutex = g_mutex_new ();
78 __tags = g_hash_table_new (g_direct_hash, g_direct_equal);
79 gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META,
82 _("commonly used title"),
83 gst_tag_merge_strings_with_comma);
84 gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META,
87 _("person(s) responsible for the recording"),
88 gst_tag_merge_strings_with_comma);
89 gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META,
92 _("album containing this data"),
93 gst_tag_merge_strings_with_comma);
94 gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META,
95 G_TYPE_UINT, /* FIXME: own data type for dates? */
97 _("date the data was created (in Julian calendar days)"),
99 gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META,
102 _("genre this data belongs to"),
103 gst_tag_merge_strings_with_comma);
104 gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META,
107 _("free text commenting the data"),
108 gst_tag_merge_strings_with_comma);
109 gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META,
112 _("track number inside a collection"),
113 gst_tag_merge_use_first);
114 gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META,
117 _("count of tracks inside collection this track belongs to"),
118 gst_tag_merge_use_first);
119 gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META,
122 _("original location of file as a URI"),
123 gst_tag_merge_strings_with_comma);
124 gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META,
127 _("short text describing the content of the data"),
128 gst_tag_merge_strings_with_comma);
129 gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META,
132 _("version of this data"),
134 gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META,
137 _("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
139 gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META,
142 _("organization"), /* FIXME */
143 gst_tag_merge_strings_with_comma);
144 gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
147 _("copyright notice of the data"),
149 gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META,
152 _("contact information"),
153 gst_tag_merge_strings_with_comma);
154 gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META,
157 _("license of data"),
159 gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META,
162 _("person(s) performing"),
163 gst_tag_merge_strings_with_comma);
164 gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED,
167 _("length in GStreamer time units (nanoseconds)"),
169 gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED,
172 _("codec the data is stored in"),
173 gst_tag_merge_strings_with_comma);
174 gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED,
177 _("exact or average bitrate in bits/s"),
179 gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED,
181 _("nominal bitrate"),
182 _("nominal bitrate in bits/s"),
184 gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
186 _("minimum bitrate"),
187 _("minimum bitrate in bits/s"),
189 gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
191 _("maximum bitrate"),
192 _("maximum bitrate in bits/s"),
194 gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED,
197 _("encoder used to encode this stream"),
199 gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED,
201 _("encoder version"),
202 _("version of the encoder used to encode this stream"),
204 gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED,
207 _("serial number of track"),
209 gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META,
211 _("replaygain track gain"),
212 _("track gain in db"),
214 gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META,
216 _("replaygain track peak"),
217 _("peak of the track"),
219 gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META,
221 _("replaygain album gain"),
222 _("album gain in db"),
224 gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
226 _("replaygain album peak"),
227 _("peak of the album"),
231 * gst_tag_merge_use_first:
232 * @dest: uninitialized GValue to store result in
233 * @src: GValue to copy from
235 * This is a convenience function for the func argument of gst_tag_register().
236 * It creates a copy of the first value from the list.
239 gst_tag_merge_use_first (GValue *dest, const GValue *src)
241 const GValue *ret = gst_value_list_get_value (src, 0);
243 g_value_init (dest, G_VALUE_TYPE (ret));
244 g_value_copy (ret, dest);
247 * gst_tag_merge_strings_with_comma:
248 * @dest: uninitialized GValue to store result in
249 * @src: GValue to copy from
251 * This is a convenience function for the func argument of gst_tag_register().
252 * It concatenates all given strings using a comma. The tag must be registered
253 * as a G_TYPE_STRING or this function will fail.
256 gst_tag_merge_strings_with_comma (GValue *dest, const GValue *src)
261 count = gst_value_list_get_size (src);
262 str = g_string_new (g_value_get_string (gst_value_list_get_value (src, 0)));
263 for (i = 1; i < count; i++) {
264 /* seperator between two string */
265 str = g_string_append (str, _(", "));
266 str = g_string_append (str, g_value_get_string (gst_value_list_get_value (src, 1)));
269 g_value_init (dest, G_TYPE_STRING);
270 g_value_set_string_take_ownership (dest, str->str);
271 g_string_free (str, FALSE);
274 gst_tag_lookup (GQuark entry)
279 ret = g_hash_table_lookup (__tags, GUINT_TO_POINTER (entry));
286 * @name: the name or identifier string
287 * @flag: a flag describing the type of tag info
288 * @type: the type this data is in
289 * @nick: human-readable name
290 * @blurb: a human-readable description about this tag
291 * @func: function for merging multiple values of this tag
293 * Registers a new tag type for the use with GStreamer's type system. If a type
294 * with that name is already registered, that one is used.
295 * The old registration may have used a different type however. So don't rely
296 * on your supplied values.
297 * This function takes ownership of all supplied variables.
300 gst_tag_register (gchar *name, GstTagFlag flag, GType type,
301 gchar *nick, gchar *blurb, GstTagMergeFunc func)
306 g_return_if_fail (name != NULL);
307 g_return_if_fail (nick != NULL);
308 g_return_if_fail (blurb != NULL);
309 g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
311 key = g_quark_from_string (name);
312 info = gst_tag_lookup (key);
313 g_return_if_fail (info == NULL);
315 info = g_new (GstTagInfo, 1);
320 info->merge_func = func;
323 g_hash_table_insert (__tags, GUINT_TO_POINTER (key), info);
328 * @tag: name of the tag
330 * Checks if the given type is already registered.
332 * Returns: TRUE if the type is already registered
335 gst_tag_exists (const gchar *tag)
337 g_return_val_if_fail (tag != NULL, FALSE);
339 return gst_tag_lookup (g_quark_from_string (tag)) != NULL;
345 * Gets the #GType used for this tag.
347 * Returns: the #GType of this tag
350 gst_tag_get_type (const gchar *tag)
354 g_return_val_if_fail (tag != NULL, 0);
355 info = gst_tag_lookup (g_quark_from_string (tag));
356 g_return_val_if_fail (info != NULL, 0);
364 * Returns the human-readable name of this tag, You must not change or free
367 * Returns: the human-readable name of this tag
370 gst_tag_get_nick (const gchar *tag)
374 g_return_val_if_fail (tag != NULL, NULL);
375 info = gst_tag_lookup (g_quark_from_string (tag));
376 g_return_val_if_fail (info != NULL, NULL);
381 * gst_tag_get_description:
384 * Returns the human-readable description of this tag, You must not change or
387 * Return the human-readable description of this tag
390 gst_tag_get_description (const gchar *tag)
394 g_return_val_if_fail (tag != NULL, NULL);
395 info = gst_tag_lookup (g_quark_from_string (tag));
396 g_return_val_if_fail (info != NULL, NULL);
401 * gst_tag_list_is_fixed:
404 * Checks if the given tag is fixed. A fixed tag can only contain one value.
405 * Unfixed tags can contain lists of values.
407 * Returns: TRUE, if the given tag is fixed.
410 gst_tag_is_fixed (const gchar *tag)
414 g_return_val_if_fail (tag != NULL, FALSE);
415 info = gst_tag_lookup (g_quark_from_string (tag));
416 g_return_val_if_fail (info != NULL, FALSE);
418 return info->merge_func == NULL;
423 * Creates a new empty GstTagList.
425 * Returns: An empty tag list
428 gst_tag_list_new (void)
430 return GST_TAG_LIST (gst_structure_new (TAGLIST, NULL));
434 * @p: Object that might be a taglist
436 * Checks if the given pointer is a taglist.
438 * Returns: TRUE, if the given pointer is a taglist
441 gst_is_tag_list (gconstpointer p)
443 g_return_val_if_fail (p != NULL, FALSE);
445 return ((GstStructure *) p)->name == gst_tag_list_quark;
449 GstTagMergeMode mode;
452 gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuark tag, GValue *value)
454 GstTagInfo *info = gst_tag_lookup (tag);
455 const GValue *value2;
457 g_assert (info != NULL);
459 if (info->merge_func && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
460 GValue dest = { 0, };
462 case GST_TAG_MERGE_REPLACE_ALL:
463 case GST_TAG_MERGE_REPLACE:
464 gst_structure_id_set_value (list, tag, value);
466 case GST_TAG_MERGE_PREPEND:
467 gst_value_list_concat (&dest, value, value2);
468 gst_structure_id_set_value (list, tag, &dest);
469 g_value_unset (&dest);
471 case GST_TAG_MERGE_APPEND:
472 gst_value_list_concat (&dest, value2, value);
473 gst_structure_id_set_value (list, tag, &dest);
474 g_value_unset (&dest);
476 case GST_TAG_MERGE_KEEP:
477 case GST_TAG_MERGE_KEEP_ALL:
480 g_assert_not_reached ();
485 case GST_TAG_MERGE_APPEND:
486 case GST_TAG_MERGE_KEEP:
487 if (gst_structure_id_get_value (list, tag) != NULL)
490 case GST_TAG_MERGE_REPLACE_ALL:
491 case GST_TAG_MERGE_REPLACE:
492 case GST_TAG_MERGE_PREPEND:
493 gst_structure_id_set_value (list, tag, value);
495 case GST_TAG_MERGE_KEEP_ALL:
498 g_assert_not_reached ();
504 gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data)
506 GstTagCopyData *copy = (GstTagCopyData *) user_data;
508 gst_tag_list_add_value_internal (copy->list, copy->mode, tag, value);
513 * gst_tag_list_insert:
514 * @into: list to merge into
515 * @from: list to merge from
516 * @mode: the mode to use
518 * Inserts the tags of the second list into the first list using the given mode.
521 gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode mode)
525 g_return_if_fail (GST_IS_TAG_LIST (into));
526 g_return_if_fail (GST_IS_TAG_LIST (from));
527 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
529 data.list = (GstStructure *) into;
531 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
532 gst_structure_remove_all_fields (data.list);
534 gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, &data);
538 * @list: list to copy
540 * Copies a given #GstTagList.
542 * Returns: copy of the given list
545 gst_tag_list_copy (const GstTagList *list)
547 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
549 return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list));
552 * gst_tag_list_merge:
553 * @list1: first list to merge
554 * @list2: second list to merge
555 * @mode: the mode to use
557 * Merges the two given lists into a new list. If one of the lists is NULL, a
558 * copy of the other is returned. If both lists are NULL, NULL is returned.
560 * Returns: the new list
563 gst_tag_list_merge (const GstTagList *list1, const GstTagList *list2, GstTagMergeMode mode)
565 g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
566 g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
567 g_return_val_if_fail (GST_TAG_MODE_IS_VALID (mode), NULL);
569 if (!list1 && !list2) {
572 return gst_tag_list_copy (list2);
574 return gst_tag_list_copy (list1);
578 ret = gst_tag_list_copy (list1);
579 gst_tag_list_insert (ret, list2, mode);
585 * @list: the list to free
587 * Frees the given list and all associated values.
590 gst_tag_list_free (GstTagList *list)
592 g_return_if_fail (GST_IS_TAG_LIST (list));
593 gst_structure_free ((GstStructure *) list);
596 * gst_tag_list_get_tag_size:
598 * @tag: the tag to query
600 * Checks how many value are stored in this tag list for the given tag.
602 * Returns: The number of tags stored
605 gst_tag_list_get_tag_size (const GstTagList *list, const gchar *tag)
609 g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
611 value = gst_structure_get_value ((GstStructure *) list, tag);
614 if (G_VALUE_TYPE (value) != GST_TYPE_LIST)
617 return gst_value_list_get_size (value);
621 * @list: list to set tags in
622 * @mode: the mode to use
624 * @...: NULL-terminated list of values to set
626 * Sets the values for the given tags using the specified mode.
629 gst_tag_list_add (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...)
633 g_return_if_fail (GST_IS_TAG_LIST (list));
634 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
635 g_return_if_fail (tag != NULL);
637 va_start (args, tag);
638 gst_tag_list_add_valist (list, mode, tag, args);
642 * gst_tag_list_add_values:
643 * @list: list to set tags in
644 * @mode: the mode to use
646 * @...: GValues to set
648 * Sets the GValues for the given tags using the specified mode.
651 gst_tag_list_add_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...)
655 g_return_if_fail (GST_IS_TAG_LIST (list));
656 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
657 g_return_if_fail (tag != NULL);
659 va_start (args, tag);
660 gst_tag_list_add_valist_values (list, mode, tag, args);
664 * gst_tag_list_add_valist:
665 * @list: list to set tags in
666 * @mode: the mode to use
668 * @var_args: tag / value pairs to set
670 * Sets the values for the given tags using the specified mode.
673 gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args)
679 g_return_if_fail (GST_IS_TAG_LIST (list));
680 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
681 g_return_if_fail (tag != NULL);
683 while (tag != NULL) {
684 GValue value = { 0, };
685 quark = g_quark_from_string (tag);
686 info = gst_tag_lookup (quark);
688 g_warning ("no GstTag for %s", tag);
689 g_return_if_fail (info != NULL);
690 g_value_init (&value, info->type);
691 G_VALUE_COLLECT (&value, var_args, 0, &error);
693 g_warning ("%s: %s", G_STRLOC, error);
695 /* we purposely leak the value here, it might not be
696 * in a sane state if an error condition occoured
700 gst_tag_list_add_value_internal (list, mode, quark, &value);
701 g_value_unset (&value);
702 tag = va_arg (var_args, gchar *);
706 * gst_tag_list_add_valist_values:
707 * @list: list to set tags in
708 * @mode: the mode to use
710 * @var_args: tag / GValue pairs to set
712 * Sets the GValues for the given tags using the specified mode.
715 gst_tag_list_add_valist_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args)
720 g_return_if_fail (GST_IS_TAG_LIST (list));
721 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
722 g_return_if_fail (tag != NULL);
724 while (tag != NULL) {
725 quark = g_quark_from_string (tag);
726 info = gst_tag_lookup (quark);
727 g_return_if_fail (info != NULL);
728 gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, GValue *));
729 tag = va_arg (var_args, gchar *);
733 * gst_tag_list_remove_tag:
734 * @list: list to remove tag from
735 * @tag: tag to remove
737 * Removes the goven tag from the taglist.
740 gst_tag_list_remove_tag (GstTagList *list, const gchar *tag)
742 g_return_if_fail (GST_IS_TAG_LIST (list));
743 g_return_if_fail (tag != NULL);
745 gst_structure_remove_field ((GstStructure *) list, tag);
748 GstTagForeachFunc func;
749 GstTagList * tag_list;
753 structure_foreach_wrapper (GQuark field_id,
754 GValue *value, gpointer user_data)
756 TagForeachData *data = (TagForeachData *) user_data;
757 data->func (data->tag_list, g_quark_to_string (field_id), data->data);
761 * gst_tag_list_foreach:
762 * @list: list to iterate over
763 * @func: function to be called for each tag
764 * @user_data: user specified data
766 * Calls the given function for each tag inside the tag list. Note that if there
767 * is no tag, the function won't be called at all.
770 gst_tag_list_foreach (GstTagList *list, GstTagForeachFunc func, gpointer user_data)
774 g_return_if_fail (GST_IS_TAG_LIST (list));
775 g_return_if_fail (func != NULL);
778 data.tag_list = list;
779 data.data = user_data;
780 gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, &data);
783 /***** tag events *****/
787 * @list: the tag list to put into the event or NULL for an empty list
789 * Creates a new tag event with the given list and takes ownership of it.
791 * Returns: a new tag event
794 gst_event_new_tag (GstTagList *list)
798 g_return_val_if_fail (list == NULL || GST_IS_TAG_LIST (list), NULL);
800 ret = gst_event_new (GST_EVENT_TAG);
802 list = gst_tag_list_new ();
803 ret->event_data.structure.structure = (GstStructure *) list;
808 * get_event_tag_get_list:
809 * @tag_event: a tagging #GstEvent
811 * Gets the taglist from a given tagging event.
813 * Returns: The #GstTagList of the event
816 gst_event_tag_get_list (GstEvent *tag_event)
818 g_return_val_if_fail (GST_IS_EVENT (tag_event), NULL);
819 g_return_val_if_fail (GST_EVENT_TYPE (tag_event) == GST_EVENT_TAG, NULL);
821 return GST_TAG_LIST (tag_event->event_data.structure.structure);
825 * gst_tag_list_get_value_index:
826 * @list: a #GStTagList
827 * @tag: tag to read out
828 * @index: number of entry to read out
830 * Gets the value that is at the given index for the given tag in the given
833 * Returns: The GValue for the specified entry or NULL if the tag wasn't available
834 * or the tag doesn't have as many entries
836 G_CONST_RETURN GValue *
837 gst_tag_list_get_value_index (const GstTagList *list, const gchar *tag, guint index)
841 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
842 g_return_val_if_fail (tag != NULL, NULL);
844 value = gst_structure_get_value ((GstStructure *) list, tag);
845 if (value == NULL) return NULL;
847 if (GST_VALUE_HOLDS_LIST (value)) {
848 if (index >= gst_value_list_get_size (value)) return NULL;
849 return gst_value_list_get_value (value, index);
851 if (index > 0) return NULL;
857 * gst_tag_list_copy_value:
858 * @dest: uninitialized #GValue to copy into
859 * @list: list to get the tag from
860 * @tag: tag to read out
862 * Copies the contents for the given tag into the value, merging multiple values
863 * into one if multiple values are associated with the tag.
864 * You must g_value_unset() the value after use.
866 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
870 gst_tag_list_copy_value (GValue *dest, const GstTagList *list, const gchar *tag)
874 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
875 g_return_val_if_fail (tag != NULL, FALSE);
876 g_return_val_if_fail (dest != NULL, FALSE);
877 g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
879 src = gst_structure_get_value ((GstStructure *) list, tag);
880 if (!src) return FALSE;
882 if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
883 GstTagInfo *info = gst_tag_lookup (g_quark_from_string (tag));
884 /* must be there or lists aren't allowed */
885 g_assert (info->merge_func);
886 info->merge_func (dest, src);
888 g_value_init (dest, G_VALUE_TYPE (src));
889 g_value_copy (src, dest);
894 /***** evil macros to get all the gst_tag_list_get_*() functions right *****/
896 #define TAG_MERGE_FUNCS(name,type) \
898 gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
903 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
904 g_return_val_if_fail (tag != NULL, FALSE); \
905 g_return_val_if_fail (value != NULL, FALSE); \
907 if (!gst_tag_list_copy_value (&v, list, tag)) \
909 *value = COPY_FUNC (g_value_get_ ## name (&v)); \
910 g_value_unset (&v); \
915 gst_tag_list_get_ ## name ## _index (const GstTagList *list, const gchar *tag, \
916 guint index, type *value) \
920 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
921 g_return_val_if_fail (tag != NULL, FALSE); \
922 g_return_val_if_fail (value != NULL, FALSE); \
924 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
926 *value = COPY_FUNC (g_value_get_ ## name (v)); \
930 #define COPY_FUNC /**/
931 TAG_MERGE_FUNCS (char, gchar)
932 TAG_MERGE_FUNCS (uchar, guchar)
933 TAG_MERGE_FUNCS (boolean, gboolean)
934 TAG_MERGE_FUNCS (int, gint)
935 TAG_MERGE_FUNCS (uint, guint)
936 TAG_MERGE_FUNCS (long, glong)
937 TAG_MERGE_FUNCS (ulong, gulong)
938 TAG_MERGE_FUNCS (int64, gint64)
939 TAG_MERGE_FUNCS (uint64, guint64)
940 TAG_MERGE_FUNCS (float, gfloat)
941 TAG_MERGE_FUNCS (double, gdouble)
944 #define COPY_FUNC g_strdup
945 TAG_MERGE_FUNCS (string, gchar *)