1 /* GStreamer non-core tag registration and tag utility functions
2 * Copyright (C) 2005 Ross Burton <ross@burtonini.com>
3 * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
25 #include <gst/gst-i18n-plugin.h>
33 * @short_description: additional tag definitions for plugins and applications
34 * @see_also: #GstTagList
38 * Contains additional standardized GStreamer tag definitions for plugins
39 * and applications, and functions to register them with the GStreamer
47 gst_tag_register_musicbrainz_tags_internal (gpointer unused)
50 GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
52 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
55 gst_tag_register (GST_TAG_MUSICBRAINZ_TRACKID, GST_TAG_FLAG_META,
56 G_TYPE_STRING, _("track ID"), _("MusicBrainz track ID"), NULL);
57 gst_tag_register (GST_TAG_MUSICBRAINZ_ARTISTID, GST_TAG_FLAG_META,
58 G_TYPE_STRING, _("artist ID"), _("MusicBrainz artist ID"), NULL);
59 gst_tag_register (GST_TAG_MUSICBRAINZ_ALBUMID, GST_TAG_FLAG_META,
60 G_TYPE_STRING, _("album ID"), _("MusicBrainz album ID"), NULL);
61 gst_tag_register (GST_TAG_MUSICBRAINZ_ALBUMARTISTID, GST_TAG_FLAG_META,
63 _("album artist ID"), _("MusicBrainz album artist ID"), NULL);
64 gst_tag_register (GST_TAG_MUSICBRAINZ_TRMID, GST_TAG_FLAG_META,
65 G_TYPE_STRING, _("track TRM ID"), _("MusicBrainz TRM ID"), NULL);
66 gst_tag_register (GST_TAG_MUSICBRAINZ_SORTNAME, GST_TAG_FLAG_META,
68 _("artist sortname"), _("MusicBrainz artist sortname"), NULL);
74 * gst_tag_register_musicbrainz_tags
76 * Registers additional musicbrainz-specific tags with the GStreamer tag
77 * system. Plugins and applications that use these tags should call this
78 * function before using them. Can be called multiple times.
81 gst_tag_register_musicbrainz_tags (void)
83 static GOnce mb_once = G_ONCE_INIT;
85 g_once (&mb_once, gst_tag_register_musicbrainz_tags_internal, NULL);
89 register_tag_image_type_enum (GType * id)
91 static const GEnumValue image_types[] = {
92 {GST_TAG_IMAGE_TYPE_UNDEFINED, "GST_TAG_IMAGE_TYPE_UNDEFINED", "undefined"},
93 {GST_TAG_IMAGE_TYPE_FRONT_COVER, "GST_TAG_IMAGE_TYPE_FRONT_COVER",
95 {GST_TAG_IMAGE_TYPE_BACK_COVER, "GST_TAG_IMAGE_TYPE_BACK_COVER",
97 {GST_TAG_IMAGE_TYPE_LEAFLET_PAGE, "GST_TAG_IMAGE_TYPE_LEAFLET_PAGE",
99 {GST_TAG_IMAGE_TYPE_MEDIUM, "GST_TAG_IMAGE_TYPE_MEDIUM", "medium"},
100 {GST_TAG_IMAGE_TYPE_LEAD_ARTIST, "GST_TAG_IMAGE_TYPE_LEAD_ARTIST",
102 {GST_TAG_IMAGE_TYPE_ARTIST, "GST_TAG_IMAGE_TYPE_ARTIST", "artist"},
103 {GST_TAG_IMAGE_TYPE_CONDUCTOR, "GST_TAG_IMAGE_TYPE_CONDUCTOR", "conductor"},
104 {GST_TAG_IMAGE_TYPE_BAND_ORCHESTRA, "GST_TAG_IMAGE_TYPE_BAND_ORCHESTRA",
106 {GST_TAG_IMAGE_TYPE_COMPOSER, "GST_TAG_IMAGE_TYPE_COMPOSER", "composer"},
107 {GST_TAG_IMAGE_TYPE_LYRICIST, "GST_TAG_IMAGE_TYPE_LYRICIST", "lyricist"},
108 {GST_TAG_IMAGE_TYPE_RECORDING_LOCATION,
109 "GST_TAG_IMAGE_TYPE_RECORDING_LOCATION",
110 "recording-location"},
111 {GST_TAG_IMAGE_TYPE_DURING_RECORDING, "GST_TAG_IMAGE_TYPE_DURING_RECORDING",
113 {GST_TAG_IMAGE_TYPE_DURING_PERFORMANCE,
114 "GST_TAG_IMAGE_TYPE_DURING_PERFORMANCE",
115 "during-performance"},
116 {GST_TAG_IMAGE_TYPE_VIDEO_CAPTURE, "GST_TAG_IMAGE_TYPE_VIDEO_CAPTURE",
118 {GST_TAG_IMAGE_TYPE_FISH, "GST_TAG_IMAGE_TYPE_FISH", "fish"},
119 {GST_TAG_IMAGE_TYPE_ILLUSTRATION, "GST_TAG_IMAGE_TYPE_ILLUSTRATION",
121 {GST_TAG_IMAGE_TYPE_BAND_ARTIST_LOGO, "GST_TAG_IMAGE_TYPE_BAND_ARTIST_LOGO",
123 {GST_TAG_IMAGE_TYPE_PUBLISHER_STUDIO_LOGO,
124 "GST_TAG_IMAGE_TYPE_PUBLISHER_STUDIO_LOGO",
125 "publisher-studio-logo"},
129 *id = g_enum_register_static ("GstTagImageType", image_types);
133 gst_tag_image_type_get_type (void)
136 static GOnce once = G_ONCE_INIT;
138 g_once (&once, (GThreadFunc) register_tag_image_type_enum, &id);
143 * gst_tag_parse_extended_comment:
144 * @ext_comment: an extended comment string, see #GST_TAG_EXTENDED_COMMENT
145 * @key: return location for the comment description key, or NULL
146 * @lang: return location for the comment ISO-639 language code, or NULL
147 * @value: return location for the actual comment string, or NULL
148 * @fail_if_no_key: whether to fail if strings are not in key=value form
150 * Convenience function to parse a GST_TAG_EXTENDED_COMMENT string and
151 * separate it into its components.
153 * If successful, @key, @lang and/or @value will be set to newly allocated
154 * strings that you need to free with g_free() when done. @key and @lang
155 * may also be set to NULL by this function if there is no key or no language
156 * code in the extended comment string.
158 * Returns: TRUE if the string could be parsed, otherwise FALSE
163 gst_tag_parse_extended_comment (const gchar * ext_comment, gchar ** key,
164 gchar ** lang, gchar ** value, gboolean fail_if_no_key)
166 const gchar *div, *bop, *bcl;
168 g_return_val_if_fail (ext_comment != NULL, FALSE);
169 g_return_val_if_fail (g_utf8_validate (ext_comment, -1, NULL), FALSE);
176 div = strchr (ext_comment, '=');
177 bop = strchr (ext_comment, '[');
178 bcl = strchr (ext_comment, ']');
184 *value = g_strdup (ext_comment);
188 if (bop != NULL && bop < div) {
189 if (bcl < bop || bcl > div)
192 *key = g_strndup (ext_comment, bop - ext_comment);
194 *lang = g_strndup (bop + 1, bcl - bop - 1);
197 *key = g_strndup (ext_comment, div - ext_comment);
201 *value = g_strdup (div + 1);