X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgsttaglist.c;h=0eac36d802f7292089611b8569d0bb555afcfeaa;hb=e10266e3f3cf9b05b69198b1ac6faa9a62840e30;hp=c1a2ab07b08032692c35f06215992d3c91140504;hpb=fb8fbdaeb35269f7095ac5f00d7ec3c10de4e35d;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gsttaglist.c b/gst/gsttaglist.c index c1a2ab0..0eac36d 100644 --- a/gst/gsttaglist.c +++ b/gst/gsttaglist.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ /** @@ -25,9 +25,8 @@ * * List of tags and values used to describe media metadata. * - * Strings must be in ASCII or UTF-8 encoding. No other encodings are allowed. - * - * Last reviewed on 2009-06-09 (0.10.23) + * Strings in structures must be ASCII or UTF-8 encoded. Other encodings are + * not allowed. Strings must not be empty or %NULL. */ #ifdef HAVE_CONFIG_H @@ -47,25 +46,28 @@ #include #include +/* FIXME: add category for tags */ +#define GST_CAT_TAGS GST_CAT_DEFAULT + #define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL) -/* FIXME 0.11: make taglists refcounted maybe? */ -/* a tag list is basically a structure, but we don't make this fact public */ -struct _GstTagList +typedef struct _GstTagListImpl { - GstStructure structure; -}; + GstTagList taglist; -/* FIXME 0.11: use GParamSpecs or something similar for tag registrations, - * possibly even gst_tag_register(). Especially value ranges might be - * useful for some tags. */ + GstStructure *structure; + GstTagScope scope; +} GstTagListImpl; + +#define GST_TAG_LIST_STRUCTURE(taglist) ((GstTagListImpl*)(taglist))->structure +#define GST_TAG_LIST_SCOPE(taglist) ((GstTagListImpl*)(taglist))->scope typedef struct { GType type; /* type the data is in */ - gchar *nick; /* translated name */ - gchar *blurb; /* translated description of type */ + const gchar *nick; /* translated short description */ + const gchar *blurb; /* translated long description */ GstTagMergeFunc merge_func; /* functions to merge the values */ GstTagFlag flag; /* type of tag */ @@ -82,299 +84,320 @@ static GMutex __tag_mutex; /* tags hash table: maps tag name string => GstTagInfo */ static GHashTable *__tags; -G_DEFINE_BOXED_TYPE (GstTagList, gst_tag_list, - (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free); +GST_DEFINE_MINI_OBJECT_TYPE (GstTagList, gst_tag_list); + +static void __gst_tag_list_free (GstTagList * list); +static GstTagList *__gst_tag_list_copy (const GstTagList * list); /* FIXME: had code: * g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING, * _gst_structure_transform_to_string); */ - void _priv_gst_tag_initialize (void) { g_mutex_init (&__tag_mutex); __tags = g_hash_table_new (g_str_hash, g_str_equal); - gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_TITLE, GST_TAG_FLAG_META, G_TYPE_STRING, _("title"), _("commonly used title"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_TITLE_SORTNAME, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_TITLE_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING, _("title sortname"), _("commonly used title for sorting purposes"), NULL); - gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ARTIST, GST_TAG_FLAG_META, G_TYPE_STRING, _("artist"), _("person(s) responsible for the recording"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_ARTIST_SORTNAME, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ARTIST_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING, _("artist sortname"), _("person(s) responsible for the recording for sorting purposes"), NULL); - gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ALBUM, GST_TAG_FLAG_META, G_TYPE_STRING, _("album"), _("album containing this data"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_ALBUM_SORTNAME, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ALBUM_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING, _("album sortname"), _("album containing this data for sorting purposes"), NULL); - gst_tag_register (GST_TAG_ALBUM_ARTIST, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ALBUM_ARTIST, GST_TAG_FLAG_META, G_TYPE_STRING, _("album artist"), _("The artist of the entire album, as it should be displayed"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_ALBUM_ARTIST_SORTNAME, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ALBUM_ARTIST_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING, _("album artist sortname"), _("The artist of the entire album, as it should be sorted"), NULL); - gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_DATE, + gst_tag_register_static (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_DATE, _("date"), _("date the data was created (as a GDate structure)"), NULL); - gst_tag_register (GST_TAG_DATE_TIME, GST_TAG_FLAG_META, GST_TYPE_DATE_TIME, - _("datetime"), + gst_tag_register_static (GST_TAG_DATE_TIME, GST_TAG_FLAG_META, + GST_TYPE_DATE_TIME, _("datetime"), _("date and time the data was created (as a GstDateTime structure)"), NULL); - gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_GENRE, GST_TAG_FLAG_META, G_TYPE_STRING, _("genre"), _("genre this data belongs to"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_COMMENT, GST_TAG_FLAG_META, G_TYPE_STRING, _("comment"), _("free text commenting the data"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_EXTENDED_COMMENT, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_EXTENDED_COMMENT, GST_TAG_FLAG_META, G_TYPE_STRING, _("extended comment"), _("free text commenting the data in key=value or key[en]=comment form"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT, _("track number"), _("track number inside a collection"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META, G_TYPE_UINT, _("track count"), _("count of tracks inside collection this track belongs to"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT, _("disc number"), _("disc number inside a collection"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META, G_TYPE_UINT, _("disc count"), _("count of discs inside collection this disc belongs to"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_LOCATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("location"), _("Origin of media as a URI (location, where the " "original of the file or stream is hosted)"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_HOMEPAGE, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_HOMEPAGE, GST_TAG_FLAG_META, G_TYPE_STRING, _("homepage"), _("Homepage for this media (i.e. artist or movie homepage)"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META, G_TYPE_STRING, - _("description"), _("short text describing the content of the data"), + gst_tag_register_static (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META, + G_TYPE_STRING, _("description"), + _("short text describing the content of the data"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META, G_TYPE_STRING, + gst_tag_register_static (GST_TAG_VERSION, GST_TAG_FLAG_META, G_TYPE_STRING, _("version"), _("version of this data"), NULL); - gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META, G_TYPE_STRING, _("ISRC"), + gst_tag_register_static (GST_TAG_ISRC, GST_TAG_FLAG_META, G_TYPE_STRING, + _("ISRC"), _ ("International Standard Recording Code - see http://www.ifpi.org/isrc/"), NULL); /* FIXME: organization (fix what? tpm) */ - gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING, - _("organization"), _("organization"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, + G_TYPE_STRING, _("organization"), _("organization"), + gst_tag_merge_strings_with_comma); + gst_tag_register_static (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META, G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL); - gst_tag_register (GST_TAG_COPYRIGHT_URI, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_COPYRIGHT_URI, GST_TAG_FLAG_META, G_TYPE_STRING, _("copyright uri"), _("URI to the copyright notice of the data"), NULL); - gst_tag_register (GST_TAG_ENCODED_BY, GST_TAG_FLAG_META, G_TYPE_STRING, + gst_tag_register_static (GST_TAG_ENCODED_BY, GST_TAG_FLAG_META, G_TYPE_STRING, _("encoded by"), _("name of the encoding person or organization"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_CONTACT, GST_TAG_FLAG_META, G_TYPE_STRING, _("contact"), _("contact information"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_LICENSE, GST_TAG_FLAG_META, G_TYPE_STRING, _("license"), _("license of data"), NULL); - gst_tag_register (GST_TAG_LICENSE_URI, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_LICENSE_URI, GST_TAG_FLAG_META, G_TYPE_STRING, _("license uri"), _("URI to the license of the data"), NULL); - gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_PERFORMER, GST_TAG_FLAG_META, G_TYPE_STRING, _("performer"), _("person(s) performing"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_COMPOSER, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_COMPOSER, GST_TAG_FLAG_META, G_TYPE_STRING, _("composer"), _("person(s) who composed the recording"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED, + gst_tag_register_static (GST_TAG_DURATION, GST_TAG_FLAG_DECODED, G_TYPE_UINT64, _("duration"), _("length in GStreamer time units (nanoseconds)"), NULL); - gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED, G_TYPE_STRING, _("codec"), _("codec the data is stored in"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED, G_TYPE_STRING, _("video codec"), _("codec the video data is stored in"), NULL); - gst_tag_register (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED, G_TYPE_STRING, _("audio codec"), _("codec the audio data is stored in"), NULL); - gst_tag_register (GST_TAG_SUBTITLE_CODEC, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_SUBTITLE_CODEC, GST_TAG_FLAG_ENCODED, G_TYPE_STRING, _("subtitle codec"), _("codec the subtitle data is stored in"), NULL); - gst_tag_register (GST_TAG_CONTAINER_FORMAT, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_CONTAINER_FORMAT, GST_TAG_FLAG_ENCODED, G_TYPE_STRING, _("container format"), _("container format the data is stored in"), NULL); - gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED, G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL); - gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED, G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL); - gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED, G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL); - gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED, G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL); - gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED, G_TYPE_STRING, _("encoder"), _("encoder used to encode this stream"), NULL); - gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED, G_TYPE_UINT, _("encoder version"), _("version of the encoder used to encode this stream"), NULL); - gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED, + gst_tag_register_static (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED, G_TYPE_UINT, _("serial"), _("serial number of track"), NULL); - gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL); - gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL); - gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL); - gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL); - gst_tag_register (GST_TAG_REFERENCE_LEVEL, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_REFERENCE_LEVEL, GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("replaygain reference level"), _("reference level of track and album gain values"), NULL); - gst_tag_register (GST_TAG_LANGUAGE_CODE, GST_TAG_FLAG_META, G_TYPE_STRING, - _("language code"), + gst_tag_register_static (GST_TAG_LANGUAGE_CODE, GST_TAG_FLAG_META, + G_TYPE_STRING, _("language code"), _("language code for this stream, conforming to ISO-639-1 or ISO-639-2"), NULL); - gst_tag_register (GST_TAG_LANGUAGE_NAME, GST_TAG_FLAG_META, G_TYPE_STRING, - _("language name"), + gst_tag_register_static (GST_TAG_LANGUAGE_NAME, GST_TAG_FLAG_META, + G_TYPE_STRING, _("language name"), _("freeform name of the language this stream is in"), NULL); - gst_tag_register (GST_TAG_IMAGE, GST_TAG_FLAG_META, GST_TYPE_SAMPLE, + gst_tag_register_static (GST_TAG_IMAGE, GST_TAG_FLAG_META, GST_TYPE_SAMPLE, _("image"), _("image related to this stream"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_PREVIEW_IMAGE, GST_TAG_FLAG_META, GST_TYPE_SAMPLE, + gst_tag_register_static (GST_TAG_PREVIEW_IMAGE, GST_TAG_FLAG_META, + GST_TYPE_SAMPLE, /* TRANSLATORS: 'preview image' = image that shows a preview of the full image */ _("preview image"), _("preview image related to this stream"), NULL); - gst_tag_register (GST_TAG_ATTACHMENT, GST_TAG_FLAG_META, GST_TYPE_SAMPLE, - _("attachment"), _("file attached to this stream"), + gst_tag_register_static (GST_TAG_ATTACHMENT, GST_TAG_FLAG_META, + GST_TYPE_SAMPLE, _("attachment"), _("file attached to this stream"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_BEATS_PER_MINUTE, GST_TAG_FLAG_META, G_TYPE_DOUBLE, - _("beats per minute"), _("number of beats per minute in audio"), NULL); - gst_tag_register (GST_TAG_KEYWORDS, GST_TAG_FLAG_META, G_TYPE_STRING, + gst_tag_register_static (GST_TAG_BEATS_PER_MINUTE, GST_TAG_FLAG_META, + G_TYPE_DOUBLE, _("beats per minute"), + _("number of beats per minute in audio"), NULL); + gst_tag_register_static (GST_TAG_KEYWORDS, GST_TAG_FLAG_META, G_TYPE_STRING, _("keywords"), _("comma separated keywords describing the content"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_GEO_LOCATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING, - _("geo location name"), _("human readable descriptive location of where " + gst_tag_register_static (GST_TAG_GEO_LOCATION_NAME, GST_TAG_FLAG_META, + G_TYPE_STRING, _("geo location name"), + _("human readable descriptive location of where " "the media has been recorded or produced"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_LATITUDE, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_GEO_LOCATION_LATITUDE, GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location latitude"), _("geo latitude location of where the media has been recorded or " "produced in degrees according to WGS84 (zero at the equator, " "negative values for southern latitudes)"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_LONGITUDE, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_GEO_LOCATION_LONGITUDE, GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location longitude"), _("geo longitude location of where the media has been recorded or " "produced in degrees according to WGS84 (zero at the prime meridian " "in Greenwich/UK, negative values for western longitudes)"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_ELEVATION, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_GEO_LOCATION_ELEVATION, GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location elevation"), _("geo elevation of where the media has been recorded or produced in " "meters according to WGS84 (zero is average sea level)"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_COUNTRY, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_GEO_LOCATION_COUNTRY, GST_TAG_FLAG_META, G_TYPE_STRING, _("geo location country"), _("country (english name) where the media has been recorded " "or produced"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_CITY, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_GEO_LOCATION_CITY, GST_TAG_FLAG_META, G_TYPE_STRING, _("geo location city"), _("city (english name) where the media has been recorded " "or produced"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_SUBLOCATION, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_GEO_LOCATION_SUBLOCATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("geo location sublocation"), - _("a location whithin a city where the media has been produced " + _("a location within a city where the media has been produced " "or created (e.g. the neighborhood)"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, _("geo location horizontal error"), + gst_tag_register_static (GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, + GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location horizontal error"), _("expected error of the horizontal positioning measures (in meters)"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, _("geo location movement speed"), + gst_tag_register_static (GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, + GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location movement speed"), _("movement speed of the capturing device while performing the capture " "in m/s"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, _("geo location movement direction"), + gst_tag_register_static (GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, + GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location movement direction"), _("indicates the movement direction of the device performing the capture" " of a media. It is represented as degrees in floating point " "representation, 0 means the geographic north, and increases " "clockwise"), NULL); - gst_tag_register (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, _("geo location capture direction"), + gst_tag_register_static (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, + GST_TAG_FLAG_META, G_TYPE_DOUBLE, _("geo location capture direction"), _("indicates the direction the device is pointing to when capturing " " a media. It is represented as degrees in floating point " " representation, 0 means the geographic north, and increases " "clockwise"), NULL); - gst_tag_register (GST_TAG_SHOW_NAME, GST_TAG_FLAG_META, G_TYPE_STRING, + gst_tag_register_static (GST_TAG_SHOW_NAME, GST_TAG_FLAG_META, G_TYPE_STRING, /* TRANSLATORS: 'show name' = 'TV/radio/podcast show name' here */ _("show name"), _("Name of the tv/podcast/series show the media is from"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_SHOW_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING, + gst_tag_register_static (GST_TAG_SHOW_SORTNAME, GST_TAG_FLAG_META, + G_TYPE_STRING, /* TRANSLATORS: 'show sortname' = 'TV/radio/podcast show name as used for sorting purposes' here */ _("show sortname"), _("Name of the tv/podcast/series show the media is from, for sorting " "purposes"), NULL); - gst_tag_register (GST_TAG_SHOW_EPISODE_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT, - _("episode number"), + gst_tag_register_static (GST_TAG_SHOW_EPISODE_NUMBER, GST_TAG_FLAG_META, + G_TYPE_UINT, _("episode number"), _("The episode number in the season the media is part of"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_SHOW_SEASON_NUMBER, GST_TAG_FLAG_META, G_TYPE_UINT, - _("season number"), + gst_tag_register_static (GST_TAG_SHOW_SEASON_NUMBER, GST_TAG_FLAG_META, + G_TYPE_UINT, _("season number"), _("The season number of the show the media is part of"), gst_tag_merge_use_first); - gst_tag_register (GST_TAG_LYRICS, GST_TAG_FLAG_META, G_TYPE_STRING, + gst_tag_register_static (GST_TAG_LYRICS, GST_TAG_FLAG_META, G_TYPE_STRING, _("lyrics"), _("The lyrics of the media, commonly used for songs"), gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_COMPOSER_SORTNAME, GST_TAG_FLAG_META, G_TYPE_STRING, - _("composer sortname"), + gst_tag_register_static (GST_TAG_COMPOSER_SORTNAME, GST_TAG_FLAG_META, + G_TYPE_STRING, _("composer sortname"), _("person(s) who composed the recording, for sorting purposes"), NULL); - gst_tag_register (GST_TAG_GROUPING, GST_TAG_FLAG_META, G_TYPE_STRING, + gst_tag_register_static (GST_TAG_GROUPING, GST_TAG_FLAG_META, G_TYPE_STRING, _("grouping"), _("Groups related media that spans multiple tracks, like the different " "pieces of a concerto. It is a higher level than a track, " "but lower than an album"), NULL); - gst_tag_register (GST_TAG_USER_RATING, GST_TAG_FLAG_META, G_TYPE_UINT, + gst_tag_register_static (GST_TAG_USER_RATING, GST_TAG_FLAG_META, G_TYPE_UINT, _("user rating"), _("Rating attributed by a user. The higher the rank, " "the more the user likes this media"), NULL); - gst_tag_register (GST_TAG_DEVICE_MANUFACTURER, GST_TAG_FLAG_META, + gst_tag_register_static (GST_TAG_DEVICE_MANUFACTURER, GST_TAG_FLAG_META, G_TYPE_STRING, _("device manufacturer"), _("Manufacturer of the device used to create this media"), NULL); - gst_tag_register (GST_TAG_DEVICE_MODEL, GST_TAG_FLAG_META, G_TYPE_STRING, - _("device model"), + gst_tag_register_static (GST_TAG_DEVICE_MODEL, GST_TAG_FLAG_META, + G_TYPE_STRING, _("device model"), _("Model of the device used to create this media"), NULL); - gst_tag_register (GST_TAG_APPLICATION_NAME, GST_TAG_FLAG_META, G_TYPE_STRING, - _("application name"), _("Application used to create the media"), NULL); - gst_tag_register (GST_TAG_APPLICATION_DATA, GST_TAG_FLAG_META, - GST_TYPE_BUFFER, _("application data"), + gst_tag_register_static (GST_TAG_APPLICATION_NAME, GST_TAG_FLAG_META, + G_TYPE_STRING, _("application name"), + _("Application used to create the media"), NULL); + gst_tag_register_static (GST_TAG_APPLICATION_DATA, GST_TAG_FLAG_META, + GST_TYPE_SAMPLE, _("application data"), _("Arbitrary application data to be serialized into the media"), NULL); - gst_tag_register (GST_TAG_IMAGE_ORIENTATION, GST_TAG_FLAG_META, G_TYPE_STRING, - _("image orientation"), + gst_tag_register_static (GST_TAG_IMAGE_ORIENTATION, GST_TAG_FLAG_META, + G_TYPE_STRING, _("image orientation"), _("How the image should be rotated or flipped before display"), NULL); + gst_tag_register_static (GST_TAG_PUBLISHER, GST_TAG_FLAG_META, + G_TYPE_STRING, + _("publisher"), + _("Name of the label or publisher"), gst_tag_merge_strings_with_comma); + gst_tag_register_static (GST_TAG_INTERPRETED_BY, GST_TAG_FLAG_META, + G_TYPE_STRING, + _("interpreted-by"), + _("Information about the people behind a remix and similar " + "interpretations"), gst_tag_merge_strings_with_comma); + gst_tag_register_static (GST_TAG_MIDI_BASE_NOTE, GST_TAG_FLAG_META, + G_TYPE_UINT, + _("midi-base-note"), _("Midi note number of the audio track."), NULL); } /** @@ -442,7 +465,7 @@ gst_tag_lookup (const gchar * tag_name) * @type: the type this data is in * @nick: human-readable name * @blurb: a human-readable description about this tag - * @func: function for merging multiple values of this tag, or NULL + * @func: (allow-none): function for merging multiple values of this tag, or %NULL * * Registers a new tag type for the use with GStreamer's type system. If a type * with that name is already registered, that one is used. @@ -451,7 +474,7 @@ gst_tag_lookup (const gchar * tag_name) * * Important: if you do not supply a merge function the implication will be * that there can only be one single value for this tag in a tag list and - * any additional values will silenty be discarded when being added (unless + * any additional values will silently be discarded when being added (unless * #GST_TAG_MERGE_REPLACE, #GST_TAG_MERGE_REPLACE_ALL, or * #GST_TAG_MERGE_PREPEND is used as merge mode, in which case the new * value will replace the old one in the list). @@ -470,8 +493,36 @@ void gst_tag_register (const gchar * name, GstTagFlag flag, GType type, const gchar * nick, const gchar * blurb, GstTagMergeFunc func) { + g_return_if_fail (name != NULL); + g_return_if_fail (nick != NULL); + g_return_if_fail (blurb != NULL); + g_return_if_fail (type != 0 && type != GST_TYPE_LIST); + + return gst_tag_register_static (g_intern_string (name), flag, type, + g_intern_string (nick), g_intern_string (blurb), func); +} + +/** + * gst_tag_register_static: + * @name: the name or identifier string (string constant) + * @flag: a flag describing the type of tag info + * @type: the type this data is in + * @nick: human-readable name or short description (string constant) + * @blurb: a human-readable description for this tag (string constant) + * @func: (allow-none): function for merging multiple values of this tag, or %NULL + * + * Registers a new tag type for the use with GStreamer's type system. + * + * Same as gst_tag_register(), but @name, @nick, and @blurb must be + * static strings or inlined strings, as they will not be copied. (GStreamer + * plugins will be made resident once loaded, so this function can be used + * even from dynamically loaded plugins.) + */ +void +gst_tag_register_static (const gchar * name, GstTagFlag flag, GType type, + const gchar * nick, const gchar * blurb, GstTagMergeFunc func) +{ GstTagInfo *info; - gchar *name_dup; g_return_if_fail (name != NULL); g_return_if_fail (nick != NULL); @@ -488,17 +539,13 @@ gst_tag_register (const gchar * name, GstTagFlag flag, GType type, info = g_slice_new (GstTagInfo); info->flag = flag; info->type = type; - info->nick = g_strdup (nick); - info->blurb = g_strdup (blurb); + info->name_quark = g_quark_from_static_string (name); + info->nick = nick; + info->blurb = blurb; info->merge_func = func; - /* we make a copy for the hash table anyway, which will stay around, so - * can use that for the quark table too */ - name_dup = g_strdup (name); - info->name_quark = g_quark_from_static_string (name_dup); - TAG_LOCK; - g_hash_table_insert (__tags, (gpointer) name_dup, info); + g_hash_table_insert (__tags, (gpointer) name, info); TAG_UNLOCK; } @@ -508,7 +555,7 @@ gst_tag_register (const gchar * name, GstTagFlag flag, GType type, * * Checks if the given type is already registered. * - * Returns: TRUE if the type is already registered + * Returns: %TRUE if the type is already registered */ gboolean gst_tag_exists (const gchar * tag) @@ -539,7 +586,7 @@ gst_tag_get_type (const gchar * tag) } /** - * gst_tag_get_nick + * gst_tag_get_nick: * @tag: the tag * * Returns the human-readable name of this tag, You must not change or free @@ -607,7 +654,7 @@ gst_tag_get_flag (const gchar * tag) * Checks if the given tag is fixed. A fixed tag can only contain one value. * Unfixed tags can contain lists of values. * - * Returns: TRUE, if the given tag is fixed. + * Returns: %TRUE, if the given tag is fixed. */ gboolean gst_tag_is_fixed (const gchar * tag) @@ -621,40 +668,96 @@ gst_tag_is_fixed (const gchar * tag) return info->merge_func == NULL; } +/* takes ownership of the structure */ +static GstTagList * +gst_tag_list_new_internal (GstStructure * s) +{ + GstTagList *tag_list; + + g_assert (s != NULL); + + tag_list = (GstTagList *) g_slice_new (GstTagListImpl); + + gst_mini_object_init (GST_MINI_OBJECT_CAST (tag_list), 0, GST_TYPE_TAG_LIST, + (GstMiniObjectCopyFunction) __gst_tag_list_copy, NULL, + (GstMiniObjectFreeFunction) __gst_tag_list_free); + + GST_TAG_LIST_STRUCTURE (tag_list) = s; + GST_TAG_LIST_SCOPE (tag_list) = GST_TAG_SCOPE_STREAM; + +#ifdef DEBUG_REFCOUNT + GST_CAT_TRACE (GST_CAT_TAGS, "created taglist %p", tag_list); +#endif + + return tag_list; +} + +static void +__gst_tag_list_free (GstTagList * list) +{ + g_return_if_fail (GST_IS_TAG_LIST (list)); + +#ifdef DEBUG_REFCOUNT + GST_CAT_TRACE (GST_CAT_TAGS, "freeing taglist %p", list); +#endif + + gst_structure_free (GST_TAG_LIST_STRUCTURE (list)); + + g_slice_free1 (sizeof (GstTagListImpl), list); +} + +static GstTagList * +__gst_tag_list_copy (const GstTagList * list) +{ + const GstStructure *s; + + g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL); + + s = GST_TAG_LIST_STRUCTURE (list); + return gst_tag_list_new_internal (gst_structure_copy (s)); +} + /** * gst_tag_list_new_empty: * * Creates a new empty GstTagList. * - * Free-function: gst_tag_list_free + * Free-function: gst_tag_list_unref * * Returns: (transfer full): An empty tag list */ GstTagList * gst_tag_list_new_empty (void) { - return GST_TAG_LIST (gst_structure_new_id_empty (GST_QUARK (TAGLIST))); + GstStructure *s; + GstTagList *tag_list; + + s = gst_structure_new_id_empty (GST_QUARK (TAGLIST)); + tag_list = gst_tag_list_new_internal (s); + return tag_list; } /** * gst_tag_list_new: * @tag: tag - * @...: NULL-terminated list of values to set + * @...: %NULL-terminated list of values to set * * Creates a new taglist and appends the values for the given tags. It expects - * tag-value pairs like gst_tag_list_add(), and a NULL terminator after the + * tag-value pairs like gst_tag_list_add(), and a %NULL terminator after the * last pair. The type of the values is implicit and is documented in the API * reference, but can also be queried at runtime with gst_tag_get_type(). It * is an error to pass a value of a type not matching the tag type into this * function. The tag list will make copies of any arguments passed * (e.g. strings, buffers). * - * Free-function: gst_tag_list_free + * After creation you might also want to set a #GstTagScope on the returned + * taglist to signal if the contained tags are global or stream tags. By + * default stream scope is assumes. See gst_tag_list_set_scope(). * - * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_free() - * when no longer needed. + * Free-function: gst_tag_list_unref * - * Since: 0.10.24 + * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_unref() + * when no longer needed. */ GstTagList * gst_tag_list_new (const gchar * tag, ...) @@ -679,12 +782,10 @@ gst_tag_list_new (const gchar * tag, ...) * Just like gst_tag_list_new(), only that it takes a va_list argument. * Useful mostly for language bindings. * - * Free-function: gst_tag_list_free + * Free-function: gst_tag_list_unref * - * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_free() + * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_unref() * when no longer needed. - * - * Since: 0.10.24 */ GstTagList * gst_tag_list_new_valist (va_list var_args) @@ -701,22 +802,54 @@ gst_tag_list_new_valist (va_list var_args) } /** + * gst_tag_list_set_scope: + * @list: a #GstTagList + * @scope: new scope for @list + * + * Sets the scope of @list to @scope. By default the scope + * of a taglist is stream scope. + * + */ +void +gst_tag_list_set_scope (GstTagList * list, GstTagScope scope) +{ + g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (gst_tag_list_is_writable (list)); + + GST_TAG_LIST_SCOPE (list) = scope; +} + +/** + * gst_tag_list_get_scope: + * @list: a #GstTagList + * + * Gets the scope of @list. + * + * Returns: The scope of @list + */ +GstTagScope +gst_tag_list_get_scope (const GstTagList * list) +{ + g_return_val_if_fail (GST_IS_TAG_LIST (list), GST_TAG_SCOPE_STREAM); + + return GST_TAG_LIST_SCOPE (list); +} + +/** * gst_tag_list_to_string: * @list: a #GstTagList * * Serializes a tag list to a string. * - * Returns: a newly-allocated string, or NULL in case of an error. The + * Returns: a newly-allocated string, or %NULL in case of an error. The * string must be freed with g_free() when no longer needed. - * - * Since: 0.10.36 */ gchar * gst_tag_list_to_string (const GstTagList * list) { g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL); - return gst_structure_to_string (GST_STRUCTURE (list)); + return gst_structure_to_string (GST_TAG_LIST_STRUCTURE (list)); } /** @@ -725,17 +858,24 @@ gst_tag_list_to_string (const GstTagList * list) * * Deserializes a tag list. * - * Returns: a new #GstTagList, or NULL in case of an error. - * - * Since: 0.10.36 + * Returns: a new #GstTagList, or %NULL in case of an error. */ GstTagList * gst_tag_list_new_from_string (const gchar * str) { + GstTagList *tag_list; + GstStructure *s; + g_return_val_if_fail (str != NULL, NULL); g_return_val_if_fail (g_str_has_prefix (str, "taglist"), NULL); - return GST_TAG_LIST (gst_structure_from_string (str, NULL)); + s = gst_structure_from_string (str, NULL); + if (s == NULL) + return NULL; + + tag_list = gst_tag_list_new_internal (s); + + return tag_list; } /** @@ -752,7 +892,7 @@ gst_tag_list_n_tags (const GstTagList * list) g_return_val_if_fail (list != NULL, 0); g_return_val_if_fail (GST_IS_TAG_LIST (list), 0); - return gst_structure_n_fields ((GstStructure *) list); + return gst_structure_n_fields (GST_TAG_LIST_STRUCTURE (list)); } /** @@ -770,7 +910,7 @@ gst_tag_list_nth_tag_name (const GstTagList * list, guint index) g_return_val_if_fail (list != NULL, 0); g_return_val_if_fail (GST_IS_TAG_LIST (list), 0); - return gst_structure_nth_field_name ((GstStructure *) list, index); + return gst_structure_nth_field_name (GST_TAG_LIST_STRUCTURE (list), index); } /** @@ -779,9 +919,7 @@ gst_tag_list_nth_tag_name (const GstTagList * list, guint index) * * Checks if the given taglist is empty. * - * Returns: TRUE if the taglist is empty, otherwise FALSE. - * - * Since: 0.10.11 + * Returns: %TRUE if the taglist is empty, otherwise %FALSE. */ gboolean gst_tag_list_is_empty (const GstTagList * list) @@ -789,7 +927,7 @@ gst_tag_list_is_empty (const GstTagList * list) g_return_val_if_fail (list != NULL, FALSE); g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); - return (gst_structure_n_fields ((GstStructure *) list) == 0); + return (gst_structure_n_fields (GST_TAG_LIST_STRUCTURE (list)) == 0); } static gboolean @@ -820,9 +958,7 @@ gst_tag_list_fields_equal (const GValue * value1, const GValue * value2) * * Checks if the two given taglists are equal. * - * Returns: TRUE if the taglists are equal, otherwise FALSE - * - * Since: 0.10.36 + * Returns: %TRUE if the taglists are equal, otherwise %FALSE */ gboolean gst_tag_list_is_equal (const GstTagList * list1, const GstTagList * list2) @@ -836,8 +972,8 @@ gst_tag_list_is_equal (const GstTagList * list1, const GstTagList * list2) /* we don't just use gst_structure_is_equal() here so we can add some * tolerance for doubles, though maybe we should just add that to * gst_value_compare_double() as well? */ - s1 = (const GstStructure *) list1; - s2 = (const GstStructure *) list2; + s1 = GST_TAG_LIST_STRUCTURE (list1); + s2 = GST_TAG_LIST_STRUCTURE (list2); num_fields1 = gst_structure_n_fields (s1); num_fields2 = gst_structure_n_fields (s2); @@ -863,24 +999,6 @@ gst_tag_list_is_equal (const GstTagList * list1, const GstTagList * list2) return TRUE; } -/** - * gst_is_tag_list: - * @p: Object that might be a taglist - * - * Checks if the given pointer is a taglist. - * - * Returns: TRUE, if the given pointer is a taglist - */ -gboolean -gst_is_tag_list (gconstpointer p) -{ - GstStructure *s = (GstStructure *) p; - - g_return_val_if_fail (p != NULL, FALSE); - - return (GST_IS_STRUCTURE (s) && s->name == GST_QUARK (TAGLIST)); -} - typedef struct { GstTagList *list; @@ -892,7 +1010,7 @@ static void gst_tag_list_add_value_internal (GstTagList * tag_list, GstTagMergeMode mode, const gchar * tag, const GValue * value, GstTagInfo * info) { - GstStructure *list = GST_STRUCTURE (tag_list); + GstStructure *list = GST_TAG_LIST_STRUCTURE (tag_list); const GValue *value2; GQuark tag_quark; @@ -904,6 +1022,14 @@ gst_tag_list_add_value_internal (GstTagList * tag_list, GstTagMergeMode mode, } } + if (G_UNLIKELY (!G_VALUE_HOLDS (value, info->type) && + !GST_VALUE_HOLDS_LIST (value))) { + g_warning ("tag '%s' should hold value of type '%s', but value of " + "type '%s' passed", info->nick, g_type_name (info->type), + g_type_name (G_VALUE_TYPE (value))); + return; + } + tag_quark = info->name_quark; if (info->merge_func @@ -916,14 +1042,20 @@ gst_tag_list_add_value_internal (GstTagList * tag_list, GstTagMergeMode mode, gst_structure_id_set_value (list, tag_quark, value); break; case GST_TAG_MERGE_PREPEND: - gst_value_list_merge (&dest, value, value2); - gst_structure_id_set_value (list, tag_quark, &dest); - g_value_unset (&dest); + if (GST_VALUE_HOLDS_LIST (value2) && !GST_VALUE_HOLDS_LIST (value)) + gst_value_list_prepend_value ((GValue *) value2, value); + else { + gst_value_list_merge (&dest, value, value2); + gst_structure_id_take_value (list, tag_quark, &dest); + } break; case GST_TAG_MERGE_APPEND: - gst_value_list_merge (&dest, value2, value); - gst_structure_id_set_value (list, tag_quark, &dest); - g_value_unset (&dest); + if (GST_VALUE_HOLDS_LIST (value2) && !GST_VALUE_HOLDS_LIST (value)) + gst_value_list_append_value ((GValue *) value2, value); + else { + gst_value_list_merge (&dest, value2, value); + gst_structure_id_take_value (list, tag_quark, &dest); + } break; case GST_TAG_MERGE_KEEP: case GST_TAG_MERGE_KEEP_ALL: @@ -981,34 +1113,17 @@ gst_tag_list_insert (GstTagList * into, const GstTagList * from, GstTagCopyData data; g_return_if_fail (GST_IS_TAG_LIST (into)); + g_return_if_fail (gst_tag_list_is_writable (into)); g_return_if_fail (GST_IS_TAG_LIST (from)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); data.list = into; data.mode = mode; if (mode == GST_TAG_MERGE_REPLACE_ALL) { - gst_structure_remove_all_fields (GST_STRUCTURE (data.list)); + gst_structure_remove_all_fields (GST_TAG_LIST_STRUCTURE (into)); } - gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, - &data); -} - -/** - * gst_tag_list_copy: - * @list: list to copy - * - * Copies a given #GstTagList. - * - * Free-function: gst_tag_list_free - * - * Returns: (transfer full): copy of the given list - */ -GstTagList * -gst_tag_list_copy (const GstTagList * list) -{ - g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL); - - return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list)); + gst_structure_foreach (GST_TAG_LIST_STRUCTURE (from), + gst_tag_list_copy_foreach, &data); } /** @@ -1017,10 +1132,10 @@ gst_tag_list_copy (const GstTagList * list) * @list2: second list to merge * @mode: the mode to use * - * Merges the two given lists into a new list. If one of the lists is NULL, a - * copy of the other is returned. If both lists are NULL, NULL is returned. + * Merges the two given lists into a new list. If one of the lists is %NULL, a + * copy of the other is returned. If both lists are %NULL, %NULL is returned. * - * Free-function: gst_tag_list_free + * Free-function: gst_tag_list_unref * * Returns: (transfer full): the new list */ @@ -1047,25 +1162,12 @@ gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2, gst_tag_list_insert (list1_cp, list2_cp, mode); if (!list2) - gst_tag_list_free ((GstTagList *) list2_cp); + gst_tag_list_unref ((GstTagList *) list2_cp); return list1_cp; } /** - * gst_tag_list_free: - * @list: (in) (transfer full): the list to free - * - * Frees the given list and all associated values. - */ -void -gst_tag_list_free (GstTagList * list) -{ - g_return_if_fail (GST_IS_TAG_LIST (list)); - gst_structure_free ((GstStructure *) list); -} - -/** * gst_tag_list_get_tag_size: * @list: a taglist * @tag: the tag to query @@ -1081,7 +1183,7 @@ gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag) g_return_val_if_fail (GST_IS_TAG_LIST (list), 0); - value = gst_structure_get_value ((GstStructure *) list, tag); + value = gst_structure_get_value (GST_TAG_LIST_STRUCTURE (list), tag); if (value == NULL) return 0; if (G_VALUE_TYPE (value) != GST_TYPE_LIST) @@ -1095,7 +1197,7 @@ gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag) * @list: list to set tags in * @mode: the mode to use * @tag: tag - * @...: NULL-terminated list of values to set + * @...: %NULL-terminated list of values to set * * Sets the values for the given tags using the specified mode. */ @@ -1106,6 +1208,7 @@ gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag, va_list args; g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (gst_tag_list_is_writable (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); @@ -1130,6 +1233,7 @@ gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode, va_list args; g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (gst_tag_list_is_writable (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); @@ -1155,11 +1259,12 @@ gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode, gchar *error = NULL; g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (gst_tag_list_is_writable (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); if (mode == GST_TAG_MERGE_REPLACE_ALL) { - gst_structure_remove_all_fields (GST_STRUCTURE (list)); + gst_structure_remove_all_fields (GST_TAG_LIST_STRUCTURE (list)); } while (tag != NULL) { @@ -1179,7 +1284,13 @@ gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode, */ return; } - gst_tag_list_add_value_internal (list, mode, tag, &value, info); + /* Facilitate GstBuffer -> GstSample transition */ + if (G_UNLIKELY (info->type == GST_TYPE_SAMPLE && + !GST_IS_SAMPLE (value.data[0].v_pointer))) { + g_warning ("Expected GstSample argument for tag '%s'", tag); + } else { + gst_tag_list_add_value_internal (list, mode, tag, &value, info); + } g_value_unset (&value); tag = va_arg (var_args, gchar *); } @@ -1199,11 +1310,12 @@ gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode, const gchar * tag, va_list var_args) { g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (gst_tag_list_is_writable (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); if (mode == GST_TAG_MERGE_REPLACE_ALL) { - gst_structure_remove_all_fields (GST_STRUCTURE (list)); + gst_structure_remove_all_fields (GST_TAG_LIST_STRUCTURE (list)); } while (tag != NULL) { @@ -1228,14 +1340,13 @@ gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode, * @value: GValue for this tag * * Sets the GValue for a given tag using the specified mode. - * - * Since: 0.10.24 */ void gst_tag_list_add_value (GstTagList * list, GstTagMergeMode mode, const gchar * tag, const GValue * value) { g_return_if_fail (GST_IS_TAG_LIST (list)); + g_return_if_fail (gst_tag_list_is_writable (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); @@ -1255,7 +1366,7 @@ gst_tag_list_remove_tag (GstTagList * list, const gchar * tag) g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (tag != NULL); - gst_structure_remove_field ((GstStructure *) list, tag); + gst_structure_remove_field (GST_TAG_LIST_STRUCTURE (list), tag); } typedef struct @@ -1297,8 +1408,8 @@ gst_tag_list_foreach (const GstTagList * list, GstTagForeachFunc func, data.func = func; data.tag_list = list; data.data = user_data; - gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, - &data); + gst_structure_foreach (GST_TAG_LIST_STRUCTURE (list), + structure_foreach_wrapper, &data); } /** @@ -1310,7 +1421,7 @@ gst_tag_list_foreach (const GstTagList * list, GstTagForeachFunc func, * Gets the value that is at the given index for the given tag in the given * list. * - * Returns: (transfer none): The GValue for the specified entry or NULL if the + * Returns: (transfer none): The GValue for the specified entry or %NULL if the * tag wasn't available or the tag doesn't have as many entries */ const GValue * @@ -1322,7 +1433,7 @@ gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag, g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL); g_return_val_if_fail (tag != NULL, NULL); - value = gst_structure_get_value ((GstStructure *) list, tag); + value = gst_structure_get_value (GST_TAG_LIST_STRUCTURE (list), tag); if (value == NULL) return NULL; @@ -1348,7 +1459,7 @@ gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag, * with the tag. * You must g_value_unset() the value after use. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ gboolean @@ -1362,7 +1473,7 @@ gst_tag_list_copy_value (GValue * dest, const GstTagList * list, g_return_val_if_fail (dest != NULL, FALSE); g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE); - src = gst_structure_get_value ((GstStructure *) list, tag); + src = gst_structure_get_value (GST_TAG_LIST_STRUCTURE (list), tag); if (!src) return FALSE; @@ -1438,7 +1549,7 @@ gst_tag_list_get_ ## name ## _index (const GstTagList *list, \ * Copies the contents for the given tag into the value, merging multiple values * into one if multiple values are associated with the tag. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ /** @@ -1451,7 +1562,7 @@ gst_tag_list_get_ ## name ## _index (const GstTagList *list, \ * Gets the value that is at the given index for the given tag in the given * list. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ TAG_MERGE_FUNCS (boolean, gboolean, TRUE); @@ -1464,7 +1575,7 @@ TAG_MERGE_FUNCS (boolean, gboolean, TRUE); * Copies the contents for the given tag into the value, merging multiple values * into one if multiple values are associated with the tag. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ /** @@ -1477,7 +1588,7 @@ TAG_MERGE_FUNCS (boolean, gboolean, TRUE); * Gets the value that is at the given index for the given tag in the given * list. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ TAG_MERGE_FUNCS (int, gint, TRUE); @@ -1490,7 +1601,7 @@ TAG_MERGE_FUNCS (int, gint, TRUE); * Copies the contents for the given tag into the value, merging multiple values * into one if multiple values are associated with the tag. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ /** @@ -1503,7 +1614,7 @@ TAG_MERGE_FUNCS (int, gint, TRUE); * Gets the value that is at the given index for the given tag in the given * list. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ TAG_MERGE_FUNCS (uint, guint, TRUE); @@ -1517,7 +1628,7 @@ TAG_MERGE_FUNCS (uint, guint, TRUE); * Gets the value that is at the given index for the given tag in the given * list. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ TAG_MERGE_FUNCS (int64, gint64, TRUE); @@ -1530,7 +1641,7 @@ TAG_MERGE_FUNCS (int64, gint64, TRUE); * Copies the contents for the given tag into the value, merging multiple values * into one if multiple values are associated with the tag. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ /** @@ -1543,7 +1654,7 @@ TAG_MERGE_FUNCS (int64, gint64, TRUE); * Gets the value that is at the given index for the given tag in the given * list. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ TAG_MERGE_FUNCS (uint64, guint64, TRUE); @@ -1556,7 +1667,7 @@ TAG_MERGE_FUNCS (uint64, guint64, TRUE); * Copies the contents for the given tag into the value, merging multiple values * into one if multiple values are associated with the tag. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ /** @@ -1569,7 +1680,7 @@ TAG_MERGE_FUNCS (uint64, guint64, TRUE); * Gets the value that is at the given index for the given tag in the given * list. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ TAG_MERGE_FUNCS (float, gfloat, TRUE); @@ -1582,7 +1693,7 @@ TAG_MERGE_FUNCS (float, gfloat, TRUE); * Copies the contents for the given tag into the value, merging multiple values * into one if multiple values are associated with the tag. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ /** @@ -1595,7 +1706,7 @@ TAG_MERGE_FUNCS (float, gfloat, TRUE); * Gets the value that is at the given index for the given tag in the given * list. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ TAG_MERGE_FUNCS (double, gdouble, TRUE); @@ -1608,7 +1719,7 @@ TAG_MERGE_FUNCS (double, gdouble, TRUE); * Copies the contents for the given tag into the value, merging multiple values * into one if multiple values are associated with the tag. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ /** @@ -1621,7 +1732,7 @@ TAG_MERGE_FUNCS (double, gdouble, TRUE); * Gets the value that is at the given index for the given tag in the given * list. * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ TAG_MERGE_FUNCS (pointer, gpointer, (*value != NULL)); @@ -1651,12 +1762,12 @@ _gst_strdup0 (const gchar * s) * to retrieve the first string associated with this tag unmodified. * * The resulting string in @value will be in UTF-8 encoding and should be - * freed by the caller using g_free when no longer needed. Since 0.10.24 the - * returned string is also guaranteed to be non-NULL and non-empty. + * freed by the caller using g_free when no longer needed. The + * returned string is also guaranteed to be non-%NULL and non-empty. * * Free-function: g_free * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ /** @@ -1670,12 +1781,12 @@ _gst_strdup0 (const gchar * s) * list. * * The resulting string in @value will be in UTF-8 encoding and should be - * freed by the caller using g_free when no longer needed. Since 0.10.24 the - * returned string is also guaranteed to be non-NULL and non-empty. + * freed by the caller using g_free when no longer needed. The + * returned string is also guaranteed to be non-%NULL and non-empty. * * Free-function: g_free * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the * given list. */ TAG_MERGE_FUNCS (string, gchar *, (*value != NULL)); @@ -1697,9 +1808,9 @@ TAG_MERGE_FUNCS (string, gchar *, (*value != NULL)); * * The resulting string in @value will be in UTF-8 encoding and doesn't need * to be freed by the caller. The returned string is also guaranteed to - * be non-NULL and non-empty. + * be non-%NULL and non-empty. * - * Returns: TRUE, if a value was set, FALSE if the tag didn't exist in the + * Returns: %TRUE, if a value was set, %FALSE if the tag didn't exist in the * given list. */ gboolean @@ -1731,8 +1842,8 @@ gst_tag_list_peek_string_index (const GstTagList * list, * * Free-function: g_date_free * - * Returns: TRUE, if a date was copied, FALSE if the tag didn't exist in the - * given list or if it was #NULL. + * Returns: %TRUE, if a date was copied, %FALSE if the tag didn't exist in the + * given list or if it was %NULL. */ gboolean gst_tag_list_get_date (const GstTagList * list, const gchar * tag, @@ -1764,8 +1875,8 @@ gst_tag_list_get_date (const GstTagList * list, const gchar * tag, * * Free-function: g_date_free * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the - * given list or if it was #NULL. + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the + * given list or if it was %NULL. */ gboolean gst_tag_list_get_date_index (const GstTagList * list, @@ -1796,10 +1907,8 @@ gst_tag_list_get_date_index (const GstTagList * list, * * Free-function: gst_date_time_unref * - * Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in - * thegiven list or if it was #NULL. - * - * Since: 0.10.31 + * Returns: %TRUE, if a datetime was copied, %FALSE if the tag didn't exist in + * the given list or if it was %NULL. */ gboolean gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag, @@ -1834,10 +1943,8 @@ gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag, * * Free-function: gst_date_time_unref * - * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the - * given list or if it was #NULL. - * - * Since: 0.10.31 + * Returns: %TRUE, if a value was copied, %FALSE if the tag didn't exist in the + * given list or if it was %NULL. */ gboolean gst_tag_list_get_date_time_index (const GstTagList * list, @@ -1856,71 +1963,71 @@ gst_tag_list_get_date_time_index (const GstTagList * list, } /** - * gst_tag_list_get_buffer: + * gst_tag_list_get_sample: * @list: a #GstTagList to get the tag from * @tag: tag to read out - * @value: (out callee-allocates) (transfer full): address of a GstBuffer + * @sample: (out callee-allocates) (transfer full): address of a GstSample * pointer variable to store the result into * - * Copies the first buffer for the given tag in the taglist into the variable - * pointed to by @value. Free the buffer with gst_buffer_unref() when it is - * no longer needed. - * - * Free-function: gst_buffer_unref + * Copies the first sample for the given tag in the taglist into the variable + * pointed to by @sample. Free the sample with gst_sample_unref() when it is + * no longer needed. You can retrieve the buffer from the sample using + * gst_sample_get_buffer() and the associated caps (if any) with + * gst_sample_get_caps(). * - * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the - * given list or if it was #NULL. + * Free-function: gst_sample_unref * - * Since: 0.10.23 + * Returns: %TRUE, if a sample was returned, %FALSE if the tag didn't exist in + * the given list or if it was %NULL. */ gboolean -gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag, - GstBuffer ** value) +gst_tag_list_get_sample (const GstTagList * list, const gchar * tag, + GstSample ** sample) { GValue v = { 0, }; g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); g_return_val_if_fail (tag != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); + g_return_val_if_fail (sample != NULL, FALSE); if (!gst_tag_list_copy_value (&v, list, tag)) return FALSE; - *value = g_value_dup_boxed (&v); + *sample = g_value_dup_boxed (&v); g_value_unset (&v); - return (*value != NULL); + return (*sample != NULL); } /** - * gst_tag_list_get_buffer_index: + * gst_tag_list_get_sample_index: * @list: a #GstTagList to get the tag from * @tag: tag to read out * @index: number of entry to read out - * @value: (out callee-allocates) (transfer full): address of a GstBuffer + * @sample: (out callee-allocates) (transfer full): address of a GstSample * pointer variable to store the result into * - * Gets the buffer that is at the given index for the given tag in the given - * list and copies it into the variable pointed to by @value. Free the buffer - * with gst_buffer_unref() when it is no longer needed. + * Gets the sample that is at the given index for the given tag in the given + * list and copies it into the variable pointed to by @sample. Free the sample + * with gst_sample_unref() when it is no longer needed. You can retrieve the + * buffer from the sample using gst_sample_get_buffer() and the associated + * caps (if any) with gst_sample_get_caps(). * - * Free-function: gst_buffer_unref + * Free-function: gst_sample_unref * - * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the - * given list or if it was #NULL. - * - * Since: 0.10.23 + * Returns: %TRUE, if a sample was copied, %FALSE if the tag didn't exist in the + * given list or if it was %NULL. */ gboolean -gst_tag_list_get_buffer_index (const GstTagList * list, - const gchar * tag, guint index, GstBuffer ** value) +gst_tag_list_get_sample_index (const GstTagList * list, + const gchar * tag, guint index, GstSample ** sample) { const GValue *v; g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); g_return_val_if_fail (tag != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); + g_return_val_if_fail (sample != NULL, FALSE); if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) return FALSE; - *value = g_value_dup_boxed (v); - return (*value != NULL); + *sample = g_value_dup_boxed (v); + return (*sample != NULL); }