diff -rupN ./easytag-1.99.7/config.h.in ./easytag-1.99.7-mpeg4/config.h.in --- ./easytag-1.99.7/config.h.in 2004-07-01 17:19:53.000000000 -0400 +++ ./easytag-1.99.7-mpeg4/config.h.in 2005-08-07 09:03:22.444032216 -0400 @@ -29,6 +29,9 @@ /* Define for Ogg Vorbis support */ #undef ENABLE_OGG +/* Define for MPEG4 support */ +#undef ENABLE_MPEG4 + /* Package name for gettext */ #undef GETTEXT_PACKAGE diff -rupN ./easytag-1.99.7/configure.in ./easytag-1.99.7-mpeg4/configure.in --- ./easytag-1.99.7/configure.in 2005-06-25 17:25:54.000000000 -0400 +++ ./easytag-1.99.7-mpeg4/configure.in 2005-08-07 08:55:21.889087672 -0400 @@ -41,6 +41,10 @@ AC_ARG_ENABLE(flac, AC_HELP_STRING([--disable-flac],[Disable support for FLAC files (default=enabled)]), , enable_flac=yes) +AC_ARG_ENABLE(mpeg4, + AC_HELP_STRING([--disable-mpeg4],[Disable support for MPEG4 files (default=enabled)]), + , enable_mpeg4=yes) + dnl ------------------------------- dnl Checks for libraries. dnl ------------------------------- @@ -191,6 +195,30 @@ AC_DEFINE_UNQUOTED(ID3LIB_MAJOR, $ID3LIB AC_DEFINE_UNQUOTED(ID3LIB_MINOR, $ID3LIB_MINOR, [id3lib minor version]) AC_DEFINE_UNQUOTED(ID3LIB_PATCH, $ID3LIB_PATCH, [id3lib patch level]) +dnl MPEG4IP Libraries +if test "x$enable_mpeg4" = "xyes" -o "x$enable_mpeg4" = "xyes"; then + AC_CHECK_LIB(mp4v2, MP4Read, , mpeg4_available=no) +fi + +AC_MSG_CHECKING(for MPEG4 file support) +if test "x$enable_mpeg4" = "xyes"; then + if test "x$mpeg4_available" = "xno"; then + AC_MSG_RESULT(no) + enable_ogg="no" + echo "***" + echo "*** Warning: MPEG4 file support disabled" + echo "*** (Install MPEG4IP tools to enable it)" + echo "***" + else + AC_MSG_RESULT(yes) + AC_DEFINE(ENABLE_MPEG4,1,[Define for MPEG4 support]) + fi +else + echo "***" + echo "*** MPEG4 file support disabled on commandline" + echo "*** (Install MPEG4IP tools, and use --enable-mpeg4 to enable it)" + echo "***" +fi dnl Use -Wall if we have gcc. changequote(,)dnl @@ -272,6 +300,7 @@ Configuration for $PACKAGE $VERSION : NLS/gettext .............: $USE_NLS Ogg Vorbis file support .: $enable_ogg FLAC file support .......: $enable_flac $LIBFLAC_VERSION + MPEG4 file support ......: $enable_mpeg4 Install path ............: $prefix Now type 'make' to build $PACKAGE $VERSION, diff -rupN ./easytag-1.99.7/src/et_core.c ./easytag-1.99.7-mpeg4/src/et_core.c --- ./easytag-1.99.7/src/et_core.c 2005-07-05 19:44:34.000000000 -0400 +++ ./easytag-1.99.7-mpeg4/src/et_core.c 2005-08-07 08:59:48.791512336 -0400 @@ -47,6 +47,9 @@ # include "flac_header.h" # include "flac_tag.h" #endif +#ifdef ENABLE_MPEG4 +# include "mp4_tag.h" +#endif #include "bar.h" #include "browser.h" #include "misc.h" @@ -455,6 +458,11 @@ GList *ET_Add_File_To_File_List (gchar * case APE_TAG: Ape_Tag_Read_File_Tag(filename,FileTag); break; +#ifdef ENABLE_MPEG4 + case MP4_TAG: + Mp4tag_Read_File_Tag(filename,FileTag); + break; +#endif case UNKNOWN_TAG: default: g_print("FileTag: Undefined tag type (%d) for file %s\n",ETFileDescription->TagType,filename_utf8); @@ -486,6 +494,11 @@ GList *ET_Add_File_To_File_List (gchar * case MAC_FILE: Mac_Header_Read_File_Info(filename,ETFileInfo); break; +#ifdef ENABLE_MPEG4 + case AAC_FILE: + ET_Read_File_Info(filename,ETFileInfo); // To get at least the file size + break; +#endif case UNKNOWN_FILE: default: g_print("ETFileInfo: Undefined file type (%d) for file %s\n",ETFileDescription->FileType,filename_utf8); @@ -2412,6 +2425,12 @@ void ET_Display_File_Data_To_UI (ET_File gtk_frame_set_label(GTK_FRAME(TagFrame),_("APE Tag")); ET_Display_File_Tag_To_UI(ETFile); break; +#ifdef ENABLE_MPEG4 + case MP4_TAG: + gtk_frame_set_label(GTK_FRAME(TagFrame),_("MP4/M4A/AAC Tag")); + ET_Display_File_Tag_To_UI(ETFile); + break; +#endif case UNKNOWN_TAG: default: gtk_frame_set_label(GTK_FRAME(TagFrame),_("Tag")); @@ -2454,6 +2473,12 @@ void ET_Display_File_Data_To_UI (ET_File gtk_frame_set_label(GTK_FRAME(FileFrame),_("Monkey's Audio File")); Mac_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo); break; +#ifdef ENABLE_MPEG4 + case AAC_FILE: + gtk_frame_set_label(GTK_FRAME(FileFrame),_("AAC/MPEG-4 File")); + Mac_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo); + break; +#endif case UNKNOWN_FILE: default: gtk_frame_set_label(GTK_FRAME(FileFrame),_("File")); @@ -2830,6 +2855,12 @@ void ET_Save_File_Data_From_UI (ET_File ET_Save_File_Tag_From_UI(FileTag); ET_Copy_File_Tag_Item_Other_Field(ETFile,FileTag); break; +#ifdef ENABLE_MPEG4 + case MP4_TAG: + ET_Save_File_Tag_From_UI(FileTag); + ET_Copy_File_Tag_Item_Other_Field(ETFile,FileTag); + break; +#endif case UNKNOWN_TAG: default: g_print("FileTag: Undefined tag type %d for file %s.\n",ETFileDescription->TagType,cur_filename); @@ -3447,6 +3478,11 @@ gboolean ET_Save_File_Tag_To_HD (ET_File case APE_TAG: state = Ape_Tag_Write_File_Tag(ETFile); break; +#ifdef ENABLE_MPEG4 + case MP4_TAG: + state = Mp4tag_Write_File_Tag(ETFile); + break; +#endif case UNKNOWN_TAG: default: g_print("Saving to HD: Undefined function for tag type '%d' (file %s).\n", diff -rupN ./easytag-1.99.7/src/et_core.h ./easytag-1.99.7-mpeg4/src/et_core.h --- ./easytag-1.99.7/src/et_core.h 2005-07-05 19:37:29.000000000 -0400 +++ ./easytag-1.99.7-mpeg4/src/et_core.h 2005-08-07 08:59:42.366489088 -0400 @@ -117,7 +117,7 @@ typedef enum FLAC_FILE, // FLAC (lossless) : .flac .fla MPC_FILE, // MusePack : .mpc .mp+ .mpp MAC_FILE, // Monkey's Audio (lossless) : .ape (.mac) -// AAC_FILE, // AAC audio files : .m4a .m4p + AAC_FILE, // AAC audio files : .m4a .m4p // SPEEX_FILE, // Speech audio files : .spx OFR_FILE, // OptimFROG (lossless) : .ofr .ofs UNKNOWN_FILE @@ -133,6 +133,7 @@ typedef enum OGG_TAG, APE_TAG, FLAC_TAG, + MP4_TAG, UNKNOWN_TAG } ET_Tag_Type; @@ -245,7 +246,7 @@ static const ET_File_Description ETFileD {MPC_FILE, ".mpp", APE_TAG}, // Implemented by Artur Polaczynski {MAC_FILE, ".ape", APE_TAG}, // Implemented by Artur Polaczynski {MAC_FILE, ".mac", APE_TAG}, // Implemented by Artur Polaczynski -// {AAC_FILE, ".m4a", ID3_TAG}, + {AAC_FILE, ".m4a", MP4_TAG}, // {AAC_FILE, ".m4p", ID3_TAG}, // {SPEEX_FILE, ".spx", OGG_TAG}, {OFR_FILE, ".ofr", APE_TAG}, diff -rupN ./easytag-1.99.7/src/Makefile.am ./easytag-1.99.7-mpeg4/src/Makefile.am --- ./easytag-1.99.7/src/Makefile.am 2004-11-21 06:14:03.000000000 -0500 +++ ./easytag-1.99.7-mpeg4/src/Makefile.am 2005-08-07 08:54:28.461209944 -0400 @@ -38,6 +38,8 @@ easytag_SOURCES = \ monkeyaudio_header.h \ mpeg_header.c \ mpeg_header.h \ + mp4_tag.c \ + mp4_tag.h \ musepack_header.c \ musepack_header.h \ msgbox.c \ diff -rupN ./easytag-1.99.7/src/mp4_tag.c ./easytag-1.99.7-mpeg4/src/mp4_tag.c --- ./easytag-1.99.7/src/mp4_tag.c 1969-12-31 19:00:00.000000000 -0500 +++ ./easytag-1.99.7-mpeg4/src/mp4_tag.c 2005-08-07 09:04:09.831828176 -0400 @@ -0,0 +1,228 @@ +/* mp4tag.c - 2001/02/16 */ +/* + * EasyTAG - Tag editor for MP3 and Ogg Vorbis files + * Copyright (C) 2001-2003 Jerome Couderc + * Copyright (C) 2005 Michael Ihde + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* Portions of this code was borrowed from the MPEG4IP tools project */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mp4_tag.h" +#include "picture.h" +#include "easytag.h" +#include "browser.h" +#include "setting.h" +#include "misc.h" +#include "et_core.h" +#include "charset.h" + + +/**************** + * Declarations * + ****************/ + + +/************** + * Prototypes * + **************/ + + +/************* + * Functions * + *************/ + +gboolean Mp4tag_Read_File_Tag (gchar *filename, File_Tag *FileTag) +{ + FILE *file; + MP4FileHandle mp4file = NULL; + uint16_t track, track_total; + + if (!filename || !FileTag) + return FALSE; + + if ( (file=fopen(filename,"r"))==NULL ) + { + gchar *filename_utf8 = filename_to_display(filename); + g_print(_("ERROR while opening file: '%s' (%s).\n\a"),filename_utf8,g_strerror(errno)); + g_free(filename_utf8); + return FALSE; + } + fclose(file); // We close it cause mp4 opens/closes file itself + + /* Get data from tag */ + mp4file = MP4Read(filename, 0); + if (mp4file == MP4_INVALID_FILE_HANDLE) { + g_print(_("Could not open mp4 file '%s'... aborting\n\a"), filename); + return FALSE; + } + + /* TODO Add error detection */ + MP4GetMetadataName(mp4file, &FileTag->title); + MP4GetMetadataArtist(mp4file, &FileTag->artist); + MP4GetMetadataAlbum(mp4file, &FileTag->album); + MP4GetMetadataYear(mp4file, &FileTag->year); + if (MP4GetMetadataTrack(mp4file, &track, &track_total)) { + FileTag->track = g_strdup_printf("%.*d",NUMBER_TRACK_FORMATED_SPIN_BUTTON,track); // Just to have numbers like this : '01', '05', '12', ... + FileTag->track_total = g_strdup_printf("%.*d",NUMBER_TRACK_FORMATED_SPIN_BUTTON,track_total); // Just to have numbers like this : '01', '05', '12', ... + } + MP4GetMetadataGenre(mp4file, &FileTag->genre); + MP4GetMetadataComment(mp4file, &FileTag->comment); + + /* Free allocated data */ + MP4Close(mp4file); + + return TRUE; +} + + +/* + * Write the ID3 tags to the file. Returns TRUE on success, else 0. + */ +gboolean Mp4tag_Write_File_Tag (ET_File *ETFile) +{ + File_Tag *FileTag; + gchar *filename; + FILE *file; + MP4FileHandle mp4file = NULL; + gint error = 0; + gboolean has_title = 1; + gboolean has_artist = 1; + gboolean has_album = 1; + gboolean has_year = 1; + gboolean has_track = 1; + gboolean has_genre = 1; + gboolean has_comment = 1; + gboolean has_song_len = 1; + + if (!ETFile || !ETFile->FileTag) + return FALSE; + + FileTag = (File_Tag *)ETFile->FileTag->data; + filename = ((File_Name *)ETFile->FileNameCur->data)->value; + + /* Test to know if we can write into the file */ + if ( (file=fopen(filename,"r+"))==NULL ) + { + gchar *filename_utf8 = filename_to_display(filename); + g_print(_("ERROR while opening file: '%s' (%s).\n\a"),filename_utf8,g_strerror(errno)); + g_free(filename_utf8); + return FALSE; + } + fclose(file); + + mp4file = MP4Modify(filename,0,0); + if (mp4file == MP4_INVALID_FILE_HANDLE) { + g_print(_("Could not open mp4 file '%s'... aborting\n\a"), filename); + return FALSE; + } + + /********* + * Title * + *********/ + if (FileTag->title && g_utf8_strlen(FileTag->title, -1) > 0) + { + MP4SetMetadataName(mp4file, FileTag->title); + } else + { + has_title = 0; + } + + /********** + * Artist * + **********/ + if (FileTag->artist && g_utf8_strlen(FileTag->artist, -1) > 0) + { + MP4SetMetadataArtist(mp4file, FileTag->artist); + } else + { + has_artist = 0; + } + + /********* + * Album * + *********/ + if (FileTag->album && g_utf8_strlen(FileTag->album, -1) > 0) + { + MP4SetMetadataAlbum(mp4file, FileTag->album); + } else + { + has_album = 0; + } + + /******** + * Year * + ********/ + if (FileTag->year && g_utf8_strlen(FileTag->year, -1) > 0) + { + MP4SetMetadataYear(mp4file, FileTag->year); + } else + { + has_year = 0; + } + + /************************* + * Track and Total Track * + *************************/ + if (FileTag->track && g_utf8_strlen(FileTag->track, -1) > 0) + { + uint16_t track, track_total; + track = atoi(FileTag->track); + track_total = atoi(FileTag->track_total); + MP4SetMetadataTrack(mp4file, track, track_total); + + } else + { + has_track = 0; + } + + /********* + * Genre * + *********/ + if (FileTag->genre && strlen(FileTag->genre)>0 ) + { + MP4SetMetadataGenre(mp4file, FileTag->genre); + } else + { + has_genre = 0; + } + + /*********** + * Comment * + ***********/ + if (FileTag->comment && g_utf8_strlen(FileTag->comment, -1) > 0) + { + MP4SetMetadataComment(mp4file, FileTag->comment); + } else + { + has_comment = 0; + } + + MP4Close(mp4file); + + if (error) return FALSE; + else return TRUE; +} diff -rupN ./easytag-1.99.7/src/mp4_tag.h ./easytag-1.99.7-mpeg4/src/mp4_tag.h --- ./easytag-1.99.7/src/mp4_tag.h 1969-12-31 19:00:00.000000000 -0500 +++ ./easytag-1.99.7-mpeg4/src/mp4_tag.h 2005-08-06 13:44:05.000000000 -0400 @@ -0,0 +1,43 @@ +/* mp4tag.h - 2005/08/06 */ +/* + * EasyTAG - Tag editor for MP3 and Ogg Vorbis files + * Copyright (C) 2001-2003 Jerome Couderc + * Copyright (C) 2005 Michael Ihde + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + +#ifndef __MP4TAG_H__ +#define __MP4TAG_H__ + + +#include +#include "et_core.h" + + +/**************** + * Declarations * + ****************/ + + + +/************** + * Prototypes * + **************/ +gboolean Mp4tag_Read_File_Tag (gchar *filename, File_Tag *FileTag); +gboolean Mp4tag_Write_File_Tag (ET_File *ETFile); + +#endif /* __MP4TAG_H__ */