2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
4 * gsttaglist.c: tag support (aka metadata)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
24 * @short_description: List of tags and values used to describe media metadata
26 * List of tags and values used to describe media metadata.
28 * Strings must be in ASCII or UTF-8 encoding. No other encodings are allowed.
30 * Last reviewed on 2009-06-09 (0.10.23)
37 #include "gst_private.h"
38 #include "gst-i18n-lib.h"
39 #include "gsttaglist.h"
42 #include "gstbuffer.h"
45 #include <gobject/gvaluecollector.h>
48 #define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL)
50 /* FIXME 0.11: use GParamSpecs or something similar for tag registrations,
51 * possibly even gst_tag_register(). Especially value ranges might be
52 * useful for some tags. */
56 GType type; /* type the data is in */
58 gchar *nick; /* translated name */
59 gchar *blurb; /* translated description of type */
61 GstTagMergeFunc merge_func; /* functions to merge the values */
62 GstTagFlag flag; /* type of tag */
66 static GMutex *__tag_mutex;
68 static GHashTable *__tags;
70 #define TAG_LOCK g_mutex_lock (__tag_mutex)
71 #define TAG_UNLOCK g_mutex_unlock (__tag_mutex)
74 gst_tag_list_get_type (void)
76 static GType _gst_tag_list_type = 0;
78 if (G_UNLIKELY (_gst_tag_list_type == 0)) {
79 _gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
80 (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
83 g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
84 _gst_structure_transform_to_string);
88 return _gst_tag_list_type;
92 _gst_tag_initialize (void)
94 __tag_mutex = g_mutex_new ();
95 __tags = g_hash_table_new (g_direct_hash, g_direct_equal);
96 gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META,
98 _("title"), _("commonly used title"), gst_tag_merge_strings_with_comma);
99 gst_tag_register (GST_TAG_TITLE_SORTNAME, GST_TAG_FLAG_META,
101 _("title sortname"), _("commonly used title for sorting purposes"), NULL);
102 gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META,
105 _("person(s) responsible for the recording"),
106 gst_tag_merge_strings_with_comma);
107 gst_tag_register (GST_TAG_ARTIST_SORTNAME, GST_TAG_FLAG_META,
109 _("artist sortname"),
110 _("person(s) responsible for the recording for sorting purposes"), NULL);
111 gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META,
114 _("album containing this data"), gst_tag_merge_strings_with_comma);
115 gst_tag_register (GST_TAG_ALBUM_SORTNAME, GST_TAG_FLAG_META,
118 _("album containing this data for sorting purposes"), NULL);
119 gst_tag_register (GST_TAG_ALBUM_ARTIST, GST_TAG_FLAG_META,
122 _("The artist of the entire album, as it should be displayed"),
123 gst_tag_merge_strings_with_comma);
124 gst_tag_register (GST_TAG_ALBUM_ARTIST_SORTNAME, GST_TAG_FLAG_META,
126 _("album artist sortname"),
127 _("The artist of the entire album, as it should be sorted"), NULL);
128 gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, GST_TYPE_DATE,
129 _("date"), _("date the data was created (as a GDate structure)"), NULL);
130 gst_tag_register (GST_TAG_DATE_TIME, GST_TAG_FLAG_META, GST_TYPE_DATE_TIME,
132 _("date and time the data was created (as a GstDateTime structure)"),
134 gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META,
137 _("genre this data belongs to"), gst_tag_merge_strings_with_comma);
138 gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META,
141 _("free text commenting the data"), gst_tag_merge_use_first);
142 gst_tag_register (GST_TAG_EXTENDED_COMMENT, GST_TAG_FLAG_META,
144 _("extended comment"),
145 _("free text commenting the data in key=value or key[en]=comment form"),
146 gst_tag_merge_use_first);
147 gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META,
150 _("track number inside a collection"), gst_tag_merge_use_first);
151 gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META,
154 _("count of tracks inside collection this track belongs to"),
155 gst_tag_merge_use_first);
156 gst_tag_register (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META,
159 _("disc number inside a collection"), gst_tag_merge_use_first);
160 gst_tag_register (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META,
163 _("count of discs inside collection this disc belongs to"),
164 gst_tag_merge_use_first);
165 gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META,
167 _("location"), _("Origin of media as a URI (location, where the "
168 "original of the file or stream is hosted)"),
169 gst_tag_merge_strings_with_comma);
170 gst_tag_register (GST_TAG_HOMEPAGE, GST_TAG_FLAG_META,
173 _("Homepage for this media (i.e. artist or movie homepage)"),
174 gst_tag_merge_strings_with_comma);
175 gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META, G_TYPE_STRING,
176 _("description"), _("short text describing the content of the data"),
177 gst_tag_merge_strings_with_comma);
178 gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META, G_TYPE_STRING,
179 _("version"), _("version of this data"), NULL);
180 gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META, G_TYPE_STRING, _("ISRC"),
182 ("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
184 /* FIXME: organization (fix what? tpm) */
185 gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING,
186 _("organization"), _("organization"), gst_tag_merge_strings_with_comma);
187 gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
188 G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL);
189 gst_tag_register (GST_TAG_COPYRIGHT_URI, GST_TAG_FLAG_META,
190 G_TYPE_STRING, _("copyright uri"),
191 _("URI to the copyright notice of the data"), NULL);
192 gst_tag_register (GST_TAG_ENCODED_BY, GST_TAG_FLAG_META, G_TYPE_STRING,
193 _("encoded by"), _("name of the encoding person or organization"),
194 gst_tag_merge_strings_with_comma);
195 gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META,
197 _("contact"), _("contact information"), gst_tag_merge_strings_with_comma);
198 gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META,
199 G_TYPE_STRING, _("license"), _("license of data"), NULL);
200 gst_tag_register (GST_TAG_LICENSE_URI, GST_TAG_FLAG_META,
201 G_TYPE_STRING, _("license uri"),
202 _("URI to the license of the data"), NULL);
203 gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META,
206 _("person(s) performing"), gst_tag_merge_strings_with_comma);
207 gst_tag_register (GST_TAG_COMPOSER, GST_TAG_FLAG_META,
210 _("person(s) who composed the recording"),
211 gst_tag_merge_strings_with_comma);
212 gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED,
214 _("duration"), _("length in GStreamer time units (nanoseconds)"), NULL);
215 gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED,
218 _("codec the data is stored in"), gst_tag_merge_strings_with_comma);
219 gst_tag_register (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED,
221 _("video codec"), _("codec the video data is stored in"), NULL);
222 gst_tag_register (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED,
224 _("audio codec"), _("codec the audio data is stored in"), NULL);
225 gst_tag_register (GST_TAG_SUBTITLE_CODEC, GST_TAG_FLAG_ENCODED,
227 _("subtitle codec"), _("codec the subtitle data is stored in"), NULL);
228 gst_tag_register (GST_TAG_CONTAINER_FORMAT, GST_TAG_FLAG_ENCODED,
229 G_TYPE_STRING, _("container format"),
230 _("container format the data is stored in"), NULL);
231 gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED,
232 G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL);
233 gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED,
234 G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL);
235 gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
236 G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL);
237 gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
238 G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL);
239 gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED,
241 _("encoder"), _("encoder used to encode this stream"), NULL);
242 gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED,
244 _("encoder version"),
245 _("version of the encoder used to encode this stream"), NULL);
246 gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED,
247 G_TYPE_UINT, _("serial"), _("serial number of track"), NULL);
248 gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META,
249 G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL);
250 gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META,
251 G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL);
252 gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META,
253 G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL);
254 gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
255 G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL);
256 gst_tag_register (GST_TAG_REFERENCE_LEVEL, GST_TAG_FLAG_META,
257 G_TYPE_DOUBLE, _("replaygain reference level"),
258 _("reference level of track and album gain values"), NULL);
259 gst_tag_register (GST_TAG_LANGUAGE_CODE, GST_TAG_FLAG_META, G_TYPE_STRING,
261 _("language code for this stream, conforming to ISO-639-1"), NULL);
262 gst_tag_register (GST_TAG_IMAGE, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
263 _("image"), _("image related to this stream"), gst_tag_merge_use_first);
264 gst_tag_register (GST_TAG_PREVIEW_IMAGE, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
265 /* TRANSLATORS: 'preview image' = image that shows a preview of the full image */
266 _("preview image"), _("preview image related to this stream"), NULL);
267 gst_tag_register (GST_TAG_ATTACHMENT, GST_TAG_FLAG_META, GST_TYPE_BUFFER,
268 _("attachment"), _("file attached to this stream"),
269 gst_tag_merge_use_first);
270 gst_tag_register (GST_TAG_BEATS_PER_MINUTE, GST_TAG_FLAG_META, G_TYPE_DOUBLE,
271 _("beats per minute"), _("number of beats per minute in audio"), NULL);
272 gst_tag_register (GST_TAG_KEYWORDS, GST_TAG_FLAG_META, G_TYPE_STRING,
273 _("keywords"), _("comma separated keywords describing the content"),
274 gst_tag_merge_strings_with_comma);
275 gst_tag_register (GST_TAG_GEO_LOCATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
276 _("geo location name"), _("human readable descriptive location of where "
277 "the media has been recorded or produced"), NULL);
278 gst_tag_register (GST_TAG_GEO_LOCATION_LATITUDE, GST_TAG_FLAG_META,
279 G_TYPE_DOUBLE, _("geo location latitude"),
280 _("geo latitude location of where the media has been recorded or "
281 "produced in degrees according to WGS84 (zero at the equator, "
282 "negative values for southern latitudes)"), NULL);
283 gst_tag_register (GST_TAG_GEO_LOCATION_LONGITUDE, GST_TAG_FLAG_META,
284 G_TYPE_DOUBLE, _("geo location longitude"),
285 _("geo longitude location of where the media has been recorded or "
286 "produced in degrees according to WGS84 (zero at the prime meridian "
287 "in Greenwich/UK, negative values for western longitudes)"), NULL);
288 gst_tag_register (GST_TAG_GEO_LOCATION_ELEVATION, GST_TAG_FLAG_META,
289 G_TYPE_DOUBLE, _("geo location elevation"),
290 _("geo elevation of where the media has been recorded or produced in "
291 "meters according to WGS84 (zero is average sea level)"), NULL);
292 gst_tag_register (GST_TAG_GEO_LOCATION_COUNTRY, GST_TAG_FLAG_META,
293 G_TYPE_STRING, _("geo location country"),
294 _("country (english name) where the media has been recorded "
295 "or produced"), NULL);
296 gst_tag_register (GST_TAG_GEO_LOCATION_CITY, GST_TAG_FLAG_META,
297 G_TYPE_STRING, _("geo location city"),
298 _("city (english name) where the media has been recorded "
299 "or produced"), NULL);
300 gst_tag_register (GST_TAG_GEO_LOCATION_SUBLOCATION, GST_TAG_FLAG_META,
301 G_TYPE_STRING, _("geo location sublocation"),
302 _("a location whithin a city where the media has been produced "
303 "or created (e.g. the neighborhood)"), NULL);
304 gst_tag_register (GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, GST_TAG_FLAG_META,
305 G_TYPE_DOUBLE, _("geo location horizontal error"),
306 _("expected error of the horizontal positioning measures (in meters)"),
308 gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, GST_TAG_FLAG_META,
309 G_TYPE_DOUBLE, _("geo location movement speed"),
310 _("movement speed of the capturing device while performing the capture "
312 gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, GST_TAG_FLAG_META,
313 G_TYPE_DOUBLE, _("geo location movement direction"),
314 _("indicates the movement direction of the device performing the capture"
315 " of a media. It is represented as degrees in floating point "
316 "representation, 0 means the geographic north, and increases "
318 gst_tag_register (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, GST_TAG_FLAG_META,
319 G_TYPE_DOUBLE, _("geo location capture direction"),
320 _("indicates the direction the device is pointing to when capturing "
321 " a media. It is represented as degrees in floating point "
322 " representation, 0 means the geographic north, and increases "
324 gst_tag_register (GST_TAG_SHOW_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
325 /* TRANSLATORS: 'show name' = 'TV/radio/podcast show name' here */
327 _("Name of the tv/podcast/series show the media is from"),
328 gst_tag_merge_strings_with_comma);
329 gst_tag_register (GST_TAG_SHOW_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING,
330 /* TRANSLATORS: 'show sortname' = 'TV/radio/podcast show name as used for sorting purposes' here */
332 _("Name of the tv/podcast/series show the media is from, for sorting "
334 gst_tag_register (GST_TAG_SHOW_EPISODE_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT,
336 _("The episode number in the season the media is part of"),
337 gst_tag_merge_use_first);
338 gst_tag_register (GST_TAG_SHOW_SEASON_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT,
340 _("The season number of the show the media is part of"),
341 gst_tag_merge_use_first);
342 gst_tag_register (GST_TAG_LYRICS, GST_TAG_FLAG_META, G_TYPE_STRING,
343 _("lyrics"), _("The lyrics of the media, commonly used for songs"),
344 gst_tag_merge_strings_with_comma);
345 gst_tag_register (GST_TAG_COMPOSER_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING,
346 _("composer sortname"),
347 _("person(s) who composed the recording, for sorting purposes"), NULL);
348 gst_tag_register (GST_TAG_GROUPING, GST_TAG_FLAG_META, G_TYPE_STRING,
350 _("Groups related media that spans multiple tracks, like the different "
351 "pieces of a concerto. It is a higher level than a track, "
352 "but lower than an album"), NULL);
353 gst_tag_register (GST_TAG_USER_RATING, GST_TAG_FLAG_META, G_TYPE_UINT,
355 _("Rating attributed by a user. The higher the rank, "
356 "the more the user likes this media"), NULL);
357 gst_tag_register (GST_TAG_DEVICE_MANUFACTURER, GST_TAG_FLAG_META,
358 G_TYPE_STRING, _("device manufacturer"),
359 _("Manufacturer of the device used to create this media"), NULL);
360 gst_tag_register (GST_TAG_DEVICE_MODEL, GST_TAG_FLAG_META, G_TYPE_STRING,
362 _("Model of the device used to create this media"), NULL);
363 gst_tag_register (GST_TAG_APPLICATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
364 _("application name"), _("Application used to create the media"), NULL);
365 gst_tag_register (GST_TAG_APPLICATION_DATA, GST_TAG_FLAG_META,
366 GST_TYPE_BUFFER, _("application data"),
367 _("Arbitrary application data to be serialized into the media"), NULL);
368 gst_tag_register (GST_TAG_IMAGE_ORIENTATION, GST_TAG_FLAG_META, G_TYPE_STRING,
369 _("image orientation"),
370 _("How the image should be rotated or flipped before display"), NULL);
374 * gst_tag_merge_use_first:
375 * @dest: (out caller-allocates): uninitialized GValue to store result in
376 * @src: GValue to copy from
378 * This is a convenience function for the func argument of gst_tag_register().
379 * It creates a copy of the first value from the list.
382 gst_tag_merge_use_first (GValue * dest, const GValue * src)
384 const GValue *ret = gst_value_list_get_value (src, 0);
386 g_value_init (dest, G_VALUE_TYPE (ret));
387 g_value_copy (ret, dest);
391 * gst_tag_merge_strings_with_comma:
392 * @dest: (out caller-allocates): uninitialized GValue to store result in
393 * @src: GValue to copy from
395 * This is a convenience function for the func argument of gst_tag_register().
396 * It concatenates all given strings using a comma. The tag must be registered
397 * as a G_TYPE_STRING or this function will fail.
400 gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src)
405 count = gst_value_list_get_size (src);
406 str = g_string_new (g_value_get_string (gst_value_list_get_value (src, 0)));
407 for (i = 1; i < count; i++) {
408 /* separator between two strings */
409 g_string_append (str, _(", "));
410 g_string_append (str,
411 g_value_get_string (gst_value_list_get_value (src, i)));
414 g_value_init (dest, G_TYPE_STRING);
415 g_value_take_string (dest, str->str);
416 g_string_free (str, FALSE);
420 gst_tag_lookup (GQuark entry)
425 ret = g_hash_table_lookup (__tags, GUINT_TO_POINTER (entry));
433 * @name: the name or identifier string
434 * @flag: a flag describing the type of tag info
435 * @type: the type this data is in
436 * @nick: human-readable name
437 * @blurb: a human-readable description about this tag
438 * @func: function for merging multiple values of this tag, or NULL
440 * Registers a new tag type for the use with GStreamer's type system. If a type
441 * with that name is already registered, that one is used.
442 * The old registration may have used a different type however. So don't rely
443 * on your supplied values.
445 * Important: if you do not supply a merge function the implication will be
446 * that there can only be one single value for this tag in a tag list and
447 * any additional values will silenty be discarded when being added (unless
448 * #GST_TAG_MERGE_REPLACE, #GST_TAG_MERGE_REPLACE_ALL, or
449 * #GST_TAG_MERGE_PREPEND is used as merge mode, in which case the new
450 * value will replace the old one in the list).
452 * The merge function will be called from gst_tag_list_copy_value() when
453 * it is required that one or more values for a tag be condensed into
454 * one single value. This may happen from gst_tag_list_get_string(),
455 * gst_tag_list_get_int(), gst_tag_list_get_double() etc. What will happen
456 * exactly in that case depends on how the tag was registered and if a
457 * merge function was supplied and if so which one.
459 * Two default merge functions are provided: gst_tag_merge_use_first() and
460 * gst_tag_merge_strings_with_comma().
463 gst_tag_register (const gchar * name, GstTagFlag flag, GType type,
464 const gchar * nick, const gchar * blurb, GstTagMergeFunc func)
469 g_return_if_fail (name != NULL);
470 g_return_if_fail (nick != NULL);
471 g_return_if_fail (blurb != NULL);
472 g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
474 key = g_quark_from_string (name);
475 info = gst_tag_lookup (key);
478 g_return_if_fail (info->type == type);
482 info = g_slice_new (GstTagInfo);
485 info->nick = g_strdup (nick);
486 info->blurb = g_strdup (blurb);
487 info->merge_func = func;
490 g_hash_table_insert (__tags, GUINT_TO_POINTER (key), info);
496 * @tag: name of the tag
498 * Checks if the given type is already registered.
500 * Returns: TRUE if the type is already registered
503 gst_tag_exists (const gchar * tag)
505 g_return_val_if_fail (tag != NULL, FALSE);
507 return gst_tag_lookup (g_quark_from_string (tag)) != NULL;
514 * Gets the #GType used for this tag.
516 * Returns: the #GType of this tag
519 gst_tag_get_type (const gchar * tag)
523 g_return_val_if_fail (tag != NULL, 0);
524 info = gst_tag_lookup (g_quark_from_string (tag));
525 g_return_val_if_fail (info != NULL, 0);
534 * Returns the human-readable name of this tag, You must not change or free
537 * Returns: the human-readable name of this tag
540 gst_tag_get_nick (const gchar * tag)
544 g_return_val_if_fail (tag != NULL, NULL);
545 info = gst_tag_lookup (g_quark_from_string (tag));
546 g_return_val_if_fail (info != NULL, NULL);
552 * gst_tag_get_description:
555 * Returns the human-readable description of this tag, You must not change or
558 * Returns: the human-readable description of this tag
561 gst_tag_get_description (const gchar * tag)
565 g_return_val_if_fail (tag != NULL, NULL);
566 info = gst_tag_lookup (g_quark_from_string (tag));
567 g_return_val_if_fail (info != NULL, NULL);
576 * Gets the flag of @tag.
578 * Returns: the flag of this tag.
581 gst_tag_get_flag (const gchar * tag)
585 g_return_val_if_fail (tag != NULL, GST_TAG_FLAG_UNDEFINED);
586 info = gst_tag_lookup (g_quark_from_string (tag));
587 g_return_val_if_fail (info != NULL, GST_TAG_FLAG_UNDEFINED);
596 * Checks if the given tag is fixed. A fixed tag can only contain one value.
597 * Unfixed tags can contain lists of values.
599 * Returns: TRUE, if the given tag is fixed.
602 gst_tag_is_fixed (const gchar * tag)
606 g_return_val_if_fail (tag != NULL, FALSE);
607 info = gst_tag_lookup (g_quark_from_string (tag));
608 g_return_val_if_fail (info != NULL, FALSE);
610 return info->merge_func == NULL;
616 * Creates a new empty GstTagList.
618 * Free-function: gst_tag_list_free
620 * Returns: (transfer full): An empty tag list
623 gst_tag_list_new (void)
625 return GST_TAG_LIST (gst_structure_id_empty_new (GST_QUARK (TAGLIST)));
629 * gst_tag_list_new_full:
631 * @...: NULL-terminated list of values to set
633 * Creates a new taglist and appends the values for the given tags. It expects
634 * tag-value pairs like gst_tag_list_add(), and a NULL terminator after the
635 * last pair. The type of the values is implicit and is documented in the API
636 * reference, but can also be queried at runtime with gst_tag_get_type(). It
637 * is an error to pass a value of a type not matching the tag type into this
638 * function. The tag list will make copies of any arguments passed
639 * (e.g. strings, buffers).
641 * Free-function: gst_tag_list_free
643 * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_free()
644 * when no longer needed.
648 /* FIXME 0.11: rename gst_tag_list_new_full to _new and _new to _new_empty */
650 gst_tag_list_new_full (const gchar * tag, ...)
655 g_return_val_if_fail (tag != NULL, NULL);
657 list = gst_tag_list_new ();
658 va_start (args, tag);
659 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, args);
666 * gst_tag_list_new_full_valist:
667 * @var_args: tag / value pairs to set
669 * Just like gst_tag_list_new_full(), only that it takes a va_list argument.
670 * Useful mostly for language bindings.
672 * Free-function: gst_tag_list_free
674 * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_free()
675 * when no longer needed.
680 gst_tag_list_new_full_valist (va_list var_args)
685 list = gst_tag_list_new ();
687 tag = va_arg (var_args, gchar *);
688 gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, var_args);
694 * gst_tag_list_is_empty:
695 * @list: A #GstTagList.
697 * Checks if the given taglist is empty.
699 * Returns: TRUE if the taglist is empty, otherwise FALSE.
704 gst_tag_list_is_empty (const GstTagList * list)
706 g_return_val_if_fail (list != NULL, FALSE);
707 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
709 return (gst_structure_n_fields ((GstStructure *) list) == 0);
714 * @p: Object that might be a taglist
716 * Checks if the given pointer is a taglist.
718 * Returns: TRUE, if the given pointer is a taglist
721 gst_is_tag_list (gconstpointer p)
723 GstStructure *s = (GstStructure *) p;
725 g_return_val_if_fail (p != NULL, FALSE);
727 return (GST_IS_STRUCTURE (s) && s->name == GST_QUARK (TAGLIST));
733 GstTagMergeMode mode;
738 gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode,
739 GQuark tag, const GValue * value, GstTagInfo * info)
741 const GValue *value2;
744 info = gst_tag_lookup (tag);
745 if (G_UNLIKELY (info == NULL)) {
746 g_warning ("unknown tag '%s'", g_quark_to_string (tag));
752 && (value2 = gst_structure_id_get_value (list, tag)) != NULL) {
753 GValue dest = { 0, };
756 case GST_TAG_MERGE_REPLACE_ALL:
757 case GST_TAG_MERGE_REPLACE:
758 gst_structure_id_set_value (list, tag, value);
760 case GST_TAG_MERGE_PREPEND:
761 gst_value_list_merge (&dest, value, value2);
762 gst_structure_id_set_value (list, tag, &dest);
763 g_value_unset (&dest);
765 case GST_TAG_MERGE_APPEND:
766 gst_value_list_merge (&dest, value2, value);
767 gst_structure_id_set_value (list, tag, &dest);
768 g_value_unset (&dest);
770 case GST_TAG_MERGE_KEEP:
771 case GST_TAG_MERGE_KEEP_ALL:
774 g_assert_not_reached ();
779 case GST_TAG_MERGE_APPEND:
780 case GST_TAG_MERGE_KEEP:
781 if (gst_structure_id_get_value (list, tag) != NULL)
784 case GST_TAG_MERGE_REPLACE_ALL:
785 case GST_TAG_MERGE_REPLACE:
786 case GST_TAG_MERGE_PREPEND:
787 gst_structure_id_set_value (list, tag, value);
789 case GST_TAG_MERGE_KEEP_ALL:
792 g_assert_not_reached ();
799 gst_tag_list_copy_foreach (GQuark tag, const GValue * value, gpointer user_data)
801 GstTagCopyData *copy = (GstTagCopyData *) user_data;
803 gst_tag_list_add_value_internal (copy->list, copy->mode, tag, value, NULL);
809 * gst_tag_list_insert:
810 * @into: list to merge into
811 * @from: list to merge from
812 * @mode: the mode to use
814 * Inserts the tags of the @from list into the first list using the given mode.
817 gst_tag_list_insert (GstTagList * into, const GstTagList * from,
818 GstTagMergeMode mode)
822 g_return_if_fail (GST_IS_TAG_LIST (into));
823 g_return_if_fail (GST_IS_TAG_LIST (from));
824 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
826 data.list = (GstStructure *) into;
828 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
829 gst_structure_remove_all_fields (data.list);
831 gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach,
837 * @list: list to copy
839 * Copies a given #GstTagList.
841 * Free-function: gst_tag_list_free
843 * Returns: (transfer full): copy of the given list
846 gst_tag_list_copy (const GstTagList * list)
848 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
850 return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list));
854 * gst_tag_list_merge:
855 * @list1: first list to merge
856 * @list2: second list to merge
857 * @mode: the mode to use
859 * Merges the two given lists into a new list. If one of the lists is NULL, a
860 * copy of the other is returned. If both lists are NULL, NULL is returned.
862 * Free-function: gst_tag_list_free
864 * Returns: (transfer full): the new list
867 gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
868 GstTagMergeMode mode)
870 GstTagList *list1_cp;
871 const GstTagList *list2_cp;
873 g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
874 g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
875 g_return_val_if_fail (GST_TAG_MODE_IS_VALID (mode), NULL);
877 /* nothing to merge */
878 if (!list1 && !list2) {
882 /* create empty list, we need to do this to correctly handling merge modes */
883 list1_cp = (list1) ? gst_tag_list_copy (list1) : gst_tag_list_new ();
884 list2_cp = (list2) ? list2 : gst_tag_list_new ();
886 gst_tag_list_insert (list1_cp, list2_cp, mode);
889 gst_tag_list_free ((GstTagList *) list2_cp);
896 * @list: (in) (transfer full): the list to free
898 * Frees the given list and all associated values.
901 gst_tag_list_free (GstTagList * list)
903 g_return_if_fail (GST_IS_TAG_LIST (list));
904 gst_structure_free ((GstStructure *) list);
908 * gst_tag_list_get_tag_size:
910 * @tag: the tag to query
912 * Checks how many value are stored in this tag list for the given tag.
914 * Returns: The number of tags stored
917 gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag)
921 g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
923 value = gst_structure_get_value ((GstStructure *) list, tag);
926 if (G_VALUE_TYPE (value) != GST_TYPE_LIST)
929 return gst_value_list_get_size (value);
934 * @list: list to set tags in
935 * @mode: the mode to use
937 * @...: NULL-terminated list of values to set
939 * Sets the values for the given tags using the specified mode.
942 gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag,
947 g_return_if_fail (GST_IS_TAG_LIST (list));
948 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
949 g_return_if_fail (tag != NULL);
951 va_start (args, tag);
952 gst_tag_list_add_valist (list, mode, tag, args);
957 * gst_tag_list_add_values:
958 * @list: list to set tags in
959 * @mode: the mode to use
961 * @...: GValues to set
963 * Sets the GValues for the given tags using the specified mode.
966 gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode,
967 const gchar * tag, ...)
971 g_return_if_fail (GST_IS_TAG_LIST (list));
972 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
973 g_return_if_fail (tag != NULL);
975 va_start (args, tag);
976 gst_tag_list_add_valist_values (list, mode, tag, args);
981 * gst_tag_list_add_valist:
982 * @list: list to set tags in
983 * @mode: the mode to use
985 * @var_args: tag / value pairs to set
987 * Sets the values for the given tags using the specified mode.
990 gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
991 const gchar * tag, va_list var_args)
997 g_return_if_fail (GST_IS_TAG_LIST (list));
998 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
999 g_return_if_fail (tag != NULL);
1001 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1002 gst_structure_remove_all_fields (list);
1005 while (tag != NULL) {
1006 GValue value = { 0, };
1008 quark = g_quark_from_string (tag);
1009 info = gst_tag_lookup (quark);
1010 if (G_UNLIKELY (info == NULL)) {
1011 g_warning ("unknown tag '%s'", tag);
1014 #if GLIB_CHECK_VERSION(2,23,3)
1015 G_VALUE_COLLECT_INIT (&value, info->type, var_args, 0, &error);
1017 g_value_init (&value, info->type);
1018 G_VALUE_COLLECT (&value, var_args, 0, &error);
1021 g_warning ("%s: %s", G_STRLOC, error);
1023 /* we purposely leak the value here, it might not be
1024 * in a sane state if an error condition occoured
1028 gst_tag_list_add_value_internal (list, mode, quark, &value, info);
1029 g_value_unset (&value);
1030 tag = va_arg (var_args, gchar *);
1035 * gst_tag_list_add_valist_values:
1036 * @list: list to set tags in
1037 * @mode: the mode to use
1039 * @var_args: tag / GValue pairs to set
1041 * Sets the GValues for the given tags using the specified mode.
1044 gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
1045 const gchar * tag, va_list var_args)
1049 g_return_if_fail (GST_IS_TAG_LIST (list));
1050 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1051 g_return_if_fail (tag != NULL);
1053 if (mode == GST_TAG_MERGE_REPLACE_ALL) {
1054 gst_structure_remove_all_fields (list);
1057 while (tag != NULL) {
1058 quark = g_quark_from_string (tag);
1059 g_return_if_fail (gst_tag_lookup (quark) != NULL);
1060 gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args,
1062 tag = va_arg (var_args, gchar *);
1067 * gst_tag_list_add_value:
1068 * @list: list to set tags in
1069 * @mode: the mode to use
1071 * @value: GValue for this tag
1073 * Sets the GValue for a given tag using the specified mode.
1078 gst_tag_list_add_value (GstTagList * list, GstTagMergeMode mode,
1079 const gchar * tag, const GValue * value)
1081 g_return_if_fail (GST_IS_TAG_LIST (list));
1082 g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
1083 g_return_if_fail (tag != NULL);
1085 gst_tag_list_add_value_internal (list, mode, g_quark_from_string (tag),
1090 * gst_tag_list_remove_tag:
1091 * @list: list to remove tag from
1092 * @tag: tag to remove
1094 * Removes the given tag from the taglist.
1097 gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
1099 g_return_if_fail (GST_IS_TAG_LIST (list));
1100 g_return_if_fail (tag != NULL);
1102 gst_structure_remove_field ((GstStructure *) list, tag);
1107 GstTagForeachFunc func;
1108 const GstTagList *tag_list;
1114 structure_foreach_wrapper (GQuark field_id, const GValue * value,
1117 TagForeachData *data = (TagForeachData *) user_data;
1119 data->func (data->tag_list, g_quark_to_string (field_id), data->data);
1124 * gst_tag_list_foreach:
1125 * @list: list to iterate over
1126 * @func: (scope call): function to be called for each tag
1127 * @user_data: (closure): user specified data
1129 * Calls the given function for each tag inside the tag list. Note that if there
1130 * is no tag, the function won't be called at all.
1133 gst_tag_list_foreach (const GstTagList * list, GstTagForeachFunc func,
1136 TagForeachData data;
1138 g_return_if_fail (GST_IS_TAG_LIST (list));
1139 g_return_if_fail (func != NULL);
1142 data.tag_list = list;
1143 data.data = user_data;
1144 gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper,
1149 * gst_tag_list_get_value_index:
1150 * @list: a #GstTagList
1151 * @tag: tag to read out
1152 * @index: number of entry to read out
1154 * Gets the value that is at the given index for the given tag in the given
1157 * Returns: (transfer none): The GValue for the specified entry or NULL if the
1158 * tag wasn't available or the tag doesn't have as many entries
1161 gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
1164 const GValue *value;
1166 g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
1167 g_return_val_if_fail (tag != NULL, NULL);
1169 value = gst_structure_get_value ((GstStructure *) list, tag);
1173 if (GST_VALUE_HOLDS_LIST (value)) {
1174 if (index >= gst_value_list_get_size (value))
1176 return gst_value_list_get_value (value, index);
1185 * gst_tag_list_copy_value:
1186 * @dest: (out caller-allocates): uninitialized #GValue to copy into
1187 * @list: list to get the tag from
1188 * @tag: tag to read out
1190 * Copies the contents for the given tag into the value,
1191 * merging multiple values into one if multiple values are associated
1193 * You must g_value_unset() the value after use.
1195 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1199 gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
1204 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1205 g_return_val_if_fail (tag != NULL, FALSE);
1206 g_return_val_if_fail (dest != NULL, FALSE);
1207 g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
1209 src = gst_structure_get_value ((GstStructure *) list, tag);
1213 if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
1214 GstTagInfo *info = gst_tag_lookup (g_quark_from_string (tag));
1219 /* must be there or lists aren't allowed */
1220 g_assert (info->merge_func);
1221 info->merge_func (dest, src);
1223 g_value_init (dest, G_VALUE_TYPE (src));
1224 g_value_copy (src, dest);
1229 /* FIXME 0.11: this whole merge function business is overdesigned, and the
1230 * _get_foo() API is misleading as well - how many application developers will
1231 * expect gst_tag_list_get_string (list, GST_TAG_ARTIST, &val) might return a
1232 * string with multiple comma-separated artists? _get_foo() should just be
1233 * a convenience wrapper around _get_foo_index (list, tag, 0, &val),
1234 * supplemented by a special _tag_list_get_string_merged() function if needed
1235 * (unless someone can actually think of real use cases where the merge
1236 * function is not 'use first' for non-strings and merge for strings) */
1238 /***** evil macros to get all the gst_tag_list_get_*() functions right *****/
1240 #define TAG_MERGE_FUNCS(name,type,ret) \
1242 gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
1245 GValue v = { 0, }; \
1247 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1248 g_return_val_if_fail (tag != NULL, FALSE); \
1249 g_return_val_if_fail (value != NULL, FALSE); \
1251 if (!gst_tag_list_copy_value (&v, list, tag)) \
1253 *value = COPY_FUNC (g_value_get_ ## name (&v)); \
1254 g_value_unset (&v); \
1259 gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
1261 guint index, type *value) \
1265 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
1266 g_return_val_if_fail (tag != NULL, FALSE); \
1267 g_return_val_if_fail (value != NULL, FALSE); \
1269 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
1271 *value = COPY_FUNC (g_value_get_ ## name (v)); \
1275 /* FIXME 0.11: maybe get rid of _get_char*(), _get_uchar*(), _get_long*(),
1276 * _get_ulong*() and _get_pointer*()? - they are not really useful/common
1277 * enough to warrant convenience accessor functions */
1279 #define COPY_FUNC /**/
1281 * gst_tag_list_get_char:
1282 * @list: a #GstTagList to get the tag from
1283 * @tag: tag to read out
1284 * @value: (out): location for the result
1286 * Copies the contents for the given tag into the value, merging multiple values
1287 * into one if multiple values are associated with the tag.
1289 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1293 * gst_tag_list_get_char_index:
1294 * @list: a #GstTagList to get the tag from
1295 * @tag: tag to read out
1296 * @index: number of entry to read out
1297 * @value: (out): location for the result
1299 * Gets the value that is at the given index for the given tag in the given
1302 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1305 TAG_MERGE_FUNCS (char, gchar, TRUE);
1307 * gst_tag_list_get_uchar:
1308 * @list: a #GstTagList to get the tag from
1309 * @tag: tag to read out
1310 * @value: (out): location for the result
1312 * Copies the contents for the given tag into the value, merging multiple values
1313 * into one if multiple values are associated with the tag.
1315 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1319 * gst_tag_list_get_uchar_index:
1320 * @list: a #GstTagList to get the tag from
1321 * @tag: tag to read out
1322 * @index: number of entry to read out
1323 * @value: (out): location for the result
1325 * Gets the value that is at the given index for the given tag in the given
1328 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1331 TAG_MERGE_FUNCS (uchar, guchar, TRUE);
1333 * gst_tag_list_get_boolean:
1334 * @list: a #GstTagList to get the tag from
1335 * @tag: tag to read out
1336 * @value: (out): location for the result
1338 * Copies the contents for the given tag into the value, merging multiple values
1339 * into one if multiple values are associated with the tag.
1341 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1345 * gst_tag_list_get_boolean_index:
1346 * @list: a #GstTagList to get the tag from
1347 * @tag: tag to read out
1348 * @index: number of entry to read out
1349 * @value: (out): location for the result
1351 * Gets the value that is at the given index for the given tag in the given
1354 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1357 TAG_MERGE_FUNCS (boolean, gboolean, TRUE);
1359 * gst_tag_list_get_int:
1360 * @list: a #GstTagList to get the tag from
1361 * @tag: tag to read out
1362 * @value: (out): location for the result
1364 * Copies the contents for the given tag into the value, merging multiple values
1365 * into one if multiple values are associated with the tag.
1367 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1371 * gst_tag_list_get_int_index:
1372 * @list: a #GstTagList to get the tag from
1373 * @tag: tag to read out
1374 * @index: number of entry to read out
1375 * @value: (out): location for the result
1377 * Gets the value that is at the given index for the given tag in the given
1380 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1383 TAG_MERGE_FUNCS (int, gint, TRUE);
1385 * gst_tag_list_get_uint:
1386 * @list: a #GstTagList to get the tag from
1387 * @tag: tag to read out
1388 * @value: (out): location for the result
1390 * Copies the contents for the given tag into the value, merging multiple values
1391 * into one if multiple values are associated with the tag.
1393 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1397 * gst_tag_list_get_uint_index:
1398 * @list: a #GstTagList to get the tag from
1399 * @tag: tag to read out
1400 * @index: number of entry to read out
1401 * @value: (out): location for the result
1403 * Gets the value that is at the given index for the given tag in the given
1406 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1409 TAG_MERGE_FUNCS (uint, guint, TRUE);
1411 * gst_tag_list_get_long:
1412 * @list: a #GstTagList to get the tag from
1413 * @tag: tag to read out
1414 * @value: (out): location for the result
1416 * Copies the contents for the given tag into the value, merging multiple values
1417 * into one if multiple values are associated with the tag.
1419 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1423 * gst_tag_list_get_long_index:
1424 * @list: a #GstTagList to get the tag from
1425 * @tag: tag to read out
1426 * @index: number of entry to read out
1427 * @value: (out): location for the result
1429 * Gets the value that is at the given index for the given tag in the given
1432 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1435 TAG_MERGE_FUNCS (long, glong, TRUE);
1437 * gst_tag_list_get_ulong:
1438 * @list: a #GstTagList to get the tag from
1439 * @tag: tag to read out
1440 * @value: (out): location for the result
1442 * Copies the contents for the given tag into the value, merging multiple values
1443 * into one if multiple values are associated with the tag.
1445 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1449 * gst_tag_list_get_ulong_index:
1450 * @list: a #GstTagList to get the tag from
1451 * @tag: tag to read out
1452 * @index: number of entry to read out
1453 * @value: (out): location for the result
1455 * Gets the value that is at the given index for the given tag in the given
1458 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1461 TAG_MERGE_FUNCS (ulong, gulong, TRUE);
1463 * gst_tag_list_get_int64:
1464 * @list: a #GstTagList to get the tag from
1465 * @tag: tag to read out
1466 * @value: (out): location for the result
1468 * Copies the contents for the given tag into the value, merging multiple values
1469 * into one if multiple values are associated with the tag.
1471 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1475 * gst_tag_list_get_int64_index:
1476 * @list: a #GstTagList to get the tag from
1477 * @tag: tag to read out
1478 * @index: number of entry to read out
1479 * @value: (out): location for the result
1481 * Gets the value that is at the given index for the given tag in the given
1484 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1487 TAG_MERGE_FUNCS (int64, gint64, TRUE);
1489 * gst_tag_list_get_uint64:
1490 * @list: a #GstTagList to get the tag from
1491 * @tag: tag to read out
1492 * @value: (out): location for the result
1494 * Copies the contents for the given tag into the value, merging multiple values
1495 * into one if multiple values are associated with the tag.
1497 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1501 * gst_tag_list_get_uint64_index:
1502 * @list: a #GstTagList to get the tag from
1503 * @tag: tag to read out
1504 * @index: number of entry to read out
1505 * @value: (out): location for the result
1507 * Gets the value that is at the given index for the given tag in the given
1510 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1513 TAG_MERGE_FUNCS (uint64, guint64, TRUE);
1515 * gst_tag_list_get_float:
1516 * @list: a #GstTagList to get the tag from
1517 * @tag: tag to read out
1518 * @value: (out): location for the result
1520 * Copies the contents for the given tag into the value, merging multiple values
1521 * into one if multiple values are associated with the tag.
1523 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1527 * gst_tag_list_get_float_index:
1528 * @list: a #GstTagList to get the tag from
1529 * @tag: tag to read out
1530 * @index: number of entry to read out
1531 * @value: (out): location for the result
1533 * Gets the value that is at the given index for the given tag in the given
1536 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1539 TAG_MERGE_FUNCS (float, gfloat, TRUE);
1541 * gst_tag_list_get_double:
1542 * @list: a #GstTagList to get the tag from
1543 * @tag: tag to read out
1544 * @value: (out): location for the result
1546 * Copies the contents for the given tag into the value, merging multiple values
1547 * into one if multiple values are associated with the tag.
1549 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1553 * gst_tag_list_get_double_index:
1554 * @list: a #GstTagList to get the tag from
1555 * @tag: tag to read out
1556 * @index: number of entry to read out
1557 * @value: (out): location for the result
1559 * Gets the value that is at the given index for the given tag in the given
1562 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1565 TAG_MERGE_FUNCS (double, gdouble, TRUE);
1567 * gst_tag_list_get_pointer:
1568 * @list: a #GstTagList to get the tag from
1569 * @tag: tag to read out
1570 * @value: (out) (transfer none): location for the result
1572 * Copies the contents for the given tag into the value, merging multiple values
1573 * into one if multiple values are associated with the tag.
1575 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1579 * gst_tag_list_get_pointer_index:
1580 * @list: a #GstTagList to get the tag from
1581 * @tag: tag to read out
1582 * @index: number of entry to read out
1583 * @value: (out) (transfer none): location for the result
1585 * Gets the value that is at the given index for the given tag in the given
1588 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1591 TAG_MERGE_FUNCS (pointer, gpointer, (*value != NULL));
1593 static inline gchar *
1594 _gst_strdup0 (const gchar * s)
1596 if (s == NULL || *s == '\0')
1599 return g_strdup (s);
1603 #define COPY_FUNC _gst_strdup0
1606 * gst_tag_list_get_string:
1607 * @list: a #GstTagList to get the tag from
1608 * @tag: tag to read out
1609 * @value: (out callee-allocates) (transfer full): location for the result
1611 * Copies the contents for the given tag into the value, possibly merging
1612 * multiple values into one if multiple values are associated with the tag.
1614 * Use gst_tag_list_get_string_index (list, tag, 0, value) if you want
1615 * to retrieve the first string associated with this tag unmodified.
1617 * The resulting string in @value will be in UTF-8 encoding and should be
1618 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1619 * returned string is also guaranteed to be non-NULL and non-empty.
1621 * Free-function: g_free
1623 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1627 * gst_tag_list_get_string_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 callee-allocates) (transfer full): location for the result
1633 * Gets the value that is at the given index for the given tag in the given
1636 * The resulting string in @value will be in UTF-8 encoding and should be
1637 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
1638 * returned string is also guaranteed to be non-NULL and non-empty.
1640 * Free-function: g_free
1642 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1645 TAG_MERGE_FUNCS (string, gchar *, (*value != NULL));
1648 *FIXME 0.11: Instead of _peek (non-copy) and _get (copy), we could have
1649 * _get (non-copy) and _dup (copy) for strings, seems more
1653 * gst_tag_list_peek_string_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) (transfer none): location for the result
1659 * Peeks at the value that is at the given index for the given tag in the given
1662 * The resulting string in @value will be in UTF-8 encoding and doesn't need
1663 * to be freed by the caller. The returned string is also guaranteed to
1664 * be non-NULL and non-empty.
1666 * Returns: TRUE, if a value was set, FALSE if the tag didn't exist in the
1670 gst_tag_list_peek_string_index (const GstTagList * list,
1671 const gchar * tag, guint index, const gchar ** value)
1675 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1676 g_return_val_if_fail (tag != NULL, FALSE);
1677 g_return_val_if_fail (value != NULL, FALSE);
1679 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1681 *value = g_value_get_string (v);
1682 return *value != NULL && **value != '\0';
1686 * gst_tag_list_get_date:
1687 * @list: a #GstTagList to get the tag from
1688 * @tag: tag to read out
1689 * @value: (out callee-allocates) (transfer full): address of a GDate pointer
1690 * variable to store the result into
1692 * Copies the first date for the given tag in the taglist into the variable
1693 * pointed to by @value. Free the date with g_date_free() when it is no longer
1696 * Free-function: g_date_free
1698 * Returns: TRUE, if a date was copied, FALSE if the tag didn't exist in the
1699 * given list or if it was #NULL.
1702 gst_tag_list_get_date (const GstTagList * list, const gchar * tag,
1707 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1708 g_return_val_if_fail (tag != NULL, FALSE);
1709 g_return_val_if_fail (value != NULL, FALSE);
1711 if (!gst_tag_list_copy_value (&v, list, tag))
1713 *value = (GDate *) g_value_dup_boxed (&v);
1715 return (*value != NULL);
1719 * gst_tag_list_get_date_index:
1720 * @list: a #GstTagList to get the tag from
1721 * @tag: tag to read out
1722 * @index: number of entry to read out
1723 * @value: (out callee-allocates) (transfer full): location for the result
1725 * Gets the date that is at the given index for the given tag in the given
1726 * list and copies it into the variable pointed to by @value. Free the date
1727 * with g_date_free() when it is no longer needed.
1729 * Free-function: g_date_free
1731 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1732 * given list or if it was #NULL.
1735 gst_tag_list_get_date_index (const GstTagList * list,
1736 const gchar * tag, guint index, GDate ** value)
1740 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1741 g_return_val_if_fail (tag != NULL, FALSE);
1742 g_return_val_if_fail (value != NULL, FALSE);
1744 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1746 *value = (GDate *) g_value_dup_boxed (v);
1747 return (*value != NULL);
1751 * gst_tag_list_get_date_time:
1752 * @list: a #GstTagList to get the tag from
1753 * @tag: tag to read out
1754 * @value: (out callee-allocates) (transfer full): address of a #GstDateTime
1755 * pointer variable to store the result into
1757 * Copies the first datetime for the given tag in the taglist into the variable
1758 * pointed to by @value. Unref the date with gst_date_time_unref() when
1759 * it is no longer needed.
1761 * Free-function: gst_date_time_unref
1763 * Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in
1764 * thegiven list or if it was #NULL.
1769 gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag,
1770 GstDateTime ** value)
1774 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1775 g_return_val_if_fail (tag != NULL, FALSE);
1776 g_return_val_if_fail (value != NULL, FALSE);
1778 if (!gst_tag_list_copy_value (&v, list, tag))
1781 g_return_val_if_fail (GST_VALUE_HOLDS_DATE_TIME (&v), FALSE);
1783 *value = (GstDateTime *) g_value_dup_boxed (&v);
1785 return (*value != NULL);
1789 * gst_tag_list_get_date_time_index:
1790 * @list: a #GstTagList to get the tag from
1791 * @tag: tag to read out
1792 * @index: number of entry to read out
1793 * @value: (out callee-allocates) (transfer full): location for the result
1795 * Gets the datetime that is at the given index for the given tag in the given
1796 * list and copies it into the variable pointed to by @value. Unref the datetime
1797 * with gst_date_time_unref() when it is no longer needed.
1799 * Free-function: gst_date_time_unref
1801 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1802 * given list or if it was #NULL.
1807 gst_tag_list_get_date_time_index (const GstTagList * list,
1808 const gchar * tag, guint index, GstDateTime ** value)
1812 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1813 g_return_val_if_fail (tag != NULL, FALSE);
1814 g_return_val_if_fail (value != NULL, FALSE);
1816 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1818 *value = (GstDateTime *) g_value_dup_boxed (v);
1819 return (*value != NULL);
1823 * gst_tag_list_get_buffer:
1824 * @list: a #GstTagList to get the tag from
1825 * @tag: tag to read out
1826 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
1827 * pointer variable to store the result into
1829 * Copies the first buffer for the given tag in the taglist into the variable
1830 * pointed to by @value. Free the buffer with gst_buffer_unref() when it is
1833 * Free-function: gst_buffer_unref
1835 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1836 * given list or if it was #NULL.
1841 gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag,
1846 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1847 g_return_val_if_fail (tag != NULL, FALSE);
1848 g_return_val_if_fail (value != NULL, FALSE);
1850 if (!gst_tag_list_copy_value (&v, list, tag))
1852 *value = (GstBuffer *) gst_value_dup_mini_object (&v);
1854 return (*value != NULL);
1858 * gst_tag_list_get_buffer_index:
1859 * @list: a #GstTagList to get the tag from
1860 * @tag: tag to read out
1861 * @index: number of entry to read out
1862 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
1863 * pointer variable to store the result into
1865 * Gets the buffer that is at the given index for the given tag in the given
1866 * list and copies it into the variable pointed to by @value. Free the buffer
1867 * with gst_buffer_unref() when it is no longer needed.
1869 * Free-function: gst_buffer_unref
1871 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1872 * given list or if it was #NULL.
1877 gst_tag_list_get_buffer_index (const GstTagList * list,
1878 const gchar * tag, guint index, GstBuffer ** value)
1882 g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1883 g_return_val_if_fail (tag != NULL, FALSE);
1884 g_return_val_if_fail (value != NULL, FALSE);
1886 if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1888 *value = (GstBuffer *) gst_value_dup_mini_object (v);
1889 return (*value != NULL);