[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-cvs
Subject:    gst-plugins-base: ext/taglib/: Add support for writing MusicBrainz
From:       tpm () kemper ! freedesktop ! org (Tim Müller)
Date:       2011-07-29 18:40:03
Message-ID: 20110729184003.352BAD8004 () kemper ! freedesktop ! org
[Download RAW message or body]

Module: gst-plugins-base
Branch: master
Commit: eca34e3cf90b4d2bae5b05194f1fa55eb66b49c4
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=eca34e3cf90b4d2bae5b05194f1fa55eb66b49c4


Author: Tim-Philipp Müller <tim@centricular.net>
Date:   Sun Mar 12 15:02:02 2006 +0000

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.

---

 gst-libs/gst/tag/gsttagmux.c |   77 +++++++++++++++++++++++++++++++++++++++++-
 gst-libs/gst/tag/gsttagmux.h |    4 +-
 2 files changed, 78 insertions(+), 3 deletions(-)

diff --git a/gst-libs/gst/tag/gsttagmux.c b/gst-libs/gst/tag/gsttagmux.c
index 781c64d..79cea00 100644
--- a/gst-libs/gst/tag/gsttagmux.c
+++ b/gst-libs/gst/tag/gsttagmux.c
@@ -1,4 +1,4 @@
-/*
+/* GStreamer taglib-based ID3 muxer
  * (c) 2006 Christophe Fergeau  <teuf@gnome.org>
  *
  * This library is free software; you can redistribute it and/or
@@ -24,8 +24,10 @@
 
 #include <string.h>
 #include <textidentificationframe.h>
+#include <uniquefileidentifierframe.h>
 #include <id3v2tag.h>
 #include <gst/gsttagsetter.h>
+#include <gst/tag/tag.h>
 #include "gsttaglib.h"
 
 using namespace TagLib;
@@ -145,6 +147,32 @@ gst_tag_lib_mux_init (GstTagLibMux * taglib,
 }
 
 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)
 {
   ID3v2::Tag * id3v2tag = (ID3v2::Tag *) 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/gst-libs/gst/tag/gsttagmux.h b/gst-libs/gst/tag/gsttagmux.h
index 1751ee7..11344d6 100644
--- a/gst-libs/gst/tag/gsttagmux.h
+++ b/gst-libs/gst/tag/gsttagmux.h
@@ -1,4 +1,4 @@
-/*
+/* GStreamer taglib-based ID3 muxer
  * (c) 2006 Christophe Fergeau  <teuf@gnome.org>
  *
  * 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. */



_______________________________________________
gstreamer-commits mailing list
gstreamer-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic