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 "math-compat.h"
39 #include "gst-i18n-lib.h"
40 #include "gsttaglist.h"
43 #include "gstbuffer.h"
45 #include "gststructure.h"
47 #include <gobject/gvaluecollector.h>
50 #define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL)
52 /* FIXME 0.11: make taglists refcounted maybe? */
53 /* a tag list is basically a structure, but we don't make this fact public */
56 GstStructure structure;
59 /* FIXME 0.11: use GParamSpecs or something similar for tag registrations,
60 * possibly even gst_tag_register(). Especially value ranges might be
61 * useful for some tags. */
65 GType type; /* type the data is in */
67 gchar *nick; /* translated name */
68 gchar *blurb; /* translated description of type */
70 GstTagMergeFunc merge_func; /* functions to merge the values */
71 GstTagFlag flag; /* type of tag */
72 GQuark name_quark; /* quark for the name */
76 #define g_value_get_char g_value_get_schar
78 static GMutex __tag_mutex;
79 #define TAG_LOCK g_mutex_lock (&__tag_mutex)
80 #define TAG_UNLOCK g_mutex_unlock (&__tag_mutex)
82 /* tags hash table: maps tag name string => GstTagInfo */
83 static GHashTable *__tags;
86 gst_tag_list_get_type (void)
88 static GType _gst_tag_list_type = 0;
90 if (G_UNLIKELY (_gst_tag_list_type == 0)) {
91 _gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
92 (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
95 g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
96 _gst_structure_transform_to_string);
100 return _gst_tag_list_type;
104 _priv_gst_tag_initialize (void)
106 g_mutex_init (&__tag_mutex);
108 __tags = g_hash_table_new (g_str_hash, g_str_equal);
109 gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META,
111 _("title"), _("commonly used title"), gst_tag_merge_strings_with_comma);
112 gst_tag_register (GST_TAG_TITLE_SORTNAME, GST_TAG_FLAG_META,
114 _("title sortname"), _("commonly used title for sorting purposes"), NULL);
115 gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META,
118 _("person(s) responsible for the recording"),
119 gst_tag_merge_strings_with_comma);
120 gst_tag_register (GST_TAG_ARTIST_SORTNAME, GST_TAG_FLAG_META,
122 _("artist sortname"),
123 _("person(s) responsible for the recording for sorting purposes"), NULL);
124 gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META,
127 _("album containing this data"), gst_tag_merge_strings_with_comma);
128 gst_tag_register (GST_TAG_ALBUM_SORTNAME, GST_TAG_FLAG_META,
131 _("album containing this data for sorting purposes"), NULL);
132 gst_tag_register (GST_TAG_ALBUM_ARTIST, GST_TAG_FLAG_META,
135 _("The artist of the entire album, as it should be displayed"),
136 gst_tag_merge_strings_with_comma);
137 gst_tag_register (GST_TAG_ALBUM_ARTIST_SORTNAME, GST_TAG_FLAG_META,
139 _("album artist sortname"),
140 _("The artist of the entire album, as it should be sorted"), NULL);
141 gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_DATE,
142 _("date"), _("date the data was created (as a GDate structure)"), NULL);
143 gst_tag_register (GST_TAG_DATE_TIME, GST_TAG_FLAG_META, G_TYPE_DATE_TIME,
145 _("date and time the data was created (as a GstDateTime structure)"),
147 gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META,
150 _("genre this data belongs to"), gst_tag_merge_strings_with_comma);
151 gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META,
154 _("free text commenting the data"), gst_tag_merge_use_first);
155 gst_tag_register (GST_TAG_EXTENDED_COMMENT, GST_TAG_FLAG_META,
157 _("extended comment"),
158 _("free text commenting the data in key=value or key[en]=comment form"),
159 gst_tag_merge_use_first);
160 gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META,
163 _("track number inside a collection"), gst_tag_merge_use_first);
164 gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META,
167 _("count of tracks inside collection this track belongs to"),
168 gst_tag_merge_use_first);
169 gst_tag_register (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META,
172 _("disc number inside a collection"), gst_tag_merge_use_first);
173 gst_tag_register (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META,
176 _("count of discs inside collection this disc belongs to"),
177 gst_tag_merge_use_first);
178 gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META,
180 _("location"), _("Origin of media as a URI (location, where the "
181 "original of the file or stream is hosted)"),
182 gst_tag_merge_strings_with_comma);
183 gst_tag_register (GST_TAG_HOMEPAGE, GST_TAG_FLAG_META,
186 _("Homepage for this media (i.e. artist or movie homepage)"),
187 gst_tag_merge_strings_with_comma);
188 gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META, G_TYPE_STRING,
189 _("description"), _("short text describing the content of the data"),
190 gst_tag_merge_strings_with_comma);
191 gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META, G_TYPE_STRING,
192 _("version"), _("version of this data"), NULL);
193 gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META, G_TYPE_STRING, _("ISRC"),
195 ("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
197 /* FIXME: organization (fix what? tpm) */
198 gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING,
199 _("organization"), _("organization"), gst_tag_merge_strings_with_comma);
200 gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
201 G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL);
202 gst_tag_register (GST_TAG_COPYRIGHT_URI, GST_TAG_FLAG_META,
203 G_TYPE_STRING, _("copyright uri"),
204 _("URI to the copyright notice of the data"), NULL);
205 gst_tag_register (GST_TAG_ENCODED_BY, GST_TAG_FLAG_META, G_TYPE_STRING,
206 _("encoded by"), _("name of the encoding person or organization"),
207 gst_tag_merge_strings_with_comma);
208 gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META,
210 _("contact"), _("contact information"), gst_tag_merge_strings_with_comma);
211 gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META,
212 G_TYPE_STRING, _("license"), _("license of data"), NULL);
213 gst_tag_register (GST_TAG_LICENSE_URI, GST_TAG_FLAG_META,
214 G_TYPE_STRING, _("license uri"),
215 _("URI to the license of the data"), NULL);
216 gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META,
219 _("person(s) performing"), gst_tag_merge_strings_with_comma);
220 gst_tag_register (GST_TAG_COMPOSER, GST_TAG_FLAG_META,
223 _("person(s) who composed the recording"),
224 gst_tag_merge_strings_with_comma);
225 gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED,
227 _("duration"), _("length in GStreamer time units (nanoseconds)"), NULL);
228 gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED,
231 _("codec the data is stored in"), gst_tag_merge_strings_with_comma);
232 gst_tag_register (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED,
234 _("video codec"), _("codec the video data is stored in"), NULL);
235 gst_tag_register (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED,
237 _("audio codec"), _("codec the audio data is stored in"), NULL);
238 gst_tag_register (GST_TAG_SUBTITLE_CODEC, GST_TAG_FLAG_ENCODED,
240 _("subtitle codec"), _("codec the subtitle data is stored in"), NULL);
241 gst_tag_register (GST_TAG_CONTAINER_FORMAT, GST_TAG_FLAG_ENCODED,
242 G_TYPE_STRING, _("container format"),
243 _("container format the data is stored in"), NULL);
244 gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED,
245 G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL);
246 gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED,
247 G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL);
248 gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
249 G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL);
250 gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
251 G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL);
252 gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED,
254 _("encoder"), _("encoder used to encode this stream"), NULL);
255 gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED,
257 _("encoder version"),
258 _("version of the encoder used to encode this stream"), NULL);
259 gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED,
260 G_TYPE_UINT, _("serial"), _("serial number of track"), NULL);
261 gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META,
262 G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL);
263 gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META,
264 G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL);
265 gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META,
266 G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL);
267 gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
268 G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL);
269 gst_tag_register (GST_TAG_REFERENCE_LEVEL, GST_TAG_FLAG_META,
270 G_TYPE_DOUBLE, _("replaygain reference level"),
271 _("reference level of track and album gain values"), NULL);
272 gst_tag_register (GST_TAG_LANGUAGE_CODE, GST_TAG_FLAG_META, G_TYPE_STRING,
274 _("language code for this stream, conforming to ISO-639-1 or ISO-639-2"),
276 gst_tag_register (GST_TAG_LANGUAGE_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
278 _("freeform name of the language this stream is in"), NULL);
279 gst_tag_register (GST_TAG_IMAGE, GST_TAG_FLAG_META, GST_TYPE_SAMPLE,
280 _("image"), _("image related to this stream"), gst_tag_merge_use_first);
281 gst_tag_register (GST_TAG_PREVIEW_IMAGE, GST_TAG_FLAG_META, GST_TYPE_SAMPLE,
282 /* TRANSLATORS: 'preview image' = image that shows a preview of the full image */
283 _("preview image"), _("preview image related to this stream"), NULL);
284 gst_tag_register (GST_TAG_ATTACHMENT, GST_TAG_FLAG_META, GST_TYPE_SAMPLE,
285 _("attachment"), _("file attached to this stream"),
286 gst_tag_merge_use_first);
287 gst_tag_register (GST_TAG_BEATS_PER_MINUTE, GST_TAG_FLAG_META, G_TYPE_DOUBLE,
288 _("beats per minute"), _("number of beats per minute in audio"), NULL);
289 gst_tag_register (GST_TAG_KEYWORDS, GST_TAG_FLAG_META, G_TYPE_STRING,
290 _("keywords"), _("comma separated keywords describing the content"),
291 gst_tag_merge_strings_with_comma);
292 gst_tag_register (GST_TAG_GEO_LOCATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
293 _("geo location name"), _("human readable descriptive location of where "
294 "the media has been recorded or produced"), NULL);
295 gst_tag_register (GST_TAG_GEO_LOCATION_LATITUDE, GST_TAG_FLAG_META,
296 G_TYPE_DOUBLE, _("geo location latitude"),
297 _("geo latitude location of where the media has been recorded or "
298 "produced in degrees according to WGS84 (zero at the equator, "
299 "negative values for southern latitudes)"), NULL);
300 gst_tag_register (GST_TAG_GEO_LOCATION_LONGITUDE, GST_TAG_FLAG_META,
301 G_TYPE_DOUBLE, _("geo location longitude"),
302 _("geo longitude location of where the media has been recorded or "
303 "produced in degrees according to WGS84 (zero at the prime meridian "
304 "in Greenwich/UK, negative values for western longitudes)"), NULL);
305 gst_tag_register (GST_TAG_GEO_LOCATION_ELEVATION, GST_TAG_FLAG_META,
306 G_TYPE_DOUBLE, _("geo location elevation"),
307 _("geo elevation of where the media has been recorded or produced in "
308 "meters according to WGS84 (zero is average sea level)"), NULL);
309 gst_tag_register (GST_TAG_GEO_LOCATION_COUNTRY, GST_TAG_FLAG_META,
310 G_TYPE_STRING, _("geo location country"),
311 _("country (english name) where the media has been recorded "
312 "or produced"), NULL);
313 gst_tag_register (GST_TAG_GEO_LOCATION_CITY, GST_TAG_FLAG_META,
314 G_TYPE_STRING, _("geo location city"),
315 _("city (english name) where the media has been recorded "
316 "or produced"), NULL);
317 gst_tag_register (GST_TAG_GEO_LOCATION_SUBLOCATION, GST_TAG_FLAG_META,
318 G_TYPE_STRING, _("geo location sublocation"),
319 _("a location whithin a city where the media has been produced "
320 "or created (e.g. the neighborhood)"), NULL);
321 gst_tag_register (GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, GST_TAG_FLAG_META,
322 G_TYPE_DOUBLE, _("geo location horizontal error"),
323 _("expected error of the horizontal positioning measures (in meters)"),
325 gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, GST_TAG_FLAG_META,
326 G_TYPE_DOUBLE, _("geo location movement speed"),
327 _("movement speed of the capturing device while performing the capture "
329 gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, GST_TAG_FLAG_META,
330 G_TYPE_DOUBLE, _("geo location movement direction"),
331 _("indicates the movement direction of the device performing the capture"
332 " of a media. It is represented as degrees in floating point "
333 "representation, 0 means the geographic north, and increases "
335 gst_tag_register (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, GST_TAG_FLAG_META,
336 G_TYPE_DOUBLE, _("geo location capture direction"),
337 _("indicates the direction the device is pointing to when capturing "
338 " a media. It is represented as degrees in floating point "
339 " representation, 0 means the geographic north, and increases "
341 gst_tag_register (GST_TAG_SHOW_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
342 /* TRANSLATORS: 'show name' = 'TV/radio/podcast show name' here */
344 _("Name of the tv/podcast/series show the media is from"),
345 gst_tag_merge_strings_with_comma);
346 gst_tag_register (GST_TAG_SHOW_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING,
347 /* TRANSLATORS: 'show sortname' = 'TV/radio/podcast show name as used for sorting purposes' here */
349 _("Name of the tv/podcast/series show the media is from, for sorting "
351 gst_tag_register (GST_TAG_SHOW_EPISODE_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT,
353 _("The episode number in the season the media is part of"),
354 gst_tag_merge_use_first);
355 gst_tag_register (GST_TAG_SHOW_SEASON_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT,
357 _("The season number of the show the media is part of"),
358 gst_tag_merge_use_first);
359 gst_tag_register (GST_TAG_LYRICS, GST_TAG_FLAG_META, G_TYPE_STRING,
360 _("lyrics"), _("The lyrics of the media, commonly used for songs"),
361 gst_tag_merge_strings_with_comma);
362 gst_tag_register (GST_TAG_COMPOSER_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING,
363 _("composer sortname"),
364 _("person(s) who composed the recording, for sorting purposes"), NULL);
365 gst_tag_register (GST_TAG_GROUPING, GST_TAG_FLAG_META, G_TYPE_STRING,
367 _("Groups related media that spans multiple tracks, like the different "
368 "pieces of a concerto. It is a higher level than a track, "
369 "but lower than an album"), NULL);
370 gst_tag_register (GST_TAG_USER_RATING, GST_TAG_FLAG_META, G_TYPE_UINT,
372 _("Rating attributed by a user. The higher the rank, "
373 "the more the user likes this media"), NULL);
374 gst_tag_register (GST_TAG_DEVICE_MANUFACTURER, GST_TAG_FLAG_META,
375 G_TYPE_STRING, _("device manufacturer"),
376 _("Manufacturer of the device used to create this media"), NULL);
377 gst_tag_register (GST_TAG_DEVICE_MODEL, GST_TAG_FLAG_META, G_TYPE_STRING,
379 _("Model of the device used to create this media"), NULL);
380 gst_tag_register (GST_TAG_APPLICATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
381 _("application name"), _("Application used to create the media"), NULL);
382 gst_tag_register (GST_TAG_APPLICATION_DATA, GST_TAG_FLAG_META,
383 GST_TYPE_BUFFER, _("application data"),
384 _("Arbitrary application data to be serialized into the media"), NULL);
385 gst_tag_register (GST_TAG_IMAGE_ORIENTATION, GST_TAG_FLAG_META, G_TYPE_STRING,
386 _("image orientation"),
387 _("How the image should be rotated or flipped before display"), NULL);
391 * gst_tag_merge_use_first:
392 * @dest: (out caller-allocates): uninitialized GValue to store result in
393 * @src: GValue to copy from
395 * This is a convenience function for the func argument of gst_tag_register().
396 * It creates a copy of the first value from the list.
399 gst_tag_merge_use_first (GValue * dest, const GValue * src)
401 const GValue *ret = gst_value_list_get_value (src, 0);
403 g_value_init (dest, G_VALUE_TYPE (ret));
404 g_value_copy (ret, dest);
408 * gst_tag_merge_strings_with_comma:
409 * @dest: (out caller-allocates): uninitialized GValue to store result in
410 * @src: GValue to copy from
412 * This is a convenience function for the func argument of gst_tag_register().
413 * It concatenates all given strings using a comma. The tag must be registered
414 * as a G_TYPE_STRING or this function will fail.
417 gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src)
422 count = gst_value_list_get_size (src);
423 str = g_string_new (g_value_get_string (gst_value_list_get_value (src, 0)));
424 for (i = 1; i < count; i++) {
425 /* separator between two strings */
426 g_string_append (str, _(", "));
427 g_string_append (str,
428 g_value_get_string (gst_value_list_get_value (src, i)));
431 g_value_init (dest, G_TYPE_STRING);
432 g_value_take_string (dest, str->str);
433 g_string_free (str, FALSE);
437 gst_tag_lookup (const gchar * tag_name)
442 ret = g_hash_table_lookup (__tags, (gpointer) tag_name);
450 * @name: the name or identifier string
451 * @flag: a flag describing the type of tag info
452 * @type: the type this data is in
453 * @nick: human-readable name
454 * @blurb: a human-readable description about this tag
455 * @func: function for merging multiple values of this tag, or NULL
457 * Registers a new tag type for the use with GStreamer's type system. If a type
458 * with that name is already registered, that one is used.
459 * The old registration may have used a different type however. So don't rely
460 * on your supplied values.
462 * Important: if you do not supply a merge function the implication will be
463 * that there can only be one single value for this tag in a tag list and
464 * any additional values will silenty be discarded when being added (unless
465 * #GST_TAG_MERGE_REPLACE, #GST_TAG_MERGE_REPLACE_ALL, or
466 * #GST_TAG_MERGE_PREPEND is used as merge mode, in which case the new
467 * value will replace the old one in the list).
469 * The merge function will be called from gst_tag_list_copy_value() when
470 * it is required that one or more values for a tag be condensed into
471 * one single value. This may happen from gst_tag_list_get_string(),
472 * gst_tag_list_get_int(), gst_tag_list_get_double() etc. What will happen
473 * exactly in that case depends on how the tag was registered and if a
474 * merge function was supplied and if so which one.
476 * Two default merge functions are provided: gst_tag_merge_use_first() and
477 * gst_tag_merge_strings_with_comma().
480 gst_tag_register (const gchar * name, GstTagFlag flag, GType type,
481 const gchar * nick, const gchar * blurb, GstTagMergeFunc func)
486 g_return_if_fail (name != NULL);
487 g_return_if_fail (nick != NULL);
488 g_return_if_fail (blurb != NULL);
489 g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
491 info = gst_tag_lookup (name);
494 g_return_if_fail (info->type == type);
498 info = g_slice_new (GstTagInfo);
501 info->nick = g_strdup (nick);
502 info->blurb = g_strdup (blurb);
503 info->merge_func = func;
505 /* we make a copy for the hash table anyway, which will stay around, so
506 * can use that for the quark table too */
507 name_dup = g_strdup (name);
508 info->name_quark = g_quark_from_static_string (name_dup);
511 g_hash_table_insert (__tags, (gpointer) name_dup, info);
517 * @tag: name of the tag
519 * Checks if the given type is already registered.
521 * Returns: TRUE if the type is already registered
524 gst_tag_exists (const gchar * tag)
526 g_return_val_if_fail (tag != NULL, FALSE);
528 return gst_tag_lookup (tag) != NULL;
535 * Gets the #GType used for this tag.
537 * Returns: the #GType of this tag
540 gst_tag_get_type (const gchar * tag)
544 g_return_val_if_fail (tag != NULL, 0);
545 info = gst_tag_lookup (tag);
546 g_return_val_if_fail (info != NULL, 0);
555 * Returns the human-readable name of this tag, You must not change or free
558 * Returns: the human-readable name of this tag
561 gst_tag_get_nick (const gchar * tag)
565 g_return_val_if_fail (tag != NULL, NULL);
566 info = gst_tag_lookup (tag);
567 g_return_val_if_fail (info != NULL, NULL);
573 * gst_tag_get_description:
576 * Returns the human-readable description of this tag, You must not change or
579 * Returns: the human-readable description of this tag
582 gst_tag_get_description (const gchar * tag)
586 g_return_val_if_fail (tag != NULL, NULL);
587 info = gst_tag_lookup (tag);
588 g_return_val_if_fail (info != NULL, NULL);
597 * Gets the flag of @tag.
599 * Returns: the flag of this tag.
602 gst_tag_get_flag (const gchar * tag)
606 g_return_val_if_fail (tag != NULL, GST_TAG_FLAG_UNDEFINED);
607 info = gst_tag_lookup (tag);
608 g_return_val_if_fail (info != NULL, GST_TAG_FLAG_UNDEFINED);
617 * Checks if the given tag is fixed. A fixed tag can only contain one value.
618 * Unfixed tags can contain lists of values.
620 * Returns: TRUE, if the given tag is fixed.
623 gst_tag_is_fixed (const gchar * tag)
627 g_return_val_if_fail (tag != NULL, FALSE);
628 info = gst_tag_lookup (tag);
629 g_return_val_if_fail (info != NULL, FALSE);
631 return info->merge_func == NULL;
635 * gst_tag_list_new_empty:
637 * Creates a new empty GstTagList.
639 * Free-function: gst_tag_list_free
641 * Returns: (transfer full): An empty tag list
644 gst_tag_list_new_empty (void)
646 return GST_TAG_LIST (gst_structure_new_id_empty (GST_QUARK (TAGLIST)));
652 * @...: NULL-terminated list of values to set
654 * Creates a new taglist and appends the values for the given tags. It expects
655 * tag-value pairs like gst_tag_list_add(), and a NULL terminator after the
656 * last pair. The type of the values is implicit and is documented in the API
657 * reference, but can also be queried at runtime with gst_tag_get_type(). It
658 * is an error to pass a value of a type not matching the tag type into this
659 * function. The tag list will make copies of any arguments passed
660 * (e.g. strings, buffers).
662 * Free-function: gst_tag_list_free
664 * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_free()
665 * when no longer needed.
670 gst_tag_list_new (const gchar * tag, ...)
675 g_return_val_if_fail (tag != NULL, NULL);
677 list = gst_tag_list_new_empty ();
678 va_start (args, tag);
679 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, args);
686 * gst_tag_list_new_valist:
687 * @var_args: tag / value pairs to set
689 * Just like gst_tag_list_new(), only that it takes a va_list argument.
690 * Useful mostly for language bindings.
692 * Free-function: gst_tag_list_free
694 * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_free()
695 * when no longer needed.
700 gst_tag_list_new_valist (va_list var_args)
705 list = gst_tag_list_new_empty ();
707 tag = va_arg (var_args, gchar *);
708 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, var_args);
714 * gst_tag_list_to_string:
715 * @list: a #GstTagList
717 * Serializes a tag list to a string.
719 * Returns: a newly-allocated string, or NULL in case of an error. The
720 * string must be freed with g_free() when no longer needed.
725 gst_tag_list_to_string (const GstTagList * list)
727 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
729 return gst_structure_to_string (GST_STRUCTURE (list));
733 * gst_tag_list_new_from_string:
734 * @str: a string created with gst_tag_list_to_string()
736 * Deserializes a tag list.
738 * Returns: a new #GstTagList, or NULL in case of an error.
743 gst_tag_list_new_from_string (const gchar * str)
745 g_return_val_if_fail (str != NULL, NULL);
746 g_return_val_if_fail (g_str_has_prefix (str, "taglist"), NULL);
748 return GST_TAG_LIST (gst_structure_from_string (str, NULL));
752 * gst_tag_list_n_tags:
753 * @list: A #GstTagList.
755 * Get the number of tags in @list.
757 * Returns: The number of tags in @list.
760 gst_tag_list_n_tags (const GstTagList * list)
762 g_return_val_if_fail (list != NULL, 0);
763 g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
765 return gst_structure_n_fields ((GstStructure *) list);
769 * gst_tag_list_nth_tag_name:
770 * @list: A #GstTagList.
773 * Get the name of the tag in @list at @index.
775 * Returns: The name of the tag at @index.
778 gst_tag_list_nth_tag_name (const GstTagList * list, guint index)
780 g_return_val_if_fail (list != NULL, 0);
781 g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
783 return gst_structure_nth_field_name ((GstStructure *) list, index);
787 * gst_tag_list_is_empty:
788 * @list: A #GstTagList.
790 * Checks if the given taglist is empty.
792 * Returns: TRUE if the taglist is empty, otherwise FALSE.
797 gst_tag_list_is_empty (const GstTagList * list)
799 g_return_val_if_fail (list != NULL, FALSE);
800 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
802 return (gst_structure_n_fields ((GstStructure *) list) == 0);
806 gst_tag_list_fields_equal (const GValue * value1, const GValue * value2)
810 if (gst_value_compare (value1, value2) == GST_VALUE_EQUAL)
813 /* fields not equal: add some tolerance for doubles, otherwise bail out */
814 if (!G_VALUE_HOLDS_DOUBLE (value1) || !G_VALUE_HOLDS_DOUBLE (value2))
817 d1 = g_value_get_double (value1);
818 d2 = g_value_get_double (value2);
820 /* This will only work for 'normal' values and values around 0,
821 * which should be good enough for our purposes here
822 * FIXME: maybe add this to gst_value_compare_double() ? */
823 return (fabs (d1 - d2) < 0.0000001);
827 * gst_tag_list_is_equal:
828 * @list1: a #GstTagList.
829 * @list2: a #GstTagList.
831 * Checks if the two given taglists are equal.
833 * Returns: TRUE if the taglists are equal, otherwise FALSE
838 gst_tag_list_is_equal (const GstTagList * list1, const GstTagList * list2)
840 const GstStructure *s1, *s2;
841 gint num_fields1, num_fields2, i;
843 g_return_val_if_fail (GST_IS_TAG_LIST (list1), FALSE);
844 g_return_val_if_fail (GST_IS_TAG_LIST (list2), FALSE);
846 /* we don't just use gst_structure_is_equal() here so we can add some
847 * tolerance for doubles, though maybe we should just add that to
848 * gst_value_compare_double() as well? */
849 s1 = (const GstStructure *) list1;
850 s2 = (const GstStructure *) list2;
852 num_fields1 = gst_structure_n_fields (s1);
853 num_fields2 = gst_structure_n_fields (s2);
855 if (num_fields1 != num_fields2)
858 for (i = 0; i < num_fields1; i++) {
859 const GValue *value1, *value2;
860 const gchar *tag_name;
862 tag_name = gst_structure_nth_field_name (s1, i);
863 value1 = gst_structure_get_value (s1, tag_name);
864 value2 = gst_structure_get_value (s2, tag_name);
869 if (!gst_tag_list_fields_equal (value1, value2))
878 * @p: Object that might be a taglist
880 * Checks if the given pointer is a taglist.
882 * Returns: TRUE, if the given pointer is a taglist
885 gst_is_tag_list (gconstpointer p)
887 GstStructure *s = (GstStructure *) p;
889 g_return_val_if_fail (p != NULL, FALSE);
891 return (GST_IS_STRUCTURE (s) && s->name == GST_QUARK (TAGLIST));
897 GstTagMergeMode mode;
902 gst_tag_list_add_value_internal (GstTagList * tag_list, GstTagMergeMode mode,
903 const gchar * tag, const GValue * value, GstTagInfo * info)
905 GstStructure *list = GST_STRUCTURE (tag_list);
906 const GValue *value2;
910 info = gst_tag_lookup (tag);
911 if (G_UNLIKELY (info == NULL)) {
912 g_warning ("unknown tag '%s'", tag);
917 tag_quark = info->name_quark;
920 && (value2 = gst_structure_id_get_value (list, tag_quark)) != NULL) {
921 GValue dest = { 0, };
924 case GST_TAG_MERGE_REPLACE_ALL:
925 case GST_TAG_MERGE_REPLACE:
926 gst_structure_id_set_value (list, tag_quark, value);
928 case GST_TAG_MERGE_PREPEND:
929 gst_value_list_merge (&dest, value, value2);
930 gst_structure_id_set_value (list, tag_quark, &dest);
931 g_value_unset (&dest);
933 case GST_TAG_MERGE_APPEND:
934 gst_value_list_merge (&dest, value2, value);
935 gst_structure_id_set_value (list, tag_quark, &dest);
936 g_value_unset (&dest);
938 case GST_TAG_MERGE_KEEP:
939 case GST_TAG_MERGE_KEEP_ALL:
942 g_assert_not_reached ();
947 case GST_TAG_MERGE_APPEND:
948 case GST_TAG_MERGE_KEEP:
949 if (gst_structure_id_get_value (list, tag_quark) != NULL)
952 case GST_TAG_MERGE_REPLACE_ALL:
953 case GST_TAG_MERGE_REPLACE:
954 case GST_TAG_MERGE_PREPEND:
955 gst_structure_id_set_value (list, tag_quark, value);
957 case GST_TAG_MERGE_KEEP_ALL:
960 g_assert_not_reached ();
967 gst_tag_list_copy_foreach (GQuark tag_quark, const GValue * value,
970 GstTagCopyData *copy = (GstTagCopyData *) user_data;
973 tag = g_quark_to_string (tag_quark);
974 gst_tag_list_add_value_internal (copy->list, copy->mode, tag, value, NULL);
980 * gst_tag_list_insert:
981 * @into: list to merge into
982 * @from: list to merge from
983 * @mode: the mode to use
985 * Inserts the tags of the @from list into the first list using the given mode.
988 gst_tag_list_insert (GstTagList * into, const GstTagList * from,
989 GstTagMergeMode mode)
993 g_return_if_fail (GST_IS_TAG_LIST (into));
994 g_return_if_fail (GST_IS_TAG_LIST (from));
995 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
999 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1000 gst_structure_remove_all_fields (GST_STRUCTURE (data.list));
1002 gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach,
1007 * gst_tag_list_copy:
1008 * @list: list to copy
1010 * Copies a given #GstTagList.
1012 * Free-function: gst_tag_list_free
1014 * Returns: (transfer full): copy of the given list
1017 gst_tag_list_copy (const GstTagList * list)
1019 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
1021 return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list));
1025 * gst_tag_list_merge:
1026 * @list1: first list to merge
1027 * @list2: second list to merge
1028 * @mode: the mode to use
1030 * Merges the two given lists into a new list. If one of the lists is NULL, a
1031 * copy of the other is returned. If both lists are NULL, NULL is returned.
1033 * Free-function: gst_tag_list_free
1035 * Returns: (transfer full): the new list
1038 gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
1039 GstTagMergeMode mode)
1041 GstTagList *list1_cp;
1042 const GstTagList *list2_cp;
1044 g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
1045 g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
1046 g_return_val_if_fail (GST_TAG_MODE_IS_VALID (mode), NULL);
1048 /* nothing to merge */
1049 if (!list1 && !list2) {
1053 /* create empty list, we need to do this to correctly handling merge modes */
1054 list1_cp = (list1) ? gst_tag_list_copy (list1) : gst_tag_list_new_empty ();
1055 list2_cp = (list2) ? list2 : gst_tag_list_new_empty ();
1057 gst_tag_list_insert (list1_cp, list2_cp, mode);
1060 gst_tag_list_free ((GstTagList *) list2_cp);
1066 * gst_tag_list_free:
1067 * @list: (in) (transfer full): the list to free
1069 * Frees the given list and all associated values.
1072 gst_tag_list_free (GstTagList * list)
1074 g_return_if_fail (GST_IS_TAG_LIST (list));
1075 gst_structure_free ((GstStructure *) list);
1079 * gst_tag_list_get_tag_size:
1081 * @tag: the tag to query
1083 * Checks how many value are stored in this tag list for the given tag.
1085 * Returns: The number of tags stored
1088 gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag)
1090 const GValue *value;
1092 g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
1094 value = gst_structure_get_value ((GstStructure *) list, tag);
1097 if (G_VALUE_TYPE (value) != GST_TYPE_LIST)
1100 return gst_value_list_get_size (value);
1105 * @list: list to set tags in
1106 * @mode: the mode to use
1108 * @...: NULL-terminated list of values to set
1110 * Sets the values for the given tags using the specified mode.
1113 gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag,
1118 g_return_if_fail (GST_IS_TAG_LIST (list));
1119 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1120 g_return_if_fail (tag != NULL);
1122 va_start (args, tag);
1123 gst_tag_list_add_valist (list, mode, tag, args);
1128 * gst_tag_list_add_values:
1129 * @list: list to set tags in
1130 * @mode: the mode to use
1132 * @...: GValues to set
1134 * Sets the GValues for the given tags using the specified mode.
1137 gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode,
1138 const gchar * tag, ...)
1142 g_return_if_fail (GST_IS_TAG_LIST (list));
1143 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1144 g_return_if_fail (tag != NULL);
1146 va_start (args, tag);
1147 gst_tag_list_add_valist_values (list, mode, tag, args);
1152 * gst_tag_list_add_valist:
1153 * @list: list to set tags in
1154 * @mode: the mode to use
1156 * @var_args: tag / value pairs to set
1158 * Sets the values for the given tags using the specified mode.
1161 gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
1162 const gchar * tag, va_list var_args)
1165 gchar *error = NULL;
1167 g_return_if_fail (GST_IS_TAG_LIST (list));
1168 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1169 g_return_if_fail (tag != NULL);
1171 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1172 gst_structure_remove_all_fields (GST_STRUCTURE (list));
1175 while (tag != NULL) {
1176 GValue value = { 0, };
1178 info = gst_tag_lookup (tag);
1179 if (G_UNLIKELY (info == NULL)) {
1180 g_warning ("unknown tag '%s'", tag);
1183 G_VALUE_COLLECT_INIT (&value, info->type, var_args, 0, &error);
1185 g_warning ("%s: %s", G_STRLOC, error);
1187 /* we purposely leak the value here, it might not be
1188 * in a sane state if an error condition occoured
1192 gst_tag_list_add_value_internal (list, mode, tag, &value, info);
1193 g_value_unset (&value);
1194 tag = va_arg (var_args, gchar *);
1199 * gst_tag_list_add_valist_values:
1200 * @list: list to set tags in
1201 * @mode: the mode to use
1203 * @var_args: tag / GValue pairs to set
1205 * Sets the GValues for the given tags using the specified mode.
1208 gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
1209 const gchar * tag, va_list var_args)
1211 g_return_if_fail (GST_IS_TAG_LIST (list));
1212 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1213 g_return_if_fail (tag != NULL);
1215 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1216 gst_structure_remove_all_fields (GST_STRUCTURE (list));
1219 while (tag != NULL) {
1222 info = gst_tag_lookup (tag);
1223 if (G_UNLIKELY (info == NULL)) {
1224 g_warning ("unknown tag '%s'", tag);
1227 gst_tag_list_add_value_internal (list, mode, tag, va_arg (var_args,
1229 tag = va_arg (var_args, gchar *);
1234 * gst_tag_list_add_value:
1235 * @list: list to set tags in
1236 * @mode: the mode to use
1238 * @value: GValue for this tag
1240 * Sets the GValue for a given tag using the specified mode.
1245 gst_tag_list_add_value (GstTagList * list, GstTagMergeMode mode,
1246 const gchar * tag, const GValue * value)
1248 g_return_if_fail (GST_IS_TAG_LIST (list));
1249 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1250 g_return_if_fail (tag != NULL);
1252 gst_tag_list_add_value_internal (list, mode, tag, value, NULL);
1256 * gst_tag_list_remove_tag:
1257 * @list: list to remove tag from
1258 * @tag: tag to remove
1260 * Removes the given tag from the taglist.
1263 gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
1265 g_return_if_fail (GST_IS_TAG_LIST (list));
1266 g_return_if_fail (tag != NULL);
1268 gst_structure_remove_field ((GstStructure *) list, tag);
1273 GstTagForeachFunc func;
1274 const GstTagList *tag_list;
1280 structure_foreach_wrapper (GQuark field_id, const GValue * value,
1283 TagForeachData *data = (TagForeachData *) user_data;
1285 data->func (data->tag_list, g_quark_to_string (field_id), data->data);
1290 * gst_tag_list_foreach:
1291 * @list: list to iterate over
1292 * @func: (scope call): function to be called for each tag
1293 * @user_data: (closure): user specified data
1295 * Calls the given function for each tag inside the tag list. Note that if there
1296 * is no tag, the function won't be called at all.
1299 gst_tag_list_foreach (const GstTagList * list, GstTagForeachFunc func,
1302 TagForeachData data;
1304 g_return_if_fail (GST_IS_TAG_LIST (list));
1305 g_return_if_fail (func != NULL);
1308 data.tag_list = list;
1309 data.data = user_data;
1310 gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper,
1315 * gst_tag_list_get_value_index:
1316 * @list: a #GstTagList
1317 * @tag: tag to read out
1318 * @index: number of entry to read out
1320 * Gets the value that is at the given index for the given tag in the given
1323 * Returns: (transfer none): The GValue for the specified entry or NULL if the
1324 * tag wasn't available or the tag doesn't have as many entries
1327 gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
1330 const GValue *value;
1332 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
1333 g_return_val_if_fail (tag != NULL, NULL);
1335 value = gst_structure_get_value ((GstStructure *) list, tag);
1339 if (GST_VALUE_HOLDS_LIST (value)) {
1340 if (index >= gst_value_list_get_size (value))
1342 return gst_value_list_get_value (value, index);
1351 * gst_tag_list_copy_value:
1352 * @dest: (out caller-allocates): uninitialized #GValue to copy into
1353 * @list: list to get the tag from
1354 * @tag: tag to read out
1356 * Copies the contents for the given tag into the value,
1357 * merging multiple values into one if multiple values are associated
1359 * You must g_value_unset() the value after use.
1361 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1365 gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
1370 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1371 g_return_val_if_fail (tag != NULL, FALSE);
1372 g_return_val_if_fail (dest != NULL, FALSE);
1373 g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
1375 src = gst_structure_get_value ((GstStructure *) list, tag);
1379 if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
1380 GstTagInfo *info = gst_tag_lookup (tag);
1385 /* must be there or lists aren't allowed */
1386 g_assert (info->merge_func);
1387 info->merge_func (dest, src);
1389 g_value_init (dest, G_VALUE_TYPE (src));
1390 g_value_copy (src, dest);
1395 /* FIXME 0.11: this whole merge function business is overdesigned, and the
1396 * _get_foo() API is misleading as well - how many application developers will
1397 * expect gst_tag_list_get_string (list, GST_TAG_ARTIST, &val) might return a
1398 * string with multiple comma-separated artists? _get_foo() should just be
1399 * a convenience wrapper around _get_foo_index (list, tag, 0, &val),
1400 * supplemented by a special _tag_list_get_string_merged() function if needed
1401 * (unless someone can actually think of real use cases where the merge
1402 * function is not 'use first' for non-strings and merge for strings) */
1404 /***** evil macros to get all the gst_tag_list_get_*() functions right *****/
1406 #define TAG_MERGE_FUNCS(name,type,ret) \
1408 gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
1411 GValue v = { 0, }; \
1413 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1414 g_return_val_if_fail (tag != NULL, FALSE); \
1415 g_return_val_if_fail (value != NULL, FALSE); \
1417 if (!gst_tag_list_copy_value (&v, list, tag)) \
1419 *value = COPY_FUNC (g_value_get_ ## name (&v)); \
1420 g_value_unset (&v); \
1425 gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
1427 guint index, type *value) \
1431 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1432 g_return_val_if_fail (tag != NULL, FALSE); \
1433 g_return_val_if_fail (value != NULL, FALSE); \
1435 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
1437 *value = COPY_FUNC (g_value_get_ ## name (v)); \
1441 #define COPY_FUNC /**/
1443 * gst_tag_list_get_boolean:
1444 * @list: a #GstTagList to get the tag from
1445 * @tag: tag to read out
1446 * @value: (out): location for the result
1448 * Copies the contents for the given tag into the value, merging multiple values
1449 * into one if multiple values are associated with the tag.
1451 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1455 * gst_tag_list_get_boolean_index:
1456 * @list: a #GstTagList to get the tag from
1457 * @tag: tag to read out
1458 * @index: number of entry to read out
1459 * @value: (out): location for the result
1461 * Gets the value that is at the given index for the given tag in the given
1464 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1467 TAG_MERGE_FUNCS (boolean, gboolean, TRUE);
1469 * gst_tag_list_get_int:
1470 * @list: a #GstTagList to get the tag from
1471 * @tag: tag to read out
1472 * @value: (out): location for the result
1474 * Copies the contents for the given tag into the value, merging multiple values
1475 * into one if multiple values are associated with the tag.
1477 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1481 * gst_tag_list_get_int_index:
1482 * @list: a #GstTagList to get the tag from
1483 * @tag: tag to read out
1484 * @index: number of entry to read out
1485 * @value: (out): location for the result
1487 * Gets the value that is at the given index for the given tag in the given
1490 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1493 TAG_MERGE_FUNCS (int, gint, TRUE);
1495 * gst_tag_list_get_uint:
1496 * @list: a #GstTagList to get the tag from
1497 * @tag: tag to read out
1498 * @value: (out): location for the result
1500 * Copies the contents for the given tag into the value, merging multiple values
1501 * into one if multiple values are associated with the tag.
1503 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1507 * gst_tag_list_get_uint_index:
1508 * @list: a #GstTagList to get the tag from
1509 * @tag: tag to read out
1510 * @index: number of entry to read out
1511 * @value: (out): location for the result
1513 * Gets the value that is at the given index for the given tag in the given
1516 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1519 TAG_MERGE_FUNCS (uint, guint, TRUE);
1521 * gst_tag_list_get_int64_index:
1522 * @list: a #GstTagList to get the tag from
1523 * @tag: tag to read out
1524 * @index: number of entry to read out
1525 * @value: (out): location for the result
1527 * Gets the value that is at the given index for the given tag in the given
1530 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1533 TAG_MERGE_FUNCS (int64, gint64, TRUE);
1535 * gst_tag_list_get_uint64:
1536 * @list: a #GstTagList to get the tag from
1537 * @tag: tag to read out
1538 * @value: (out): location for the result
1540 * Copies the contents for the given tag into the value, merging multiple values
1541 * into one if multiple values are associated with the tag.
1543 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1547 * gst_tag_list_get_uint64_index:
1548 * @list: a #GstTagList to get the tag from
1549 * @tag: tag to read out
1550 * @index: number of entry to read out
1551 * @value: (out): location for the result
1553 * Gets the value that is at the given index for the given tag in the given
1556 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1559 TAG_MERGE_FUNCS (uint64, guint64, TRUE);
1561 * gst_tag_list_get_float:
1562 * @list: a #GstTagList to get the tag from
1563 * @tag: tag to read out
1564 * @value: (out): location for the result
1566 * Copies the contents for the given tag into the value, merging multiple values
1567 * into one if multiple values are associated with the tag.
1569 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1573 * gst_tag_list_get_float_index:
1574 * @list: a #GstTagList to get the tag from
1575 * @tag: tag to read out
1576 * @index: number of entry to read out
1577 * @value: (out): location for the result
1579 * Gets the value that is at the given index for the given tag in the given
1582 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1585 TAG_MERGE_FUNCS (float, gfloat, TRUE);
1587 * gst_tag_list_get_double:
1588 * @list: a #GstTagList to get the tag from
1589 * @tag: tag to read out
1590 * @value: (out): location for the result
1592 * Copies the contents for the given tag into the value, merging multiple values
1593 * into one if multiple values are associated with the tag.
1595 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1599 * gst_tag_list_get_double_index:
1600 * @list: a #GstTagList to get the tag from
1601 * @tag: tag to read out
1602 * @index: number of entry to read out
1603 * @value: (out): location for the result
1605 * Gets the value that is at the given index for the given tag in the given
1608 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1611 TAG_MERGE_FUNCS (double, gdouble, TRUE);
1613 * gst_tag_list_get_pointer:
1614 * @list: a #GstTagList to get the tag from
1615 * @tag: tag to read out
1616 * @value: (out) (transfer none): location for the result
1618 * Copies the contents for the given tag into the value, merging multiple values
1619 * into one if multiple values are associated with the tag.
1621 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1625 * gst_tag_list_get_pointer_index:
1626 * @list: a #GstTagList to get the tag from
1627 * @tag: tag to read out
1628 * @index: number of entry to read out
1629 * @value: (out) (transfer none): location for the result
1631 * Gets the value that is at the given index for the given tag in the given
1634 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1637 TAG_MERGE_FUNCS (pointer, gpointer, (*value != NULL));
1639 static inline gchar *
1640 _gst_strdup0 (const gchar * s)
1642 if (s == NULL || *s == '\0')
1645 return g_strdup (s);
1649 #define COPY_FUNC _gst_strdup0
1652 * gst_tag_list_get_string:
1653 * @list: a #GstTagList to get the tag from
1654 * @tag: tag to read out
1655 * @value: (out callee-allocates) (transfer full): location for the result
1657 * Copies the contents for the given tag into the value, possibly merging
1658 * multiple values into one if multiple values are associated with the tag.
1660 * Use gst_tag_list_get_string_index (list, tag, 0, value) if you want
1661 * to retrieve the first string associated with this tag unmodified.
1663 * The resulting string in @value will be in UTF-8 encoding and should be
1664 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1665 * returned string is also guaranteed to be non-NULL and non-empty.
1667 * Free-function: g_free
1669 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1673 * gst_tag_list_get_string_index:
1674 * @list: a #GstTagList to get the tag from
1675 * @tag: tag to read out
1676 * @index: number of entry to read out
1677 * @value: (out callee-allocates) (transfer full): location for the result
1679 * Gets the value that is at the given index for the given tag in the given
1682 * The resulting string in @value will be in UTF-8 encoding and should be
1683 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1684 * returned string is also guaranteed to be non-NULL and non-empty.
1686 * Free-function: g_free
1688 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1691 TAG_MERGE_FUNCS (string, gchar *, (*value != NULL));
1694 *FIXME 0.11: Instead of _peek (non-copy) and _get (copy), we could have
1695 * _get (non-copy) and _dup (copy) for strings, seems more
1699 * gst_tag_list_peek_string_index:
1700 * @list: a #GstTagList to get the tag from
1701 * @tag: tag to read out
1702 * @index: number of entry to read out
1703 * @value: (out) (transfer none): location for the result
1705 * Peeks at the value that is at the given index for the given tag in the given
1708 * The resulting string in @value will be in UTF-8 encoding and doesn't need
1709 * to be freed by the caller. The returned string is also guaranteed to
1710 * be non-NULL and non-empty.
1712 * Returns: TRUE, if a value was set, FALSE if the tag didn't exist in the
1716 gst_tag_list_peek_string_index (const GstTagList * list,
1717 const gchar * tag, guint index, const gchar ** value)
1721 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1722 g_return_val_if_fail (tag != NULL, FALSE);
1723 g_return_val_if_fail (value != NULL, FALSE);
1725 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1727 *value = g_value_get_string (v);
1728 return *value != NULL && **value != '\0';
1732 * gst_tag_list_get_date:
1733 * @list: a #GstTagList to get the tag from
1734 * @tag: tag to read out
1735 * @value: (out callee-allocates) (transfer full): address of a GDate pointer
1736 * variable to store the result into
1738 * Copies the first date for the given tag in the taglist into the variable
1739 * pointed to by @value. Free the date with g_date_free() when it is no longer
1742 * Free-function: g_date_free
1744 * Returns: TRUE, if a date was copied, FALSE if the tag didn't exist in the
1745 * given list or if it was #NULL.
1748 gst_tag_list_get_date (const GstTagList * list, const gchar * tag,
1753 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1754 g_return_val_if_fail (tag != NULL, FALSE);
1755 g_return_val_if_fail (value != NULL, FALSE);
1757 if (!gst_tag_list_copy_value (&v, list, tag))
1759 *value = (GDate *) g_value_dup_boxed (&v);
1761 return (*value != NULL);
1765 * gst_tag_list_get_date_index:
1766 * @list: a #GstTagList to get the tag from
1767 * @tag: tag to read out
1768 * @index: number of entry to read out
1769 * @value: (out callee-allocates) (transfer full): location for the result
1771 * Gets the date that is at the given index for the given tag in the given
1772 * list and copies it into the variable pointed to by @value. Free the date
1773 * with g_date_free() when it is no longer needed.
1775 * Free-function: g_date_free
1777 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1778 * given list or if it was #NULL.
1781 gst_tag_list_get_date_index (const GstTagList * list,
1782 const gchar * tag, guint index, GDate ** value)
1786 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1787 g_return_val_if_fail (tag != NULL, FALSE);
1788 g_return_val_if_fail (value != NULL, FALSE);
1790 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1792 *value = (GDate *) g_value_dup_boxed (v);
1793 return (*value != NULL);
1797 * gst_tag_list_get_date_time:
1798 * @list: a #GstTagList to get the tag from
1799 * @tag: tag to read out
1800 * @value: (out callee-allocates) (transfer full): address of a #GstDateTime
1801 * pointer variable to store the result into
1803 * Copies the first datetime for the given tag in the taglist into the variable
1804 * pointed to by @value. Unref the date with gst_date_time_unref() when
1805 * it is no longer needed.
1807 * Free-function: gst_date_time_unref
1809 * Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in
1810 * thegiven list or if it was #NULL.
1815 gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag,
1816 GstDateTime ** value)
1820 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1821 g_return_val_if_fail (tag != NULL, FALSE);
1822 g_return_val_if_fail (value != NULL, FALSE);
1824 if (!gst_tag_list_copy_value (&v, list, tag))
1827 g_return_val_if_fail (GST_VALUE_HOLDS_DATE_TIME (&v), FALSE);
1829 *value = (GstDateTime *) g_value_dup_boxed (&v);
1831 return (*value != NULL);
1835 * gst_tag_list_get_date_time_index:
1836 * @list: a #GstTagList to get the tag from
1837 * @tag: tag to read out
1838 * @index: number of entry to read out
1839 * @value: (out callee-allocates) (transfer full): location for the result
1841 * Gets the datetime that is at the given index for the given tag in the given
1842 * list and copies it into the variable pointed to by @value. Unref the datetime
1843 * with gst_date_time_unref() when it is no longer needed.
1845 * Free-function: gst_date_time_unref
1847 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1848 * given list or if it was #NULL.
1853 gst_tag_list_get_date_time_index (const GstTagList * list,
1854 const gchar * tag, guint index, GstDateTime ** value)
1858 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1859 g_return_val_if_fail (tag != NULL, FALSE);
1860 g_return_val_if_fail (value != NULL, FALSE);
1862 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1864 *value = (GstDateTime *) g_value_dup_boxed (v);
1865 return (*value != NULL);
1869 * gst_tag_list_get_buffer:
1870 * @list: a #GstTagList to get the tag from
1871 * @tag: tag to read out
1872 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
1873 * pointer variable to store the result into
1875 * Copies the first buffer for the given tag in the taglist into the variable
1876 * pointed to by @value. Free the buffer with gst_buffer_unref() when it is
1879 * Free-function: gst_buffer_unref
1881 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1882 * given list or if it was #NULL.
1887 gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag,
1892 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1893 g_return_val_if_fail (tag != NULL, FALSE);
1894 g_return_val_if_fail (value != NULL, FALSE);
1896 if (!gst_tag_list_copy_value (&v, list, tag))
1898 *value = g_value_dup_boxed (&v);
1900 return (*value != NULL);
1904 * gst_tag_list_get_buffer_index:
1905 * @list: a #GstTagList to get the tag from
1906 * @tag: tag to read out
1907 * @index: number of entry to read out
1908 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
1909 * pointer variable to store the result into
1911 * Gets the buffer that is at the given index for the given tag in the given
1912 * list and copies it into the variable pointed to by @value. Free the buffer
1913 * with gst_buffer_unref() when it is no longer needed.
1915 * Free-function: gst_buffer_unref
1917 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1918 * given list or if it was #NULL.
1923 gst_tag_list_get_buffer_index (const GstTagList * list,
1924 const gchar * tag, guint index, GstBuffer ** value)
1928 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1929 g_return_val_if_fail (tag != NULL, FALSE);
1930 g_return_val_if_fail (value != NULL, FALSE);
1932 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1934 *value = g_value_dup_boxed (v);
1935 return (*value != NULL);