From bff11ca735fe3e4926ec571dd481ec6e9f8e95e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 12 Mar 2006 15:02:02 +0000 Subject: ext/taglib/: Add support for writing MusicBrainz IDs. Original commit message from CVS: * ext/taglib/Makefile.am: * ext/taglib/gsttaglib.cc: * ext/taglib/gsttaglib.h: Add support for writing MusicBrainz IDs. --- ChangeLog | 7 +++++ ext/taglib/Makefile.am | 10 +++++-- ext/taglib/gsttaglib.cc | 77 ++++++++++++++++++++++++++++++++++++++++++++++++- ext/taglib/gsttaglib.h | 4 +-- 4 files changed, 93 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9177e563..047ef448 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-12 Tim-Philipp Müller + + * ext/taglib/Makefile.am: + * ext/taglib/gsttaglib.cc: + * ext/taglib/gsttaglib.h: + Add support for writing MusicBrainz IDs. + 2006-03-12 Tim-Philipp Müller * sys/v4l2/gstv4l2element.h: diff --git a/ext/taglib/Makefile.am b/ext/taglib/Makefile.am index 5b83b90c..18c4c084 100644 --- a/ext/taglib/Makefile.am +++ b/ext/taglib/Makefile.am @@ -1,8 +1,14 @@ plugin_LTLIBRARIES = libgsttaglib.la libgsttaglib_la_SOURCES = gsttaglib.cc -libgsttaglib_la_CXXFLAGS = $(GST_CFLAGS) $(TAGLIB_CFLAGS) -libgsttaglib_la_LIBADD = $(GST_LIBS) $(TAGLIB_LIBS) +libgsttaglib_la_CXXFLAGS = \ + $(GST_CFLAGS) \ + $(GST_PLUGINS_BASE_CFLAGS) \ + $(TAGLIB_CFLAGS) +libgsttaglib_la_LIBADD = \ + $(GST_LIBS) \ + $(GST_PLUGINS_BASE_LIBS) -lgsttag-@GST_MAJORMINOR@ \ + $(TAGLIB_LIBS) libgsttaglib_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) noinst_HEADERS = gsttaglib.h diff --git a/ext/taglib/gsttaglib.cc b/ext/taglib/gsttaglib.cc index 781c64da..79cea006 100644 --- a/ext/taglib/gsttaglib.cc +++ b/ext/taglib/gsttaglib.cc @@ -1,4 +1,4 @@ -/* +/* GStreamer taglib-based ID3 muxer * (c) 2006 Christophe Fergeau * * This library is free software; you can redistribute it and/or @@ -24,8 +24,10 @@ #include #include +#include #include #include +#include #include "gsttaglib.h" using namespace TagLib; @@ -144,6 +146,32 @@ gst_tag_lib_mux_init (GstTagLibMux * taglib, taglib->render_tag = TRUE; } +static void +add_one_txxx_musicbrainz_tag (ID3v2::Tag * id3v2tag, const gchar * spec_id, + const gchar * realworld_id, const gchar * id_str) +{ + ID3v2::UserTextIdentificationFrame * frame; + + if (id_str == NULL) + return; + + GST_DEBUG ("Setting %s to %s", GST_STR_NULL (spec_id), id_str); + + if (spec_id) { + frame = new ID3v2::UserTextIdentificationFrame (String::Latin1); + id3v2tag->addFrame (frame); + frame->setDescription (spec_id); + frame->setText (id_str); + } + + if (realworld_id) { + frame = new ID3v2::UserTextIdentificationFrame (String::Latin1); + id3v2tag->addFrame (frame); + frame->setDescription (realworld_id); + frame->setText (id_str); + } +} + static void add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data) { @@ -275,6 +303,51 @@ add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data) g_free (copyright); GST_DEBUG ("Setting copyright to %s", copyright); } + } else if (strcmp (tag, GST_TAG_MUSICBRAINZ_ARTISTID) == 0) { + gchar *id_str; + + if (gst_tag_list_get_string_index (list, tag, 0, &id_str) && id_str) { + add_one_txxx_musicbrainz_tag (id3v2tag, "MusicBrainz Artist Id", + "musicbrainz_artistid", id_str); + g_free (id_str); + } + } else if (strcmp (tag, GST_TAG_MUSICBRAINZ_ALBUMID) == 0) { + gchar *id_str; + + if (gst_tag_list_get_string_index (list, tag, 0, &id_str) && id_str) { + add_one_txxx_musicbrainz_tag (id3v2tag, "MusicBrainz Album Id", + "musicbrainz_albumid", id_str); + g_free (id_str); + } + } else if (strcmp (tag, GST_TAG_MUSICBRAINZ_ALBUMARTISTID) == 0) { + gchar *id_str; + + if (gst_tag_list_get_string_index (list, tag, 0, &id_str) && id_str) { + add_one_txxx_musicbrainz_tag (id3v2tag, "MusicBrainz Album Artist Id", + "musicbrainz_albumartistid", id_str); + g_free (id_str); + } + } else if (strcmp (tag, GST_TAG_MUSICBRAINZ_TRMID) == 0) { + gchar *id_str; + + if (gst_tag_list_get_string_index (list, tag, 0, &id_str) && id_str) { + add_one_txxx_musicbrainz_tag (id3v2tag, "MusicBrainz TRM Id", + "musicbrainz_trmid", id_str); + g_free (id_str); + } + } else if (strcmp (tag, GST_TAG_MUSICBRAINZ_TRACKID) == 0) { + gchar *id_str; + + if (gst_tag_list_get_string_index (list, tag, 0, &id_str) && id_str) { + ID3v2::UniqueFileIdentifierFrame * frame; + + GST_DEBUG ("Setting Musicbrainz Track Id to %s", id_str); + + frame = new ID3v2::UniqueFileIdentifierFrame ("http://musicbrainz.org", + id_str); + id3v2tag->addFrame (frame); + g_free (id_str); + } } else { GST_WARNING ("Unsupported tag: %s", tag); } @@ -451,6 +524,8 @@ plugin_init (GstPlugin * plugin) GST_DEBUG_CATEGORY_INIT (gst_tag_lib_mux_debug, "taglibmux", 0, "ID3 Tag Muxer"); + gst_tag_register_musicbrainz_tags (); + return TRUE; } diff --git a/ext/taglib/gsttaglib.h b/ext/taglib/gsttaglib.h index 1751ee7e..11344d61 100644 --- a/ext/taglib/gsttaglib.h +++ b/ext/taglib/gsttaglib.h @@ -1,4 +1,4 @@ -/* +/* GStreamer taglib-based ID3 muxer * (c) 2006 Christophe Fergeau * * This library is free software; you can redistribute it and/or @@ -51,7 +51,7 @@ typedef struct _GstTagLibMuxClass { (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TAGLIB_MUX,GstTagLibMuxClass)) #define GST_IS_TAGLIB_MUX(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TAGLIB_MUX)) -#define GST_IS_TAGLIB_MUX_CLASS(obj) \ +#define GST_IS_TAGLIB_MUX_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TAGLIB_MUX)) /* Standard function returning type information. */ -- cgit v1.2.1