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;
629 * gst_tag_list_new_empty:
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_empty (void)
640 return GST_TAG_LIST (gst_structure_new_id_empty (GST_QUARK (TAGLIST)));
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.
664 gst_tag_list_new (const gchar * tag, ...)
669 g_return_val_if_fail (tag != NULL, NULL);
671 list = gst_tag_list_new_empty ();
672 va_start (args, tag);
673 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, args);
680 * gst_tag_list_new_valist:
681 * @var_args: tag / value pairs to set
683 * Just like gst_tag_list_new(), only that it takes a va_list argument.
684 * Useful mostly for language bindings.
686 * Free-function: gst_tag_list_free
688 * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_free()
689 * when no longer needed.
694 gst_tag_list_new_valist (va_list var_args)
699 list = gst_tag_list_new_empty ();
701 tag = va_arg (var_args, gchar *);
702 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, var_args);
708 * gst_tag_list_to_string:
709 * @list: a #GstTagList
711 * Serializes a tag list to a string.
713 * Returns: a newly-allocated string, or NULL in case of an error. The
714 * string must be freed with g_free() when no longer needed.
719 gst_tag_list_to_string (const GstTagList * list)
721 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
723 return gst_structure_to_string (GST_STRUCTURE (list));
727 * gst_tag_list_new_from_string:
728 * @str: a string created with gst_tag_list_to_string()
730 * Deserializes a tag list.
732 * Returns: a new #GstTagList, or NULL in case of an error.
737 gst_tag_list_new_from_string (const gchar * str)
739 g_return_val_if_fail (str != NULL, NULL);
740 g_return_val_if_fail (g_str_has_prefix (str, "taglist"), NULL);
742 return GST_TAG_LIST (gst_structure_from_string (str, NULL));
746 * gst_tag_list_is_empty:
747 * @list: A #GstTagList.
749 * Checks if the given taglist is empty.
751 * Returns: TRUE if the taglist is empty, otherwise FALSE.
756 gst_tag_list_is_empty (const GstTagList * list)
758 g_return_val_if_fail (list != NULL, FALSE);
759 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
761 return (gst_structure_n_fields ((GstStructure *) list) == 0);
765 gst_tag_list_fields_equal (const GValue * value1, const GValue * value2)
769 if (gst_value_compare (value1, value2) == GST_VALUE_EQUAL)
772 /* fields not equal: add some tolerance for doubles, otherwise bail out */
773 if (!G_VALUE_HOLDS_DOUBLE (value1) || !G_VALUE_HOLDS_DOUBLE (value2))
776 d1 = g_value_get_double (value1);
777 d2 = g_value_get_double (value2);
779 /* This will only work for 'normal' values and values around 0,
780 * which should be good enough for our purposes here
781 * FIXME: maybe add this to gst_value_compare_double() ? */
782 return (fabs (d1 - d2) < 0.0000001);
786 * gst_tag_list_is_equal:
787 * @list1: a #GstTagList.
788 * @list2: a #GstTagList.
790 * Checks if the two given taglists are equal.
792 * Returns: TRUE if the taglists are equal, otherwise FALSE
797 gst_tag_list_is_equal (const GstTagList * list1, const GstTagList * list2)
799 const GstStructure *s1, *s2;
800 gint num_fields1, num_fields2, i;
802 g_return_val_if_fail (GST_IS_TAG_LIST (list1), FALSE);
803 g_return_val_if_fail (GST_IS_TAG_LIST (list2), FALSE);
805 /* we don't just use gst_structure_is_equal() here so we can add some
806 * tolerance for doubles, though maybe we should just add that to
807 * gst_value_compare_double() as well? */
808 s1 = (const GstStructure *) list1;
809 s2 = (const GstStructure *) list2;
811 num_fields1 = gst_structure_n_fields (s1);
812 num_fields2 = gst_structure_n_fields (s2);
814 if (num_fields1 != num_fields2)
817 for (i = 0; i < num_fields1; i++) {
818 const GValue *value1, *value2;
819 const gchar *tag_name;
821 tag_name = gst_structure_nth_field_name (s1, i);
822 value1 = gst_structure_get_value (s1, tag_name);
823 value2 = gst_structure_get_value (s2, tag_name);
828 if (!gst_tag_list_fields_equal (value1, value2))
837 * @p: Object that might be a taglist
839 * Checks if the given pointer is a taglist.
841 * Returns: TRUE, if the given pointer is a taglist
844 gst_is_tag_list (gconstpointer p)
846 GstStructure *s = (GstStructure *) p;
848 g_return_val_if_fail (p != NULL, FALSE);
850 return (GST_IS_STRUCTURE (s) && s->name == GST_QUARK (TAGLIST));
856 GstTagMergeMode mode;
861 gst_tag_list_add_value_internal (GstTagList * tag_list, GstTagMergeMode mode,
862 const gchar * tag, const GValue * value, GstTagInfo * info)
864 GstStructure *list = GST_STRUCTURE (tag_list);
865 const GValue *value2;
869 info = gst_tag_lookup (tag);
870 if (G_UNLIKELY (info == NULL)) {
871 g_warning ("unknown tag '%s'", tag);
876 tag_quark = info->name_quark;
879 && (value2 = gst_structure_id_get_value (list, tag_quark)) != NULL) {
880 GValue dest = { 0, };
883 case GST_TAG_MERGE_REPLACE_ALL:
884 case GST_TAG_MERGE_REPLACE:
885 gst_structure_id_set_value (list, tag_quark, value);
887 case GST_TAG_MERGE_PREPEND:
888 gst_value_list_merge (&dest, value, value2);
889 gst_structure_id_set_value (list, tag_quark, &dest);
890 g_value_unset (&dest);
892 case GST_TAG_MERGE_APPEND:
893 gst_value_list_merge (&dest, value2, value);
894 gst_structure_id_set_value (list, tag_quark, &dest);
895 g_value_unset (&dest);
897 case GST_TAG_MERGE_KEEP:
898 case GST_TAG_MERGE_KEEP_ALL:
901 g_assert_not_reached ();
906 case GST_TAG_MERGE_APPEND:
907 case GST_TAG_MERGE_KEEP:
908 if (gst_structure_id_get_value (list, tag_quark) != NULL)
911 case GST_TAG_MERGE_REPLACE_ALL:
912 case GST_TAG_MERGE_REPLACE:
913 case GST_TAG_MERGE_PREPEND:
914 gst_structure_id_set_value (list, tag_quark, value);
916 case GST_TAG_MERGE_KEEP_ALL:
919 g_assert_not_reached ();
926 gst_tag_list_copy_foreach (GQuark tag_quark, const GValue * value,
929 GstTagCopyData *copy = (GstTagCopyData *) user_data;
932 tag = g_quark_to_string (tag_quark);
933 gst_tag_list_add_value_internal (copy->list, copy->mode, tag, value, NULL);
939 * gst_tag_list_insert:
940 * @into: list to merge into
941 * @from: list to merge from
942 * @mode: the mode to use
944 * Inserts the tags of the @from list into the first list using the given mode.
947 gst_tag_list_insert (GstTagList * into, const GstTagList * from,
948 GstTagMergeMode mode)
952 g_return_if_fail (GST_IS_TAG_LIST (into));
953 g_return_if_fail (GST_IS_TAG_LIST (from));
954 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
958 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
959 gst_structure_remove_all_fields (GST_STRUCTURE (data.list));
961 gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach,
967 * @list: list to copy
969 * Copies a given #GstTagList.
971 * Free-function: gst_tag_list_free
973 * Returns: (transfer full): copy of the given list
976 gst_tag_list_copy (const GstTagList * list)
978 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
980 return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list));
984 * gst_tag_list_merge:
985 * @list1: first list to merge
986 * @list2: second list to merge
987 * @mode: the mode to use
989 * Merges the two given lists into a new list. If one of the lists is NULL, a
990 * copy of the other is returned. If both lists are NULL, NULL is returned.
992 * Free-function: gst_tag_list_free
994 * Returns: (transfer full): the new list
997 gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
998 GstTagMergeMode mode)
1000 GstTagList *list1_cp;
1001 const GstTagList *list2_cp;
1003 g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
1004 g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
1005 g_return_val_if_fail (GST_TAG_MODE_IS_VALID (mode), NULL);
1007 /* nothing to merge */
1008 if (!list1 && !list2) {
1012 /* create empty list, we need to do this to correctly handling merge modes */
1013 list1_cp = (list1) ? gst_tag_list_copy (list1) : gst_tag_list_new_empty ();
1014 list2_cp = (list2) ? list2 : gst_tag_list_new_empty ();
1016 gst_tag_list_insert (list1_cp, list2_cp, mode);
1019 gst_tag_list_free ((GstTagList *) list2_cp);
1025 * gst_tag_list_free:
1026 * @list: (in) (transfer full): the list to free
1028 * Frees the given list and all associated values.
1031 gst_tag_list_free (GstTagList * list)
1033 g_return_if_fail (GST_IS_TAG_LIST (list));
1034 gst_structure_free ((GstStructure *) list);
1038 * gst_tag_list_get_tag_size:
1040 * @tag: the tag to query
1042 * Checks how many value are stored in this tag list for the given tag.
1044 * Returns: The number of tags stored
1047 gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag)
1049 const GValue *value;
1051 g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
1053 value = gst_structure_get_value ((GstStructure *) list, tag);
1056 if (G_VALUE_TYPE (value) != GST_TYPE_LIST)
1059 return gst_value_list_get_size (value);
1064 * @list: list to set tags in
1065 * @mode: the mode to use
1067 * @...: NULL-terminated list of values to set
1069 * Sets the values for the given tags using the specified mode.
1072 gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag,
1077 g_return_if_fail (GST_IS_TAG_LIST (list));
1078 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1079 g_return_if_fail (tag != NULL);
1081 va_start (args, tag);
1082 gst_tag_list_add_valist (list, mode, tag, args);
1087 * gst_tag_list_add_values:
1088 * @list: list to set tags in
1089 * @mode: the mode to use
1091 * @...: GValues to set
1093 * Sets the GValues for the given tags using the specified mode.
1096 gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode,
1097 const gchar * tag, ...)
1101 g_return_if_fail (GST_IS_TAG_LIST (list));
1102 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1103 g_return_if_fail (tag != NULL);
1105 va_start (args, tag);
1106 gst_tag_list_add_valist_values (list, mode, tag, args);
1111 * gst_tag_list_add_valist:
1112 * @list: list to set tags in
1113 * @mode: the mode to use
1115 * @var_args: tag / value pairs to set
1117 * Sets the values for the given tags using the specified mode.
1120 gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
1121 const gchar * tag, va_list var_args)
1124 gchar *error = NULL;
1126 g_return_if_fail (GST_IS_TAG_LIST (list));
1127 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1128 g_return_if_fail (tag != NULL);
1130 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1131 gst_structure_remove_all_fields (GST_STRUCTURE (list));
1134 while (tag != NULL) {
1135 GValue value = { 0, };
1137 info = gst_tag_lookup (tag);
1138 if (G_UNLIKELY (info == NULL)) {
1139 g_warning ("unknown tag '%s'", tag);
1142 G_VALUE_COLLECT_INIT (&value, info->type, var_args, 0, &error);
1144 g_warning ("%s: %s", G_STRLOC, error);
1146 /* we purposely leak the value here, it might not be
1147 * in a sane state if an error condition occoured
1151 gst_tag_list_add_value_internal (list, mode, tag, &value, info);
1152 g_value_unset (&value);
1153 tag = va_arg (var_args, gchar *);
1158 * gst_tag_list_add_valist_values:
1159 * @list: list to set tags in
1160 * @mode: the mode to use
1162 * @var_args: tag / GValue pairs to set
1164 * Sets the GValues for the given tags using the specified mode.
1167 gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
1168 const gchar * tag, va_list var_args)
1170 g_return_if_fail (GST_IS_TAG_LIST (list));
1171 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1172 g_return_if_fail (tag != NULL);
1174 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1175 gst_structure_remove_all_fields (GST_STRUCTURE (list));
1178 while (tag != NULL) {
1181 info = gst_tag_lookup (tag);
1182 if (G_UNLIKELY (info == NULL)) {
1183 g_warning ("unknown tag '%s'", tag);
1186 gst_tag_list_add_value_internal (list, mode, tag, va_arg (var_args,
1188 tag = va_arg (var_args, gchar *);
1193 * gst_tag_list_add_value:
1194 * @list: list to set tags in
1195 * @mode: the mode to use
1197 * @value: GValue for this tag
1199 * Sets the GValue for a given tag using the specified mode.
1204 gst_tag_list_add_value (GstTagList * list, GstTagMergeMode mode,
1205 const gchar * tag, const GValue * value)
1207 g_return_if_fail (GST_IS_TAG_LIST (list));
1208 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1209 g_return_if_fail (tag != NULL);
1211 gst_tag_list_add_value_internal (list, mode, tag, value, NULL);
1215 * gst_tag_list_remove_tag:
1216 * @list: list to remove tag from
1217 * @tag: tag to remove
1219 * Removes the given tag from the taglist.
1222 gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
1224 g_return_if_fail (GST_IS_TAG_LIST (list));
1225 g_return_if_fail (tag != NULL);
1227 gst_structure_remove_field ((GstStructure *) list, tag);
1232 GstTagForeachFunc func;
1233 const GstTagList *tag_list;
1239 structure_foreach_wrapper (GQuark field_id, const GValue * value,
1242 TagForeachData *data = (TagForeachData *) user_data;
1244 data->func (data->tag_list, g_quark_to_string (field_id), data->data);
1249 * gst_tag_list_foreach:
1250 * @list: list to iterate over
1251 * @func: (scope call): function to be called for each tag
1252 * @user_data: (closure): user specified data
1254 * Calls the given function for each tag inside the tag list. Note that if there
1255 * is no tag, the function won't be called at all.
1258 gst_tag_list_foreach (const GstTagList * list, GstTagForeachFunc func,
1261 TagForeachData data;
1263 g_return_if_fail (GST_IS_TAG_LIST (list));
1264 g_return_if_fail (func != NULL);
1267 data.tag_list = list;
1268 data.data = user_data;
1269 gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper,
1274 * gst_tag_list_get_value_index:
1275 * @list: a #GstTagList
1276 * @tag: tag to read out
1277 * @index: number of entry to read out
1279 * Gets the value that is at the given index for the given tag in the given
1282 * Returns: (transfer none): The GValue for the specified entry or NULL if the
1283 * tag wasn't available or the tag doesn't have as many entries
1286 gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
1289 const GValue *value;
1291 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
1292 g_return_val_if_fail (tag != NULL, NULL);
1294 value = gst_structure_get_value ((GstStructure *) list, tag);
1298 if (GST_VALUE_HOLDS_LIST (value)) {
1299 if (index >= gst_value_list_get_size (value))
1301 return gst_value_list_get_value (value, index);
1310 * gst_tag_list_copy_value:
1311 * @dest: (out caller-allocates): uninitialized #GValue to copy into
1312 * @list: list to get the tag from
1313 * @tag: tag to read out
1315 * Copies the contents for the given tag into the value,
1316 * merging multiple values into one if multiple values are associated
1318 * You must g_value_unset() the value after use.
1320 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1324 gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
1329 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1330 g_return_val_if_fail (tag != NULL, FALSE);
1331 g_return_val_if_fail (dest != NULL, FALSE);
1332 g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
1334 src = gst_structure_get_value ((GstStructure *) list, tag);
1338 if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
1339 GstTagInfo *info = gst_tag_lookup (tag);
1344 /* must be there or lists aren't allowed */
1345 g_assert (info->merge_func);
1346 info->merge_func (dest, src);
1348 g_value_init (dest, G_VALUE_TYPE (src));
1349 g_value_copy (src, dest);
1354 /* FIXME 0.11: this whole merge function business is overdesigned, and the
1355 * _get_foo() API is misleading as well - how many application developers will
1356 * expect gst_tag_list_get_string (list, GST_TAG_ARTIST, &val) might return a
1357 * string with multiple comma-separated artists? _get_foo() should just be
1358 * a convenience wrapper around _get_foo_index (list, tag, 0, &val),
1359 * supplemented by a special _tag_list_get_string_merged() function if needed
1360 * (unless someone can actually think of real use cases where the merge
1361 * function is not 'use first' for non-strings and merge for strings) */
1363 /***** evil macros to get all the gst_tag_list_get_*() functions right *****/
1365 #define TAG_MERGE_FUNCS(name,type,ret) \
1367 gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
1370 GValue v = { 0, }; \
1372 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1373 g_return_val_if_fail (tag != NULL, FALSE); \
1374 g_return_val_if_fail (value != NULL, FALSE); \
1376 if (!gst_tag_list_copy_value (&v, list, tag)) \
1378 *value = COPY_FUNC (g_value_get_ ## name (&v)); \
1379 g_value_unset (&v); \
1384 gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
1386 guint index, type *value) \
1390 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1391 g_return_val_if_fail (tag != NULL, FALSE); \
1392 g_return_val_if_fail (value != NULL, FALSE); \
1394 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
1396 *value = COPY_FUNC (g_value_get_ ## name (v)); \
1400 /* FIXME 0.11: maybe get rid of _get_char*(), _get_uchar*(), _get_long*(),
1401 * _get_ulong*() and _get_pointer*()? - they are not really useful/common
1402 * enough to warrant convenience accessor functions */
1404 #define COPY_FUNC /**/
1406 * gst_tag_list_get_char:
1407 * @list: a #GstTagList to get the tag from
1408 * @tag: tag to read out
1409 * @value: (out): location for the result
1411 * Copies the contents for the given tag into the value, merging multiple values
1412 * into one if multiple values are associated with the tag.
1414 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1418 * gst_tag_list_get_char_index:
1419 * @list: a #GstTagList to get the tag from
1420 * @tag: tag to read out
1421 * @index: number of entry to read out
1422 * @value: (out): location for the result
1424 * Gets the value that is at the given index for the given tag in the given
1427 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1430 TAG_MERGE_FUNCS (char, gchar, TRUE);
1432 * gst_tag_list_get_uchar:
1433 * @list: a #GstTagList to get the tag from
1434 * @tag: tag to read out
1435 * @value: (out): location for the result
1437 * Copies the contents for the given tag into the value, merging multiple values
1438 * into one if multiple values are associated with the tag.
1440 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1444 * gst_tag_list_get_uchar_index:
1445 * @list: a #GstTagList to get the tag from
1446 * @tag: tag to read out
1447 * @index: number of entry to read out
1448 * @value: (out): location for the result
1450 * Gets the value that is at the given index for the given tag in the given
1453 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1456 TAG_MERGE_FUNCS (uchar, guchar, TRUE);
1458 * gst_tag_list_get_boolean:
1459 * @list: a #GstTagList to get the tag from
1460 * @tag: tag to read out
1461 * @value: (out): location for the result
1463 * Copies the contents for the given tag into the value, merging multiple values
1464 * into one if multiple values are associated with the tag.
1466 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1470 * gst_tag_list_get_boolean_index:
1471 * @list: a #GstTagList to get the tag from
1472 * @tag: tag to read out
1473 * @index: number of entry to read out
1474 * @value: (out): location for the result
1476 * Gets the value that is at the given index for the given tag in the given
1479 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1482 TAG_MERGE_FUNCS (boolean, gboolean, TRUE);
1484 * gst_tag_list_get_int:
1485 * @list: a #GstTagList to get the tag from
1486 * @tag: tag to read out
1487 * @value: (out): location for the result
1489 * Copies the contents for the given tag into the value, merging multiple values
1490 * into one if multiple values are associated with the tag.
1492 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1496 * gst_tag_list_get_int_index:
1497 * @list: a #GstTagList to get the tag from
1498 * @tag: tag to read out
1499 * @index: number of entry to read out
1500 * @value: (out): location for the result
1502 * Gets the value that is at the given index for the given tag in the given
1505 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1508 TAG_MERGE_FUNCS (int, gint, TRUE);
1510 * gst_tag_list_get_uint:
1511 * @list: a #GstTagList to get the tag from
1512 * @tag: tag to read out
1513 * @value: (out): location for the result
1515 * Copies the contents for the given tag into the value, merging multiple values
1516 * into one if multiple values are associated with the tag.
1518 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1522 * gst_tag_list_get_uint_index:
1523 * @list: a #GstTagList to get the tag from
1524 * @tag: tag to read out
1525 * @index: number of entry to read out
1526 * @value: (out): location for the result
1528 * Gets the value that is at the given index for the given tag in the given
1531 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1534 TAG_MERGE_FUNCS (uint, guint, TRUE);
1536 * gst_tag_list_get_int64_index:
1537 * @list: a #GstTagList to get the tag from
1538 * @tag: tag to read out
1539 * @index: number of entry to read out
1540 * @value: (out): location for the result
1542 * Gets the value that is at the given index for the given tag in the given
1545 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1548 TAG_MERGE_FUNCS (int64, gint64, TRUE);
1550 * gst_tag_list_get_uint64:
1551 * @list: a #GstTagList to get the tag from
1552 * @tag: tag to read out
1553 * @value: (out): location for the result
1555 * Copies the contents for the given tag into the value, merging multiple values
1556 * into one if multiple values are associated with the tag.
1558 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1562 * gst_tag_list_get_uint64_index:
1563 * @list: a #GstTagList to get the tag from
1564 * @tag: tag to read out
1565 * @index: number of entry to read out
1566 * @value: (out): location for the result
1568 * Gets the value that is at the given index for the given tag in the given
1571 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1574 TAG_MERGE_FUNCS (uint64, guint64, TRUE);
1576 * gst_tag_list_get_float:
1577 * @list: a #GstTagList to get the tag from
1578 * @tag: tag to read out
1579 * @value: (out): location for the result
1581 * Copies the contents for the given tag into the value, merging multiple values
1582 * into one if multiple values are associated with the tag.
1584 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1588 * gst_tag_list_get_float_index:
1589 * @list: a #GstTagList to get the tag from
1590 * @tag: tag to read out
1591 * @index: number of entry to read out
1592 * @value: (out): location for the result
1594 * Gets the value that is at the given index for the given tag in the given
1597 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1600 TAG_MERGE_FUNCS (float, gfloat, TRUE);
1602 * gst_tag_list_get_double:
1603 * @list: a #GstTagList to get the tag from
1604 * @tag: tag to read out
1605 * @value: (out): location for the result
1607 * Copies the contents for the given tag into the value, merging multiple values
1608 * into one if multiple values are associated with the tag.
1610 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1614 * gst_tag_list_get_double_index:
1615 * @list: a #GstTagList to get the tag from
1616 * @tag: tag to read out
1617 * @index: number of entry to read out
1618 * @value: (out): location for the result
1620 * Gets the value that is at the given index for the given tag in the given
1623 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1626 TAG_MERGE_FUNCS (double, gdouble, TRUE);
1628 * gst_tag_list_get_pointer:
1629 * @list: a #GstTagList to get the tag from
1630 * @tag: tag to read out
1631 * @value: (out) (transfer none): location for the result
1633 * Copies the contents for the given tag into the value, merging multiple values
1634 * into one if multiple values are associated with the tag.
1636 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1640 * gst_tag_list_get_pointer_index:
1641 * @list: a #GstTagList to get the tag from
1642 * @tag: tag to read out
1643 * @index: number of entry to read out
1644 * @value: (out) (transfer none): location for the result
1646 * Gets the value that is at the given index for the given tag in the given
1649 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1652 TAG_MERGE_FUNCS (pointer, gpointer, (*value != NULL));
1654 static inline gchar *
1655 _gst_strdup0 (const gchar * s)
1657 if (s == NULL || *s == '\0')
1660 return g_strdup (s);
1664 #define COPY_FUNC _gst_strdup0
1667 * gst_tag_list_get_string:
1668 * @list: a #GstTagList to get the tag from
1669 * @tag: tag to read out
1670 * @value: (out callee-allocates) (transfer full): location for the result
1672 * Copies the contents for the given tag into the value, possibly merging
1673 * multiple values into one if multiple values are associated with the tag.
1675 * Use gst_tag_list_get_string_index (list, tag, 0, value) if you want
1676 * to retrieve the first string associated with this tag unmodified.
1678 * The resulting string in @value will be in UTF-8 encoding and should be
1679 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1680 * returned string is also guaranteed to be non-NULL and non-empty.
1682 * Free-function: g_free
1684 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1688 * gst_tag_list_get_string_index:
1689 * @list: a #GstTagList to get the tag from
1690 * @tag: tag to read out
1691 * @index: number of entry to read out
1692 * @value: (out callee-allocates) (transfer full): location for the result
1694 * Gets the value that is at the given index for the given tag in the given
1697 * The resulting string in @value will be in UTF-8 encoding and should be
1698 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1699 * returned string is also guaranteed to be non-NULL and non-empty.
1701 * Free-function: g_free
1703 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1706 TAG_MERGE_FUNCS (string, gchar *, (*value != NULL));
1709 *FIXME 0.11: Instead of _peek (non-copy) and _get (copy), we could have
1710 * _get (non-copy) and _dup (copy) for strings, seems more
1714 * gst_tag_list_peek_string_index:
1715 * @list: a #GstTagList to get the tag from
1716 * @tag: tag to read out
1717 * @index: number of entry to read out
1718 * @value: (out) (transfer none): location for the result
1720 * Peeks at the value that is at the given index for the given tag in the given
1723 * The resulting string in @value will be in UTF-8 encoding and doesn't need
1724 * to be freed by the caller. The returned string is also guaranteed to
1725 * be non-NULL and non-empty.
1727 * Returns: TRUE, if a value was set, FALSE if the tag didn't exist in the
1731 gst_tag_list_peek_string_index (const GstTagList * list,
1732 const gchar * tag, guint index, const gchar ** value)
1736 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1737 g_return_val_if_fail (tag != NULL, FALSE);
1738 g_return_val_if_fail (value != NULL, FALSE);
1740 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1742 *value = g_value_get_string (v);
1743 return *value != NULL && **value != '\0';
1747 * gst_tag_list_get_date:
1748 * @list: a #GstTagList to get the tag from
1749 * @tag: tag to read out
1750 * @value: (out callee-allocates) (transfer full): address of a GDate pointer
1751 * variable to store the result into
1753 * Copies the first date for the given tag in the taglist into the variable
1754 * pointed to by @value. Free the date with g_date_free() when it is no longer
1757 * Free-function: g_date_free
1759 * Returns: TRUE, if a date was copied, FALSE if the tag didn't exist in the
1760 * given list or if it was #NULL.
1763 gst_tag_list_get_date (const GstTagList * list, const gchar * tag,
1768 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1769 g_return_val_if_fail (tag != NULL, FALSE);
1770 g_return_val_if_fail (value != NULL, FALSE);
1772 if (!gst_tag_list_copy_value (&v, list, tag))
1774 *value = (GDate *) g_value_dup_boxed (&v);
1776 return (*value != NULL);
1780 * gst_tag_list_get_date_index:
1781 * @list: a #GstTagList to get the tag from
1782 * @tag: tag to read out
1783 * @index: number of entry to read out
1784 * @value: (out callee-allocates) (transfer full): location for the result
1786 * Gets the date that is at the given index for the given tag in the given
1787 * list and copies it into the variable pointed to by @value. Free the date
1788 * with g_date_free() when it is no longer needed.
1790 * Free-function: g_date_free
1792 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1793 * given list or if it was #NULL.
1796 gst_tag_list_get_date_index (const GstTagList * list,
1797 const gchar * tag, guint index, GDate ** 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 = (GDate *) g_value_dup_boxed (v);
1808 return (*value != NULL);
1812 * gst_tag_list_get_date_time:
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 #GstDateTime
1816 * pointer variable to store the result into
1818 * Copies the first datetime for the given tag in the taglist into the variable
1819 * pointed to by @value. Unref the date with gst_date_time_unref() when
1820 * it is no longer needed.
1822 * Free-function: gst_date_time_unref
1824 * Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in
1825 * thegiven list or if it was #NULL.
1830 gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag,
1831 GstDateTime ** value)
1835 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1836 g_return_val_if_fail (tag != NULL, FALSE);
1837 g_return_val_if_fail (value != NULL, FALSE);
1839 if (!gst_tag_list_copy_value (&v, list, tag))
1842 g_return_val_if_fail (GST_VALUE_HOLDS_DATE_TIME (&v), FALSE);
1844 *value = (GstDateTime *) g_value_dup_boxed (&v);
1846 return (*value != NULL);
1850 * gst_tag_list_get_date_time_index:
1851 * @list: a #GstTagList to get the tag from
1852 * @tag: tag to read out
1853 * @index: number of entry to read out
1854 * @value: (out callee-allocates) (transfer full): location for the result
1856 * Gets the datetime that is at the given index for the given tag in the given
1857 * list and copies it into the variable pointed to by @value. Unref the datetime
1858 * with gst_date_time_unref() when it is no longer needed.
1860 * Free-function: gst_date_time_unref
1862 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1863 * given list or if it was #NULL.
1868 gst_tag_list_get_date_time_index (const GstTagList * list,
1869 const gchar * tag, guint index, GstDateTime ** value)
1873 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1874 g_return_val_if_fail (tag != NULL, FALSE);
1875 g_return_val_if_fail (value != NULL, FALSE);
1877 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1879 *value = (GstDateTime *) g_value_dup_boxed (v);
1880 return (*value != NULL);
1884 * gst_tag_list_get_buffer:
1885 * @list: a #GstTagList to get the tag from
1886 * @tag: tag to read out
1887 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
1888 * pointer variable to store the result into
1890 * Copies the first buffer for the given tag in the taglist into the variable
1891 * pointed to by @value. Free the buffer with gst_buffer_unref() when it is
1894 * Free-function: gst_buffer_unref
1896 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1897 * given list or if it was #NULL.
1902 gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag,
1907 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1908 g_return_val_if_fail (tag != NULL, FALSE);
1909 g_return_val_if_fail (value != NULL, FALSE);
1911 if (!gst_tag_list_copy_value (&v, list, tag))
1913 *value = g_value_dup_boxed (&v);
1915 return (*value != NULL);
1919 * gst_tag_list_get_buffer_index:
1920 * @list: a #GstTagList to get the tag from
1921 * @tag: tag to read out
1922 * @index: number of entry to read out
1923 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
1924 * pointer variable to store the result into
1926 * Gets the buffer that is at the given index for the given tag in the given
1927 * list and copies it into the variable pointed to by @value. Free the buffer
1928 * with gst_buffer_unref() when it is no longer needed.
1930 * Free-function: gst_buffer_unref
1932 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1933 * given list or if it was #NULL.
1938 gst_tag_list_get_buffer_index (const GstTagList * list,
1939 const gchar * tag, guint index, GstBuffer ** value)
1943 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1944 g_return_val_if_fail (tag != NULL, FALSE);
1945 g_return_val_if_fail (value != NULL, FALSE);
1947 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1949 *value = g_value_dup_boxed (v);
1950 return (*value != NULL);