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 static GMutex *__tag_mutex;
78 /* tags hash table: maps tag name string => GstTagInfo */
79 static GHashTable *__tags;
81 #define TAG_LOCK g_mutex_lock (__tag_mutex)
82 #define TAG_UNLOCK g_mutex_unlock (__tag_mutex)
85 gst_tag_list_get_type (void)
87 static GType _gst_tag_list_type = 0;
89 if (G_UNLIKELY (_gst_tag_list_type == 0)) {
90 _gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
91 (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
94 g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
95 _gst_structure_transform_to_string);
99 return _gst_tag_list_type;
103 _priv_gst_tag_initialize (void)
105 __tag_mutex = g_mutex_new ();
106 __tags = g_hash_table_new (g_str_hash, g_str_equal);
107 gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META,
109 _("title"), _("commonly used title"), gst_tag_merge_strings_with_comma);
110 gst_tag_register (GST_TAG_TITLE_SORTNAME, GST_TAG_FLAG_META,
112 _("title sortname"), _("commonly used title for sorting purposes"), NULL);
113 gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META,
116 _("person(s) responsible for the recording"),
117 gst_tag_merge_strings_with_comma);
118 gst_tag_register (GST_TAG_ARTIST_SORTNAME, GST_TAG_FLAG_META,
120 _("artist sortname"),
121 _("person(s) responsible for the recording for sorting purposes"), NULL);
122 gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META,
125 _("album containing this data"), gst_tag_merge_strings_with_comma);
126 gst_tag_register (GST_TAG_ALBUM_SORTNAME, GST_TAG_FLAG_META,
129 _("album containing this data for sorting purposes"), NULL);
130 gst_tag_register (GST_TAG_ALBUM_ARTIST, GST_TAG_FLAG_META,
133 _("The artist of the entire album, as it should be displayed"),
134 gst_tag_merge_strings_with_comma);
135 gst_tag_register (GST_TAG_ALBUM_ARTIST_SORTNAME, GST_TAG_FLAG_META,
137 _("album artist sortname"),
138 _("The artist of the entire album, as it should be sorted"), NULL);
139 gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, GST_TYPE_DATE,
140 _("date"), _("date the data was created (as a GDate structure)"), NULL);
141 gst_tag_register (GST_TAG_DATE_TIME, GST_TAG_FLAG_META, GST_TYPE_DATE_TIME,
143 _("date and time the data was created (as a GstDateTime structure)"),
145 gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META,
148 _("genre this data belongs to"), gst_tag_merge_strings_with_comma);
149 gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META,
152 _("free text commenting the data"), gst_tag_merge_use_first);
153 gst_tag_register (GST_TAG_EXTENDED_COMMENT, GST_TAG_FLAG_META,
155 _("extended comment"),
156 _("free text commenting the data in key=value or key[en]=comment form"),
157 gst_tag_merge_use_first);
158 gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META,
161 _("track number inside a collection"), gst_tag_merge_use_first);
162 gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META,
165 _("count of tracks inside collection this track belongs to"),
166 gst_tag_merge_use_first);
167 gst_tag_register (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META,
170 _("disc number inside a collection"), gst_tag_merge_use_first);
171 gst_tag_register (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META,
174 _("count of discs inside collection this disc belongs to"),
175 gst_tag_merge_use_first);
176 gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META,
178 _("location"), _("Origin of media as a URI (location, where the "
179 "original of the file or stream is hosted)"),
180 gst_tag_merge_strings_with_comma);
181 gst_tag_register (GST_TAG_HOMEPAGE, GST_TAG_FLAG_META,
184 _("Homepage for this media (i.e. artist or movie homepage)"),
185 gst_tag_merge_strings_with_comma);
186 gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META, G_TYPE_STRING,
187 _("description"), _("short text describing the content of the data"),
188 gst_tag_merge_strings_with_comma);
189 gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META, G_TYPE_STRING,
190 _("version"), _("version of this data"), NULL);
191 gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META, G_TYPE_STRING, _("ISRC"),
193 ("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
195 /* FIXME: organization (fix what? tpm) */
196 gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING,
197 _("organization"), _("organization"), gst_tag_merge_strings_with_comma);
198 gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
199 G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL);
200 gst_tag_register (GST_TAG_COPYRIGHT_URI, GST_TAG_FLAG_META,
201 G_TYPE_STRING, _("copyright uri"),
202 _("URI to the copyright notice of the data"), NULL);
203 gst_tag_register (GST_TAG_ENCODED_BY, GST_TAG_FLAG_META, G_TYPE_STRING,
204 _("encoded by"), _("name of the encoding person or organization"),
205 gst_tag_merge_strings_with_comma);
206 gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META,
208 _("contact"), _("contact information"), gst_tag_merge_strings_with_comma);
209 gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META,
210 G_TYPE_STRING, _("license"), _("license of data"), NULL);
211 gst_tag_register (GST_TAG_LICENSE_URI, GST_TAG_FLAG_META,
212 G_TYPE_STRING, _("license uri"),
213 _("URI to the license of the data"), NULL);
214 gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META,
217 _("person(s) performing"), gst_tag_merge_strings_with_comma);
218 gst_tag_register (GST_TAG_COMPOSER, GST_TAG_FLAG_META,
221 _("person(s) who composed the recording"),
222 gst_tag_merge_strings_with_comma);
223 gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED,
225 _("duration"), _("length in GStreamer time units (nanoseconds)"), NULL);
226 gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED,
229 _("codec the data is stored in"), gst_tag_merge_strings_with_comma);
230 gst_tag_register (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED,
232 _("video codec"), _("codec the video data is stored in"), NULL);
233 gst_tag_register (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED,
235 _("audio codec"), _("codec the audio data is stored in"), NULL);
236 gst_tag_register (GST_TAG_SUBTITLE_CODEC, GST_TAG_FLAG_ENCODED,
238 _("subtitle codec"), _("codec the subtitle data is stored in"), NULL);
239 gst_tag_register (GST_TAG_CONTAINER_FORMAT, GST_TAG_FLAG_ENCODED,
240 G_TYPE_STRING, _("container format"),
241 _("container format the data is stored in"), NULL);
242 gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED,
243 G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL);
244 gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED,
245 G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL);
246 gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
247 G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL);
248 gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
249 G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL);
250 gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED,
252 _("encoder"), _("encoder used to encode this stream"), NULL);
253 gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED,
255 _("encoder version"),
256 _("version of the encoder used to encode this stream"), NULL);
257 gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED,
258 G_TYPE_UINT, _("serial"), _("serial number of track"), NULL);
259 gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META,
260 G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL);
261 gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META,
262 G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL);
263 gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META,
264 G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL);
265 gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
266 G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL);
267 gst_tag_register (GST_TAG_REFERENCE_LEVEL, GST_TAG_FLAG_META,
268 G_TYPE_DOUBLE, _("replaygain reference level"),
269 _("reference level of track and album gain values"), NULL);
270 gst_tag_register (GST_TAG_LANGUAGE_CODE, GST_TAG_FLAG_META, G_TYPE_STRING,
272 _("language code for this stream, conforming to ISO-639-1"), NULL);
273 gst_tag_register (GST_TAG_IMAGE, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
274 _("image"), _("image related to this stream"), gst_tag_merge_use_first);
275 gst_tag_register (GST_TAG_PREVIEW_IMAGE, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
276 /* TRANSLATORS: 'preview image' = image that shows a preview of the full image */
277 _("preview image"), _("preview image related to this stream"), NULL);
278 gst_tag_register (GST_TAG_ATTACHMENT, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
279 _("attachment"), _("file attached to this stream"),
280 gst_tag_merge_use_first);
281 gst_tag_register (GST_TAG_BEATS_PER_MINUTE, GST_TAG_FLAG_META, G_TYPE_DOUBLE,
282 _("beats per minute"), _("number of beats per minute in audio"), NULL);
283 gst_tag_register (GST_TAG_KEYWORDS, GST_TAG_FLAG_META, G_TYPE_STRING,
284 _("keywords"), _("comma separated keywords describing the content"),
285 gst_tag_merge_strings_with_comma);
286 gst_tag_register (GST_TAG_GEO_LOCATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
287 _("geo location name"), _("human readable descriptive location of where "
288 "the media has been recorded or produced"), NULL);
289 gst_tag_register (GST_TAG_GEO_LOCATION_LATITUDE, GST_TAG_FLAG_META,
290 G_TYPE_DOUBLE, _("geo location latitude"),
291 _("geo latitude location of where the media has been recorded or "
292 "produced in degrees according to WGS84 (zero at the equator, "
293 "negative values for southern latitudes)"), NULL);
294 gst_tag_register (GST_TAG_GEO_LOCATION_LONGITUDE, GST_TAG_FLAG_META,
295 G_TYPE_DOUBLE, _("geo location longitude"),
296 _("geo longitude location of where the media has been recorded or "
297 "produced in degrees according to WGS84 (zero at the prime meridian "
298 "in Greenwich/UK, negative values for western longitudes)"), NULL);
299 gst_tag_register (GST_TAG_GEO_LOCATION_ELEVATION, GST_TAG_FLAG_META,
300 G_TYPE_DOUBLE, _("geo location elevation"),
301 _("geo elevation of where the media has been recorded or produced in "
302 "meters according to WGS84 (zero is average sea level)"), NULL);
303 gst_tag_register (GST_TAG_GEO_LOCATION_COUNTRY, GST_TAG_FLAG_META,
304 G_TYPE_STRING, _("geo location country"),
305 _("country (english name) where the media has been recorded "
306 "or produced"), NULL);
307 gst_tag_register (GST_TAG_GEO_LOCATION_CITY, GST_TAG_FLAG_META,
308 G_TYPE_STRING, _("geo location city"),
309 _("city (english name) where the media has been recorded "
310 "or produced"), NULL);
311 gst_tag_register (GST_TAG_GEO_LOCATION_SUBLOCATION, GST_TAG_FLAG_META,
312 G_TYPE_STRING, _("geo location sublocation"),
313 _("a location whithin a city where the media has been produced "
314 "or created (e.g. the neighborhood)"), NULL);
315 gst_tag_register (GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, GST_TAG_FLAG_META,
316 G_TYPE_DOUBLE, _("geo location horizontal error"),
317 _("expected error of the horizontal positioning measures (in meters)"),
319 gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, GST_TAG_FLAG_META,
320 G_TYPE_DOUBLE, _("geo location movement speed"),
321 _("movement speed of the capturing device while performing the capture "
323 gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, GST_TAG_FLAG_META,
324 G_TYPE_DOUBLE, _("geo location movement direction"),
325 _("indicates the movement direction of the device performing the capture"
326 " of a media. It is represented as degrees in floating point "
327 "representation, 0 means the geographic north, and increases "
329 gst_tag_register (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, GST_TAG_FLAG_META,
330 G_TYPE_DOUBLE, _("geo location capture direction"),
331 _("indicates the direction the device is pointing to when capturing "
332 " 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_SHOW_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
336 /* TRANSLATORS: 'show name' = 'TV/radio/podcast show name' here */
338 _("Name of the tv/podcast/series show the media is from"),
339 gst_tag_merge_strings_with_comma);
340 gst_tag_register (GST_TAG_SHOW_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING,
341 /* TRANSLATORS: 'show sortname' = 'TV/radio/podcast show name as used for sorting purposes' here */
343 _("Name of the tv/podcast/series show the media is from, for sorting "
345 gst_tag_register (GST_TAG_SHOW_EPISODE_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT,
347 _("The episode number in the season the media is part of"),
348 gst_tag_merge_use_first);
349 gst_tag_register (GST_TAG_SHOW_SEASON_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT,
351 _("The season number of the show the media is part of"),
352 gst_tag_merge_use_first);
353 gst_tag_register (GST_TAG_LYRICS, GST_TAG_FLAG_META, G_TYPE_STRING,
354 _("lyrics"), _("The lyrics of the media, commonly used for songs"),
355 gst_tag_merge_strings_with_comma);
356 gst_tag_register (GST_TAG_COMPOSER_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING,
357 _("composer sortname"),
358 _("person(s) who composed the recording, for sorting purposes"), NULL);
359 gst_tag_register (GST_TAG_GROUPING, GST_TAG_FLAG_META, G_TYPE_STRING,
361 _("Groups related media that spans multiple tracks, like the different "
362 "pieces of a concerto. It is a higher level than a track, "
363 "but lower than an album"), NULL);
364 gst_tag_register (GST_TAG_USER_RATING, GST_TAG_FLAG_META, G_TYPE_UINT,
366 _("Rating attributed by a user. The higher the rank, "
367 "the more the user likes this media"), NULL);
368 gst_tag_register (GST_TAG_DEVICE_MANUFACTURER, GST_TAG_FLAG_META,
369 G_TYPE_STRING, _("device manufacturer"),
370 _("Manufacturer of the device used to create this media"), NULL);
371 gst_tag_register (GST_TAG_DEVICE_MODEL, GST_TAG_FLAG_META, G_TYPE_STRING,
373 _("Model of the device used to create this media"), NULL);
374 gst_tag_register (GST_TAG_APPLICATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
375 _("application name"), _("Application used to create the media"), NULL);
376 gst_tag_register (GST_TAG_APPLICATION_DATA, GST_TAG_FLAG_META,
377 GST_TYPE_BUFFER, _("application data"),
378 _("Arbitrary application data to be serialized into the media"), NULL);
379 gst_tag_register (GST_TAG_IMAGE_ORIENTATION, GST_TAG_FLAG_META, G_TYPE_STRING,
380 _("image orientation"),
381 _("How the image should be rotated or flipped before display"), NULL);
385 * gst_tag_merge_use_first:
386 * @dest: (out caller-allocates): uninitialized GValue to store result in
387 * @src: GValue to copy from
389 * This is a convenience function for the func argument of gst_tag_register().
390 * It creates a copy of the first value from the list.
393 gst_tag_merge_use_first (GValue * dest, const GValue * src)
395 const GValue *ret = gst_value_list_get_value (src, 0);
397 g_value_init (dest, G_VALUE_TYPE (ret));
398 g_value_copy (ret, dest);
402 * gst_tag_merge_strings_with_comma:
403 * @dest: (out caller-allocates): uninitialized GValue to store result in
404 * @src: GValue to copy from
406 * This is a convenience function for the func argument of gst_tag_register().
407 * It concatenates all given strings using a comma. The tag must be registered
408 * as a G_TYPE_STRING or this function will fail.
411 gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src)
416 count = gst_value_list_get_size (src);
417 str = g_string_new (g_value_get_string (gst_value_list_get_value (src, 0)));
418 for (i = 1; i < count; i++) {
419 /* separator between two strings */
420 g_string_append (str, _(", "));
421 g_string_append (str,
422 g_value_get_string (gst_value_list_get_value (src, i)));
425 g_value_init (dest, G_TYPE_STRING);
426 g_value_take_string (dest, str->str);
427 g_string_free (str, FALSE);
431 gst_tag_lookup (const gchar * tag_name)
436 ret = g_hash_table_lookup (__tags, (gpointer) tag_name);
444 * @name: the name or identifier string
445 * @flag: a flag describing the type of tag info
446 * @type: the type this data is in
447 * @nick: human-readable name
448 * @blurb: a human-readable description about this tag
449 * @func: function for merging multiple values of this tag, or NULL
451 * Registers a new tag type for the use with GStreamer's type system. If a type
452 * with that name is already registered, that one is used.
453 * The old registration may have used a different type however. So don't rely
454 * on your supplied values.
456 * Important: if you do not supply a merge function the implication will be
457 * that there can only be one single value for this tag in a tag list and
458 * any additional values will silenty be discarded when being added (unless
459 * #GST_TAG_MERGE_REPLACE, #GST_TAG_MERGE_REPLACE_ALL, or
460 * #GST_TAG_MERGE_PREPEND is used as merge mode, in which case the new
461 * value will replace the old one in the list).
463 * The merge function will be called from gst_tag_list_copy_value() when
464 * it is required that one or more values for a tag be condensed into
465 * one single value. This may happen from gst_tag_list_get_string(),
466 * gst_tag_list_get_int(), gst_tag_list_get_double() etc. What will happen
467 * exactly in that case depends on how the tag was registered and if a
468 * merge function was supplied and if so which one.
470 * Two default merge functions are provided: gst_tag_merge_use_first() and
471 * gst_tag_merge_strings_with_comma().
474 gst_tag_register (const gchar * name, GstTagFlag flag, GType type,
475 const gchar * nick, const gchar * blurb, GstTagMergeFunc func)
480 g_return_if_fail (name != NULL);
481 g_return_if_fail (nick != NULL);
482 g_return_if_fail (blurb != NULL);
483 g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
485 info = gst_tag_lookup (name);
488 g_return_if_fail (info->type == type);
492 info = g_slice_new (GstTagInfo);
495 info->nick = g_strdup (nick);
496 info->blurb = g_strdup (blurb);
497 info->merge_func = func;
499 /* we make a copy for the hash table anyway, which will stay around, so
500 * can use that for the quark table too */
501 name_dup = g_strdup (name);
502 info->name_quark = g_quark_from_static_string (name_dup);
505 g_hash_table_insert (__tags, (gpointer) name_dup, info);
511 * @tag: name of the tag
513 * Checks if the given type is already registered.
515 * Returns: TRUE if the type is already registered
518 gst_tag_exists (const gchar * tag)
520 g_return_val_if_fail (tag != NULL, FALSE);
522 return gst_tag_lookup (tag) != NULL;
529 * Gets the #GType used for this tag.
531 * Returns: the #GType of this tag
534 gst_tag_get_type (const gchar * tag)
538 g_return_val_if_fail (tag != NULL, 0);
539 info = gst_tag_lookup (tag);
540 g_return_val_if_fail (info != NULL, 0);
549 * Returns the human-readable name of this tag, You must not change or free
552 * Returns: the human-readable name of this tag
555 gst_tag_get_nick (const gchar * tag)
559 g_return_val_if_fail (tag != NULL, NULL);
560 info = gst_tag_lookup (tag);
561 g_return_val_if_fail (info != NULL, NULL);
567 * gst_tag_get_description:
570 * Returns the human-readable description of this tag, You must not change or
573 * Returns: the human-readable description of this tag
576 gst_tag_get_description (const gchar * tag)
580 g_return_val_if_fail (tag != NULL, NULL);
581 info = gst_tag_lookup (tag);
582 g_return_val_if_fail (info != NULL, NULL);
591 * Gets the flag of @tag.
593 * Returns: the flag of this tag.
596 gst_tag_get_flag (const gchar * tag)
600 g_return_val_if_fail (tag != NULL, GST_TAG_FLAG_UNDEFINED);
601 info = gst_tag_lookup (tag);
602 g_return_val_if_fail (info != NULL, GST_TAG_FLAG_UNDEFINED);
611 * Checks if the given tag is fixed. A fixed tag can only contain one value.
612 * Unfixed tags can contain lists of values.
614 * Returns: TRUE, if the given tag is fixed.
617 gst_tag_is_fixed (const gchar * tag)
621 g_return_val_if_fail (tag != NULL, FALSE);
622 info = gst_tag_lookup (tag);
623 g_return_val_if_fail (info != NULL, FALSE);
625 return info->merge_func == NULL;
631 * Creates a new empty GstTagList.
633 * Free-function: gst_tag_list_free
635 * Returns: (transfer full): An empty tag list
638 gst_tag_list_new (void)
640 return GST_TAG_LIST (gst_structure_id_empty_new (GST_QUARK (TAGLIST)));
644 * gst_tag_list_new_full:
646 * @...: NULL-terminated list of values to set
648 * Creates a new taglist and appends the values for the given tags. It expects
649 * tag-value pairs like gst_tag_list_add(), and a NULL terminator after the
650 * last pair. The type of the values is implicit and is documented in the API
651 * reference, but can also be queried at runtime with gst_tag_get_type(). It
652 * is an error to pass a value of a type not matching the tag type into this
653 * function. The tag list will make copies of any arguments passed
654 * (e.g. strings, buffers).
656 * Free-function: gst_tag_list_free
658 * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_free()
659 * when no longer needed.
663 /* FIXME 0.11: rename gst_tag_list_new_full to _new and _new to _new_empty */
665 gst_tag_list_new_full (const gchar * tag, ...)
670 g_return_val_if_fail (tag != NULL, NULL);
672 list = gst_tag_list_new ();
673 va_start (args, tag);
674 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, args);
681 * gst_tag_list_new_full_valist:
682 * @var_args: tag / value pairs to set
684 * Just like gst_tag_list_new_full(), only that it takes a va_list argument.
685 * Useful mostly for language bindings.
687 * Free-function: gst_tag_list_free
689 * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_free()
690 * when no longer needed.
695 gst_tag_list_new_full_valist (va_list var_args)
700 list = gst_tag_list_new ();
702 tag = va_arg (var_args, gchar *);
703 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, var_args);
709 * gst_tag_list_to_string:
710 * @list: a #GstTagList
712 * Serializes a tag list to a string.
714 * Returns: a newly-allocated string, or NULL in case of an error. The
715 * string must be freed with g_free() when no longer needed.
720 gst_tag_list_to_string (const GstTagList * list)
722 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
724 return gst_structure_to_string (GST_STRUCTURE (list));
728 * gst_tag_list_new_from_string:
729 * @str: a string created with gst_tag_list_to_string()
731 * Deserializes a tag list.
733 * Returns: a new #GstTagList, or NULL in case of an error.
738 gst_tag_list_new_from_string (const gchar * str)
740 g_return_val_if_fail (str != NULL, NULL);
741 g_return_val_if_fail (g_str_has_prefix (str, "taglist"), NULL);
743 return GST_TAG_LIST (gst_structure_from_string (str, NULL));
747 * gst_tag_list_is_empty:
748 * @list: A #GstTagList.
750 * Checks if the given taglist is empty.
752 * Returns: TRUE if the taglist is empty, otherwise FALSE.
757 gst_tag_list_is_empty (const GstTagList * list)
759 g_return_val_if_fail (list != NULL, FALSE);
760 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
762 return (gst_structure_n_fields ((GstStructure *) list) == 0);
766 gst_tag_list_fields_equal (const GValue * value1, const GValue * value2)
770 if (gst_value_compare (value1, value2) == GST_VALUE_EQUAL)
773 /* fields not equal: add some tolerance for doubles, otherwise bail out */
774 if (!G_VALUE_HOLDS_DOUBLE (value1) || !G_VALUE_HOLDS_DOUBLE (value2))
777 d1 = g_value_get_double (value1);
778 d2 = g_value_get_double (value2);
780 /* This will only work for 'normal' values and values around 0,
781 * which should be good enough for our purposes here
782 * FIXME: maybe add this to gst_value_compare_double() ? */
783 return (fabs (d1 - d2) < 0.0000001);
787 * gst_tag_list_is_equal:
788 * @list1: a #GstTagList.
789 * @list2: a #GstTagList.
791 * Checks if the two given taglists are equal.
793 * Returns: TRUE if the taglists are equal, otherwise FALSE
798 gst_tag_list_is_equal (const GstTagList * list1, const GstTagList * list2)
800 const GstStructure *s1, *s2;
801 gint num_fields1, num_fields2, i;
803 g_return_val_if_fail (GST_IS_TAG_LIST (list1), FALSE);
804 g_return_val_if_fail (GST_IS_TAG_LIST (list2), FALSE);
806 /* we don't just use gst_structure_is_equal() here so we can add some
807 * tolerance for doubles, though maybe we should just add that to
808 * gst_value_compare_double() as well? */
809 s1 = (const GstStructure *) list1;
810 s2 = (const GstStructure *) list2;
812 num_fields1 = gst_structure_n_fields (s1);
813 num_fields2 = gst_structure_n_fields (s2);
815 if (num_fields1 != num_fields2)
818 for (i = 0; i < num_fields1; i++) {
819 const GValue *value1, *value2;
820 const gchar *tag_name;
822 tag_name = gst_structure_nth_field_name (s1, i);
823 value1 = gst_structure_get_value (s1, tag_name);
824 value2 = gst_structure_get_value (s2, tag_name);
829 if (!gst_tag_list_fields_equal (value1, value2))
838 * @p: Object that might be a taglist
840 * Checks if the given pointer is a taglist.
842 * Returns: TRUE, if the given pointer is a taglist
845 gst_is_tag_list (gconstpointer p)
847 GstStructure *s = (GstStructure *) p;
849 g_return_val_if_fail (p != NULL, FALSE);
851 return (GST_IS_STRUCTURE (s) && s->name == GST_QUARK (TAGLIST));
857 GstTagMergeMode mode;
862 gst_tag_list_add_value_internal (GstTagList * tag_list, GstTagMergeMode mode,
863 const gchar * tag, const GValue * value, GstTagInfo * info)
865 GstStructure *list = GST_STRUCTURE (tag_list);
866 const GValue *value2;
870 info = gst_tag_lookup (tag);
871 if (G_UNLIKELY (info == NULL)) {
872 g_warning ("unknown tag '%s'", tag);
877 tag_quark = info->name_quark;
880 && (value2 = gst_structure_id_get_value (list, tag_quark)) != NULL) {
881 GValue dest = { 0, };
884 case GST_TAG_MERGE_REPLACE_ALL:
885 case GST_TAG_MERGE_REPLACE:
886 gst_structure_id_set_value (list, tag_quark, value);
888 case GST_TAG_MERGE_PREPEND:
889 gst_value_list_merge (&dest, value, value2);
890 gst_structure_id_set_value (list, tag_quark, &dest);
891 g_value_unset (&dest);
893 case GST_TAG_MERGE_APPEND:
894 gst_value_list_merge (&dest, value2, value);
895 gst_structure_id_set_value (list, tag_quark, &dest);
896 g_value_unset (&dest);
898 case GST_TAG_MERGE_KEEP:
899 case GST_TAG_MERGE_KEEP_ALL:
902 g_assert_not_reached ();
907 case GST_TAG_MERGE_APPEND:
908 case GST_TAG_MERGE_KEEP:
909 if (gst_structure_id_get_value (list, tag_quark) != NULL)
912 case GST_TAG_MERGE_REPLACE_ALL:
913 case GST_TAG_MERGE_REPLACE:
914 case GST_TAG_MERGE_PREPEND:
915 gst_structure_id_set_value (list, tag_quark, value);
917 case GST_TAG_MERGE_KEEP_ALL:
920 g_assert_not_reached ();
927 gst_tag_list_copy_foreach (GQuark tag_quark, const GValue * value,
930 GstTagCopyData *copy = (GstTagCopyData *) user_data;
933 tag = g_quark_to_string (tag_quark);
934 gst_tag_list_add_value_internal (copy->list, copy->mode, tag, value, NULL);
940 * gst_tag_list_insert:
941 * @into: list to merge into
942 * @from: list to merge from
943 * @mode: the mode to use
945 * Inserts the tags of the @from list into the first list using the given mode.
948 gst_tag_list_insert (GstTagList * into, const GstTagList * from,
949 GstTagMergeMode mode)
953 g_return_if_fail (GST_IS_TAG_LIST (into));
954 g_return_if_fail (GST_IS_TAG_LIST (from));
955 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
959 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
960 gst_structure_remove_all_fields (GST_STRUCTURE (data.list));
962 gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach,
968 * @list: list to copy
970 * Copies a given #GstTagList.
972 * Free-function: gst_tag_list_free
974 * Returns: (transfer full): copy of the given list
977 gst_tag_list_copy (const GstTagList * list)
979 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
981 return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list));
985 * gst_tag_list_merge:
986 * @list1: first list to merge
987 * @list2: second list to merge
988 * @mode: the mode to use
990 * Merges the two given lists into a new list. If one of the lists is NULL, a
991 * copy of the other is returned. If both lists are NULL, NULL is returned.
993 * Free-function: gst_tag_list_free
995 * Returns: (transfer full): the new list
998 gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
999 GstTagMergeMode mode)
1001 GstTagList *list1_cp;
1002 const GstTagList *list2_cp;
1004 g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
1005 g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
1006 g_return_val_if_fail (GST_TAG_MODE_IS_VALID (mode), NULL);
1008 /* nothing to merge */
1009 if (!list1 && !list2) {
1013 /* create empty list, we need to do this to correctly handling merge modes */
1014 list1_cp = (list1) ? gst_tag_list_copy (list1) : gst_tag_list_new ();
1015 list2_cp = (list2) ? list2 : gst_tag_list_new ();
1017 gst_tag_list_insert (list1_cp, list2_cp, mode);
1020 gst_tag_list_free ((GstTagList *) list2_cp);
1026 * gst_tag_list_free:
1027 * @list: (in) (transfer full): the list to free
1029 * Frees the given list and all associated values.
1032 gst_tag_list_free (GstTagList * list)
1034 g_return_if_fail (GST_IS_TAG_LIST (list));
1035 gst_structure_free ((GstStructure *) list);
1039 * gst_tag_list_get_tag_size:
1041 * @tag: the tag to query
1043 * Checks how many value are stored in this tag list for the given tag.
1045 * Returns: The number of tags stored
1048 gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag)
1050 const GValue *value;
1052 g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
1054 value = gst_structure_get_value ((GstStructure *) list, tag);
1057 if (G_VALUE_TYPE (value) != GST_TYPE_LIST)
1060 return gst_value_list_get_size (value);
1065 * @list: list to set tags in
1066 * @mode: the mode to use
1068 * @...: NULL-terminated list of values to set
1070 * Sets the values for the given tags using the specified mode.
1073 gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag,
1078 g_return_if_fail (GST_IS_TAG_LIST (list));
1079 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1080 g_return_if_fail (tag != NULL);
1082 va_start (args, tag);
1083 gst_tag_list_add_valist (list, mode, tag, args);
1088 * gst_tag_list_add_values:
1089 * @list: list to set tags in
1090 * @mode: the mode to use
1092 * @...: GValues to set
1094 * Sets the GValues for the given tags using the specified mode.
1097 gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode,
1098 const gchar * tag, ...)
1102 g_return_if_fail (GST_IS_TAG_LIST (list));
1103 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1104 g_return_if_fail (tag != NULL);
1106 va_start (args, tag);
1107 gst_tag_list_add_valist_values (list, mode, tag, args);
1112 * gst_tag_list_add_valist:
1113 * @list: list to set tags in
1114 * @mode: the mode to use
1116 * @var_args: tag / value pairs to set
1118 * Sets the values for the given tags using the specified mode.
1121 gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
1122 const gchar * tag, va_list var_args)
1125 gchar *error = NULL;
1127 g_return_if_fail (GST_IS_TAG_LIST (list));
1128 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1129 g_return_if_fail (tag != NULL);
1131 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1132 gst_structure_remove_all_fields (GST_STRUCTURE (list));
1135 while (tag != NULL) {
1136 GValue value = { 0, };
1138 info = gst_tag_lookup (tag);
1139 if (G_UNLIKELY (info == NULL)) {
1140 g_warning ("unknown tag '%s'", tag);
1143 G_VALUE_COLLECT_INIT (&value, info->type, var_args, 0, &error);
1145 g_warning ("%s: %s", G_STRLOC, error);
1147 /* we purposely leak the value here, it might not be
1148 * in a sane state if an error condition occoured
1152 gst_tag_list_add_value_internal (list, mode, tag, &value, info);
1153 g_value_unset (&value);
1154 tag = va_arg (var_args, gchar *);
1159 * gst_tag_list_add_valist_values:
1160 * @list: list to set tags in
1161 * @mode: the mode to use
1163 * @var_args: tag / GValue pairs to set
1165 * Sets the GValues for the given tags using the specified mode.
1168 gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
1169 const gchar * tag, va_list var_args)
1171 g_return_if_fail (GST_IS_TAG_LIST (list));
1172 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1173 g_return_if_fail (tag != NULL);
1175 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1176 gst_structure_remove_all_fields (GST_STRUCTURE (list));
1179 while (tag != NULL) {
1182 info = gst_tag_lookup (tag);
1183 if (G_UNLIKELY (info == NULL)) {
1184 g_warning ("unknown tag '%s'", tag);
1187 gst_tag_list_add_value_internal (list, mode, tag, va_arg (var_args,
1189 tag = va_arg (var_args, gchar *);
1194 * gst_tag_list_add_value:
1195 * @list: list to set tags in
1196 * @mode: the mode to use
1198 * @value: GValue for this tag
1200 * Sets the GValue for a given tag using the specified mode.
1205 gst_tag_list_add_value (GstTagList * list, GstTagMergeMode mode,
1206 const gchar * tag, const GValue * value)
1208 g_return_if_fail (GST_IS_TAG_LIST (list));
1209 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1210 g_return_if_fail (tag != NULL);
1212 gst_tag_list_add_value_internal (list, mode, tag, value, NULL);
1216 * gst_tag_list_remove_tag:
1217 * @list: list to remove tag from
1218 * @tag: tag to remove
1220 * Removes the given tag from the taglist.
1223 gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
1225 g_return_if_fail (GST_IS_TAG_LIST (list));
1226 g_return_if_fail (tag != NULL);
1228 gst_structure_remove_field ((GstStructure *) list, tag);
1233 GstTagForeachFunc func;
1234 const GstTagList *tag_list;
1240 structure_foreach_wrapper (GQuark field_id, const GValue * value,
1243 TagForeachData *data = (TagForeachData *) user_data;
1245 data->func (data->tag_list, g_quark_to_string (field_id), data->data);
1250 * gst_tag_list_foreach:
1251 * @list: list to iterate over
1252 * @func: (scope call): function to be called for each tag
1253 * @user_data: (closure): user specified data
1255 * Calls the given function for each tag inside the tag list. Note that if there
1256 * is no tag, the function won't be called at all.
1259 gst_tag_list_foreach (const GstTagList * list, GstTagForeachFunc func,
1262 TagForeachData data;
1264 g_return_if_fail (GST_IS_TAG_LIST (list));
1265 g_return_if_fail (func != NULL);
1268 data.tag_list = list;
1269 data.data = user_data;
1270 gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper,
1275 * gst_tag_list_get_value_index:
1276 * @list: a #GstTagList
1277 * @tag: tag to read out
1278 * @index: number of entry to read out
1280 * Gets the value that is at the given index for the given tag in the given
1283 * Returns: (transfer none): The GValue for the specified entry or NULL if the
1284 * tag wasn't available or the tag doesn't have as many entries
1287 gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
1290 const GValue *value;
1292 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
1293 g_return_val_if_fail (tag != NULL, NULL);
1295 value = gst_structure_get_value ((GstStructure *) list, tag);
1299 if (GST_VALUE_HOLDS_LIST (value)) {
1300 if (index >= gst_value_list_get_size (value))
1302 return gst_value_list_get_value (value, index);
1311 * gst_tag_list_copy_value:
1312 * @dest: (out caller-allocates): uninitialized #GValue to copy into
1313 * @list: list to get the tag from
1314 * @tag: tag to read out
1316 * Copies the contents for the given tag into the value,
1317 * merging multiple values into one if multiple values are associated
1319 * You must g_value_unset() the value after use.
1321 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1325 gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
1330 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1331 g_return_val_if_fail (tag != NULL, FALSE);
1332 g_return_val_if_fail (dest != NULL, FALSE);
1333 g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
1335 src = gst_structure_get_value ((GstStructure *) list, tag);
1339 if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
1340 GstTagInfo *info = gst_tag_lookup (tag);
1345 /* must be there or lists aren't allowed */
1346 g_assert (info->merge_func);
1347 info->merge_func (dest, src);
1349 g_value_init (dest, G_VALUE_TYPE (src));
1350 g_value_copy (src, dest);
1355 /* FIXME 0.11: this whole merge function business is overdesigned, and the
1356 * _get_foo() API is misleading as well - how many application developers will
1357 * expect gst_tag_list_get_string (list, GST_TAG_ARTIST, &val) might return a
1358 * string with multiple comma-separated artists? _get_foo() should just be
1359 * a convenience wrapper around _get_foo_index (list, tag, 0, &val),
1360 * supplemented by a special _tag_list_get_string_merged() function if needed
1361 * (unless someone can actually think of real use cases where the merge
1362 * function is not 'use first' for non-strings and merge for strings) */
1364 /***** evil macros to get all the gst_tag_list_get_*() functions right *****/
1366 #define TAG_MERGE_FUNCS(name,type,ret) \
1368 gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
1371 GValue v = { 0, }; \
1373 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1374 g_return_val_if_fail (tag != NULL, FALSE); \
1375 g_return_val_if_fail (value != NULL, FALSE); \
1377 if (!gst_tag_list_copy_value (&v, list, tag)) \
1379 *value = COPY_FUNC (g_value_get_ ## name (&v)); \
1380 g_value_unset (&v); \
1385 gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
1387 guint index, type *value) \
1391 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1392 g_return_val_if_fail (tag != NULL, FALSE); \
1393 g_return_val_if_fail (value != NULL, FALSE); \
1395 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
1397 *value = COPY_FUNC (g_value_get_ ## name (v)); \
1401 /* FIXME 0.11: maybe get rid of _get_char*(), _get_uchar*(), _get_long*(),
1402 * _get_ulong*() and _get_pointer*()? - they are not really useful/common
1403 * enough to warrant convenience accessor functions */
1405 #define COPY_FUNC /**/
1407 * gst_tag_list_get_char:
1408 * @list: a #GstTagList to get the tag from
1409 * @tag: tag to read out
1410 * @value: (out): location for the result
1412 * Copies the contents for the given tag into the value, merging multiple values
1413 * into one if multiple values are associated with the tag.
1415 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1419 * gst_tag_list_get_char_index:
1420 * @list: a #GstTagList to get the tag from
1421 * @tag: tag to read out
1422 * @index: number of entry to read out
1423 * @value: (out): location for the result
1425 * Gets the value that is at the given index for the given tag in the given
1428 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1431 TAG_MERGE_FUNCS (char, gchar, TRUE);
1433 * gst_tag_list_get_uchar:
1434 * @list: a #GstTagList to get the tag from
1435 * @tag: tag to read out
1436 * @value: (out): location for the result
1438 * Copies the contents for the given tag into the value, merging multiple values
1439 * into one if multiple values are associated with the tag.
1441 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1445 * gst_tag_list_get_uchar_index:
1446 * @list: a #GstTagList to get the tag from
1447 * @tag: tag to read out
1448 * @index: number of entry to read out
1449 * @value: (out): location for the result
1451 * Gets the value that is at the given index for the given tag in the given
1454 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1457 TAG_MERGE_FUNCS (uchar, guchar, TRUE);
1459 * gst_tag_list_get_boolean:
1460 * @list: a #GstTagList to get the tag from
1461 * @tag: tag to read out
1462 * @value: (out): location for the result
1464 * Copies the contents for the given tag into the value, merging multiple values
1465 * into one if multiple values are associated with the tag.
1467 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1471 * gst_tag_list_get_boolean_index:
1472 * @list: a #GstTagList to get the tag from
1473 * @tag: tag to read out
1474 * @index: number of entry to read out
1475 * @value: (out): location for the result
1477 * Gets the value that is at the given index for the given tag in the given
1480 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1483 TAG_MERGE_FUNCS (boolean, gboolean, TRUE);
1485 * gst_tag_list_get_int:
1486 * @list: a #GstTagList to get the tag from
1487 * @tag: tag to read out
1488 * @value: (out): location for the result
1490 * Copies the contents for the given tag into the value, merging multiple values
1491 * into one if multiple values are associated with the tag.
1493 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1497 * gst_tag_list_get_int_index:
1498 * @list: a #GstTagList to get the tag from
1499 * @tag: tag to read out
1500 * @index: number of entry to read out
1501 * @value: (out): location for the result
1503 * Gets the value that is at the given index for the given tag in the given
1506 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1509 TAG_MERGE_FUNCS (int, gint, TRUE);
1511 * gst_tag_list_get_uint:
1512 * @list: a #GstTagList to get the tag from
1513 * @tag: tag to read out
1514 * @value: (out): location for the result
1516 * Copies the contents for the given tag into the value, merging multiple values
1517 * into one if multiple values are associated with the tag.
1519 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1523 * gst_tag_list_get_uint_index:
1524 * @list: a #GstTagList to get the tag from
1525 * @tag: tag to read out
1526 * @index: number of entry to read out
1527 * @value: (out): location for the result
1529 * Gets the value that is at the given index for the given tag in the given
1532 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1535 TAG_MERGE_FUNCS (uint, guint, TRUE);
1537 * gst_tag_list_get_long:
1538 * @list: a #GstTagList to get the tag from
1539 * @tag: tag to read out
1540 * @value: (out): location for the result
1542 * Copies the contents for the given tag into the value, merging multiple values
1543 * into one if multiple values are associated with the tag.
1545 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1549 * gst_tag_list_get_long_index:
1550 * @list: a #GstTagList to get the tag from
1551 * @tag: tag to read out
1552 * @index: number of entry to read out
1553 * @value: (out): location for the result
1555 * Gets the value that is at the given index for the given tag in the given
1558 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1561 TAG_MERGE_FUNCS (long, glong, TRUE);
1563 * gst_tag_list_get_ulong:
1564 * @list: a #GstTagList to get the tag from
1565 * @tag: tag to read out
1566 * @value: (out): location for the result
1568 * Copies the contents for the given tag into the value, merging multiple values
1569 * into one if multiple values are associated with the tag.
1571 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1575 * gst_tag_list_get_ulong_index:
1576 * @list: a #GstTagList to get the tag from
1577 * @tag: tag to read out
1578 * @index: number of entry to read out
1579 * @value: (out): location for the result
1581 * Gets the value that is at the given index for the given tag in the given
1584 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1587 TAG_MERGE_FUNCS (ulong, gulong, TRUE);
1589 * gst_tag_list_get_int64:
1590 * @list: a #GstTagList to get the tag from
1591 * @tag: tag to read out
1592 * @value: (out): location for the result
1594 * Copies the contents for the given tag into the value, merging multiple values
1595 * into one if multiple values are associated with the tag.
1597 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1601 * gst_tag_list_get_int64_index:
1602 * @list: a #GstTagList to get the tag from
1603 * @tag: tag to read out
1604 * @index: number of entry to read out
1605 * @value: (out): location for the result
1607 * Gets the value that is at the given index for the given tag in the given
1610 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1613 TAG_MERGE_FUNCS (int64, gint64, TRUE);
1615 * gst_tag_list_get_uint64:
1616 * @list: a #GstTagList to get the tag from
1617 * @tag: tag to read out
1618 * @value: (out): location for the result
1620 * Copies the contents for the given tag into the value, merging multiple values
1621 * into one if multiple values are associated with the tag.
1623 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1627 * gst_tag_list_get_uint64_index:
1628 * @list: a #GstTagList to get the tag from
1629 * @tag: tag to read out
1630 * @index: number of entry to read out
1631 * @value: (out): location for the result
1633 * Gets the value that is at the given index for the given tag in the given
1636 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1639 TAG_MERGE_FUNCS (uint64, guint64, TRUE);
1641 * gst_tag_list_get_float:
1642 * @list: a #GstTagList to get the tag from
1643 * @tag: tag to read out
1644 * @value: (out): location for the result
1646 * Copies the contents for the given tag into the value, merging multiple values
1647 * into one if multiple values are associated with the tag.
1649 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1653 * gst_tag_list_get_float_index:
1654 * @list: a #GstTagList to get the tag from
1655 * @tag: tag to read out
1656 * @index: number of entry to read out
1657 * @value: (out): location for the result
1659 * Gets the value that is at the given index for the given tag in the given
1662 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1665 TAG_MERGE_FUNCS (float, gfloat, TRUE);
1667 * gst_tag_list_get_double:
1668 * @list: a #GstTagList to get the tag from
1669 * @tag: tag to read out
1670 * @value: (out): location for the result
1672 * Copies the contents for the given tag into the value, merging multiple values
1673 * into one if multiple values are associated with the tag.
1675 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1679 * gst_tag_list_get_double_index:
1680 * @list: a #GstTagList to get the tag from
1681 * @tag: tag to read out
1682 * @index: number of entry to read out
1683 * @value: (out): location for the result
1685 * Gets the value that is at the given index for the given tag in the given
1688 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1691 TAG_MERGE_FUNCS (double, gdouble, TRUE);
1693 * gst_tag_list_get_pointer:
1694 * @list: a #GstTagList to get the tag from
1695 * @tag: tag to read out
1696 * @value: (out) (transfer none): location for the result
1698 * Copies the contents for the given tag into the value, merging multiple values
1699 * into one if multiple values are associated with the tag.
1701 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1705 * gst_tag_list_get_pointer_index:
1706 * @list: a #GstTagList to get the tag from
1707 * @tag: tag to read out
1708 * @index: number of entry to read out
1709 * @value: (out) (transfer none): location for the result
1711 * Gets the value that is at the given index for the given tag in the given
1714 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1717 TAG_MERGE_FUNCS (pointer, gpointer, (*value != NULL));
1719 static inline gchar *
1720 _gst_strdup0 (const gchar * s)
1722 if (s == NULL || *s == '\0')
1725 return g_strdup (s);
1729 #define COPY_FUNC _gst_strdup0
1732 * gst_tag_list_get_string:
1733 * @list: a #GstTagList to get the tag from
1734 * @tag: tag to read out
1735 * @value: (out callee-allocates) (transfer full): location for the result
1737 * Copies the contents for the given tag into the value, possibly merging
1738 * multiple values into one if multiple values are associated with the tag.
1740 * Use gst_tag_list_get_string_index (list, tag, 0, value) if you want
1741 * to retrieve the first string associated with this tag unmodified.
1743 * The resulting string in @value will be in UTF-8 encoding and should be
1744 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1745 * returned string is also guaranteed to be non-NULL and non-empty.
1747 * Free-function: g_free
1749 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1753 * gst_tag_list_get_string_index:
1754 * @list: a #GstTagList to get the tag from
1755 * @tag: tag to read out
1756 * @index: number of entry to read out
1757 * @value: (out callee-allocates) (transfer full): location for the result
1759 * Gets the value that is at the given index for the given tag in the given
1762 * The resulting string in @value will be in UTF-8 encoding and should be
1763 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1764 * returned string is also guaranteed to be non-NULL and non-empty.
1766 * Free-function: g_free
1768 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1771 TAG_MERGE_FUNCS (string, gchar *, (*value != NULL));
1774 *FIXME 0.11: Instead of _peek (non-copy) and _get (copy), we could have
1775 * _get (non-copy) and _dup (copy) for strings, seems more
1779 * gst_tag_list_peek_string_index:
1780 * @list: a #GstTagList to get the tag from
1781 * @tag: tag to read out
1782 * @index: number of entry to read out
1783 * @value: (out) (transfer none): location for the result
1785 * Peeks at the value that is at the given index for the given tag in the given
1788 * The resulting string in @value will be in UTF-8 encoding and doesn't need
1789 * to be freed by the caller. The returned string is also guaranteed to
1790 * be non-NULL and non-empty.
1792 * Returns: TRUE, if a value was set, FALSE if the tag didn't exist in the
1796 gst_tag_list_peek_string_index (const GstTagList * list,
1797 const gchar * tag, guint index, const gchar ** value)
1801 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1802 g_return_val_if_fail (tag != NULL, FALSE);
1803 g_return_val_if_fail (value != NULL, FALSE);
1805 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1807 *value = g_value_get_string (v);
1808 return *value != NULL && **value != '\0';
1812 * gst_tag_list_get_date:
1813 * @list: a #GstTagList to get the tag from
1814 * @tag: tag to read out
1815 * @value: (out callee-allocates) (transfer full): address of a GDate pointer
1816 * variable to store the result into
1818 * Copies the first date for the given tag in the taglist into the variable
1819 * pointed to by @value. Free the date with g_date_free() when it is no longer
1822 * Free-function: g_date_free
1824 * Returns: TRUE, if a date was copied, FALSE if the tag didn't exist in the
1825 * given list or if it was #NULL.
1828 gst_tag_list_get_date (const GstTagList * list, const gchar * tag,
1833 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1834 g_return_val_if_fail (tag != NULL, FALSE);
1835 g_return_val_if_fail (value != NULL, FALSE);
1837 if (!gst_tag_list_copy_value (&v, list, tag))
1839 *value = (GDate *) g_value_dup_boxed (&v);
1841 return (*value != NULL);
1845 * gst_tag_list_get_date_index:
1846 * @list: a #GstTagList to get the tag from
1847 * @tag: tag to read out
1848 * @index: number of entry to read out
1849 * @value: (out callee-allocates) (transfer full): location for the result
1851 * Gets the date that is at the given index for the given tag in the given
1852 * list and copies it into the variable pointed to by @value. Free the date
1853 * with g_date_free() when it is no longer needed.
1855 * Free-function: g_date_free
1857 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1858 * given list or if it was #NULL.
1861 gst_tag_list_get_date_index (const GstTagList * list,
1862 const gchar * tag, guint index, GDate ** value)
1866 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1867 g_return_val_if_fail (tag != NULL, FALSE);
1868 g_return_val_if_fail (value != NULL, FALSE);
1870 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1872 *value = (GDate *) g_value_dup_boxed (v);
1873 return (*value != NULL);
1877 * gst_tag_list_get_date_time:
1878 * @list: a #GstTagList to get the tag from
1879 * @tag: tag to read out
1880 * @value: (out callee-allocates) (transfer full): address of a #GstDateTime
1881 * pointer variable to store the result into
1883 * Copies the first datetime for the given tag in the taglist into the variable
1884 * pointed to by @value. Unref the date with gst_date_time_unref() when
1885 * it is no longer needed.
1887 * Free-function: gst_date_time_unref
1889 * Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in
1890 * thegiven list or if it was #NULL.
1895 gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag,
1896 GstDateTime ** value)
1900 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1901 g_return_val_if_fail (tag != NULL, FALSE);
1902 g_return_val_if_fail (value != NULL, FALSE);
1904 if (!gst_tag_list_copy_value (&v, list, tag))
1907 g_return_val_if_fail (GST_VALUE_HOLDS_DATE_TIME (&v), FALSE);
1909 *value = (GstDateTime *) g_value_dup_boxed (&v);
1911 return (*value != NULL);
1915 * gst_tag_list_get_date_time_index:
1916 * @list: a #GstTagList to get the tag from
1917 * @tag: tag to read out
1918 * @index: number of entry to read out
1919 * @value: (out callee-allocates) (transfer full): location for the result
1921 * Gets the datetime that is at the given index for the given tag in the given
1922 * list and copies it into the variable pointed to by @value. Unref the datetime
1923 * with gst_date_time_unref() when it is no longer needed.
1925 * Free-function: gst_date_time_unref
1927 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1928 * given list or if it was #NULL.
1933 gst_tag_list_get_date_time_index (const GstTagList * list,
1934 const gchar * tag, guint index, GstDateTime ** value)
1938 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1939 g_return_val_if_fail (tag != NULL, FALSE);
1940 g_return_val_if_fail (value != NULL, FALSE);
1942 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1944 *value = (GstDateTime *) g_value_dup_boxed (v);
1945 return (*value != NULL);
1949 * gst_tag_list_get_buffer:
1950 * @list: a #GstTagList to get the tag from
1951 * @tag: tag to read out
1952 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
1953 * pointer variable to store the result into
1955 * Copies the first buffer for the given tag in the taglist into the variable
1956 * pointed to by @value. Free the buffer with gst_buffer_unref() when it is
1959 * Free-function: gst_buffer_unref
1961 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1962 * given list or if it was #NULL.
1967 gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag,
1972 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1973 g_return_val_if_fail (tag != NULL, FALSE);
1974 g_return_val_if_fail (value != NULL, FALSE);
1976 if (!gst_tag_list_copy_value (&v, list, tag))
1978 *value = g_value_dup_boxed (&v);
1980 return (*value != NULL);
1984 * gst_tag_list_get_buffer_index:
1985 * @list: a #GstTagList to get the tag from
1986 * @tag: tag to read out
1987 * @index: number of entry to read out
1988 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
1989 * pointer variable to store the result into
1991 * Gets the buffer that is at the given index for the given tag in the given
1992 * list and copies it into the variable pointed to by @value. Free the buffer
1993 * with gst_buffer_unref() when it is no longer needed.
1995 * Free-function: gst_buffer_unref
1997 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1998 * given list or if it was #NULL.
2003 gst_tag_list_get_buffer_index (const GstTagList * list,
2004 const gchar * tag, guint index, GstBuffer ** value)
2008 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
2009 g_return_val_if_fail (tag != NULL, FALSE);
2010 g_return_val_if_fail (value != NULL, FALSE);
2012 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
2014 *value = g_value_dup_boxed (v);
2015 return (*value != NULL);