Blame gst/gsttaglist.c

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