2003-11-24 02:09:23 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
|
|
|
*
|
2005-09-07 13:22:16 +00:00
|
|
|
* gsttaglist.c: tag support (aka metadata)
|
2003-11-24 02:09:23 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-09-06 22:03:01 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gsttaglist
|
|
|
|
* @short_description: List of tags and values used to describe media metadata
|
|
|
|
*
|
2005-11-24 09:44:07 +00:00
|
|
|
* List of tags and values used to describe media metadata.
|
|
|
|
*
|
2009-06-08 23:16:05 +00:00
|
|
|
* Strings must be in ASCII or UTF-8 encoding. No other encodings are allowed.
|
|
|
|
*
|
|
|
|
* Last reviewed on 2009-06-09 (0.10.23)
|
2005-09-06 22:03:01 +00:00
|
|
|
*/
|
2003-11-24 02:09:23 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gst_private.h"
|
2011-10-29 23:44:44 +00:00
|
|
|
#include "math-compat.h"
|
2004-01-13 11:04:25 +00:00
|
|
|
#include "gst-i18n-lib.h"
|
2005-09-07 13:22:16 +00:00
|
|
|
#include "gsttaglist.h"
|
2003-11-24 02:09:23 +00:00
|
|
|
#include "gstinfo.h"
|
|
|
|
#include "gstvalue.h"
|
2006-05-09 10:02:51 +00:00
|
|
|
#include "gstbuffer.h"
|
2009-05-29 17:00:06 +00:00
|
|
|
#include "gstquark.h"
|
2011-10-30 10:05:23 +00:00
|
|
|
#include "gststructure.h"
|
2003-11-24 02:09:23 +00:00
|
|
|
|
|
|
|
#include <gobject/gvaluecollector.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
/* FIXME: add category for tags */
|
|
|
|
#define GST_CAT_TAGS GST_CAT_DEFAULT
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL)
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
typedef struct _GstTagListImpl
|
2011-10-30 10:05:23 +00:00
|
|
|
{
|
2012-05-27 22:58:27 +00:00
|
|
|
GstTagList taglist;
|
|
|
|
|
2012-05-20 23:31:29 +00:00
|
|
|
GstStructure *structure;
|
2012-07-27 21:52:12 +00:00
|
|
|
GstTagScope scope;
|
2012-05-27 22:58:27 +00:00
|
|
|
} GstTagListImpl;
|
|
|
|
|
2012-06-14 15:11:11 +00:00
|
|
|
#define GST_TAG_LIST_STRUCTURE(taglist) ((GstTagListImpl*)(taglist))->structure
|
2012-07-27 21:52:12 +00:00
|
|
|
#define GST_TAG_LIST_SCOPE(taglist) ((GstTagListImpl*)(taglist))->scope
|
2012-05-27 22:58:27 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2004-03-15 19:27:17 +00:00
|
|
|
GType type; /* type the data is in */
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2012-05-28 22:54:10 +00:00
|
|
|
const gchar *nick; /* translated short description */
|
|
|
|
const gchar *blurb; /* translated long description */
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
GstTagMergeFunc merge_func; /* functions to merge the values */
|
|
|
|
GstTagFlag flag; /* type of tag */
|
2011-10-30 00:46:22 +00:00
|
|
|
GQuark name_quark; /* quark for the name */
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
GstTagInfo;
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2011-12-03 15:36:58 +00:00
|
|
|
#define g_value_get_char g_value_get_schar
|
|
|
|
|
|
|
|
static GMutex __tag_mutex;
|
|
|
|
#define TAG_LOCK g_mutex_lock (&__tag_mutex)
|
|
|
|
#define TAG_UNLOCK g_mutex_unlock (&__tag_mutex)
|
2008-06-20 08:39:54 +00:00
|
|
|
|
2011-10-30 00:46:22 +00:00
|
|
|
/* tags hash table: maps tag name string => GstTagInfo */
|
2003-11-24 02:09:23 +00:00
|
|
|
static GHashTable *__tags;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
GST_DEFINE_MINI_OBJECT_TYPE (GstTagList, gst_tag_list);
|
|
|
|
|
|
|
|
static void __gst_tag_list_free (GstTagList * list);
|
|
|
|
static GstTagList *__gst_tag_list_copy (const GstTagList * list);
|
2004-02-18 05:26:59 +00:00
|
|
|
|
2012-01-28 14:35:51 +00:00
|
|
|
/* FIXME: had code:
|
|
|
|
* g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
|
|
|
|
* _gst_structure_transform_to_string);
|
|
|
|
*/
|
2003-11-24 02:09:23 +00:00
|
|
|
void
|
2011-08-29 11:27:26 +00:00
|
|
|
_priv_gst_tag_initialize (void)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
2011-12-03 15:36:58 +00:00
|
|
|
g_mutex_init (&__tag_mutex);
|
2012-01-22 01:25:22 +00:00
|
|
|
|
2011-10-30 00:46:22 +00:00
|
|
|
__tags = g_hash_table_new (g_str_hash, g_str_equal);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_TITLE, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("title"), _("commonly used title"), gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_TITLE_SORTNAME, GST_TAG_FLAG_META,
|
2007-10-24 13:13:56 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("title sortname"), _("commonly used title for sorting purposes"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ARTIST, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("artist"),
|
|
|
|
_("person(s) responsible for the recording"),
|
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ARTIST_SORTNAME, GST_TAG_FLAG_META,
|
2007-10-24 13:13:56 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("artist sortname"),
|
|
|
|
_("person(s) responsible for the recording for sorting purposes"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ALBUM, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("album"),
|
|
|
|
_("album containing this data"), gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ALBUM_SORTNAME, GST_TAG_FLAG_META,
|
2007-10-24 13:13:56 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("album sortname"),
|
|
|
|
_("album containing this data for sorting purposes"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ALBUM_ARTIST, GST_TAG_FLAG_META,
|
2009-08-04 12:13:34 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("album artist"),
|
|
|
|
_("The artist of the entire album, as it should be displayed"),
|
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ALBUM_ARTIST_SORTNAME, GST_TAG_FLAG_META,
|
2009-08-04 12:13:34 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("album artist sortname"),
|
|
|
|
_("The artist of the entire album, as it should be sorted"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_DATE,
|
2005-10-13 15:13:32 +00:00
|
|
|
_("date"), _("date the data was created (as a GDate structure)"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_DATE_TIME, GST_TAG_FLAG_META,
|
|
|
|
GST_TYPE_DATE_TIME, _("datetime"),
|
2010-06-22 02:42:44 +00:00
|
|
|
_("date and time the data was created (as a GstDateTime structure)"),
|
|
|
|
NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GENRE, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("genre"),
|
|
|
|
_("genre this data belongs to"), gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_COMMENT, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("comment"),
|
2006-08-14 19:04:56 +00:00
|
|
|
_("free text commenting the data"), gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_EXTENDED_COMMENT, GST_TAG_FLAG_META,
|
2006-08-14 19:04:56 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("extended comment"),
|
|
|
|
_("free text commenting the data in key=value or key[en]=comment form"),
|
|
|
|
gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT,
|
|
|
|
_("track number"),
|
|
|
|
_("track number inside a collection"), gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT,
|
|
|
|
_("track count"),
|
|
|
|
_("count of tracks inside collection this track belongs to"),
|
|
|
|
gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT,
|
|
|
|
_("disc number"),
|
|
|
|
_("disc number inside a collection"), gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT,
|
|
|
|
_("disc count"),
|
|
|
|
_("count of discs inside collection this disc belongs to"),
|
|
|
|
gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_LOCATION, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
2010-02-15 00:29:37 +00:00
|
|
|
_("location"), _("Origin of media as a URI (location, where the "
|
|
|
|
"original of the file or stream is hosted)"),
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_HOMEPAGE, GST_TAG_FLAG_META,
|
2009-02-12 09:38:05 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("homepage"),
|
2010-02-15 00:29:37 +00:00
|
|
|
_("Homepage for this media (i.e. artist or movie homepage)"),
|
2009-02-12 09:38:05 +00:00
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING, _("description"),
|
|
|
|
_("short text describing the content of the data"),
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_VERSION, GST_TAG_FLAG_META, G_TYPE_STRING,
|
2008-09-01 13:35:32 +00:00
|
|
|
_("version"), _("version of this data"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ISRC, GST_TAG_FLAG_META, G_TYPE_STRING,
|
|
|
|
_("ISRC"),
|
2004-03-13 15:27:01 +00:00
|
|
|
_
|
|
|
|
("International Standard Recording Code - see http://www.ifpi.org/isrc/"),
|
|
|
|
NULL);
|
2010-02-15 00:29:37 +00:00
|
|
|
/* FIXME: organization (fix what? tpm) */
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING, _("organization"), _("organization"),
|
|
|
|
gst_tag_merge_strings_with_comma);
|
|
|
|
gst_tag_register_static (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_COPYRIGHT_URI, GST_TAG_FLAG_META,
|
2007-07-26 15:48:40 +00:00
|
|
|
G_TYPE_STRING, _("copyright uri"),
|
|
|
|
_("URI to the copyright notice of the data"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ENCODED_BY, GST_TAG_FLAG_META, G_TYPE_STRING,
|
2010-08-19 19:43:07 +00:00
|
|
|
_("encoded by"), _("name of the encoding person or organization"),
|
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_CONTACT, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("contact"), _("contact information"), gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_LICENSE, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING, _("license"), _("license of data"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_LICENSE_URI, GST_TAG_FLAG_META,
|
2007-07-26 15:48:40 +00:00
|
|
|
G_TYPE_STRING, _("license uri"),
|
|
|
|
_("URI to the license of the data"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_PERFORMER, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("performer"),
|
|
|
|
_("person(s) performing"), gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_COMPOSER, GST_TAG_FLAG_META,
|
2007-09-25 18:35:39 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("composer"),
|
|
|
|
_("person(s) who composed the recording"),
|
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_DURATION, GST_TAG_FLAG_DECODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT64,
|
|
|
|
_("duration"), _("length in GStreamer time units (nanoseconds)"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("codec"),
|
|
|
|
_("codec the data is stored in"), gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("video codec"), _("codec the video data is stored in"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("audio codec"), _("codec the audio data is stored in"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_SUBTITLE_CODEC, GST_TAG_FLAG_ENCODED,
|
2009-03-25 00:50:07 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("subtitle codec"), _("codec the subtitle data is stored in"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_CONTAINER_FORMAT, GST_TAG_FLAG_ENCODED,
|
2009-05-07 15:08:43 +00:00
|
|
|
G_TYPE_STRING, _("container format"),
|
|
|
|
_("container format the data is stored in"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_STRING,
|
|
|
|
_("encoder"), _("encoder used to encode this stream"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT,
|
|
|
|
_("encoder version"),
|
|
|
|
_("version of the encoder used to encode this stream"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_UINT, _("serial"), _("serial number of track"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META,
|
2004-03-13 15:27:01 +00:00
|
|
|
G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_REFERENCE_LEVEL, GST_TAG_FLAG_META,
|
2007-02-12 10:50:20 +00:00
|
|
|
G_TYPE_DOUBLE, _("replaygain reference level"),
|
|
|
|
_("reference level of track and album gain values"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_LANGUAGE_CODE, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING, _("language code"),
|
2012-01-02 00:17:17 +00:00
|
|
|
_("language code for this stream, conforming to ISO-639-1 or ISO-639-2"),
|
|
|
|
NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_LANGUAGE_NAME, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING, _("language name"),
|
2012-01-02 00:17:17 +00:00
|
|
|
_("freeform name of the language this stream is in"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_IMAGE, GST_TAG_FLAG_META, GST_TYPE_SAMPLE,
|
2006-07-24 16:33:31 +00:00
|
|
|
_("image"), _("image related to this stream"), gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_PREVIEW_IMAGE, GST_TAG_FLAG_META,
|
|
|
|
GST_TYPE_SAMPLE,
|
2010-03-01 12:02:44 +00:00
|
|
|
/* TRANSLATORS: 'preview image' = image that shows a preview of the full image */
|
2006-05-30 10:12:02 +00:00
|
|
|
_("preview image"), _("preview image related to this stream"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_ATTACHMENT, GST_TAG_FLAG_META,
|
|
|
|
GST_TYPE_SAMPLE, _("attachment"), _("file attached to this stream"),
|
2008-06-20 08:39:54 +00:00
|
|
|
gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_BEATS_PER_MINUTE, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_DOUBLE, _("beats per minute"),
|
|
|
|
_("number of beats per minute in audio"), NULL);
|
|
|
|
gst_tag_register_static (GST_TAG_KEYWORDS, GST_TAG_FLAG_META, G_TYPE_STRING,
|
2008-08-04 12:30:26 +00:00
|
|
|
_("keywords"), _("comma separated keywords describing the content"),
|
2008-08-04 13:01:35 +00:00
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_NAME, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING, _("geo location name"),
|
|
|
|
_("human readable descriptive location of where "
|
2010-02-15 00:29:37 +00:00
|
|
|
"the media has been recorded or produced"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_LATITUDE, GST_TAG_FLAG_META,
|
2008-09-01 13:35:32 +00:00
|
|
|
G_TYPE_DOUBLE, _("geo location latitude"),
|
2010-02-15 00:29:37 +00:00
|
|
|
_("geo latitude location of where the media has been recorded or "
|
|
|
|
"produced in degrees according to WGS84 (zero at the equator, "
|
|
|
|
"negative values for southern latitudes)"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_LONGITUDE, GST_TAG_FLAG_META,
|
2008-09-01 13:35:32 +00:00
|
|
|
G_TYPE_DOUBLE, _("geo location longitude"),
|
2010-02-15 00:29:37 +00:00
|
|
|
_("geo longitude location of where the media has been recorded or "
|
|
|
|
"produced in degrees according to WGS84 (zero at the prime meridian "
|
|
|
|
"in Greenwich/UK, negative values for western longitudes)"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_ELEVATION, GST_TAG_FLAG_META,
|
2008-09-01 13:35:32 +00:00
|
|
|
G_TYPE_DOUBLE, _("geo location elevation"),
|
2010-02-15 00:29:37 +00:00
|
|
|
_("geo elevation of where the media has been recorded or produced in "
|
|
|
|
"meters according to WGS84 (zero is average sea level)"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_COUNTRY, GST_TAG_FLAG_META,
|
2010-03-09 23:38:47 +00:00
|
|
|
G_TYPE_STRING, _("geo location country"),
|
|
|
|
_("country (english name) where the media has been recorded "
|
|
|
|
"or produced"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_CITY, GST_TAG_FLAG_META,
|
2010-03-09 23:38:47 +00:00
|
|
|
G_TYPE_STRING, _("geo location city"),
|
|
|
|
_("city (english name) where the media has been recorded "
|
|
|
|
"or produced"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_SUBLOCATION, GST_TAG_FLAG_META,
|
2010-03-09 23:38:47 +00:00
|
|
|
G_TYPE_STRING, _("geo location sublocation"),
|
2012-09-25 12:14:53 +00:00
|
|
|
_("a location within a city where the media has been produced "
|
2010-03-09 23:38:47 +00:00
|
|
|
"or created (e.g. the neighborhood)"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR,
|
|
|
|
GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location horizontal error"),
|
2010-09-23 13:08:05 +00:00
|
|
|
_("expected error of the horizontal positioning measures (in meters)"),
|
|
|
|
NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED,
|
|
|
|
GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location movement speed"),
|
2010-04-30 00:57:15 +00:00
|
|
|
_("movement speed of the capturing device while performing the capture "
|
|
|
|
"in m/s"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION,
|
|
|
|
GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location movement direction"),
|
2010-04-30 00:57:15 +00:00
|
|
|
_("indicates the movement direction of the device performing the capture"
|
|
|
|
" of a media. It is represented as degrees in floating point "
|
|
|
|
"representation, 0 means the geographic north, and increases "
|
|
|
|
"clockwise"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION,
|
|
|
|
GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location capture direction"),
|
2010-04-30 00:57:15 +00:00
|
|
|
_("indicates the direction the device is pointing to when capturing "
|
|
|
|
" a media. It is represented as degrees in floating point "
|
|
|
|
" representation, 0 means the geographic north, and increases "
|
|
|
|
"clockwise"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_SHOW_NAME, GST_TAG_FLAG_META, G_TYPE_STRING,
|
2010-03-01 12:02:44 +00:00
|
|
|
/* TRANSLATORS: 'show name' = 'TV/radio/podcast show name' here */
|
2010-01-06 20:04:15 +00:00
|
|
|
_("show name"),
|
2009-12-21 14:58:12 +00:00
|
|
|
_("Name of the tv/podcast/series show the media is from"),
|
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_SHOW_SORTNAME, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING,
|
2010-03-01 12:02:44 +00:00
|
|
|
/* TRANSLATORS: 'show sortname' = 'TV/radio/podcast show name as used for sorting purposes' here */
|
2010-01-06 20:04:15 +00:00
|
|
|
_("show sortname"),
|
2009-12-21 14:58:12 +00:00
|
|
|
_("Name of the tv/podcast/series show the media is from, for sorting "
|
|
|
|
"purposes"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_SHOW_EPISODE_NUMBER, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_UINT, _("episode number"),
|
2010-01-06 20:04:15 +00:00
|
|
|
_("The episode number in the season the media is part of"),
|
2009-12-21 14:58:12 +00:00
|
|
|
gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_SHOW_SEASON_NUMBER, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_UINT, _("season number"),
|
2010-01-06 20:04:15 +00:00
|
|
|
_("The season number of the show the media is part of"),
|
2009-12-21 14:58:12 +00:00
|
|
|
gst_tag_merge_use_first);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_LYRICS, GST_TAG_FLAG_META, G_TYPE_STRING,
|
2010-01-06 20:04:15 +00:00
|
|
|
_("lyrics"), _("The lyrics of the media, commonly used for songs"),
|
2009-12-21 14:58:12 +00:00
|
|
|
gst_tag_merge_strings_with_comma);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_COMPOSER_SORTNAME, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING, _("composer sortname"),
|
2009-12-21 14:58:12 +00:00
|
|
|
_("person(s) who composed the recording, for sorting purposes"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_GROUPING, GST_TAG_FLAG_META, G_TYPE_STRING,
|
2010-01-06 20:04:15 +00:00
|
|
|
_("grouping"),
|
2009-12-21 14:58:12 +00:00
|
|
|
_("Groups related media that spans multiple tracks, like the different "
|
|
|
|
"pieces of a concerto. It is a higher level than a track, "
|
|
|
|
"but lower than an album"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_USER_RATING, GST_TAG_FLAG_META, G_TYPE_UINT,
|
2010-03-19 18:10:07 +00:00
|
|
|
_("user rating"),
|
|
|
|
_("Rating attributed by a user. The higher the rank, "
|
|
|
|
"the more the user likes this media"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_DEVICE_MANUFACTURER, GST_TAG_FLAG_META,
|
2010-04-16 09:57:05 +00:00
|
|
|
G_TYPE_STRING, _("device manufacturer"),
|
|
|
|
_("Manufacturer of the device used to create this media"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_DEVICE_MODEL, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING, _("device model"),
|
2010-04-16 09:57:05 +00:00
|
|
|
_("Model of the device used to create this media"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_APPLICATION_NAME, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING, _("application name"),
|
|
|
|
_("Application used to create the media"), NULL);
|
|
|
|
gst_tag_register_static (GST_TAG_APPLICATION_DATA, GST_TAG_FLAG_META,
|
2012-07-26 15:44:15 +00:00
|
|
|
GST_TYPE_SAMPLE, _("application data"),
|
2010-08-16 17:12:35 +00:00
|
|
|
_("Arbitrary application data to be serialized into the media"), NULL);
|
2012-05-28 22:54:10 +00:00
|
|
|
gst_tag_register_static (GST_TAG_IMAGE_ORIENTATION, GST_TAG_FLAG_META,
|
|
|
|
G_TYPE_STRING, _("image orientation"),
|
2010-06-15 21:26:01 +00:00
|
|
|
_("How the image should be rotated or flipped before display"), NULL);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_merge_use_first:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @dest: (out caller-allocates): uninitialized GValue to store result in
|
2003-11-24 02:09:23 +00:00
|
|
|
* @src: GValue to copy from
|
|
|
|
*
|
2005-06-19 11:32:42 +00:00
|
|
|
* This is a convenience function for the func argument of gst_tag_register().
|
2003-11-24 02:09:23 +00:00
|
|
|
* It creates a copy of the first value from the list.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_merge_use_first (GValue * dest, const GValue * src)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
const GValue *ret = gst_value_list_get_value (src, 0);
|
|
|
|
|
|
|
|
g_value_init (dest, G_VALUE_TYPE (ret));
|
|
|
|
g_value_copy (ret, dest);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_merge_strings_with_comma:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @dest: (out caller-allocates): uninitialized GValue to store result in
|
2003-11-24 02:09:23 +00:00
|
|
|
* @src: GValue to copy from
|
2005-06-19 11:32:42 +00:00
|
|
|
*
|
2003-11-24 02:09:23 +00:00
|
|
|
* This is a convenience function for the func argument of gst_tag_register().
|
|
|
|
* It concatenates all given strings using a comma. The tag must be registered
|
|
|
|
* as a G_TYPE_STRING or this function will fail.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GString *str;
|
|
|
|
gint i, count;
|
|
|
|
|
|
|
|
count = gst_value_list_get_size (src);
|
|
|
|
str = g_string_new (g_value_get_string (gst_value_list_get_value (src, 0)));
|
|
|
|
for (i = 1; i < count; i++) {
|
2010-07-11 17:59:53 +00:00
|
|
|
/* separator between two strings */
|
|
|
|
g_string_append (str, _(", "));
|
|
|
|
g_string_append (str,
|
|
|
|
g_value_get_string (gst_value_list_get_value (src, i)));
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init (dest, G_TYPE_STRING);
|
2008-04-19 16:05:58 +00:00
|
|
|
g_value_take_string (dest, str->str);
|
2003-11-24 02:09:23 +00:00
|
|
|
g_string_free (str, FALSE);
|
|
|
|
}
|
2008-06-20 08:39:54 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
static GstTagInfo *
|
2011-10-30 00:46:22 +00:00
|
|
|
gst_tag_lookup (const gchar * tag_name)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstTagInfo *ret;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
TAG_LOCK;
|
2011-10-30 00:46:22 +00:00
|
|
|
ret = g_hash_table_lookup (__tags, (gpointer) tag_name);
|
2003-11-24 02:09:23 +00:00
|
|
|
TAG_UNLOCK;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_register:
|
|
|
|
* @name: the name or identifier string
|
2004-01-22 13:59:57 +00:00
|
|
|
* @flag: a flag describing the type of tag info
|
2003-11-24 02:09:23 +00:00
|
|
|
* @type: the type this data is in
|
|
|
|
* @nick: human-readable name
|
|
|
|
* @blurb: a human-readable description about this tag
|
2006-07-20 16:10:17 +00:00
|
|
|
* @func: function for merging multiple values of this tag, or NULL
|
2003-11-24 02:09:23 +00:00
|
|
|
*
|
|
|
|
* Registers a new tag type for the use with GStreamer's type system. If a type
|
|
|
|
* with that name is already registered, that one is used.
|
|
|
|
* The old registration may have used a different type however. So don't rely
|
2004-01-22 13:59:57 +00:00
|
|
|
* on your supplied values.
|
2006-07-20 16:10:17 +00:00
|
|
|
*
|
|
|
|
* Important: if you do not supply a merge function the implication will be
|
|
|
|
* that there can only be one single value for this tag in a tag list and
|
|
|
|
* any additional values will silenty be discarded when being added (unless
|
|
|
|
* #GST_TAG_MERGE_REPLACE, #GST_TAG_MERGE_REPLACE_ALL, or
|
|
|
|
* #GST_TAG_MERGE_PREPEND is used as merge mode, in which case the new
|
2007-07-10 20:10:16 +00:00
|
|
|
* value will replace the old one in the list).
|
2006-07-20 16:10:17 +00:00
|
|
|
*
|
|
|
|
* The merge function will be called from gst_tag_list_copy_value() when
|
|
|
|
* it is required that one or more values for a tag be condensed into
|
|
|
|
* one single value. This may happen from gst_tag_list_get_string(),
|
|
|
|
* gst_tag_list_get_int(), gst_tag_list_get_double() etc. What will happen
|
|
|
|
* exactly in that case depends on how the tag was registered and if a
|
|
|
|
* merge function was supplied and if so which one.
|
|
|
|
*
|
|
|
|
* Two default merge functions are provided: gst_tag_merge_use_first() and
|
2009-11-25 14:44:05 +00:00
|
|
|
* gst_tag_merge_strings_with_comma().
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-04-13 02:22:02 +00:00
|
|
|
gst_tag_register (const gchar * name, GstTagFlag flag, GType type,
|
|
|
|
const gchar * nick, const gchar * blurb, GstTagMergeFunc func)
|
2012-05-28 22:54:10 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
g_return_if_fail (nick != NULL);
|
|
|
|
g_return_if_fail (blurb != NULL);
|
|
|
|
g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
|
|
|
|
|
|
|
|
return gst_tag_register_static (g_intern_string (name), flag, type,
|
|
|
|
g_intern_string (nick), g_intern_string (blurb), func);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_register_static:
|
|
|
|
* @name: the name or identifier string (string constant)
|
|
|
|
* @flag: a flag describing the type of tag info
|
|
|
|
* @type: the type this data is in
|
|
|
|
* @nick: human-readable name or short description (string constant)
|
|
|
|
* @blurb: a human-readable description for this tag (string constant)
|
|
|
|
* @func: function for merging multiple values of this tag, or NULL
|
|
|
|
*
|
|
|
|
* Registers a new tag type for the use with GStreamer's type system.
|
|
|
|
*
|
|
|
|
* Same as gst_tag_register(), but @name, @nick, and @blurb must be
|
|
|
|
* static strings or inlined strings, as they will not be copied. (GStreamer
|
|
|
|
* plugins will be made resident once loaded, so this function can be used
|
|
|
|
* even from dynamically loaded plugins.)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_tag_register_static (const gchar * name, GstTagFlag flag, GType type,
|
|
|
|
const gchar * nick, const gchar * blurb, GstTagMergeFunc func)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstTagInfo *info;
|
|
|
|
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
g_return_if_fail (nick != NULL);
|
|
|
|
g_return_if_fail (blurb != NULL);
|
2003-11-29 06:31:10 +00:00
|
|
|
g_return_if_fail (type != 0 && type != GST_TYPE_LIST);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2011-10-30 00:46:22 +00:00
|
|
|
info = gst_tag_lookup (name);
|
2005-08-13 10:33:22 +00:00
|
|
|
|
|
|
|
if (info) {
|
|
|
|
g_return_if_fail (info->type == type);
|
|
|
|
return;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2010-03-28 16:05:36 +00:00
|
|
|
info = g_slice_new (GstTagInfo);
|
2004-01-22 13:59:57 +00:00
|
|
|
info->flag = flag;
|
2003-11-24 02:09:23 +00:00
|
|
|
info->type = type;
|
2012-05-28 22:54:10 +00:00
|
|
|
info->name_quark = g_quark_from_static_string (name);
|
|
|
|
info->nick = nick;
|
|
|
|
info->blurb = blurb;
|
2003-11-24 02:09:23 +00:00
|
|
|
info->merge_func = func;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
TAG_LOCK;
|
2012-05-28 22:54:10 +00:00
|
|
|
g_hash_table_insert (__tags, (gpointer) name, info);
|
2003-11-24 02:09:23 +00:00
|
|
|
TAG_UNLOCK;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_exists:
|
|
|
|
* @tag: name of the tag
|
|
|
|
*
|
|
|
|
* Checks if the given type is already registered.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the type is already registered
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_exists (const gchar * tag)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2011-10-30 00:46:22 +00:00
|
|
|
return gst_tag_lookup (tag) != NULL;
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_get_type:
|
|
|
|
* @tag: the tag
|
|
|
|
*
|
|
|
|
* Gets the #GType used for this tag.
|
|
|
|
*
|
|
|
|
* Returns: the #GType of this tag
|
|
|
|
*/
|
|
|
|
GType
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_get_type (const gchar * tag)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstTagInfo *info;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (tag != NULL, 0);
|
2011-10-30 00:46:22 +00:00
|
|
|
info = gst_tag_lookup (tag);
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (info != NULL, 0);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
return info->type;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
2012-06-15 23:43:30 +00:00
|
|
|
* gst_tag_get_nick:
|
2003-11-24 02:09:23 +00:00
|
|
|
* @tag: the tag
|
|
|
|
*
|
2005-06-19 11:32:42 +00:00
|
|
|
* Returns the human-readable name of this tag, You must not change or free
|
2003-11-24 02:09:23 +00:00
|
|
|
* this string.
|
|
|
|
*
|
|
|
|
* Returns: the human-readable name of this tag
|
|
|
|
*/
|
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_get_nick (const gchar * tag)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstTagInfo *info;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (tag != NULL, NULL);
|
2011-10-30 00:46:22 +00:00
|
|
|
info = gst_tag_lookup (tag);
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
return info->nick;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_get_description:
|
|
|
|
* @tag: the tag
|
|
|
|
*
|
2005-06-19 11:32:42 +00:00
|
|
|
* Returns the human-readable description of this tag, You must not change or
|
2003-11-24 02:09:23 +00:00
|
|
|
* free this string.
|
|
|
|
*
|
2004-09-02 14:24:22 +00:00
|
|
|
* Returns: the human-readable description of this tag
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_get_description (const gchar * tag)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstTagInfo *info;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (tag != NULL, NULL);
|
2011-10-30 00:46:22 +00:00
|
|
|
info = gst_tag_lookup (tag);
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (info != NULL, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
return info->blurb;
|
|
|
|
}
|
2004-03-06 20:19:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_get_flag:
|
|
|
|
* @tag: the tag
|
|
|
|
*
|
2004-03-26 03:46:16 +00:00
|
|
|
* Gets the flag of @tag.
|
|
|
|
*
|
2007-07-10 20:10:16 +00:00
|
|
|
* Returns: the flag of this tag.
|
2004-03-06 20:19:23 +00:00
|
|
|
*/
|
|
|
|
GstTagFlag
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_get_flag (const gchar * tag)
|
2004-03-06 20:19:23 +00:00
|
|
|
{
|
|
|
|
GstTagInfo *info;
|
|
|
|
|
|
|
|
g_return_val_if_fail (tag != NULL, GST_TAG_FLAG_UNDEFINED);
|
2011-10-30 00:46:22 +00:00
|
|
|
info = gst_tag_lookup (tag);
|
2004-03-06 20:19:23 +00:00
|
|
|
g_return_val_if_fail (info != NULL, GST_TAG_FLAG_UNDEFINED);
|
|
|
|
|
|
|
|
return info->flag;
|
|
|
|
}
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
2004-03-26 03:46:16 +00:00
|
|
|
* gst_tag_is_fixed:
|
2003-11-24 02:09:23 +00:00
|
|
|
* @tag: tag to check
|
|
|
|
*
|
|
|
|
* Checks if the given tag is fixed. A fixed tag can only contain one value.
|
|
|
|
* Unfixed tags can contain lists of values.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if the given tag is fixed.
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_is_fixed (const gchar * tag)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstTagInfo *info;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
2011-10-30 00:46:22 +00:00
|
|
|
info = gst_tag_lookup (tag);
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (info != NULL, FALSE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
return info->merge_func == NULL;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2012-05-20 23:31:29 +00:00
|
|
|
/* takes ownership of the structure */
|
|
|
|
static GstTagList *
|
|
|
|
gst_tag_list_new_internal (GstStructure * s)
|
|
|
|
{
|
|
|
|
GstTagList *tag_list;
|
|
|
|
|
|
|
|
g_assert (s != NULL);
|
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
tag_list = (GstTagList *) g_slice_new (GstTagListImpl);
|
|
|
|
|
2012-07-04 14:38:15 +00:00
|
|
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (tag_list), 0, GST_TYPE_TAG_LIST,
|
2012-06-23 18:56:12 +00:00
|
|
|
(GstMiniObjectCopyFunction) __gst_tag_list_copy, NULL,
|
|
|
|
(GstMiniObjectFreeFunction) __gst_tag_list_free);
|
2012-05-27 22:58:27 +00:00
|
|
|
|
|
|
|
GST_TAG_LIST_STRUCTURE (tag_list) = s;
|
2012-07-27 21:52:12 +00:00
|
|
|
GST_TAG_LIST_SCOPE (tag_list) = GST_TAG_SCOPE_STREAM;
|
2012-05-27 22:58:27 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_REFCOUNT
|
|
|
|
GST_CAT_TRACE (GST_CAT_TAGS, "created taglist %p", tag_list);
|
|
|
|
#endif
|
|
|
|
|
2012-05-20 23:31:29 +00:00
|
|
|
return tag_list;
|
|
|
|
}
|
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
static void
|
|
|
|
__gst_tag_list_free (GstTagList * list)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (list));
|
|
|
|
|
|
|
|
#ifdef DEBUG_REFCOUNT
|
2012-06-23 20:42:58 +00:00
|
|
|
GST_CAT_TRACE (GST_CAT_TAGS, "freeing taglist %p", list);
|
2012-05-27 22:58:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
gst_structure_free (GST_TAG_LIST_STRUCTURE (list));
|
|
|
|
|
2012-06-14 22:36:29 +00:00
|
|
|
g_slice_free1 (sizeof (GstTagListImpl), list);
|
2012-05-27 22:58:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstTagList *
|
|
|
|
__gst_tag_list_copy (const GstTagList * list)
|
|
|
|
{
|
|
|
|
const GstStructure *s;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
|
|
|
|
|
|
|
|
s = GST_TAG_LIST_STRUCTURE (list);
|
|
|
|
return gst_tag_list_new_internal (gst_structure_copy (s));
|
|
|
|
}
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
2011-10-30 10:26:11 +00:00
|
|
|
* gst_tag_list_new_empty:
|
2003-11-24 02:09:23 +00:00
|
|
|
*
|
|
|
|
* Creates a new empty GstTagList.
|
|
|
|
*
|
2012-05-27 22:58:27 +00:00
|
|
|
* Free-function: gst_tag_list_unref
|
2010-12-07 18:35:04 +00:00
|
|
|
*
|
|
|
|
* Returns: (transfer full): An empty tag list
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
|
|
|
GstTagList *
|
2011-10-30 10:26:11 +00:00
|
|
|
gst_tag_list_new_empty (void)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
2012-05-20 23:31:29 +00:00
|
|
|
GstStructure *s;
|
|
|
|
GstTagList *tag_list;
|
|
|
|
|
|
|
|
s = gst_structure_new_id_empty (GST_QUARK (TAGLIST));
|
|
|
|
tag_list = gst_tag_list_new_internal (s);
|
|
|
|
return tag_list;
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2009-06-14 15:17:50 +00:00
|
|
|
/**
|
2011-10-30 10:26:11 +00:00
|
|
|
* gst_tag_list_new:
|
2009-06-14 15:17:50 +00:00
|
|
|
* @tag: tag
|
|
|
|
* @...: NULL-terminated list of values to set
|
|
|
|
*
|
|
|
|
* Creates a new taglist and appends the values for the given tags. It expects
|
|
|
|
* tag-value pairs like gst_tag_list_add(), and a NULL terminator after the
|
|
|
|
* last pair. The type of the values is implicit and is documented in the API
|
|
|
|
* reference, but can also be queried at runtime with gst_tag_get_type(). It
|
|
|
|
* is an error to pass a value of a type not matching the tag type into this
|
|
|
|
* function. The tag list will make copies of any arguments passed
|
|
|
|
* (e.g. strings, buffers).
|
|
|
|
*
|
2012-08-11 21:19:32 +00:00
|
|
|
* After creation you might also want to set a #GstTagScope on the returned
|
|
|
|
* taglist to signal if the contained tags are global or stream tags. By
|
|
|
|
* default stream scope is assumes. See gst_tag_list_set_scope().
|
|
|
|
*
|
2012-05-27 22:58:27 +00:00
|
|
|
* Free-function: gst_tag_list_unref
|
2010-12-07 18:35:04 +00:00
|
|
|
*
|
2012-05-27 22:58:27 +00:00
|
|
|
* Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_unref()
|
2010-12-07 18:35:04 +00:00
|
|
|
* when no longer needed.
|
2009-06-14 15:17:50 +00:00
|
|
|
*/
|
|
|
|
GstTagList *
|
2011-10-30 10:26:11 +00:00
|
|
|
gst_tag_list_new (const gchar * tag, ...)
|
2009-06-14 15:17:50 +00:00
|
|
|
{
|
|
|
|
GstTagList *list;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
g_return_val_if_fail (tag != NULL, NULL);
|
|
|
|
|
2011-10-30 10:26:11 +00:00
|
|
|
list = gst_tag_list_new_empty ();
|
2009-06-14 15:17:50 +00:00
|
|
|
va_start (args, tag);
|
|
|
|
gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-30 10:26:11 +00:00
|
|
|
* gst_tag_list_new_valist:
|
2009-06-14 15:17:50 +00:00
|
|
|
* @var_args: tag / value pairs to set
|
|
|
|
*
|
2011-10-30 10:26:11 +00:00
|
|
|
* Just like gst_tag_list_new(), only that it takes a va_list argument.
|
2009-06-14 15:17:50 +00:00
|
|
|
* Useful mostly for language bindings.
|
|
|
|
*
|
2012-05-27 22:58:27 +00:00
|
|
|
* Free-function: gst_tag_list_unref
|
2010-12-07 18:35:04 +00:00
|
|
|
*
|
2012-05-27 22:58:27 +00:00
|
|
|
* Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_unref()
|
2010-12-07 18:35:04 +00:00
|
|
|
* when no longer needed.
|
2009-06-14 15:17:50 +00:00
|
|
|
*/
|
|
|
|
GstTagList *
|
2011-10-30 10:26:11 +00:00
|
|
|
gst_tag_list_new_valist (va_list var_args)
|
2009-06-14 15:17:50 +00:00
|
|
|
{
|
|
|
|
GstTagList *list;
|
|
|
|
const gchar *tag;
|
|
|
|
|
2011-10-30 10:26:11 +00:00
|
|
|
list = gst_tag_list_new_empty ();
|
2009-06-14 15:17:50 +00:00
|
|
|
|
|
|
|
tag = va_arg (var_args, gchar *);
|
|
|
|
gst_tag_list_add_valist (list, GST_TAG_MERGE_APPEND, tag, var_args);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2012-07-27 21:52:12 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_set_scope:
|
|
|
|
* @list: a #GstTagList
|
|
|
|
* @scope: new scope for @list
|
|
|
|
*
|
|
|
|
* Sets the scope of @list to @scope. By default the scope
|
2012-08-11 21:19:32 +00:00
|
|
|
* of a taglist is stream scope.
|
2012-07-27 21:52:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_tag_list_set_scope (GstTagList * list, GstTagScope scope)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (list));
|
|
|
|
g_return_if_fail (gst_tag_list_is_writable (list));
|
|
|
|
|
|
|
|
GST_TAG_LIST_SCOPE (list) = scope;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_scope:
|
|
|
|
* @list: a #GstTagList
|
|
|
|
*
|
|
|
|
* Gets the scope of @list.
|
|
|
|
*
|
|
|
|
* Returns: The scope of @list
|
|
|
|
*/
|
|
|
|
GstTagScope
|
|
|
|
gst_tag_list_get_scope (const GstTagList * list)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), GST_TAG_SCOPE_STREAM);
|
|
|
|
|
|
|
|
return GST_TAG_LIST_SCOPE (list);
|
|
|
|
}
|
|
|
|
|
2011-10-30 09:58:16 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_to_string:
|
|
|
|
* @list: a #GstTagList
|
|
|
|
*
|
|
|
|
* Serializes a tag list to a string.
|
|
|
|
*
|
|
|
|
* Returns: a newly-allocated string, or NULL in case of an error. The
|
|
|
|
* string must be freed with g_free() when no longer needed.
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
gst_tag_list_to_string (const GstTagList * list)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
|
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
return gst_structure_to_string (GST_TAG_LIST_STRUCTURE (list));
|
2011-10-30 09:58:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_list_new_from_string:
|
|
|
|
* @str: a string created with gst_tag_list_to_string()
|
|
|
|
*
|
|
|
|
* Deserializes a tag list.
|
|
|
|
*
|
|
|
|
* Returns: a new #GstTagList, or NULL in case of an error.
|
|
|
|
*/
|
|
|
|
GstTagList *
|
|
|
|
gst_tag_list_new_from_string (const gchar * str)
|
|
|
|
{
|
2012-05-20 23:31:29 +00:00
|
|
|
GstTagList *tag_list;
|
|
|
|
|
2011-10-30 09:58:16 +00:00
|
|
|
g_return_val_if_fail (str != NULL, NULL);
|
|
|
|
g_return_val_if_fail (g_str_has_prefix (str, "taglist"), NULL);
|
|
|
|
|
2012-05-20 23:31:29 +00:00
|
|
|
tag_list = gst_tag_list_new_internal (gst_structure_from_string (str, NULL));
|
|
|
|
return tag_list;
|
2011-10-30 09:58:16 +00:00
|
|
|
}
|
|
|
|
|
2012-01-03 12:42:12 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_n_tags:
|
|
|
|
* @list: A #GstTagList.
|
|
|
|
*
|
|
|
|
* Get the number of tags in @list.
|
|
|
|
*
|
|
|
|
* Returns: The number of tags in @list.
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gst_tag_list_n_tags (const GstTagList * list)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (list != NULL, 0);
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
|
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
return gst_structure_n_fields (GST_TAG_LIST_STRUCTURE (list));
|
2012-01-03 12:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_list_nth_tag_name:
|
|
|
|
* @list: A #GstTagList.
|
|
|
|
* @index: the index
|
|
|
|
*
|
|
|
|
* Get the name of the tag in @list at @index.
|
|
|
|
*
|
|
|
|
* Returns: The name of the tag at @index.
|
|
|
|
*/
|
|
|
|
const gchar *
|
|
|
|
gst_tag_list_nth_tag_name (const GstTagList * list, guint index)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (list != NULL, 0);
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
|
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
return gst_structure_nth_field_name (GST_TAG_LIST_STRUCTURE (list), index);
|
2012-01-03 12:42:12 +00:00
|
|
|
}
|
|
|
|
|
2006-10-09 11:20:44 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_is_empty:
|
2006-10-09 17:15:39 +00:00
|
|
|
* @list: A #GstTagList.
|
2006-10-09 11:20:44 +00:00
|
|
|
*
|
|
|
|
* Checks if the given taglist is empty.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the taglist is empty, otherwise FALSE.
|
|
|
|
*/
|
|
|
|
gboolean
|
2006-10-09 17:15:39 +00:00
|
|
|
gst_tag_list_is_empty (const GstTagList * list)
|
2006-10-09 11:20:44 +00:00
|
|
|
{
|
2006-10-09 17:15:39 +00:00
|
|
|
g_return_val_if_fail (list != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
2006-10-09 11:20:44 +00:00
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
return (gst_structure_n_fields (GST_TAG_LIST_STRUCTURE (list)) == 0);
|
2006-10-09 11:20:44 +00:00
|
|
|
}
|
|
|
|
|
2011-10-29 23:44:44 +00:00
|
|
|
static gboolean
|
|
|
|
gst_tag_list_fields_equal (const GValue * value1, const GValue * value2)
|
|
|
|
{
|
|
|
|
gdouble d1, d2;
|
|
|
|
|
|
|
|
if (gst_value_compare (value1, value2) == GST_VALUE_EQUAL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* fields not equal: add some tolerance for doubles, otherwise bail out */
|
|
|
|
if (!G_VALUE_HOLDS_DOUBLE (value1) || !G_VALUE_HOLDS_DOUBLE (value2))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
d1 = g_value_get_double (value1);
|
|
|
|
d2 = g_value_get_double (value2);
|
|
|
|
|
|
|
|
/* This will only work for 'normal' values and values around 0,
|
|
|
|
* which should be good enough for our purposes here
|
|
|
|
* FIXME: maybe add this to gst_value_compare_double() ? */
|
|
|
|
return (fabs (d1 - d2) < 0.0000001);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_list_is_equal:
|
|
|
|
* @list1: a #GstTagList.
|
|
|
|
* @list2: a #GstTagList.
|
|
|
|
*
|
|
|
|
* Checks if the two given taglists are equal.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the taglists are equal, otherwise FALSE
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_tag_list_is_equal (const GstTagList * list1, const GstTagList * list2)
|
|
|
|
{
|
|
|
|
const GstStructure *s1, *s2;
|
|
|
|
gint num_fields1, num_fields2, i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list1), FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list2), FALSE);
|
|
|
|
|
|
|
|
/* we don't just use gst_structure_is_equal() here so we can add some
|
|
|
|
* tolerance for doubles, though maybe we should just add that to
|
|
|
|
* gst_value_compare_double() as well? */
|
2012-05-27 22:58:27 +00:00
|
|
|
s1 = GST_TAG_LIST_STRUCTURE (list1);
|
|
|
|
s2 = GST_TAG_LIST_STRUCTURE (list2);
|
2011-10-29 23:44:44 +00:00
|
|
|
|
|
|
|
num_fields1 = gst_structure_n_fields (s1);
|
|
|
|
num_fields2 = gst_structure_n_fields (s2);
|
|
|
|
|
|
|
|
if (num_fields1 != num_fields2)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (i = 0; i < num_fields1; i++) {
|
|
|
|
const GValue *value1, *value2;
|
|
|
|
const gchar *tag_name;
|
|
|
|
|
|
|
|
tag_name = gst_structure_nth_field_name (s1, i);
|
|
|
|
value1 = gst_structure_get_value (s1, tag_name);
|
|
|
|
value2 = gst_structure_get_value (s2, tag_name);
|
|
|
|
|
|
|
|
if (value2 == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!gst_tag_list_fields_equal (value1, value2))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2011-10-30 10:05:23 +00:00
|
|
|
GstTagList *list;
|
2004-03-13 15:27:01 +00:00
|
|
|
GstTagMergeMode mode;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
GstTagCopyData;
|
2008-06-20 08:39:54 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
static void
|
2011-10-30 10:05:23 +00:00
|
|
|
gst_tag_list_add_value_internal (GstTagList * tag_list, GstTagMergeMode mode,
|
2011-10-30 00:46:22 +00:00
|
|
|
const gchar * tag, const GValue * value, GstTagInfo * info)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
2012-05-27 22:58:27 +00:00
|
|
|
GstStructure *list = GST_TAG_LIST_STRUCTURE (tag_list);
|
2003-12-22 01:39:35 +00:00
|
|
|
const GValue *value2;
|
2011-10-30 00:46:22 +00:00
|
|
|
GQuark tag_quark;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2009-11-05 15:59:31 +00:00
|
|
|
if (info == NULL) {
|
|
|
|
info = gst_tag_lookup (tag);
|
|
|
|
if (G_UNLIKELY (info == NULL)) {
|
2011-10-30 00:46:22 +00:00
|
|
|
g_warning ("unknown tag '%s'", tag);
|
2009-11-05 15:59:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2012-07-14 18:08:24 +00:00
|
|
|
if (G_UNLIKELY (!G_VALUE_HOLDS (value, info->type) &&
|
|
|
|
!GST_VALUE_HOLDS_LIST (value))) {
|
|
|
|
g_warning ("tag '%s' should hold value of type '%s', but value of "
|
|
|
|
"type '%s' passed", info->nick, g_type_name (info->type),
|
|
|
|
g_type_name (G_VALUE_TYPE (value)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-30 00:46:22 +00:00
|
|
|
tag_quark = info->name_quark;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (info->merge_func
|
2011-10-30 00:46:22 +00:00
|
|
|
&& (value2 = gst_structure_id_get_value (list, tag_quark)) != NULL) {
|
2003-12-22 01:39:35 +00:00
|
|
|
GValue dest = { 0, };
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
switch (mode) {
|
|
|
|
case GST_TAG_MERGE_REPLACE_ALL:
|
|
|
|
case GST_TAG_MERGE_REPLACE:
|
2011-10-30 00:46:22 +00:00
|
|
|
gst_structure_id_set_value (list, tag_quark, value);
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2003-11-24 02:09:23 +00:00
|
|
|
case GST_TAG_MERGE_PREPEND:
|
2010-12-21 21:03:12 +00:00
|
|
|
gst_value_list_merge (&dest, value, value2);
|
2011-10-30 00:46:22 +00:00
|
|
|
gst_structure_id_set_value (list, tag_quark, &dest);
|
2004-03-15 19:27:17 +00:00
|
|
|
g_value_unset (&dest);
|
|
|
|
break;
|
2003-11-24 02:09:23 +00:00
|
|
|
case GST_TAG_MERGE_APPEND:
|
2010-12-21 21:03:12 +00:00
|
|
|
gst_value_list_merge (&dest, value2, value);
|
2011-10-30 00:46:22 +00:00
|
|
|
gst_structure_id_set_value (list, tag_quark, &dest);
|
2004-03-15 19:27:17 +00:00
|
|
|
g_value_unset (&dest);
|
|
|
|
break;
|
2003-11-24 02:09:23 +00:00
|
|
|
case GST_TAG_MERGE_KEEP:
|
|
|
|
case GST_TAG_MERGE_KEEP_ALL:
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2003-11-24 02:09:23 +00:00
|
|
|
default:
|
2004-03-15 19:27:17 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (mode) {
|
|
|
|
case GST_TAG_MERGE_APPEND:
|
|
|
|
case GST_TAG_MERGE_KEEP:
|
2011-10-30 00:46:22 +00:00
|
|
|
if (gst_structure_id_get_value (list, tag_quark) != NULL)
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
|
|
|
/* fall through */
|
2003-11-24 02:09:23 +00:00
|
|
|
case GST_TAG_MERGE_REPLACE_ALL:
|
|
|
|
case GST_TAG_MERGE_REPLACE:
|
|
|
|
case GST_TAG_MERGE_PREPEND:
|
2011-10-30 00:46:22 +00:00
|
|
|
gst_structure_id_set_value (list, tag_quark, value);
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2003-11-24 02:09:23 +00:00
|
|
|
case GST_TAG_MERGE_KEEP_ALL:
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2003-11-24 02:09:23 +00:00
|
|
|
default:
|
2004-03-15 19:27:17 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-20 08:39:54 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
static gboolean
|
2011-10-30 00:46:22 +00:00
|
|
|
gst_tag_list_copy_foreach (GQuark tag_quark, const GValue * value,
|
|
|
|
gpointer user_data)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstTagCopyData *copy = (GstTagCopyData *) user_data;
|
2011-10-30 00:46:22 +00:00
|
|
|
const gchar *tag;
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2011-10-30 00:46:22 +00:00
|
|
|
tag = g_quark_to_string (tag_quark);
|
2009-11-05 15:59:31 +00:00
|
|
|
gst_tag_list_add_value_internal (copy->list, copy->mode, tag, value, NULL);
|
2003-12-22 01:39:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_insert:
|
|
|
|
* @into: list to merge into
|
|
|
|
* @from: list to merge from
|
|
|
|
* @mode: the mode to use
|
2005-06-19 11:32:42 +00:00
|
|
|
*
|
2008-12-16 09:23:21 +00:00
|
|
|
* Inserts the tags of the @from list into the first list using the given mode.
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_insert (GstTagList * into, const GstTagList * from,
|
|
|
|
GstTagMergeMode mode)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstTagCopyData data;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (into));
|
2012-05-29 07:48:36 +00:00
|
|
|
g_return_if_fail (gst_tag_list_is_writable (into));
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (from));
|
|
|
|
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
|
|
|
|
|
2011-10-30 10:05:23 +00:00
|
|
|
data.list = into;
|
2003-11-24 02:09:23 +00:00
|
|
|
data.mode = mode;
|
|
|
|
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
|
2012-05-27 22:58:27 +00:00
|
|
|
gst_structure_remove_all_fields (GST_TAG_LIST_STRUCTURE (into));
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2012-05-27 22:58:27 +00:00
|
|
|
gst_structure_foreach (GST_TAG_LIST_STRUCTURE (from),
|
|
|
|
gst_tag_list_copy_foreach, &data);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_merge:
|
|
|
|
* @list1: first list to merge
|
|
|
|
* @list2: second list to merge
|
|
|
|
* @mode: the mode to use
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2003-11-24 02:09:23 +00:00
|
|
|
* Merges the two given lists into a new list. If one of the lists is NULL, a
|
|
|
|
* copy of the other is returned. If both lists are NULL, NULL is returned.
|
|
|
|
*
|
2012-05-27 22:58:27 +00:00
|
|
|
* Free-function: gst_tag_list_unref
|
2010-12-07 18:35:04 +00:00
|
|
|
*
|
|
|
|
* Returns: (transfer full): the new list
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
|
|
|
GstTagList *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2,
|
|
|
|
GstTagMergeMode mode)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
2008-12-16 09:37:53 +00:00
|
|
|
GstTagList *list1_cp;
|
|
|
|
const GstTagList *list2_cp;
|
2008-12-16 09:23:21 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL);
|
|
|
|
g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL);
|
|
|
|
g_return_val_if_fail (GST_TAG_MODE_IS_VALID (mode), NULL);
|
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
/* nothing to merge */
|
2003-11-24 02:09:23 +00:00
|
|
|
if (!list1 && !list2) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-12-16 09:23:21 +00:00
|
|
|
|
|
|
|
/* create empty list, we need to do this to correctly handling merge modes */
|
2011-10-30 10:26:11 +00:00
|
|
|
list1_cp = (list1) ? gst_tag_list_copy (list1) : gst_tag_list_new_empty ();
|
|
|
|
list2_cp = (list2) ? list2 : gst_tag_list_new_empty ();
|
2008-12-16 09:23:21 +00:00
|
|
|
|
2008-12-16 09:37:53 +00:00
|
|
|
gst_tag_list_insert (list1_cp, list2_cp, mode);
|
2008-12-16 09:23:21 +00:00
|
|
|
|
|
|
|
if (!list2)
|
2012-05-27 22:58:27 +00:00
|
|
|
gst_tag_list_unref ((GstTagList *) list2_cp);
|
2008-12-16 09:23:21 +00:00
|
|
|
|
2008-12-16 09:37:53 +00:00
|
|
|
return list1_cp;
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_tag_size:
|
|
|
|
* @list: a taglist
|
|
|
|
* @tag: the tag to query
|
|
|
|
*
|
|
|
|
* Checks how many value are stored in this tag list for the given tag.
|
|
|
|
*
|
|
|
|
* Returns: The number of tags stored
|
|
|
|
*/
|
|
|
|
guint
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
const GValue *value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), 0);
|
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
value = gst_structure_get_value (GST_TAG_LIST_STRUCTURE (list), tag);
|
2003-11-24 02:09:23 +00:00
|
|
|
if (value == NULL)
|
|
|
|
return 0;
|
2003-11-29 06:31:10 +00:00
|
|
|
if (G_VALUE_TYPE (value) != GST_TYPE_LIST)
|
2003-11-24 02:09:23 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return gst_value_list_get_size (value);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_add:
|
|
|
|
* @list: list to set tags in
|
|
|
|
* @mode: the mode to use
|
|
|
|
* @tag: tag
|
2004-01-15 20:33:53 +00:00
|
|
|
* @...: NULL-terminated list of values to set
|
2003-11-24 02:09:23 +00:00
|
|
|
*
|
|
|
|
* Sets the values for the given tags using the specified mode.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag,
|
|
|
|
...)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (list));
|
2012-05-29 07:48:36 +00:00
|
|
|
g_return_if_fail (gst_tag_list_is_writable (list));
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
|
|
|
|
g_return_if_fail (tag != NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
va_start (args, tag);
|
|
|
|
gst_tag_list_add_valist (list, mode, tag, args);
|
|
|
|
va_end (args);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-12-23 04:50:01 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_add_values:
|
|
|
|
* @list: list to set tags in
|
|
|
|
* @mode: the mode to use
|
|
|
|
* @tag: tag
|
|
|
|
* @...: GValues to set
|
|
|
|
*
|
|
|
|
* Sets the GValues for the given tags using the specified mode.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode,
|
|
|
|
const gchar * tag, ...)
|
2003-12-23 04:50:01 +00:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (list));
|
2012-05-29 07:48:36 +00:00
|
|
|
g_return_if_fail (gst_tag_list_is_writable (list));
|
2003-12-23 04:50:01 +00:00
|
|
|
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
|
|
|
|
g_return_if_fail (tag != NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-12-23 04:50:01 +00:00
|
|
|
va_start (args, tag);
|
|
|
|
gst_tag_list_add_valist_values (list, mode, tag, args);
|
|
|
|
va_end (args);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_add_valist:
|
|
|
|
* @list: list to set tags in
|
|
|
|
* @mode: the mode to use
|
|
|
|
* @tag: tag
|
|
|
|
* @var_args: tag / value pairs to set
|
|
|
|
*
|
|
|
|
* Sets the values for the given tags using the specified mode.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode,
|
|
|
|
const gchar * tag, va_list var_args)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstTagInfo *info;
|
|
|
|
gchar *error = NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (list));
|
2012-05-29 07:48:36 +00:00
|
|
|
g_return_if_fail (gst_tag_list_is_writable (list));
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
|
|
|
|
g_return_if_fail (tag != NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2008-12-16 09:23:21 +00:00
|
|
|
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
|
2012-05-27 22:58:27 +00:00
|
|
|
gst_structure_remove_all_fields (GST_TAG_LIST_STRUCTURE (list));
|
2008-12-16 09:23:21 +00:00
|
|
|
}
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
while (tag != NULL) {
|
|
|
|
GValue value = { 0, };
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2011-10-30 00:46:22 +00:00
|
|
|
info = gst_tag_lookup (tag);
|
2009-11-05 15:59:31 +00:00
|
|
|
if (G_UNLIKELY (info == NULL)) {
|
|
|
|
g_warning ("unknown tag '%s'", tag);
|
|
|
|
return;
|
|
|
|
}
|
2010-03-16 17:56:13 +00:00
|
|
|
G_VALUE_COLLECT_INIT (&value, info->type, var_args, 0, &error);
|
2003-11-24 02:09:23 +00:00
|
|
|
if (error) {
|
|
|
|
g_warning ("%s: %s", G_STRLOC, error);
|
|
|
|
g_free (error);
|
|
|
|
/* we purposely leak the value here, it might not be
|
|
|
|
* in a sane state if an error condition occoured
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
2012-09-12 23:38:21 +00:00
|
|
|
/* Facilitate GstBuffer -> GstSample transition */
|
|
|
|
if (G_UNLIKELY (info->type == GST_TYPE_SAMPLE &&
|
|
|
|
!GST_IS_SAMPLE (value.data[0].v_pointer))) {
|
|
|
|
g_warning ("Expected GstSample argument for tag '%s'", tag);
|
|
|
|
} else {
|
|
|
|
gst_tag_list_add_value_internal (list, mode, tag, &value, info);
|
|
|
|
}
|
2003-11-24 02:09:23 +00:00
|
|
|
g_value_unset (&value);
|
|
|
|
tag = va_arg (var_args, gchar *);
|
2003-12-23 04:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-12-23 04:50:01 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_add_valist_values:
|
|
|
|
* @list: list to set tags in
|
|
|
|
* @mode: the mode to use
|
|
|
|
* @tag: tag
|
|
|
|
* @var_args: tag / GValue pairs to set
|
|
|
|
*
|
|
|
|
* Sets the GValues for the given tags using the specified mode.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode,
|
|
|
|
const gchar * tag, va_list var_args)
|
2003-12-23 04:50:01 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (list));
|
2012-05-29 07:48:36 +00:00
|
|
|
g_return_if_fail (gst_tag_list_is_writable (list));
|
2003-12-23 04:50:01 +00:00
|
|
|
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
|
|
|
|
g_return_if_fail (tag != NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2009-03-12 10:20:25 +00:00
|
|
|
if (mode == GST_TAG_MERGE_REPLACE_ALL) {
|
2012-05-27 22:58:27 +00:00
|
|
|
gst_structure_remove_all_fields (GST_TAG_LIST_STRUCTURE (list));
|
2009-03-12 10:20:25 +00:00
|
|
|
}
|
|
|
|
|
2003-12-23 04:50:01 +00:00
|
|
|
while (tag != NULL) {
|
2011-10-30 00:46:22 +00:00
|
|
|
GstTagInfo *info;
|
|
|
|
|
|
|
|
info = gst_tag_lookup (tag);
|
|
|
|
if (G_UNLIKELY (info == NULL)) {
|
|
|
|
g_warning ("unknown tag '%s'", tag);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gst_tag_list_add_value_internal (list, mode, tag, va_arg (var_args,
|
|
|
|
GValue *), info);
|
2003-12-23 04:50:01 +00:00
|
|
|
tag = va_arg (var_args, gchar *);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2009-05-07 07:31:01 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_add_value:
|
|
|
|
* @list: list to set tags in
|
|
|
|
* @mode: the mode to use
|
|
|
|
* @tag: tag
|
|
|
|
* @value: GValue for this tag
|
|
|
|
*
|
|
|
|
* Sets the GValue for a given tag using the specified mode.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_tag_list_add_value (GstTagList * list, GstTagMergeMode mode,
|
|
|
|
const gchar * tag, const GValue * value)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (list));
|
2012-05-29 07:48:36 +00:00
|
|
|
g_return_if_fail (gst_tag_list_is_writable (list));
|
2009-05-07 07:31:01 +00:00
|
|
|
g_return_if_fail (GST_TAG_MODE_IS_VALID (mode));
|
|
|
|
g_return_if_fail (tag != NULL);
|
|
|
|
|
2011-10-30 00:46:22 +00:00
|
|
|
gst_tag_list_add_value_internal (list, mode, tag, value, NULL);
|
2009-05-07 07:31:01 +00:00
|
|
|
}
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_remove_tag:
|
|
|
|
* @list: list to remove tag from
|
|
|
|
* @tag: tag to remove
|
|
|
|
*
|
2006-07-20 16:10:17 +00:00
|
|
|
* Removes the given tag from the taglist.
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (list));
|
|
|
|
g_return_if_fail (tag != NULL);
|
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
gst_structure_remove_field (GST_TAG_LIST_STRUCTURE (list), tag);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2008-06-20 08:39:54 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstTagForeachFunc func;
|
2005-11-19 16:05:11 +00:00
|
|
|
const GstTagList *tag_list;
|
2004-03-13 15:27:01 +00:00
|
|
|
gpointer data;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
TagForeachData;
|
2008-06-20 08:39:54 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
static int
|
2005-03-07 18:27:42 +00:00
|
|
|
structure_foreach_wrapper (GQuark field_id, const GValue * value,
|
|
|
|
gpointer user_data)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
TagForeachData *data = (TagForeachData *) user_data;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
data->func (data->tag_list, g_quark_to_string (field_id), data->data);
|
|
|
|
return TRUE;
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_foreach:
|
|
|
|
* @list: list to iterate over
|
2010-12-17 18:14:41 +00:00
|
|
|
* @func: (scope call): function to be called for each tag
|
2010-12-07 18:35:04 +00:00
|
|
|
* @user_data: (closure): user specified data
|
2003-11-24 02:09:23 +00:00
|
|
|
*
|
|
|
|
* Calls the given function for each tag inside the tag list. Note that if there
|
|
|
|
* is no tag, the function won't be called at all.
|
|
|
|
*/
|
|
|
|
void
|
2005-11-19 15:51:41 +00:00
|
|
|
gst_tag_list_foreach (const GstTagList * list, GstTagForeachFunc func,
|
2004-03-13 15:27:01 +00:00
|
|
|
gpointer user_data)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
TagForeachData data;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_TAG_LIST (list));
|
|
|
|
g_return_if_fail (func != NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
data.func = func;
|
2003-12-22 01:39:35 +00:00
|
|
|
data.tag_list = list;
|
2003-11-24 02:09:23 +00:00
|
|
|
data.data = user_data;
|
2012-05-27 22:58:27 +00:00
|
|
|
gst_structure_foreach (GST_TAG_LIST_STRUCTURE (list),
|
|
|
|
structure_foreach_wrapper, &data);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_value_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList
|
2003-11-24 02:09:23 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
|
|
|
*
|
2005-06-19 11:32:42 +00:00
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
2003-11-24 02:09:23 +00:00
|
|
|
* list.
|
2005-06-19 11:32:42 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Returns: (transfer none): The GValue for the specified entry or NULL if the
|
|
|
|
* tag wasn't available or the tag doesn't have as many entries
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
2011-06-09 16:13:35 +00:00
|
|
|
const GValue *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
|
|
|
|
guint index)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
const GValue *value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
|
|
|
|
g_return_val_if_fail (tag != NULL, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
value = gst_structure_get_value (GST_TAG_LIST_STRUCTURE (list), tag);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (value == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
if (GST_VALUE_HOLDS_LIST (value)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
if (index >= gst_value_list_get_size (value))
|
|
|
|
return NULL;
|
2003-11-24 02:09:23 +00:00
|
|
|
return gst_value_list_get_value (value, index);
|
|
|
|
} else {
|
2010-12-26 21:20:31 +00:00
|
|
|
if (index > 0)
|
2004-03-13 15:27:01 +00:00
|
|
|
return NULL;
|
2003-11-24 02:09:23 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_list_copy_value:
|
2010-12-07 18:35:04 +00:00
|
|
|
* @dest: (out caller-allocates): uninitialized #GValue to copy into
|
2003-11-24 02:09:23 +00:00
|
|
|
* @list: list to get the tag from
|
|
|
|
* @tag: tag to read out
|
|
|
|
*
|
2005-06-19 11:32:42 +00:00
|
|
|
* Copies the contents for the given tag into the value,
|
|
|
|
* merging multiple values into one if multiple values are associated
|
|
|
|
* with the tag.
|
2003-11-24 02:09:23 +00:00
|
|
|
* You must g_value_unset() the value after use.
|
|
|
|
*
|
2005-06-19 11:32:42 +00:00
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_tag_list_copy_value (GValue * dest, const GstTagList * list,
|
|
|
|
const gchar * tag)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
const GValue *src;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (dest != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2012-05-27 22:58:27 +00:00
|
|
|
src = gst_structure_get_value (GST_TAG_LIST_STRUCTURE (list), tag);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!src)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
|
2011-10-30 00:46:22 +00:00
|
|
|
GstTagInfo *info = gst_tag_lookup (tag);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2009-02-04 14:26:23 +00:00
|
|
|
if (!info)
|
|
|
|
return FALSE;
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/* must be there or lists aren't allowed */
|
|
|
|
g_assert (info->merge_func);
|
|
|
|
info->merge_func (dest, src);
|
|
|
|
} else {
|
|
|
|
g_value_init (dest, G_VALUE_TYPE (src));
|
|
|
|
g_value_copy (src, dest);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-07-20 16:10:17 +00:00
|
|
|
/* FIXME 0.11: this whole merge function business is overdesigned, and the
|
|
|
|
* _get_foo() API is misleading as well - how many application developers will
|
|
|
|
* expect gst_tag_list_get_string (list, GST_TAG_ARTIST, &val) might return a
|
|
|
|
* string with multiple comma-separated artists? _get_foo() should just be
|
|
|
|
* a convenience wrapper around _get_foo_index (list, tag, 0, &val),
|
|
|
|
* supplemented by a special _tag_list_get_string_merged() function if needed
|
|
|
|
* (unless someone can actually think of real use cases where the merge
|
|
|
|
* function is not 'use first' for non-strings and merge for strings) */
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/***** evil macros to get all the gst_tag_list_get_*() functions right *****/
|
|
|
|
|
2009-05-31 15:17:45 +00:00
|
|
|
#define TAG_MERGE_FUNCS(name,type,ret) \
|
2005-12-06 19:29:15 +00:00
|
|
|
gboolean \
|
|
|
|
gst_tag_list_get_ ## name (const GstTagList *list, const gchar *tag, \
|
|
|
|
type *value) \
|
|
|
|
{ \
|
|
|
|
GValue v = { 0, }; \
|
|
|
|
\
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE); \
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE); \
|
|
|
|
\
|
|
|
|
if (!gst_tag_list_copy_value (&v, list, tag)) \
|
|
|
|
return FALSE; \
|
|
|
|
*value = COPY_FUNC (g_value_get_ ## name (&v)); \
|
|
|
|
g_value_unset (&v); \
|
2009-05-31 15:17:45 +00:00
|
|
|
return ret; \
|
2005-12-06 19:29:15 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
gboolean \
|
|
|
|
gst_tag_list_get_ ## name ## _index (const GstTagList *list, \
|
|
|
|
const gchar *tag, \
|
|
|
|
guint index, type *value) \
|
|
|
|
{ \
|
|
|
|
const GValue *v; \
|
|
|
|
\
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); \
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE); \
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE); \
|
|
|
|
\
|
|
|
|
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) \
|
|
|
|
return FALSE; \
|
|
|
|
*value = COPY_FUNC (g_value_get_ ## name (v)); \
|
2009-05-31 15:17:45 +00:00
|
|
|
return ret; \
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define COPY_FUNC /**/
|
2005-10-08 18:07:20 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_boolean:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Copies the contents for the given tag into the value, merging multiple values
|
|
|
|
* into one if multiple values are associated with the tag.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_boolean_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
2010-12-19 11:49:58 +00:00
|
|
|
TAG_MERGE_FUNCS (boolean, gboolean, TRUE);
|
2005-10-08 18:07:20 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_int:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Copies the contents for the given tag into the value, merging multiple values
|
|
|
|
* into one if multiple values are associated with the tag.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_int_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
2010-12-19 11:49:58 +00:00
|
|
|
TAG_MERGE_FUNCS (int, gint, TRUE);
|
2005-10-08 18:07:20 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_uint:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Copies the contents for the given tag into the value, merging multiple values
|
|
|
|
* into one if multiple values are associated with the tag.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_uint_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
2010-12-19 11:49:58 +00:00
|
|
|
TAG_MERGE_FUNCS (uint, guint, TRUE);
|
2005-10-08 18:07:20 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_int64_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
2010-12-19 11:49:58 +00:00
|
|
|
TAG_MERGE_FUNCS (int64, gint64, TRUE);
|
2005-10-08 18:07:20 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_uint64:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Copies the contents for the given tag into the value, merging multiple values
|
|
|
|
* into one if multiple values are associated with the tag.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_uint64_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
2010-12-19 11:49:58 +00:00
|
|
|
TAG_MERGE_FUNCS (uint64, guint64, TRUE);
|
2005-10-08 18:07:20 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_float:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Copies the contents for the given tag into the value, merging multiple values
|
|
|
|
* into one if multiple values are associated with the tag.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_float_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
2010-12-19 11:49:58 +00:00
|
|
|
TAG_MERGE_FUNCS (float, gfloat, TRUE);
|
2005-10-08 18:07:20 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_double:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Copies the contents for the given tag into the value, merging multiple values
|
|
|
|
* into one if multiple values are associated with the tag.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_double_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
2010-12-19 11:49:58 +00:00
|
|
|
TAG_MERGE_FUNCS (double, gdouble, TRUE);
|
2005-10-08 18:07:20 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_pointer:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out) (transfer none): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Copies the contents for the given tag into the value, merging multiple values
|
|
|
|
* into one if multiple values are associated with the tag.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_pointer_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out) (transfer none): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
2010-12-19 11:49:58 +00:00
|
|
|
TAG_MERGE_FUNCS (pointer, gpointer, (*value != NULL));
|
|
|
|
|
|
|
|
static inline gchar *
|
|
|
|
_gst_strdup0 (const gchar * s)
|
|
|
|
{
|
|
|
|
if (s == NULL || *s == '\0')
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return g_strdup (s);
|
|
|
|
}
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
#undef COPY_FUNC
|
2010-12-19 11:49:58 +00:00
|
|
|
#define COPY_FUNC _gst_strdup0
|
|
|
|
|
2005-10-08 18:07:20 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_string:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out callee-allocates) (transfer full): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
2006-07-20 16:10:17 +00:00
|
|
|
* Copies the contents for the given tag into the value, possibly merging
|
|
|
|
* multiple values into one if multiple values are associated with the tag.
|
|
|
|
*
|
|
|
|
* Use gst_tag_list_get_string_index (list, tag, 0, value) if you want
|
|
|
|
* to retrieve the first string associated with this tag unmodified.
|
2007-07-10 20:10:16 +00:00
|
|
|
*
|
2007-12-18 12:03:18 +00:00
|
|
|
* The resulting string in @value will be in UTF-8 encoding and should be
|
2012-07-10 09:46:41 +00:00
|
|
|
* freed by the caller using g_free when no longer needed. The
|
2009-06-08 23:16:05 +00:00
|
|
|
* returned string is also guaranteed to be non-NULL and non-empty.
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Free-function: g_free
|
|
|
|
*
|
2005-10-08 18:07:20 +00:00
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_string_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-08 18:07:20 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out callee-allocates) (transfer full): location for the result
|
2005-10-08 18:07:20 +00:00
|
|
|
*
|
|
|
|
* Gets the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
2007-12-18 12:03:18 +00:00
|
|
|
* The resulting string in @value will be in UTF-8 encoding and should be
|
2012-07-10 09:46:41 +00:00
|
|
|
* freed by the caller using g_free when no longer needed. The
|
2009-06-08 23:16:05 +00:00
|
|
|
* returned string is also guaranteed to be non-NULL and non-empty.
|
2006-04-04 14:58:50 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Free-function: g_free
|
|
|
|
*
|
2005-10-08 18:07:20 +00:00
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list.
|
2005-10-08 18:07:20 +00:00
|
|
|
*/
|
2010-12-19 11:49:58 +00:00
|
|
|
TAG_MERGE_FUNCS (string, gchar *, (*value != NULL));
|
2005-10-13 15:13:32 +00:00
|
|
|
|
2010-06-17 14:39:04 +00:00
|
|
|
/*
|
|
|
|
*FIXME 0.11: Instead of _peek (non-copy) and _get (copy), we could have
|
|
|
|
* _get (non-copy) and _dup (copy) for strings, seems more
|
|
|
|
* widely used
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* gst_tag_list_peek_string_index:
|
|
|
|
* @list: a #GstTagList to get the tag from
|
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out) (transfer none): location for the result
|
2010-06-17 14:39:04 +00:00
|
|
|
*
|
|
|
|
* Peeks at the value that is at the given index for the given tag in the given
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* The resulting string in @value will be in UTF-8 encoding and doesn't need
|
|
|
|
* to be freed by the caller. The returned string is also guaranteed to
|
|
|
|
* be non-NULL and non-empty.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a value was set, FALSE if the tag didn't exist in the
|
|
|
|
* given list.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_tag_list_peek_string_index (const GstTagList * list,
|
|
|
|
const gchar * tag, guint index, const gchar ** value)
|
|
|
|
{
|
|
|
|
const GValue *v;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
|
|
|
|
return FALSE;
|
|
|
|
*value = g_value_get_string (v);
|
|
|
|
return *value != NULL && **value != '\0';
|
|
|
|
}
|
|
|
|
|
2005-10-13 15:13:32 +00:00
|
|
|
/**
|
|
|
|
* gst_tag_list_get_date:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-13 15:13:32 +00:00
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out callee-allocates) (transfer full): address of a GDate pointer
|
|
|
|
* variable to store the result into
|
2005-10-13 15:13:32 +00:00
|
|
|
*
|
2009-03-08 17:15:33 +00:00
|
|
|
* Copies the first date for the given tag in the taglist into the variable
|
|
|
|
* pointed to by @value. Free the date with g_date_free() when it is no longer
|
|
|
|
* needed.
|
2005-10-13 15:13:32 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Free-function: g_date_free
|
|
|
|
*
|
2009-03-08 17:15:33 +00:00
|
|
|
* Returns: TRUE, if a date was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list or if it was #NULL.
|
2005-10-13 15:13:32 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_tag_list_get_date (const GstTagList * list, const gchar * tag,
|
|
|
|
GDate ** value)
|
|
|
|
{
|
|
|
|
GValue v = { 0, };
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
if (!gst_tag_list_copy_value (&v, list, tag))
|
|
|
|
return FALSE;
|
|
|
|
*value = (GDate *) g_value_dup_boxed (&v);
|
|
|
|
g_value_unset (&v);
|
|
|
|
return (*value != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_date_index:
|
2006-07-20 16:10:17 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
2005-10-13 15:13:32 +00:00
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out callee-allocates) (transfer full): location for the result
|
2005-10-13 15:13:32 +00:00
|
|
|
*
|
2009-03-08 17:15:33 +00:00
|
|
|
* Gets the date that is at the given index for the given tag in the given
|
|
|
|
* list and copies it into the variable pointed to by @value. Free the date
|
|
|
|
* with g_date_free() when it is no longer needed.
|
2005-10-13 15:13:32 +00:00
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Free-function: g_date_free
|
|
|
|
*
|
2005-10-13 15:13:32 +00:00
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
2005-12-06 19:29:15 +00:00
|
|
|
* given list or if it was #NULL.
|
2005-10-13 15:13:32 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_tag_list_get_date_index (const GstTagList * list,
|
|
|
|
const gchar * tag, guint index, GDate ** value)
|
|
|
|
{
|
|
|
|
const GValue *v;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
|
|
|
|
return FALSE;
|
|
|
|
*value = (GDate *) g_value_dup_boxed (v);
|
2010-07-22 01:08:21 +00:00
|
|
|
return (*value != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_date_time:
|
|
|
|
* @list: a #GstTagList to get the tag from
|
|
|
|
* @tag: tag to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out callee-allocates) (transfer full): address of a #GstDateTime
|
|
|
|
* pointer variable to store the result into
|
2010-07-22 01:08:21 +00:00
|
|
|
*
|
|
|
|
* Copies the first datetime for the given tag in the taglist into the variable
|
|
|
|
* pointed to by @value. Unref the date with gst_date_time_unref() when
|
|
|
|
* it is no longer needed.
|
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Free-function: gst_date_time_unref
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in
|
|
|
|
* thegiven list or if it was #NULL.
|
2010-07-22 01:08:21 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag,
|
|
|
|
GstDateTime ** value)
|
|
|
|
{
|
|
|
|
GValue v = { 0, };
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
if (!gst_tag_list_copy_value (&v, list, tag))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_VALUE_HOLDS_DATE_TIME (&v), FALSE);
|
|
|
|
|
|
|
|
*value = (GstDateTime *) g_value_dup_boxed (&v);
|
|
|
|
g_value_unset (&v);
|
|
|
|
return (*value != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_tag_list_get_date_time_index:
|
|
|
|
* @list: a #GstTagList to get the tag from
|
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2010-12-07 18:35:04 +00:00
|
|
|
* @value: (out callee-allocates) (transfer full): location for the result
|
2010-07-22 01:08:21 +00:00
|
|
|
*
|
|
|
|
* Gets the datetime that is at the given index for the given tag in the given
|
|
|
|
* list and copies it into the variable pointed to by @value. Unref the datetime
|
|
|
|
* with gst_date_time_unref() when it is no longer needed.
|
|
|
|
*
|
2010-12-07 18:35:04 +00:00
|
|
|
* Free-function: gst_date_time_unref
|
|
|
|
*
|
2010-07-22 01:08:21 +00:00
|
|
|
* Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
|
|
|
|
* given list or if it was #NULL.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_tag_list_get_date_time_index (const GstTagList * list,
|
|
|
|
const gchar * tag, guint index, GstDateTime ** value)
|
|
|
|
{
|
|
|
|
const GValue *v;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
|
|
|
|
return FALSE;
|
|
|
|
*value = (GstDateTime *) g_value_dup_boxed (v);
|
2005-10-13 15:13:32 +00:00
|
|
|
return (*value != NULL);
|
|
|
|
}
|
2009-03-26 01:09:03 +00:00
|
|
|
|
|
|
|
/**
|
2012-07-26 14:51:10 +00:00
|
|
|
* gst_tag_list_get_sample:
|
2009-03-26 01:09:03 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
|
|
|
* @tag: tag to read out
|
2012-07-26 14:51:10 +00:00
|
|
|
* @sample: (out callee-allocates) (transfer full): address of a GstSample
|
2010-12-07 18:35:04 +00:00
|
|
|
* pointer variable to store the result into
|
2009-03-26 01:09:03 +00:00
|
|
|
*
|
2012-07-26 14:51:10 +00:00
|
|
|
* Copies the first sample for the given tag in the taglist into the variable
|
|
|
|
* pointed to by @sample. Free the sample with gst_sample_unref() when it is
|
|
|
|
* no longer needed. You can retrieve the buffer from the sample using
|
|
|
|
* gst_sample_get_buffer() and the associated caps (if any) with
|
|
|
|
* gst_sample_get_caps().
|
2009-03-26 01:09:03 +00:00
|
|
|
*
|
2012-07-26 14:51:10 +00:00
|
|
|
* Free-function: gst_sample_unref
|
2010-12-07 18:35:04 +00:00
|
|
|
*
|
2012-07-26 14:51:10 +00:00
|
|
|
* Returns: TRUE, if a sample was returned, FALSE if the tag didn't exist in
|
|
|
|
* the given list or if it was #NULL.
|
2009-03-26 01:09:03 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2012-07-26 14:51:10 +00:00
|
|
|
gst_tag_list_get_sample (const GstTagList * list, const gchar * tag,
|
|
|
|
GstSample ** sample)
|
2009-03-26 01:09:03 +00:00
|
|
|
{
|
|
|
|
GValue v = { 0, };
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
2012-07-26 14:51:10 +00:00
|
|
|
g_return_val_if_fail (sample != NULL, FALSE);
|
2009-03-26 01:09:03 +00:00
|
|
|
|
|
|
|
if (!gst_tag_list_copy_value (&v, list, tag))
|
|
|
|
return FALSE;
|
2012-07-26 14:51:10 +00:00
|
|
|
*sample = g_value_dup_boxed (&v);
|
2009-03-26 01:09:03 +00:00
|
|
|
g_value_unset (&v);
|
2012-07-26 14:51:10 +00:00
|
|
|
return (*sample != NULL);
|
2009-03-26 01:09:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-07-26 14:51:10 +00:00
|
|
|
* gst_tag_list_get_sample_index:
|
2009-03-26 01:09:03 +00:00
|
|
|
* @list: a #GstTagList to get the tag from
|
|
|
|
* @tag: tag to read out
|
|
|
|
* @index: number of entry to read out
|
2012-07-26 14:51:10 +00:00
|
|
|
* @sample: (out callee-allocates) (transfer full): address of a GstSample
|
2010-12-07 18:35:04 +00:00
|
|
|
* pointer variable to store the result into
|
2009-03-26 01:09:03 +00:00
|
|
|
*
|
2012-07-26 14:51:10 +00:00
|
|
|
* Gets the sample that is at the given index for the given tag in the given
|
|
|
|
* list and copies it into the variable pointed to by @smple. Free the sample
|
|
|
|
* with gst_sample_unref() when it is no longer needed. You can retrieve the
|
|
|
|
* buffer from the sample using gst_sample_get_buffer() and the associated
|
|
|
|
* caps (if any) with gst_sample_get_caps().
|
2009-03-26 01:09:03 +00:00
|
|
|
*
|
2012-07-26 14:51:10 +00:00
|
|
|
* Free-function: gst_sample_unref
|
2010-12-07 18:35:04 +00:00
|
|
|
*
|
2012-07-26 14:51:10 +00:00
|
|
|
* Returns: TRUE, if a sample was copied, FALSE if the tag didn't exist in the
|
2009-03-26 01:09:03 +00:00
|
|
|
* given list or if it was #NULL.
|
|
|
|
*/
|
|
|
|
gboolean
|
2012-07-26 14:51:10 +00:00
|
|
|
gst_tag_list_get_sample_index (const GstTagList * list,
|
|
|
|
const gchar * tag, guint index, GstSample ** sample)
|
2009-03-26 01:09:03 +00:00
|
|
|
{
|
|
|
|
const GValue *v;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
|
|
|
|
g_return_val_if_fail (tag != NULL, FALSE);
|
2012-07-26 14:51:10 +00:00
|
|
|
g_return_val_if_fail (sample != NULL, FALSE);
|
2009-03-26 01:09:03 +00:00
|
|
|
|
|
|
|
if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
|
|
|
|
return FALSE;
|
2012-07-26 14:51:10 +00:00
|
|
|
*sample = g_value_dup_boxed (v);
|
|
|
|
return (*sample != NULL);
|
2009-03-26 01:09:03 +00:00
|
|
|
}
|