[easytag/wip/taglib-mp4-cxx: 2/2] MP4 TagLib C++ WIP
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/taglib-mp4-cxx: 2/2] MP4 TagLib C++ WIP
- Date: Sat, 19 Apr 2014 09:20:35 +0000 (UTC)
commit 7eb661810efa7ba979d4601055697b3d5c949ec0
Author: David King <amigadave amigadave com>
Date: Sat Mar 15 10:33:48 2014 +0000
MP4 TagLib C++ WIP
configure.ac | 2 +-
src/easytag.c | 12 +++++-----
src/mp4_tag.cc | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 64 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7fe6699..86d3b85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -257,7 +257,7 @@ dnl ################################################
dnl # taglib library
dnl ################################################
-TAGLIB_DEPS="taglib >= 1.6.0"
+TAGLIB_DEPS="taglib >= 1.6.0 taglib_c"
AS_IF([test "x$enable_mp4" != "xno"],
[PKG_CHECK_EXISTS([$TAGLIB_DEPS], [have_taglib=yes], [have_taglib=no])],
[have_taglib=no])
diff --git a/src/easytag.c b/src/easytag.c
index 7612a55..05a6998 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -4108,16 +4108,16 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
case MP4_TAG:
gtk_widget_hide(GTK_WIDGET(DiscNumberLabel));
gtk_widget_hide(GTK_WIDGET(DiscNumberEntry));
- gtk_widget_hide(GTK_WIDGET(ComposerLabel));
- gtk_widget_hide(GTK_WIDGET(ComposerEntry));
+ gtk_widget_show (GTK_WIDGET (ComposerLabel));
+ gtk_widget_show (GTK_WIDGET (ComposerEntry));
gtk_widget_hide(GTK_WIDGET(OrigArtistLabel));
gtk_widget_hide(GTK_WIDGET(OrigArtistEntry));
- gtk_widget_hide(GTK_WIDGET(CopyrightLabel));
- gtk_widget_hide(GTK_WIDGET(CopyrightEntry));
+ gtk_widget_show (GTK_WIDGET (CopyrightLabel));
+ gtk_widget_show (GTK_WIDGET (CopyrightEntry));
gtk_widget_hide(GTK_WIDGET(URLLabel));
gtk_widget_hide(GTK_WIDGET(URLEntry));
- gtk_widget_hide(GTK_WIDGET(EncodedByLabel));
- gtk_widget_hide(GTK_WIDGET(EncodedByEntry));
+ gtk_widget_show (GTK_WIDGET (EncodedByLabel));
+ gtk_widget_show (GTK_WIDGET (EncodedByEntry));
et_tag_notebook_hide_images_tab (TagNoteBook);
break;
#endif
diff --git a/src/mp4_tag.cc b/src/mp4_tag.cc
index 37d2a02..2bd871b 100644
--- a/src/mp4_tag.cc
+++ b/src/mp4_tag.cc
@@ -38,6 +38,8 @@
#include "charset.h"
#include <mp4file.h>
+#include <mp4tag.h>
+#include <tmap.h>
extern "C" {
@@ -53,7 +55,7 @@ extern "C" {
*/
gboolean Mp4tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
{
- TagLib::Tag *tag;
+ TagLib::MP4::Tag *tag;
guint track;
g_return_val_if_fail (filename != NULL && FileTag != NULL, FALSE);
@@ -94,10 +96,24 @@ gboolean Mp4tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
*********/
FileTag->album = g_strdup (tag->title ().toCString (true));
+ const TagLib::MP4::ItemListMap extra_tag = tag->itemListMap ();
+
/****************
* Album Artist *
****************/
- /* TODO: No album artist or disc number support in the TagLib C API! */
+ if (extra_tag.contains ("ALBUMARTIST"))
+ {
+ const TagLib::MP4::Item album_artist = extra_tag["ALBUMARTIST"];
+ FileTag->album_artist = g_strdup (album_artist.toStringList ().front ().toCString (true));
+ }
+
+ /* Disc number. */
+ /* TODO: Total disc number support. */
+ if (extra_tag.contains ("DISCNUMBER"))
+ {
+ const TagLib::MP4::Item disc_number = extra_tag["DISCNUMBER"];
+ FileTag->disc_number = et_disc_number_to_string (disc_number.toStringList ().front ().toInt ());
+ }
/********
* Year *
@@ -126,12 +142,27 @@ gboolean Mp4tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
/**********************
* Composer or Writer *
**********************/
- /* TODO: No composer support in the TagLib C API! */
+ if (extra_tag.contains ("COMPOSER"))
+ {
+ const TagLib::MP4::Item composer = extra_tag["COMPOSER"];
+ FileTag->composer = g_strdup (composer.toStringList ().front ().toCString (true));
+ }
+
+ /* Copyright. */
+ if (extra_tag.contains ("COPYRIGHT"))
+ {
+ const TagLib::MP4::Item copyright = extra_tag["COPYRIGHT"];
+ FileTag->copyright = g_strdup (copyright.toStringList ().front ().toCString (true));
+ }
/*****************
* Encoding Tool *
*****************/
- /* TODO: No encode_by support in the TagLib C API! */
+ if (extra_tag.contains ("ENCODEDBY"))
+ {
+ const TagLib::MP4::Item encodedby = extra_tag["ENCODEDBY"];
+ FileTag->encoded_by = g_strdup (encodedby.toStringList ().front ().toCString (true));
+ }
/***********
* Picture *
@@ -224,6 +255,7 @@ gboolean Mp4tag_Write_File_Tag (ET_File *ETFile)
if (FileTag->track)
{
tag->setTrack (atoi (FileTag->track));
+ /* TODO: Total track support. */
}
/*********
@@ -244,18 +276,39 @@ gboolean Mp4tag_Write_File_Tag (ET_File *ETFile)
tag->setComment (string);
}
+ TagLib::MP4::ItemListMap extra_tag;
+
/**********************
* Composer or Writer *
**********************/
+ if (FileTag->composer && *(FileTag->composer))
+ {
+ TagLib::String string (FileTag->composer, TagLib::String::UTF8);
+ extra_tag.insert ("COMPOSER", TagLib::MP4::Item (string));
+ }
+
+ /* Copyright. */
+ if (FileTag->copyright && *(FileTag->copyright))
+ {
+ TagLib::String string (FileTag->copyright, TagLib::String::UTF8);
+ extra_tag.insert ("COPYRIGHT", TagLib::MP4::Item (string));
+ }
/*****************
* Encoding Tool *
*****************/
+ if (FileTag->encoded_by && *(FileTag->encoded_by))
+ {
+ TagLib::String string (FileTag->composer, TagLib::String::UTF8);
+ extra_tag.insert ("ENCODEDBY", TagLib::MP4::Item (string));
+ }
/***********
* Picture *
***********/
+ /* FIXME: Add support to TagLib. */
+ tag->setProperties (extra_tag);
success = mp4file.save () ? TRUE : FALSE;
return success;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]