gst-libs/gst/tag/: Forward-port some tags stuff from the 0.8 branch. This is mostly the addition of musicbrainz tags ...

Original commit message from CVS:
* gst-libs/gst/tag/Makefile.am:
* gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_add):
* gst-libs/gst/tag/tag.h:
* gst-libs/gst/tag/tags.c:
(gst_tag_register_musicbrainz_tags_internal),
(gst_tag_register_musicbrainz_tags):
Forward-port some tags stuff from the 0.8 branch. This is
mostly the addition of musicbrainz tags and their mapping
to vorbistags, and a vorbistag mapping of the language tag.
This commit is contained in:
Tim-Philipp Müller 2006-02-05 14:59:28 +00:00
parent 189cd30822
commit ce175c9953
5 changed files with 140 additions and 7 deletions

View file

@ -1,3 +1,15 @@
2006-02-05 Tim-Philipp Müller <tim at centricular dot net>
* gst-libs/gst/tag/Makefile.am:
* gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_add):
* gst-libs/gst/tag/tag.h:
* gst-libs/gst/tag/tags.c:
(gst_tag_register_musicbrainz_tags_internal),
(gst_tag_register_musicbrainz_tags):
Forward-port some tags stuff from the 0.8 branch. This is
mostly the addition of musicbrainz tags and their mapping
to vorbistags, and a vorbistag mapping of the language tag.
2006-02-05 Julien MOUTTE <julien@moutte.net>
* gst/playback/gstplaybin.c: (gen_text_element): Fix broken code

View file

@ -6,7 +6,7 @@ libgsttaginclude_HEADERS = \
lib_LTLIBRARIES = libgsttag-@GST_MAJORMINOR@.la
libgsttag_@GST_MAJORMINOR@_la_SOURCES = gstvorbistag.c gstid3tag.c
libgsttag_@GST_MAJORMINOR@_la_SOURCES = gstvorbistag.c gstid3tag.c tags.c
libgsttag_@GST_MAJORMINOR@_la_CFLAGS = $(GST_CFLAGS)
libgsttag_@GST_MAJORMINOR@_la_LIBADD = $(GST_LIBS)
libgsttag_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)

View file

