2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
4 * gsttaglist.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.
24 * @short_description: List of tags and values used to describe media metadata
26 * List of tags and values used to describe media metadata.
28 * Strings must be in ASCII or UTF-8 encoding. No other encodings are allowed.
30 * Last reviewed on 2009-06-09 (0.10.23)
37 #include "gst_private.h"
38 #include "gst-i18n-lib.h"
39 #include "gsttaglist.h"
42 #include "gstbuffer.h"
45 #include <gobject/gvaluecollector.h>
48 #define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL)
50 /* FIXME 0.11: use GParamSpecs or something similar for tag registrations,
51 * possibly even gst_tag_register(). Especially value ranges might be
52 * useful for some tags. */
56 GType type; /* type the data is in */
58 gchar *nick; /* translated name */
59 gchar *blurb; /* translated description of type */
61 GstTagMergeFunc merge_func; /* functions to merge the values */
62 GstTagFlag flag; /* type of tag */
66 static GMutex *__tag_mutex;
68 static GHashTable *__tags;
70 #define TAG_LOCK g_mutex_lock (__tag_mutex)
71 #define TAG_UNLOCK g_mutex_unlock (__tag_mutex)
74 gst_tag_list_get_type (void)
76 static GType _gst_tag_list_type = 0;
78 if (G_UNLIKELY (_gst_tag_list_type == 0)) {
79 _gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
80 (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
83 g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
84 _gst_structure_transform_to_string);
88 return _gst_tag_list_type;
92 _gst_tag_initialize (void)
94 __tag_mutex = g_mutex_new ();
95 __tags = g_hash_table_new (g_direct_hash, g_direct_equal);
96 gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META,
98 _("title"), _("commonly used title"), gst_tag_merge_strings_with_comma);
99 gst_tag_register (GST_TAG_TITLE_SORTNAME, GST_TAG_FLAG_META,
101 _("title sortname"), _("commonly used title for sorting purposes"), NULL);
102 gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META,
105 _("person(s) responsible for the recording"),
106 gst_tag_merge_strings_with_comma);
107 gst_tag_register (GST_TAG_ARTIST_SORTNAME, GST_TAG_FLAG_META,
109 _("artist sortname"),
110 _("person(s) responsible for the recording for sorting purposes"), NULL);
111 gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META,
114 _("album containing this data"), gst_tag_merge_strings_with_comma);
115 gst_tag_register (GST_TAG_ALBUM_SORTNAME, GST_TAG_FLAG_META,
118 _("album containing this data for sorting purposes"), NULL);
119 gst_tag_register (GST_TAG_ALBUM_ARTIST, GST_TAG_FLAG_META,
122 _("The artist of the entire album, as it should be displayed"),
123 gst_tag_merge_strings_with_comma);
124 gst_tag_register (GST_TAG_ALBUM_ARTIST_SORTNAME, GST_TAG_FLAG_META,
126 _("album artist sortname"),
127 _("The artist of the entire album, as it should be sorted"), NULL);
128 gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, GST_TYPE_DATE,
129 _("date"), _("date the data was created (as a GDate structure)"), NULL);
130 gst_tag_register (GST_TAG_DATE_TIME, GST_TAG_FLAG_META, GST_TYPE_DATE_TIME,
132 _("date and time the data was created (as a GstDateTime structure)"),
134 gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META,
137 _("genre this data belongs to"), gst_tag_merge_strings_with_comma);
138 gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META,
141 _("free text commenting the data"), gst_tag_merge_use_first);
142 gst_tag_register (GST_TAG_EXTENDED_COMMENT, GST_TAG_FLAG_META,
144 _("extended comment"),
145 _("free text commenting the data in key=value or key[en]=comment form"),
146 gst_tag_merge_use_first);
147 gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META,
150 _("track number inside a collection"), gst_tag_merge_use_first);
151 gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META,
154 _("count of tracks inside collection this track belongs to"),
155 gst_tag_merge_use_first);
156 gst_tag_register (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META,
159 _("disc number inside a collection"), gst_tag_merge_use_first);
160 gst_tag_register (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META,
163 _("count of discs inside collection this disc belongs to"),
164 gst_tag_merge_use_first);
165 gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META,
167 _("location"), _("Origin of media as a URI (location, where the "
168 "original of the file or stream is hosted)"),
169 gst_tag_merge_strings_with_comma);
170 gst_tag_register (GST_TAG_HOMEPAGE, GST_TAG_FLAG_META,
173 _("Homepage for this media (i.e. artist or movie homepage)"),
174 gst_tag_merge_strings_with_comma);
175 gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META, G_TYPE_STRING,
176 _("description"), _("short text describing the content of the data"),
177 gst_tag_merge_strings_with_comma);
178 gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META, G_TYPE_STRING,
179 _("version"), _("version of this data"), NULL);
180 gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META, G_TYPE_STRING, _("ISRC"),
182 ("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
184 /* FIXME: organization (fix what? tpm) */
185 gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING,
186 _("organization"), _("organization"), gst_tag_merge_strings_with_comma);
187 gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
188 G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL);
189 gst_tag_register (GST_TAG_COPYRIGHT_URI, GST_TAG_FLAG_META,
190 G_TYPE_STRING, _("copyright uri"),
191 _("URI to the copyright notice of the data"), NULL);
192 gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META,
194 _("contact"), _("contact information"), gst_tag_merge_strings_with_comma);
195 gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META,
196 G_TYPE_STRING, _("license"), _("license of data"), NULL);
197 gst_tag_register (GST_TAG_LICENSE_URI, GST_TAG_FLAG_META,
198 G_TYPE_STRING, _("license uri"),
199 _("URI to the license of the data"), NULL);
200 gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META,
203 _("person(s) performing"), gst_tag_merge_strings_with_comma);
204 gst_tag_register (GST_TAG_COMPOSER, GST_TAG_FLAG_META,
207 _("person(s) who composed the recording"),
208 gst_tag_merge_strings_with_comma);
209 gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED,
211 _("duration"), _("length in GStreamer time units (nanoseconds)"), NULL);
212 gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED,
215 _("codec the data is stored in"), gst_tag_merge_strings_with_comma);
216 gst_tag_register (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED,
218 _("video codec"), _("codec the video data is stored in"), NULL);
219 gst_tag_register (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED,
221 _("audio codec"), _("codec the audio data is stored in"), NULL);
222 gst_tag_register (GST_TAG_SUBTITLE_CODEC, GST_TAG_FLAG_ENCODED,
224 _("subtitle codec"), _("codec the subtitle data is stored in"), NULL);
225 gst_tag_register (GST_TAG_CONTAINER_FORMAT, GST_TAG_FLAG_ENCODED,
226 G_TYPE_STRING, _("container format"),
227 _("container format the data is stored in"), NULL);
228 gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED,
229 G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL);
230 gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED,
231 G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL);
232 gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
233 G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL);
234 gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
235 G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL);
236 gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED,
238 _("encoder"), _("encoder used to encode this stream"), NULL);
239 gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED,
241 _("encoder version"),
242 _("version of the encoder used to encode this stream"), NULL);
243 gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED,
244 G_TYPE_UINT, _("serial"), _("serial number of track"), NULL);
245 gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META,
246 G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL);
247 gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META,
248 G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL);
249 gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META,
250 G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL);
251 gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
252 G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL);
253 gst_tag_register (GST_TAG_REFERENCE_LEVEL, GST_TAG_FLAG_META,
254 G_TYPE_DOUBLE, _("replaygain reference level"),
255 _("reference level of track and album gain values"), NULL);
256 gst_tag_register (GST_TAG_LANGUAGE_CODE, GST_TAG_FLAG_META, G_TYPE_STRING,
258 _("language code for this stream, conforming to ISO-639-1"), NULL);
259 gst_tag_register (GST_TAG_IMAGE, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
260 _("image"), _("image related to this stream"), gst_tag_merge_use_first);
261 gst_tag_register (GST_TAG_PREVIEW_IMAGE, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
262 /* TRANSLATORS: 'preview image' = image that shows a preview of the full image */
263 _("preview image"), _("preview image related to this stream"), NULL);
264 gst_tag_register (GST_TAG_ATTACHMENT, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
265 _("attachment"), _("file attached to this stream"),
266 gst_tag_merge_use_first);
267 gst_tag_register (GST_TAG_BEATS_PER_MINUTE, GST_TAG_FLAG_META, G_TYPE_DOUBLE,
268 _("beats per minute"), _("number of beats per minute in audio"), NULL);
269 gst_tag_register (GST_TAG_KEYWORDS, GST_TAG_FLAG_META, G_TYPE_STRING,
270 _("keywords"), _("comma separated keywords describing the content"),
271 gst_tag_merge_strings_with_comma);
272 gst_tag_register (GST_TAG_GEO_LOCATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
273 _("geo location name"), _("human readable descriptive location of where "
274 "the media has been recorded or produced"), NULL);
275 gst_tag_register (GST_TAG_GEO_LOCATION_LATITUDE, GST_TAG_FLAG_META,
276 G_TYPE_DOUBLE, _("geo location latitude"),
277 _("geo latitude location of where the media has been recorded or "
278 "produced in degrees according to WGS84 (zero at the equator, "
279 "negative values for southern latitudes)"), NULL);
280 gst_tag_register (GST_TAG_GEO_LOCATION_LONGITUDE, GST_TAG_FLAG_META,
281 G_TYPE_DOUBLE, _("geo location longitude"),
282 _("geo longitude location of where the media has been recorded or "
283 "produced in degrees according to WGS84 (zero at the prime meridian "
284 "in Greenwich/UK, negative values for western longitudes)"), NULL);
285 gst_tag_register (GST_TAG_GEO_LOCATION_ELEVATION, GST_TAG_FLAG_META,
286 G_TYPE_DOUBLE, _("geo location elevation"),
287 _("geo elevation of where the media has been recorded or produced in "
288 "meters according to WGS84 (zero is average sea level)"), NULL);
289 gst_tag_register (GST_TAG_GEO_LOCATION_COUNTRY, GST_TAG_FLAG_META,
290 G_TYPE_STRING, _("geo location country"),
291 _("country (english name) where the media has been recorded "
292 "or produced"), NULL);
293 gst_tag_register (GST_TAG_GEO_LOCATION_CITY, GST_TAG_FLAG_META,
294 G_TYPE_STRING, _("geo location city"),
295 _("city (english name) where the media has been recorded "
296 "or produced"), NULL);
297 gst_tag_register (GST_TAG_GEO_LOCATION_SUBLOCATION, GST_TAG_FLAG_META,
298 G_TYPE_STRING, _("geo location sublocation"),
299 _("a location whithin a city where the media has been produced "
300 "or created (e.g. the neighborhood)"), NULL);
301 gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, GST_TAG_FLAG_META,
302 G_TYPE_DOUBLE, _("geo location movement speed"),
303 _("movement speed of the capturing device while performing the capture "
305 gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, GST_TAG_FLAG_META,
306 G_TYPE_DOUBLE, _("geo location movement direction"),
307 _("indicates the movement direction of the device performing the capture"
308 " of a media. It is represented as degrees in floating point "
309 "representation, 0 means the geographic north, and increases "
311 gst_tag_register (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, GST_TAG_FLAG_META,
312 G_TYPE_DOUBLE, _("geo location capture direction"),
313 _("indicates the direction the device is pointing to when capturing "
314 " a media. It is represented as degrees in floating point "
315 " representation, 0 means the geographic north, and increases "
317 gst_tag_register (GST_TAG_SHOW_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
318 /* TRANSLATORS: 'show name' = 'TV/radio/podcast show name' here */
320 _("Name of the tv/podcast/series show the media is from"),
321 gst_tag_merge_strings_with_comma);
322 gst_tag_register (GST_TAG_SHOW_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING,
323 /* TRANSLATORS: 'show sortname' = 'TV/radio/podcast show name as used for sorting purposes' here */
325 _("Name of the tv/podcast/series show the media is from, for sorting "
327 gst_tag_register (GST_TAG_SHOW_EPISODE_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT,
329 _("The episode number in the season the media is part of"),
330 gst_tag_merge_use_first);
331 gst_tag_register (GST_TAG_SHOW_SEASON_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT,
333 _("The season number of the show the media is part of"),
334 gst_tag_merge_use_first);
335 gst_tag_register (GST_TAG_LYRICS, GST_TAG_FLAG_META, G_TYPE_STRING,
336 _("lyrics"), _("The lyrics of the media, commonly used for songs"),
337 gst_tag_merge_strings_with_comma);
338 gst_tag_register (GST_TAG_COMPOSER_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING,
339 _("composer sortname"),
340 _("person(s) who composed the recording, for sorting purposes"), NULL);
341 gst_tag_register (GST_TAG_GROUPING, GST_TAG_FLAG_META, G_TYPE_STRING,
343 _("Groups related media that spans multiple tracks, like the different "
344 "pieces of a concerto. It is a higher level than a track, "
345 "but lower than an album"), NULL);
346 gst_tag_register (GST_TAG_USER_RATING, GST_TAG_FLAG_META, G_TYPE_UINT,
348 _("Rating attributed by a user. The higher the rank, "
349 "the more the user likes this media"), NULL);
350 gst_tag_register (GST_TAG_DEVICE_MANUFACTURER, GST_TAG_FLAG_META,
351 G_TYPE_STRING, _("device manufacturer"),
352 _("Manufacturer of the device used to create this media"), NULL);
353 gst_tag_register (GST_TAG_DEVICE_MODEL, GST_TAG_FLAG_META, G_TYPE_STRING,
355 _("Model of the device used to create this media"), NULL);
356 gst_tag_register (GST_TAG_APPLICATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
357 _("application name"), _("Application used to create the media"), NULL);
358 gst_tag_register (GST_TAG_APPLICATION_DATA, GST_TAG_FLAG_META,
359 GST_TYPE_BUFFER, _("application data"),
360 _("Arbitrary application data to be serialized into the media"), NULL);
361 gst_tag_register (GST_TAG_IMAGE_ORIENTATION, GST_TAG_FLAG_META, G_TYPE_STRING,
362 _("image orientation"),
363 _("How the image should be rotated or flipped before display"), NULL);
367 * gst_tag_merge_use_first:
368 * @dest: uninitialized GValue to store result in
369 * @src: GValue to copy from
371 * This is a convenience function for the func argument of gst_tag_register().
372 * It creates a copy of the first value from the list.
375 gst_tag_merge_use_first (GValue * dest, const GValue * src)
377 const GValue *ret = gst_value_list_get_value (src, 0);
379 g_value_init (dest, G_VALUE_TYPE (ret));
380 g_value_copy (ret, dest);
384 * gst_tag_merge_strings_with_comma:
385 * @dest: uninitialized GValue to store result in
386 * @src: GValue to copy from
388 * This is a convenience function for the func argument of gst_tag_register().
389 * It concatenates all given strings using a comma. The tag must be registered
390 * as a G_TYPE_STRING or this function will fail.
393 gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src)
398 count = gst_value_list_get_size (src);
399 str = g_string_new (g_value_get_string (gst_value_list_get_value (src, 0)));
400 for (i = 1; i < count; i++) {
401 /* separator between two strings */
402 g_string_append (str, _(", "));
403 g_string_append (str,
404 g_value_get_string (gst_value_list_get_value (src, i)));
407 g_value_init (dest, G_TYPE_STRING);
408 g_value_take_string (dest, str->str);
409 g_string_free (str, FALSE);
413 gst_tag_lookup (GQuark entry)
418 ret = g_hash_table_lookup (__tags, GUINT_TO_POINTER (entry));
426 * @name: the name or identifier string
427 * @flag: a flag describing the type of tag info
428 * @type: the type this data is in
429 * @nick: human-readable name
430 * @blurb: a human-readable description about this tag
431 * @func: function for merging multiple values of this tag, or NULL
433 * Registers a new tag type for the use with GStreamer's type system. If a type
434 * with that name is already registered, that one is used.
435 * The old registration may have used a different type however. So don't rely
436 * on your supplied values.
438 * Important: if you do not supply a merge function the implication will be
439 * that there can only be one single value for this tag in a tag list and
440 * any additional values will silenty be discarded when being added (unless
441 * #GST_TAG_MERGE_REPLACE, #GST_TAG_MERGE_REPLACE_ALL, or
442 * #GST_TAG_MERGE_PREPEND is used as merge mode, in which case the new
443 * value will replace the old one in the list).
445 * The merge function will be called from gst_tag_list_copy_value() when
446 * it is required that one or more values for a tag be condensed into
447 * one single value. This may happen from gst_tag_list_get_string(),
448 * gst_tag_list_get_int(), gst_tag_list_get_double() etc. What will happen
449 * exactly in that case depends on how the tag was registered and if a
450 * merge function was supplied and if so which one.
452 * Two default merge functions are provided: gst_tag_merge_use_first() and
453 * gst_tag_merge_strings_with_comma().
456 gst_tag_register (const gchar * name, GstTagFlag flag, GType type,
457 const gchar * nick, const gchar * blurb, GstTagMergeFunc func)
462 g_return_if_fail (name != NULL);
463 g_return_if_fail (nick != NULL);
464 g_return_if_fail (blurb != NULL);
465 g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
467 key = g_quark_from_string (name);
468 info = gst_tag_lookup (key);
471 g_return_if_fail (info->type == type);
475 info = g_slice_new (GstTagInfo);
478 info->nick = g_strdup (nick);
479 info->blurb = g_strdup (blurb);
480 info->merge_func = func;
483 g_hash_table_insert (__tags, GUINT_TO_POINTER (key), info);
489 * @tag: name of the tag
491 * Checks if the given type is already registered.
493 * Returns: TRUE if the type is already registered
496 gst_tag_exists (const gchar * tag)
498 g_return_val_if_fail (tag != NULL, FALSE);
500 return gst_tag_lookup (g_quark_from_string (tag)) != NULL;
507 * Gets the #GType used for this tag.
509 * Returns: the #GType of this tag
512 gst_tag_get_type (const gchar * tag)
516 g_return_val_if_fail (tag != NULL, 0);
517 info = gst_tag_lookup (g_quark_from_string (tag));
518 g_return_val_if_fail (info != NULL, 0);
527 * Returns the human-readable name of this tag, You must not change or free
530 * Returns: the human-readable name of this tag
533 gst_tag_get_nick (const gchar * tag)
537 g_return_val_if_fail (tag != NULL, NULL);
538 info = gst_tag_lookup (g_quark_from_string (tag));
539 g_return_val_if_fail (info != NULL, NULL);
545 * gst_tag_get_description:
548 * Returns the human-readable description of this tag, You must not change or
551 * Returns: the human-readable description of this tag
554 gst_tag_get_description (const gchar * tag)
558 g_return_val_if_fail (tag != NULL, NULL);
559 info = gst_tag_lookup (g_quark_from_string (tag));
560 g_return_val_if_fail (info != NULL, NULL);
569 * Gets the flag of @tag.
571 * Returns: the flag of this tag.
574 gst_tag_get_flag (const gchar * tag)
578 g_return_val_if_fail (tag != NULL, GST_TAG_FLAG_UNDEFINED);
579 info = gst_tag_lookup (g_quark_from_string (tag));
580 g_return_val_if_fail (info != NULL, GST_TAG_FLAG_UNDEFINED);
589 * Checks if the given tag is fixed. A fixed tag can only contain one value.
590 * Unfixed tags can contain lists of values.
592 * Returns: TRUE, if the given tag is fixed.
595 gst_tag_is_fixed (const gchar * tag)
599 g_return_val_if_fail (tag != NULL, FALSE);
600 info = gst_tag_lookup (g_quark_from_string (tag));
601 g_return_val_if_fail (info != NULL, FALSE);
603 return info->merge_func == NULL;
609 * Creates a new empty GstTagList.
611 * Returns: An empty tag list
614 gst_tag_list_new (void)
616 return GST_TAG_LIST (gst_structure_id_empty_new (GST_QUARK (TAGLIST)));
620 * gst_tag_list_new_full:
622 * @...: NULL-terminated list of values to set
624 * Creates a new taglist and appends the values for the given tags. It expects
625 * tag-value pairs like gst_tag_list_add(), and a NULL terminator after the
626 * last pair. The type of the values is implicit and is documented in the API
627 * reference, but can also be queried at runtime with gst_tag_get_type(). It
628 * is an error to pass a value of a type not matching the tag type into this
629 * function. The tag list will make copies of any arguments passed
630 * (e.g. strings, buffers).
632 * Returns: a new #GstTagList. Free with gst_tag_list_free() when no longer
637 /* FIXME 0.11: rename gst_tag_list_new_full to _new and _new to _new_empty */
639 gst_tag_list_new_full (const gchar * tag, ...)
644 g_return_val_if_fail (tag != NULL, NULL);
646 list = gst_tag_list_new ();
647 va_start (args, tag);
648 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, args);
655 * gst_tag_list_new_full_valist:
656 * @var_args: tag / value pairs to set
658 * Just like gst_tag_list_new_full(), only that it takes a va_list argument.
659 * Useful mostly for language bindings.
661 * Returns: a new #GstTagList. Free with gst_tag_list_free() when no longer
667 gst_tag_list_new_full_valist (va_list var_args)
672 list = gst_tag_list_new ();
674 tag = va_arg (var_args, gchar *);
675 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, var_args);
681 * gst_tag_list_is_empty:
682 * @list: A #GstTagList.
684 * Checks if the given taglist is empty.
686 * Returns: TRUE if the taglist is empty, otherwise FALSE.
691 gst_tag_list_is_empty (const GstTagList * list)
693 g_return_val_if_fail (list != NULL, FALSE);
694 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
696 return (gst_structure_n_fields ((GstStructure *) list) == 0);
701 * @p: Object that might be a taglist
703 * Checks if the given pointer is a taglist.
705 * Returns: TRUE, if the given pointer is a taglist
708 gst_is_tag_list (gconstpointer p)
710 GstStructure *s = (GstStructure *) p;
712 g_return_val_if_fail (p != NULL, FALSE);
714 return (GST_IS_STRUCTURE (s) && s->name == GST_QUARK (TAGLIST));
720 GstTagMergeMode mode;
725 gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode,
726 GQuark tag, const GValue * value, GstTagInfo * info)
728 const GValue *value2;
731 info = gst_tag_lookup (tag);
732 if (G_UNLIKELY (info == NULL)) {
733 g_warning ("unknown tag '%s'", g_quark_to_string (tag));
739 && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
740 GValue dest = { 0, };
743 case GST_TAG_MERGE_REPLACE_ALL:
744 case GST_TAG_MERGE_REPLACE:
745 gst_structure_id_set_value (list, tag, value);
747 case GST_TAG_MERGE_PREPEND:
748 gst_value_list_concat (&dest, value, value2);
749 gst_structure_id_set_value (list, tag, &dest);
750 g_value_unset (&dest);
752 case GST_TAG_MERGE_APPEND:
753 gst_value_list_concat (&dest, value2, value);
754 gst_structure_id_set_value (list, tag, &dest);
755 g_value_unset (&dest);
757 case GST_TAG_MERGE_KEEP:
758 case GST_TAG_MERGE_KEEP_ALL:
761 g_assert_not_reached ();
766 case GST_TAG_MERGE_APPEND:
767 case GST_TAG_MERGE_KEEP:
768 if (gst_structure_id_get_value (list, tag) != NULL)
771 case GST_TAG_MERGE_REPLACE_ALL:
772 case GST_TAG_MERGE_REPLACE:
773 case GST_TAG_MERGE_PREPEND:
774 gst_structure_id_set_value (list, tag, value);
776 case GST_TAG_MERGE_KEEP_ALL:
779 g_assert_not_reached ();
786 gst_tag_list_copy_foreach (GQuark tag, const GValue * value, gpointer user_data)
788 GstTagCopyData *copy = (GstTagCopyData *) user_data;
790 gst_tag_list_add_value_internal (copy->list, copy->mode, tag, value, NULL);
796 * gst_tag_list_insert:
797 * @into: list to merge into
798 * @from: list to merge from
799 * @mode: the mode to use
801 * Inserts the tags of the @from list into the first list using the given mode.
804 gst_tag_list_insert (GstTagList * into, const GstTagList * from,
805 GstTagMergeMode mode)
809 g_return_if_fail (GST_IS_TAG_LIST (into));
810 g_return_if_fail (GST_IS_TAG_LIST (from));
811 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
813 data.list = (GstStructure *) into;
815 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
816 gst_structure_remove_all_fields (data.list);
818 gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach,
824 * @list: list to copy
826 * Copies a given #GstTagList.
828 * Returns: copy of the given list
831 gst_tag_list_copy (const GstTagList * list)
833 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
835 return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list));
839 * gst_tag_list_merge:
840 * @list1: first list to merge
841 * @list2: second list to merge
842 * @mode: the mode to use
844 * Merges the two given lists into a new list. If one of the lists is NULL, a
845 * copy of the other is returned. If both lists are NULL, NULL is returned.
847 * Returns: the new list
850 gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
851 GstTagMergeMode mode)
853 GstTagList *list1_cp;
854 const GstTagList *list2_cp;
856 g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
857 g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
858 g_return_val_if_fail (GST_TAG_MODE_IS_VALID (mode), NULL);
860 /* nothing to merge */
861 if (!list1 && !list2) {
865 /* create empty list, we need to do this to correctly handling merge modes */
866 list1_cp = (list1) ? gst_tag_list_copy (list1) : gst_tag_list_new ();
867 list2_cp = (list2) ? list2 : gst_tag_list_new ();
869 gst_tag_list_insert (list1_cp, list2_cp, mode);
872 gst_tag_list_free ((GstTagList *) list2_cp);
879 * @list: the list to free
881 * Frees the given list and all associated values.
884 gst_tag_list_free (GstTagList * list)
886 g_return_if_fail (GST_IS_TAG_LIST (list));
887 gst_structure_free ((GstStructure *) list);
891 * gst_tag_list_get_tag_size:
893 * @tag: the tag to query
895 * Checks how many value are stored in this tag list for the given tag.
897 * Returns: The number of tags stored
900 gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag)
904 g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
906 value = gst_structure_get_value ((GstStructure *) list, tag);
909 if (G_VALUE_TYPE (value) != GST_TYPE_LIST)
912 return gst_value_list_get_size (value);
917 * @list: list to set tags in
918 * @mode: the mode to use
920 * @...: NULL-terminated list of values to set
922 * Sets the values for the given tags using the specified mode.
925 gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag,
930 g_return_if_fail (GST_IS_TAG_LIST (list));
931 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
932 g_return_if_fail (tag != NULL);
934 va_start (args, tag);
935 gst_tag_list_add_valist (list, mode, tag, args);
940 * gst_tag_list_add_values:
941 * @list: list to set tags in
942 * @mode: the mode to use
944 * @...: GValues to set
946 * Sets the GValues for the given tags using the specified mode.
949 gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode,
950 const gchar * tag, ...)
954 g_return_if_fail (GST_IS_TAG_LIST (list));
955 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
956 g_return_if_fail (tag != NULL);
958 va_start (args, tag);
959 gst_tag_list_add_valist_values (list, mode, tag, args);
964 * gst_tag_list_add_valist:
965 * @list: list to set tags in
966 * @mode: the mode to use
968 * @var_args: tag / value pairs to set
970 * Sets the values for the given tags using the specified mode.
973 gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
974 const gchar * tag, va_list var_args)
980 g_return_if_fail (GST_IS_TAG_LIST (list));
981 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
982 g_return_if_fail (tag != NULL);
984 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
985 gst_structure_remove_all_fields (list);
988 while (tag != NULL) {
989 GValue value = { 0, };
991 quark = g_quark_from_string (tag);
992 info = gst_tag_lookup (quark);
993 if (G_UNLIKELY (info == NULL)) {
994 g_warning ("unknown tag '%s'", tag);
997 #if GLIB_CHECK_VERSION(2,23,3)
998 G_VALUE_COLLECT_INIT (&value, info->type, var_args, 0, &error);
1000 g_value_init (&value, info->type);
1001 G_VALUE_COLLECT (&value, var_args, 0, &error);
1004 g_warning ("%s: %s", G_STRLOC, error);
1006 /* we purposely leak the value here, it might not be
1007 * in a sane state if an error condition occoured
1011 gst_tag_list_add_value_internal (list, mode, quark, &value, info);
1012 g_value_unset (&value);
1013 tag = va_arg (var_args, gchar *);
1018 * gst_tag_list_add_valist_values:
1019 * @list: list to set tags in
1020 * @mode: the mode to use
1022 * @var_args: tag / GValue pairs to set
1024 * Sets the GValues for the given tags using the specified mode.
1027 gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
1028 const gchar * tag, va_list var_args)
1032 g_return_if_fail (GST_IS_TAG_LIST (list));
1033 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1034 g_return_if_fail (tag != NULL);
1036 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1037 gst_structure_remove_all_fields (list);
1040 while (tag != NULL) {
1041 quark = g_quark_from_string (tag);
1042 g_return_if_fail (gst_tag_lookup (quark) != NULL);
1043 gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args,
1045 tag = va_arg (var_args, gchar *);
1050 * gst_tag_list_add_value:
1051 * @list: list to set tags in
1052 * @mode: the mode to use
1054 * @value: GValue for this tag
1056 * Sets the GValue for a given tag using the specified mode.
1061 gst_tag_list_add_value (GstTagList * list, GstTagMergeMode mode,
1062 const gchar * tag, const GValue * value)
1064 g_return_if_fail (GST_IS_TAG_LIST (list));
1065 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1066 g_return_if_fail (tag != NULL);
1068 gst_tag_list_add_value_internal (list, mode, g_quark_from_string (tag),
1073 * gst_tag_list_remove_tag:
1074 * @list: list to remove tag from
1075 * @tag: tag to remove
1077 * Removes the given tag from the taglist.
1080 gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
1082 g_return_if_fail (GST_IS_TAG_LIST (list));
1083 g_return_if_fail (tag != NULL);
1085 gst_structure_remove_field ((GstStructure *) list, tag);
1090 GstTagForeachFunc func;
1091 const GstTagList *tag_list;
1097 structure_foreach_wrapper (GQuark field_id, const GValue * value,
1100 TagForeachData *data = (TagForeachData *) user_data;
1102 data->func (data->tag_list, g_quark_to_string (field_id), data->data);
1107 * gst_tag_list_foreach:
1108 * @list: list to iterate over
1109 * @func: function to be called for each tag
1110 * @user_data: user specified data
1112 * Calls the given function for each tag inside the tag list. Note that if there
1113 * is no tag, the function won't be called at all.
1116 gst_tag_list_foreach (const GstTagList * list, GstTagForeachFunc func,
1119 TagForeachData data;
1121 g_return_if_fail (GST_IS_TAG_LIST (list));
1122 g_return_if_fail (func != NULL);
1125 data.tag_list = list;
1126 data.data = user_data;
1127 gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper,
1132 * gst_tag_list_get_value_index:
1133 * @list: a #GstTagList
1134 * @tag: tag to read out
1135 * @index: number of entry to read out
1137 * Gets the value that is at the given index for the given tag in the given
1140 * Returns: The GValue for the specified entry or NULL if the tag wasn't
1141 * available or the tag doesn't have as many entries
1143 G_CONST_RETURN GValue *
1144 gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
1147 const GValue *value;
1149 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
1150 g_return_val_if_fail (tag != NULL, NULL);
1152 value = gst_structure_get_value ((GstStructure *) list, tag);
1156 if (GST_VALUE_HOLDS_LIST (value)) {
1157 if (index >= gst_value_list_get_size (value))
1159 return gst_value_list_get_value (value, index);
1168 * gst_tag_list_copy_value:
1169 * @dest: uninitialized #GValue to copy into
1170 * @list: list to get the tag from
1171 * @tag: tag to read out
1173 * Copies the contents for the given tag into the value,
1174 * merging multiple values into one if multiple values are associated
1176 * You must g_value_unset() the value after use.
1178 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1182 gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
1187 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1188 g_return_val_if_fail (tag != NULL, FALSE);
1189 g_return_val_if_fail (dest != NULL, FALSE);
1190 g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
1192 src = gst_structure_get_value ((GstStructure *) list, tag);
1196 if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
1197 GstTagInfo *info = gst_tag_lookup (g_quark_from_string (tag));
1202 /* must be there or lists aren't allowed */
1203 g_assert (info->merge_func);
1204 info->merge_func (dest, src);
1206 g_value_init (dest, G_VALUE_TYPE (src));
1207 g_value_copy (src, dest);
1212 /* FIXME 0.11: this whole merge function business is overdesigned, and the
1213 * _get_foo() API is misleading as well - how many application developers will
1214 * expect gst_tag_list_get_string (list, GST_TAG_ARTIST, &val) might return a
1215 * string with multiple comma-separated artists? _get_foo() should just be
1216 * a convenience wrapper around _get_foo_index (list, tag, 0, &val),
1217 * supplemented by a special _tag_list_get_string_merged() function if needed
1218 * (unless someone can actually think of real use cases where the merge
1219 * function is not 'use first' for non-strings and merge for strings) */
1221 /***** evil macros to get all the gst_tag_list_get_*() functions right *****/
1223 #define TAG_MERGE_FUNCS(name,type,ret) \
1225 gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
1228 GValue v = { 0, }; \
1230 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1231 g_return_val_if_fail (tag != NULL, FALSE); \
1232 g_return_val_if_fail (value != NULL, FALSE); \
1234 if (!gst_tag_list_copy_value (&v, list, tag)) \
1236 *value = COPY_FUNC (g_value_get_ ## name (&v)); \
1237 g_value_unset (&v); \
1242 gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
1244 guint index, type *value) \
1248 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1249 g_return_val_if_fail (tag != NULL, FALSE); \
1250 g_return_val_if_fail (value != NULL, FALSE); \
1252 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
1254 *value = COPY_FUNC (g_value_get_ ## name (v)); \
1258 /* FIXME 0.11: maybe get rid of _get_char*(), _get_uchar*(), _get_long*(),
1259 * _get_ulong*() and _get_pointer*()? - they are not really useful/common
1260 * enough to warrant convenience accessor functions */
1262 #define COPY_FUNC /**/
1264 * gst_tag_list_get_char:
1265 * @list: a #GstTagList to get the tag from
1266 * @tag: tag to read out
1267 * @value: location for the result
1269 * Copies the contents for the given tag into the value, merging multiple values
1270 * into one if multiple values are associated with the tag.
1272 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1276 * gst_tag_list_get_char_index:
1277 * @list: a #GstTagList to get the tag from
1278 * @tag: tag to read out
1279 * @index: number of entry to read out
1280 * @value: location for the result
1282 * Gets the value that is at the given index for the given tag in the given
1285 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1288 TAG_MERGE_FUNCS (char, gchar, TRUE)
1290 * gst_tag_list_get_uchar:
1291 * @list: a #GstTagList to get the tag from
1292 * @tag: tag to read out
1293 * @value: location for the result
1295 * Copies the contents for the given tag into the value, merging multiple values
1296 * into one if multiple values are associated with the tag.
1298 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1302 * gst_tag_list_get_uchar_index:
1303 * @list: a #GstTagList to get the tag from
1304 * @tag: tag to read out
1305 * @index: number of entry to read out
1306 * @value: location for the result
1308 * Gets the value that is at the given index for the given tag in the given
1311 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1314 TAG_MERGE_FUNCS (uchar, guchar, TRUE)
1316 * gst_tag_list_get_boolean:
1317 * @list: a #GstTagList to get the tag from
1318 * @tag: tag to read out
1319 * @value: location for the result
1321 * Copies the contents for the given tag into the value, merging multiple values
1322 * into one if multiple values are associated with the tag.
1324 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1328 * gst_tag_list_get_boolean_index:
1329 * @list: a #GstTagList to get the tag from
1330 * @tag: tag to read out
1331 * @index: number of entry to read out
1332 * @value: location for the result
1334 * Gets the value that is at the given index for the given tag in the given
1337 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1340 TAG_MERGE_FUNCS (boolean, gboolean, TRUE)
1342 * gst_tag_list_get_int:
1343 * @list: a #GstTagList to get the tag from
1344 * @tag: tag to read out
1345 * @value: location for the result
1347 * Copies the contents for the given tag into the value, merging multiple values
1348 * into one if multiple values are associated with the tag.
1350 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1354 * gst_tag_list_get_int_index:
1355 * @list: a #GstTagList to get the tag from
1356 * @tag: tag to read out
1357 * @index: number of entry to read out
1358 * @value: location for the result
1360 * Gets the value that is at the given index for the given tag in the given
1363 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1366 TAG_MERGE_FUNCS (int, gint, TRUE)
1368 * gst_tag_list_get_uint:
1369 * @list: a #GstTagList to get the tag from
1370 * @tag: tag to read out
1371 * @value: location for the result
1373 * Copies the contents for the given tag into the value, merging multiple values
1374 * into one if multiple values are associated with the tag.
1376 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1380 * gst_tag_list_get_uint_index:
1381 * @list: a #GstTagList to get the tag from
1382 * @tag: tag to read out
1383 * @index: number of entry to read out
1384 * @value: location for the result
1386 * Gets the value that is at the given index for the given tag in the given
1389 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1392 TAG_MERGE_FUNCS (uint, guint, TRUE)
1394 * gst_tag_list_get_long:
1395 * @list: a #GstTagList to get the tag from
1396 * @tag: tag to read out
1397 * @value: location for the result
1399 * Copies the contents for the given tag into the value, merging multiple values
1400 * into one if multiple values are associated with the tag.
1402 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1406 * gst_tag_list_get_long_index:
1407 * @list: a #GstTagList to get the tag from
1408 * @tag: tag to read out
1409 * @index: number of entry to read out
1410 * @value: location for the result
1412 * Gets the value that is at the given index for the given tag in the given
1415 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1418 TAG_MERGE_FUNCS (long, glong, TRUE)
1420 * gst_tag_list_get_ulong:
1421 * @list: a #GstTagList to get the tag from
1422 * @tag: tag to read out
1423 * @value: location for the result
1425 * Copies the contents for the given tag into the value, merging multiple values
1426 * into one if multiple values are associated with the tag.
1428 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1432 * gst_tag_list_get_ulong_index:
1433 * @list: a #GstTagList to get the tag from
1434 * @tag: tag to read out
1435 * @index: number of entry to read out
1436 * @value: location for the result
1438 * Gets the value that is at the given index for the given tag in the given
1441 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1444 TAG_MERGE_FUNCS (ulong, gulong, TRUE)
1446 * gst_tag_list_get_int64:
1447 * @list: a #GstTagList to get the tag from
1448 * @tag: tag to read out
1449 * @value: location for the result
1451 * Copies the contents for the given tag into the value, merging multiple values
1452 * into one if multiple values are associated with the tag.
1454 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1458 * gst_tag_list_get_int64_index:
1459 * @list: a #GstTagList to get the tag from
1460 * @tag: tag to read out
1461 * @index: number of entry to read out
1462 * @value: location for the result
1464 * Gets the value that is at the given index for the given tag in the given
1467 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1470 TAG_MERGE_FUNCS (int64, gint64, TRUE)
1472 * gst_tag_list_get_uint64:
1473 * @list: a #GstTagList to get the tag from
1474 * @tag: tag to read out
1475 * @value: location for the result
1477 * Copies the contents for the given tag into the value, merging multiple values
1478 * into one if multiple values are associated with the tag.
1480 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1484 * gst_tag_list_get_uint64_index:
1485 * @list: a #GstTagList to get the tag from
1486 * @tag: tag to read out
1487 * @index: number of entry to read out
1488 * @value: location for the result
1490 * Gets the value that is at the given index for the given tag in the given
1493 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1496 TAG_MERGE_FUNCS (uint64, guint64, TRUE)
1498 * gst_tag_list_get_float:
1499 * @list: a #GstTagList to get the tag from
1500 * @tag: tag to read out
1501 * @value: location for the result
1503 * Copies the contents for the given tag into the value, merging multiple values
1504 * into one if multiple values are associated with the tag.
1506 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1510 * gst_tag_list_get_float_index:
1511 * @list: a #GstTagList to get the tag from
1512 * @tag: tag to read out
1513 * @index: number of entry to read out
1514 * @value: location for the result
1516 * Gets the value that is at the given index for the given tag in the given
1519 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1522 TAG_MERGE_FUNCS (float, gfloat, TRUE)
1524 * gst_tag_list_get_double:
1525 * @list: a #GstTagList to get the tag from
1526 * @tag: tag to read out
1527 * @value: location for the result
1529 * Copies the contents for the given tag into the value, merging multiple values
1530 * into one if multiple values are associated with the tag.
1532 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1536 * gst_tag_list_get_double_index:
1537 * @list: a #GstTagList to get the tag from
1538 * @tag: tag to read out
1539 * @index: number of entry to read out
1540 * @value: location for the result
1542 * Gets the value that is at the given index for the given tag in the given
1545 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1548 TAG_MERGE_FUNCS (double, gdouble, TRUE)
1550 * gst_tag_list_get_pointer:
1551 * @list: a #GstTagList to get the tag from
1552 * @tag: tag to read out
1553 * @value: location for the result
1555 * Copies the contents for the given tag into the value, merging multiple values
1556 * into one if multiple values are associated with the tag.
1558 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1562 * gst_tag_list_get_pointer_index:
1563 * @list: a #GstTagList to get the tag from
1564 * @tag: tag to read out
1565 * @index: number of entry to read out
1566 * @value: location for the result
1568 * Gets the value that is at the given index for the given tag in the given
1571 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1574 TAG_MERGE_FUNCS (pointer, gpointer, (*value != NULL))
1576 #define COPY_FUNC g_strdup
1578 * gst_tag_list_get_string:
1579 * @list: a #GstTagList to get the tag from
1580 * @tag: tag to read out
1581 * @value: location for the result
1583 * Copies the contents for the given tag into the value, possibly merging
1584 * multiple values into one if multiple values are associated with the tag.
1586 * Use gst_tag_list_get_string_index (list, tag, 0, value) if you want
1587 * to retrieve the first string associated with this tag unmodified.
1589 * The resulting string in @value will be in UTF-8 encoding and should be
1590 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1591 * returned string is also guaranteed to be non-NULL and non-empty.
1593 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1597 * gst_tag_list_get_string_index:
1598 * @list: a #GstTagList to get the tag from
1599 * @tag: tag to read out
1600 * @index: number of entry to read out
1601 * @value: location for the result
1603 * Gets the value that is at the given index for the given tag in the given
1606 * The resulting string in @value will be in UTF-8 encoding and should be
1607 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1608 * returned string is also guaranteed to be non-NULL and non-empty.
1610 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1613 TAG_MERGE_FUNCS (string, gchar *, (*value != NULL && **value != '\0'))
1616 *FIXME 0.11: Instead of _peek (non-copy) and _get (copy), we could have
1617 * _get (non-copy) and _dup (copy) for strings, seems more
1621 * gst_tag_list_peek_string_index:
1622 * @list: a #GstTagList to get the tag from
1623 * @tag: tag to read out
1624 * @index: number of entry to read out
1625 * @value: location for the result
1627 * Peeks at the value that is at the given index for the given tag in the given
1630 * The resulting string in @value will be in UTF-8 encoding and doesn't need
1631 * to be freed by the caller. The returned string is also guaranteed to
1632 * be non-NULL and non-empty.
1634 * Returns: TRUE, if a value was set, FALSE if the tag didn't exist in the
1638 gst_tag_list_peek_string_index (const GstTagList * list,
1639 const gchar * tag, guint index, const gchar ** value)
1643 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1644 g_return_val_if_fail (tag != NULL, FALSE);
1645 g_return_val_if_fail (value != NULL, FALSE);
1647 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1649 *value = g_value_get_string (v);
1650 return *value != NULL && **value != '\0';
1654 * gst_tag_list_get_date:
1655 * @list: a #GstTagList to get the tag from
1656 * @tag: tag to read out
1657 * @value: address of a GDate pointer variable to store the result into
1659 * Copies the first date for the given tag in the taglist into the variable
1660 * pointed to by @value. Free the date with g_date_free() when it is no longer
1663 * Returns: TRUE, if a date was copied, FALSE if the tag didn't exist in the
1664 * given list or if it was #NULL.
1667 gst_tag_list_get_date (const GstTagList * list, const gchar * tag,
1672 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1673 g_return_val_if_fail (tag != NULL, FALSE);
1674 g_return_val_if_fail (value != NULL, FALSE);
1676 if (!gst_tag_list_copy_value (&v, list, tag))
1678 *value = (GDate *) g_value_dup_boxed (&v);
1680 return (*value != NULL);
1684 * gst_tag_list_get_date_index:
1685 * @list: a #GstTagList to get the tag from
1686 * @tag: tag to read out
1687 * @index: number of entry to read out
1688 * @value: location for the result
1690 * Gets the date that is at the given index for the given tag in the given
1691 * list and copies it into the variable pointed to by @value. Free the date
1692 * with g_date_free() when it is no longer needed.
1694 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1695 * given list or if it was #NULL.
1698 gst_tag_list_get_date_index (const GstTagList * list,
1699 const gchar * tag, guint index, GDate ** value)
1703 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1704 g_return_val_if_fail (tag != NULL, FALSE);
1705 g_return_val_if_fail (value != NULL, FALSE);
1707 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1709 *value = (GDate *) g_value_dup_boxed (v);
1710 return (*value != NULL);
1714 * gst_tag_list_get_date_time:
1715 * @list: a #GstTagList to get the tag from
1716 * @tag: tag to read out
1717 * @value: address of a #GstDateTime pointer variable to store the result into
1719 * Copies the first datetime for the given tag in the taglist into the variable
1720 * pointed to by @value. Unref the date with gst_date_time_unref() when
1721 * it is no longer needed.
1723 * Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in the
1724 * given list or if it was #NULL.
1728 gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag,
1729 GstDateTime ** value)
1733 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1734 g_return_val_if_fail (tag != NULL, FALSE);
1735 g_return_val_if_fail (value != NULL, FALSE);
1737 if (!gst_tag_list_copy_value (&v, list, tag))
1740 g_return_val_if_fail (GST_VALUE_HOLDS_DATE_TIME (&v), FALSE);
1742 *value = (GstDateTime *) g_value_dup_boxed (&v);
1744 return (*value != NULL);
1748 * gst_tag_list_get_date_time_index:
1749 * @list: a #GstTagList to get the tag from
1750 * @tag: tag to read out
1751 * @index: number of entry to read out
1752 * @value: location for the result
1754 * Gets the datetime that is at the given index for the given tag in the given
1755 * list and copies it into the variable pointed to by @value. Unref the datetime
1756 * with gst_date_time_unref() when it is no longer needed.
1758 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1759 * given list or if it was #NULL.
1763 gst_tag_list_get_date_time_index (const GstTagList * list,
1764 const gchar * tag, guint index, GstDateTime ** value)
1768 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1769 g_return_val_if_fail (tag != NULL, FALSE);
1770 g_return_val_if_fail (value != NULL, FALSE);
1772 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1774 *value = (GstDateTime *) g_value_dup_boxed (v);
1775 return (*value != NULL);
1779 * gst_tag_list_get_buffer:
1780 * @list: a #GstTagList to get the tag from
1781 * @tag: tag to read out
1782 * @value: address of a GstBuffer pointer variable to store the result into
1784 * Copies the first buffer for the given tag in the taglist into the variable
1785 * pointed to by @value. Free the buffer with gst_buffer_unref() when it is
1788 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1789 * given list or if it was #NULL.
1794 gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag,
1799 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1800 g_return_val_if_fail (tag != NULL, FALSE);
1801 g_return_val_if_fail (value != NULL, FALSE);
1803 if (!gst_tag_list_copy_value (&v, list, tag))
1805 *value = (GstBuffer *) gst_value_dup_mini_object (&v);
1807 return (*value != NULL);
1811 * gst_tag_list_get_buffer_index:
1812 * @list: a #GstTagList to get the tag from
1813 * @tag: tag to read out
1814 * @index: number of entry to read out
1815 * @value: address of a GstBuffer pointer variable to store the result into
1817 * Gets the buffer that is at the given index for the given tag in the given
1818 * list and copies it into the variable pointed to by @value. Free the buffer
1819 * with gst_buffer_unref() when it is no longer needed.
1821 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1822 * given list or if it was #NULL.
1827 gst_tag_list_get_buffer_index (const GstTagList * list,
1828 const gchar * tag, guint index, GstBuffer ** value)
1832 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1833 g_return_val_if_fail (tag != NULL, FALSE);
1834 g_return_val_if_fail (value != NULL, FALSE);
1836 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1838 *value = (GstBuffer *) gst_value_dup_mini_object (v);
1839 return (*value != NULL);