@ -50,6 +50,13 @@ static GstTagEntryMatch tag_matches[] = {
{GST_TAG_TRACK_PEAK, "REPLAYGAIN_TRACK_PEAK"},
{GST_TAG_ALBUM_GAIN, "REPLAYGAIN_ALBUM_GAIN"},
{GST_TAG_ALBUM_PEAK, "REPLAYGAIN_ALBUM_PEAK"},
{GST_TAG_MUSICBRAINZ_TRACKID, "MUSICBRAINZ_TRACKID"},
{GST_TAG_MUSICBRAINZ_ARTISTID, "MUSICBRAINZ_ARTISTID"},
{GST_TAG_MUSICBRAINZ_ALBUMID, "MUSICBRAINZ_ALBUMID"},
{GST_TAG_MUSICBRAINZ_ALBUMARTISTID, "MUSICBRAINZ_ALBUMARTISTID"},
{GST_TAG_MUSICBRAINZ_TRMID, "MUSICBRAINZ_TRMID"},
{GST_TAG_MUSICBRAINZ_SORTNAME, "MUSICBRAINZ_SORTNAME"},
{GST_TAG_LANGUAGE_CODE, "LANGUAGE"},
{NULL, NULL}
};
@ -146,13 +153,24 @@ gst_vorbis_tag_add (GstTagList * list, const gchar * tag, const gchar * value)
break;
}
case G_TYPE_STRING:{
gchar *valid;
gchar *valid = NULL;
if (!g_utf8_validate (value, -1, (const gchar **) &valid)) {
valid = g_strndup (value, valid - value);
GST_DEBUG ("Invalid vorbis comment tag, truncated it to %s\n", valid);
} else {
valid = g_strdup (value);
/* specialcase for language code */
if (strcmp (tag, "LANGUAGE") == 0) {
const gchar *s = strchr (value, '[');
if (s && strchr (s, ']') == s + 4) {
valid = g_strndup (s + 1, 3);
}
}
if (!valid) {
if (!g_utf8_validate (value, -1, (const gchar **) &valid)) {
valid = g_strndup (value, valid - value);
GST_DEBUG ("Invalid vorbis comment tag, truncated it to %s", valid);
} else {
valid = g_strdup (value);
}
}
gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, valid, NULL);
g_free (valid);

View file

@ -25,6 +25,45 @@
G_BEGIN_DECLS
/* Tag names */
/**
* GST_TAG_MUSICBRAINZ_TRACKID
*
* MusicBrainz track ID
*/
#define GST_TAG_MUSICBRAINZ_TRACKID "musicbrainz-trackid"
/**
* GST_TAG_MUSICBRAINZ_ARTISTID
*
* MusicBrainz artist ID
*/
#define GST_TAG_MUSICBRAINZ_ARTISTID "musicbrainz-artistid"
/**
* GST_TAG_MUSICBRAINZ_ALBUMID
*
* MusicBrainz album ID
*/
#define GST_TAG_MUSICBRAINZ_ALBUMID "musicbrainz-albumid"
/**
* GST_TAG_MUSICBRAINZ_ALBUMARTISTID
*
* MusicBrainz album artist ID
*/
#define GST_TAG_MUSICBRAINZ_ALBUMARTISTID "musicbrainz-albumartistid"
/**
* GST_TAG_MUSICBRAINZ_TRMID
*
* MusicBrainz track TRM ID
*/
#define GST_TAG_MUSICBRAINZ_TRMID "musicbrainz-trmid"
/**
* GST_TAG_MUSICBRAINZ_SORTNAME
*
* MusicBrainz artist sort name
*/
#define GST_TAG_MUSICBRAINZ_SORTNAME "musicbrainz-sortname"
/* functions for vorbis comment manipulation */
@ -56,6 +95,7 @@ GstTagList * gst_tag_list_new_from_id3v1 (const guint8 *
G_CONST_RETURN gchar * gst_tag_from_id3_tag (const gchar * vorbis_tag);
G_CONST_RETURN gchar * gst_tag_to_id3_tag (const gchar * gst_tag);
void gst_tag_register_musicbrainz_tags (void);
G_END_DECLS

63
gst-libs/gst/tag/tags.c Normal file
View file

@ -0,0 +1,63 @@
/* GStreamer
* Copyright (C) 2005 Ross Burton <ross@burtonini.com>
*
* tags.c: Non-core tag registration
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst-i18n-plugin.h>
#include <gst/gst.h>
#include "tag.h"
static gpointer
gst_tag_register_musicbrainz_tags_internal (gpointer unused)
{
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif
gst_tag_register (GST_TAG_MUSICBRAINZ_TRACKID, GST_TAG_FLAG_META,
G_TYPE_STRING, _("track ID"), _("MusicBrainz track ID"), NULL);
gst_tag_register (GST_TAG_MUSICBRAINZ_ARTISTID, GST_TAG_FLAG_META,
G_TYPE_STRING, _("artist ID"), _("MusicBrainz artist ID"), NULL);
gst_tag_register (GST_TAG_MUSICBRAINZ_ALBUMID, GST_TAG_FLAG_META,
G_TYPE_STRING, _("album ID"), _("MusicBrainz album ID"), NULL);
gst_tag_register (GST_TAG_MUSICBRAINZ_ALBUMARTISTID, GST_TAG_FLAG_META,
G_TYPE_STRING,
_("album artist ID"), _("MusicBrainz album artist ID"), NULL);
gst_tag_register (GST_TAG_MUSICBRAINZ_TRMID, GST_TAG_FLAG_META,
G_TYPE_STRING, _("track TRM ID"), _("MusicBrainz TRM ID"), NULL);
gst_tag_register (GST_TAG_MUSICBRAINZ_SORTNAME, GST_TAG_FLAG_META,
G_TYPE_STRING,
_("artist sortname"), _("MusicBrainz artist sortname"), NULL);
return NULL;
}
void
gst_tag_register_musicbrainz_tags (void)
{
static GOnce mb_once = G_ONCE_INIT;
g_once (&mb_once, gst_tag_register_musicbrainz_tags_internal, NULL);
}