[easytag/wip/gmodule-mp4v2] WIP Avoid using mp4v2 headers
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/gmodule-mp4v2] WIP Avoid using mp4v2 headers
- Date: Wed, 5 Jun 2013 20:08:55 +0000 (UTC)
commit 76a51dbac61503e510b39704e95d18135e812d80
Author: David King <amigadave amigadave com>
Date: Wed Jun 5 20:40:27 2013 +0100
WIP Avoid using mp4v2 headers
Use custom definitions of the mp4v2 types to avoid including the mp4v2
headers.
configure.ac | 12 +--
src/easytag.c | 2 -
src/et_core.c | 18 +---
src/et_core.h | 2 -
src/mp4_header.c | 42 ++++----
src/mp4_tag.c | 135 ++++++++++++-------------
src/mp4_tag_private.h | 270 ++++++++++++++++++++++++++++++++++++++++---------
7 files changed, 307 insertions(+), 174 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 690b087..c4153b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -237,19 +237,9 @@ AS_IF([test "x$have_mp3" = "xyes" -a "x$enable_id3v23" != "xno"],
[have_id3lib=no])
dnl ################################################
-dnl # libmp4v2 headers
+dnl # libmp4v2 dynamic loader
dnl ################################################
GMODULE_DEPS="gmodule-2.0"
-AS_IF([test "x$enable_mp4" != "xno"],
- [AC_CHECK_HEADER([mp4v2/mp4v2.h], [have_libmp4v2=yes],
- [have_libmp4v2=no])],
- [have_libmp4v2=no])
-
-AS_IF([test "x$have_libmp4v2" != "xno"],
- [AC_DEFINE([ENABLE_MP4], [], [Define for libmp4v2 MP4 support])],
- [GMODULE_DEPS=""
- AS_IF([test "x$enable_mp4" = "xyes"],
- [AC_MSG_ERROR([libmp4v2 support requested but required headers were not found])])])
dnl ################################################
dnl # WavPack library
diff --git a/src/easytag.c b/src/easytag.c
index 2d8243e..13b8f33 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -4004,7 +4004,6 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
gtk_widget_hide (GTK_WIDGET (image_properties_toolitem));
break;
-#ifdef ENABLE_MP4
case MP4_TAG:
gtk_widget_show (GTK_WIDGET (DiscNumberLabel));
gtk_widget_show (GTK_WIDGET (DiscNumberEntry));
@@ -4025,7 +4024,6 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
gtk_widget_show (GTK_WIDGET (save_image_toolitem));
gtk_widget_show (GTK_WIDGET (image_properties_toolitem));
break;
-#endif
#ifdef ENABLE_WAVPACK
case WAVPACK_TAG:
diff --git a/src/et_core.c b/src/et_core.c
index 9c13984..88016f5 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -50,10 +50,8 @@
# include "flac_header.h"
# include "flac_tag.h"
#endif
-#ifdef ENABLE_MP4
-# include "mp4_header.h"
-# include "mp4_tag.h"
-#endif
+#include "mp4_header.h"
+#include "mp4_tag.h"
#ifdef ENABLE_WAVPACK
# include "wavpack_header.h"
# include "wavpack_tag.h"
@@ -515,7 +513,6 @@ GList *ET_Add_File_To_File_List (gchar *filename)
case APE_TAG:
Ape_Tag_Read_File_Tag(filename,FileTag);
break;
-#ifdef ENABLE_MP4
case MP4_TAG:
{
EtMP4Tag *tag = ET_MP4_TAG (g_object_new (ET_TYPE_MP4_TAG,
@@ -532,7 +529,6 @@ GList *ET_Add_File_To_File_List (gchar *filename)
g_object_unref (tag);
}
break;
-#endif
#ifdef ENABLE_WAVPACK
case WAVPACK_TAG:
Wavpack_Tag_Read_File_Tag(filename, FileTag);
@@ -581,7 +577,6 @@ GList *ET_Add_File_To_File_List (gchar *filename)
Wavpack_Header_Read_File_Info(filename, ETFileInfo);
break;
#endif
-#ifdef ENABLE_MP4
case MP4_FILE:
{
EtMP4Tag *tag = ET_MP4_TAG (g_object_new (ET_TYPE_MP4_TAG,
@@ -598,7 +593,6 @@ GList *ET_Add_File_To_File_List (gchar *filename)
g_object_unref (tag);
}
break;
-#endif
case UNKNOWN_FILE:
default:
Log_Print(LOG_ERROR,"ETFileInfo: Undefined file type (%d) for file
%s",ETFileDescription->FileType,filename_utf8);
@@ -2662,12 +2656,10 @@ void ET_Display_File_Data_To_UI (ET_File *ETFile)
gtk_frame_set_label(GTK_FRAME(TagFrame),_("APE Tag"));
ET_Display_File_Tag_To_UI(ETFile);
break;
-#ifdef ENABLE_MP4
case MP4_TAG:
gtk_frame_set_label(GTK_FRAME(TagFrame),_("MP4/M4A/AAC Tag"));
ET_Display_File_Tag_To_UI(ETFile);
break;
-#endif
#ifdef ENABLE_WAVPACK
case WAVPACK_TAG:
gtk_frame_set_label(GTK_FRAME(TagFrame),_("Wavpack Tag"));
@@ -2724,12 +2716,10 @@ void ET_Display_File_Data_To_UI (ET_File *ETFile)
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_MP4
case MP4_FILE:
gtk_frame_set_label(GTK_FRAME(FileFrame),_("MP4/AAC File"));
Mp4_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
break;
-#endif
#ifdef ENABLE_WAVPACK
case WAVPACK_FILE:
gtk_frame_set_label(GTK_FRAME(FileFrame),_("Wavpack File"));
@@ -3210,9 +3200,7 @@ void ET_Save_File_Data_From_UI (ET_File *ETFile)
#ifdef ENABLE_FLAC
case FLAC_TAG:
#endif
-#ifdef ENABLE_MP4
case MP4_TAG:
-#endif
#ifdef ENABLE_WAVPACK
case WAVPACK_TAG:
#endif
@@ -3885,7 +3873,6 @@ gboolean ET_Save_File_Tag_To_HD (ET_File *ETFile)
case APE_TAG:
state = Ape_Tag_Write_File_Tag(ETFile);
break;
-#ifdef ENABLE_MP4
case MP4_TAG:
{
EtMP4Tag *tag = ET_MP4_TAG (g_object_new (ET_TYPE_MP4_TAG,
@@ -3903,7 +3890,6 @@ gboolean ET_Save_File_Tag_To_HD (ET_File *ETFile)
g_object_unref (tag);
}
break;
-#endif
#ifdef ENABLE_WAVPACK
case WAVPACK_TAG:
state = Wavpack_Tag_Write_File_Tag(ETFile);
diff --git a/src/et_core.h b/src/et_core.h
index 8688bb4..549dd5f 100644
--- a/src/et_core.h
+++ b/src/et_core.h
@@ -248,11 +248,9 @@ static const ET_File_Description ETFileDescription[] =
{MAC_FILE, ".mac", APE_TAG}, // Implemented by Artur Polaczynski
{OFR_FILE, ".ofr", APE_TAG},
{OFR_FILE, ".ofs", APE_TAG},
-#ifdef ENABLE_MP4
{MP4_FILE, ".mp4", MP4_TAG}, // Implemented by Michael Ihde
{MP4_FILE, ".m4a", MP4_TAG}, // Implemented by Michael Ihde
{MP4_FILE, ".m4p", MP4_TAG}, // Implemented by Michael Ihde
-#endif
#ifdef ENABLE_WAVPACK
{WAVPACK_FILE, ".wv", WAVPACK_TAG}, // Implemented by Maarten Maathuis
#endif
diff --git a/src/mp4_header.c b/src/mp4_header.c
index 34b6fd5..6f4cb7c 100644
--- a/src/mp4_header.c
+++ b/src/mp4_header.c
@@ -21,8 +21,6 @@
#include <config.h> // For definition of ENABLE_MP4
-#ifdef ENABLE_MP4
-
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <stdio.h>
@@ -39,8 +37,6 @@
#include "charset.h"
#include "mp4_tag_private.h"
-#include <mp4v2/mp4v2.h>
-
/****************
* Declarations *
@@ -48,7 +44,7 @@
static const struct
{
- uint8_t profile;
+ guint8 profile;
const char *format;
const char *subformat;
} MP4AudioProfileToName[] = {
@@ -82,7 +78,7 @@ static const struct
static const struct
{
- uint8_t profile;
+ guint8 profile;
const char *format;
const char *subformat;
} AudioProfileToName[] = {
@@ -121,8 +117,8 @@ static void getType(EtMP4Tag *tag, MP4FileHandle file, MP4TrackId trackId, const
{
EtMP4TagPrivate *priv = tag->priv;
unsigned i;
- const char *media_data_name = priv->mp4v2_gettrackmediadataname (file,
- trackId);
+ const char *media_data_name = priv->mp4v2_get_track_media_data_name (file,
+ trackId);
*format = _("Audio");
*subformat = _("Unknown");
@@ -138,15 +134,16 @@ static void getType(EtMP4Tag *tag, MP4FileHandle file, MP4TrackId trackId, const
*subformat = "AMR-WB";
} else if (strcasecmp(media_data_name, "mp4a") == 0)
{
- u_int8_t type = priv->mp4v2_gettrackesdsobjecttypeid (file, trackId);
+ u_int8_t type = priv->mp4v2_get_track_esds_object_type_id (file,
+ trackId);
if( type == MP4_MPEG4_AUDIO_TYPE )
{
- u_int8_t* pAacConfig = NULL;
- u_int32_t aacConfigLength;
+ guint8* pAacConfig = NULL;
+ guint32 aacConfigLength;
- priv->mp4v2_gettrackesconfiguration (file, trackId, &pAacConfig,
- &aacConfigLength);
+ priv->mp4v2_get_track_es_configuration (file, trackId, &pAacConfig,
+ &aacConfigLength);
if (pAacConfig != NULL)
{
@@ -217,7 +214,7 @@ Mp4_Header_Read_File_Info (EtMP4Tag *tag, const gchar *filename,
}
/* Check for audio track */
- if (priv->mp4v2_getnumberoftracks (file, MP4_AUDIO_TRACK_TYPE, 0) < 1)
+ if (priv->mp4v2_get_n_tracks (file, MP4_AUDIO_TRACK_TYPE, 0) < 1)
{
gchar *filename_utf8 = filename_to_display(filename);
Log_Print(LOG_ERROR,_("ERROR while opening file: '%s' (%s)."),filename_utf8,("Contains no audio
track"));
@@ -227,7 +224,7 @@ Mp4_Header_Read_File_Info (EtMP4Tag *tag, const gchar *filename,
}
/* Get the first track id (index 0) */
- trackId = priv->mp4v2_findtrackid (file, 0, MP4_AUDIO_TRACK_TYPE, 0);
+ trackId = priv->mp4v2_find_track_id (file, 0, MP4_AUDIO_TRACK_TYPE, 0);
/* Get format/subformat */
{
@@ -241,12 +238,13 @@ Mp4_Header_Read_File_Info (EtMP4Tag *tag, const gchar *filename,
ETFileInfo->layer = 14;
ETFileInfo->variable_bitrate = TRUE;
- ETFileInfo->bitrate = priv->mp4v2_gettrackbitrate (file, trackId) / 1000;
- ETFileInfo->samplerate = priv->mp4v2_gettracktimescale (file, trackId);
- ETFileInfo->mode = priv->mp4v2_gettrackaudiochannels (file, trackId);
- ETFileInfo->duration = priv->mp4v2_convertfromtrackduration (file, trackId,
- priv->mp4v2_gettrackduration (file,
trackId),
- MP4_SECS_TIME_SCALE);
+ ETFileInfo->bitrate = priv->mp4v2_get_track_bitrate (file, trackId) / 1000;
+ ETFileInfo->samplerate = priv->mp4v2_get_track_timescale (file, trackId);
+ ETFileInfo->mode = priv->mp4v2_get_track_audio_channels (file, trackId);
+ ETFileInfo->duration = priv->mp4v2_convert_from_track_duration (file,
+ trackId,
+ priv->mp4v2_get_track_duration (file,
trackId),
+ 1 /* TODO: seconds per second? */);
priv->mp4v2_close (file, 0);
return TRUE;
@@ -318,5 +316,3 @@ Mp4_Header_Display_File_Info_To_UI (const gchar *filename,
return TRUE;
}
-
-#endif
diff --git a/src/mp4_tag.c b/src/mp4_tag.c
index 55d504a..ed43d3d 100644
--- a/src/mp4_tag.c
+++ b/src/mp4_tag.c
@@ -23,8 +23,6 @@
/* Portions of this code was borrowed from the MPEG4IP tools project */
#include "config.h" /* For definition of ENABLE_MP4. */
-#ifdef ENABLE_MP4
-
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <stdio.h>
@@ -45,8 +43,6 @@
#include "charset.h"
#include "mp4_tag_private.h"
-#include <mp4v2/mp4v2.h>
-
G_DEFINE_TYPE (EtMP4Tag, et_mp4_tag, G_TYPE_OBJECT);
/**************
@@ -113,34 +109,34 @@ et_mp4_tag_load_symbols (EtMP4Tag *tag)
{ "MP4Read", (gpointer *)&priv->mp4v2_read },
{ "MP4Modify", (gpointer *)&priv->mp4v2_modify },
{ "MP4Close", (gpointer *)&priv->mp4v2_close },
- { "MP4TagsAlloc", (gpointer *)&priv->mp4v2_tagsalloc },
- { "MP4TagsFetch", (gpointer *)&priv->mp4v2_tagsfetch },
- { "MP4TagsFree", (gpointer *)&priv->mp4v2_tagsfree },
- { "MP4TagsStore", (gpointer *)&priv->mp4v2_tagsstore },
- { "MP4TagsSetName", (gpointer *)&priv->mp4v2_tagssetname },
- { "MP4TagsSetArtist", (gpointer *)&priv->mp4v2_tagssetartist },
- { "MP4TagsSetAlbum", (gpointer *)&priv->mp4v2_tagssetalbum },
- { "MP4TagsSetAlbumArtist", (gpointer *)&priv->mp4v2_tagssetalbumartist },
- { "MP4TagsSetDisk", (gpointer *)&priv->mp4v2_tagssetdisk },
- { "MP4TagsSetReleaseDate", (gpointer *)&priv->mp4v2_tagssetreleasedate },
- { "MP4TagsSetTrack", (gpointer *)&priv->mp4v2_tagssettrack },
- { "MP4TagsSetGenre", (gpointer *)&priv->mp4v2_tagssetgenre },
- { "MP4TagsSetComments", (gpointer *)&priv->mp4v2_tagssetcomments },
- { "MP4TagsSetComposer", (gpointer *)&priv->mp4v2_tagssetcomposer },
- { "MP4TagsSetEncodedBy", (gpointer *)&priv->mp4v2_tagssetencodedby },
- { "MP4TagsAddArtwork", (gpointer *)&priv->mp4v2_addartwork },
- { "MP4TagsSetArtwork", (gpointer *)&priv->mp4v2_setartwork },
- { "MP4TagsRemoveArtwork", (gpointer *)&priv->mp4v2_removeartwork },
- { "MP4GetTrackMediaDataName", (gpointer *)&priv->mp4v2_gettrackmediadataname },
- { "MP4GetTrackEsdsObjectTypeId", (gpointer *)&priv->mp4v2_gettrackesdsobjecttypeid },
- { "MP4GetTrackESConfiguration", (gpointer *)&priv->mp4v2_gettrackesconfiguration },
- { "MP4GetNumberOfTracks", (gpointer *)&priv->mp4v2_getnumberoftracks },
- { "MP4FindTrackId", (gpointer *)&priv->mp4v2_findtrackid },
- { "MP4GetTrackBitRate", (gpointer *)&priv->mp4v2_gettrackbitrate },
- { "MP4GetTrackTimeScale", (gpointer *)&priv->mp4v2_gettracktimescale },
- { "MP4GetTrackAudioChannels", (gpointer *)&priv->mp4v2_gettrackaudiochannels },
- { "MP4GetTrackDuration", (gpointer *)&priv->mp4v2_gettrackduration },
- { "MP4ConvertFromTrackDuration", (gpointer *)&priv->mp4v2_convertfromtrackduration },
+ { "MP4TagsAlloc", (gpointer *)&priv->mp4v2_tags_alloc },
+ { "MP4TagsFetch", (gpointer *)&priv->mp4v2_tags_fetch },
+ { "MP4TagsFree", (gpointer *)&priv->mp4v2_tags_free },
+ { "MP4TagsStore", (gpointer *)&priv->mp4v2_tags_store },
+ { "MP4TagsSetName", (gpointer *)&priv->mp4v2_tags_set_title },
+ { "MP4TagsSetArtist", (gpointer *)&priv->mp4v2_tags_set_artist },
+ { "MP4TagsSetAlbum", (gpointer *)&priv->mp4v2_tags_set_album },
+ { "MP4TagsSetAlbumArtist", (gpointer *)&priv->mp4v2_tags_set_album_artist },
+ { "MP4TagsSetDisk", (gpointer *)&priv->mp4v2_tags_set_disk },
+ { "MP4TagsSetReleaseDate", (gpointer *)&priv->mp4v2_tags_set_release_date },
+ { "MP4TagsSetTrack", (gpointer *)&priv->mp4v2_tags_set_track },
+ { "MP4TagsSetGenre", (gpointer *)&priv->mp4v2_tags_set_genre },
+ { "MP4TagsSetComments", (gpointer *)&priv->mp4v2_tags_set_comments },
+ { "MP4TagsSetComposer", (gpointer *)&priv->mp4v2_tags_set_composer },
+ { "MP4TagsSetEncodedBy", (gpointer *)&priv->mp4v2_tags_set_encoded_by },
+ { "MP4TagsAddArtwork", (gpointer *)&priv->mp4v2_tags_add_artwork },
+ { "MP4TagsSetArtwork", (gpointer *)&priv->mp4v2_tags_set_artwork },
+ { "MP4TagsRemoveArtwork", (gpointer *)&priv->mp4v2_tags_remove_artwork },
+ { "MP4GetTrackMediaDataName", (gpointer *)&priv->mp4v2_get_track_media_data_name },
+ { "MP4GetTrackEsdsObjectTypeId", (gpointer *)&priv->mp4v2_get_track_esds_object_type_id },
+ { "MP4GetTrackESConfiguration", (gpointer *)&priv->mp4v2_get_track_es_configuration },
+ { "MP4GetNumberOfTracks", (gpointer *)&priv->mp4v2_get_n_tracks },
+ { "MP4FindTrackId", (gpointer *)&priv->mp4v2_find_track_id },
+ { "MP4GetTrackBitRate", (gpointer *)&priv->mp4v2_get_track_bitrate },
+ { "MP4GetTrackAudioChannels", (gpointer *)&priv->mp4v2_get_track_audio_channels },
+ { "MP4GetTrackTimeScale", (gpointer *)&priv->mp4v2_get_track_timescale },
+ { "MP4GetTrackDuration", (gpointer *)&priv->mp4v2_get_track_duration },
+ { "MP4ConvertFromTrackDuration", (gpointer *)&priv->mp4v2_convert_from_track_duration },
};
for (i = 0; i < G_N_ELEMENTS (symbols); i++)
@@ -225,8 +221,8 @@ Mp4tag_Read_File_Tag (EtMP4Tag *tag, gchar *filename, File_Tag *FileTag)
EtMP4TagPrivate *priv;
MP4FileHandle mp4file = NULL;
const MP4Tags *mp4tags = NULL;
- uint16_t track, track_total;
- uint16_t disk, disktotal;
+ guint16 track, track_total;
+ guint16 disk, disktotal;
Picture *prev_pic = NULL;
gint pic_num;
const MP4TagArtwork *mp4artwork = NULL;
@@ -246,8 +242,8 @@ Mp4tag_Read_File_Tag (EtMP4Tag *tag, gchar *filename, File_Tag *FileTag)
return FALSE;
}
- mp4tags = priv->mp4v2_tagsalloc ();
- if (!priv->mp4v2_tagsfetch (mp4tags, mp4file))
+ mp4tags = priv->mp4v2_tags_alloc ();
+ if (!priv->mp4v2_tags_fetch (mp4tags, mp4file))
{
gchar *filename_utf8 = filename_to_display(filename);
Log_Print(LOG_ERROR,_("ERROR reading tags from file: '%s' (%s)."),filename_utf8,_("MP4 format
invalid"));
@@ -370,7 +366,7 @@ Mp4tag_Read_File_Tag (EtMP4Tag *tag, gchar *filename, File_Tag *FileTag)
/* Free allocated data */
- priv->mp4v2_tagsfree (mp4tags);
+ priv->mp4v2_tags_free (mp4tags);
priv->mp4v2_close (mp4file, 0);
return TRUE;
@@ -422,8 +418,8 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
return FALSE;
}
- mp4tags = priv->mp4v2_tagsalloc ();
- if (!priv->mp4v2_tagsfetch (mp4tags, mp4file))
+ mp4tags = priv->mp4v2_tags_alloc ();
+ if (!priv->mp4v2_tags_fetch (mp4tags, mp4file))
{
Log_Print(LOG_ERROR,_("ERROR reading tags from file: '%s' (%s)."),filename_utf8,_("MP4 format
invalid"));
return FALSE;
@@ -434,10 +430,10 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
*********/
if (FileTag->title && g_utf8_strlen(FileTag->title, -1) > 0)
{
- priv->mp4v2_tagssetname (mp4tags, FileTag->title);
+ priv->mp4v2_tags_set_title (mp4tags, FileTag->title);
}else
{
- priv->mp4v2_tagssetname (mp4tags, "");
+ priv->mp4v2_tags_set_title (mp4tags, "");
}
/**********
@@ -445,10 +441,10 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
**********/
if (FileTag->artist && g_utf8_strlen(FileTag->artist, -1) > 0)
{
- priv->mp4v2_tagssetartist (mp4tags, FileTag->artist);
+ priv->mp4v2_tags_set_artist (mp4tags, FileTag->artist);
}else
{
- priv->mp4v2_tagssetartist (mp4tags, "");
+ priv->mp4v2_tags_set_artist (mp4tags, "");
}
/*********
@@ -456,10 +452,10 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
*********/
if (FileTag->album && g_utf8_strlen(FileTag->album, -1) > 0)
{
- priv->mp4v2_tagssetalbum (mp4tags, FileTag->album);
+ priv->mp4v2_tags_set_album (mp4tags, FileTag->album);
}else
{
- priv->mp4v2_tagssetalbum (mp4tags, "");
+ priv->mp4v2_tags_set_album (mp4tags, "");
}
/****************
@@ -467,10 +463,10 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
****************/
if (FileTag->album_artist && g_utf8_strlen(FileTag->album_artist, -1) > 0)
{
- priv->mp4v2_tagssetalbumartist (mp4tags, FileTag->album_artist);
+ priv->mp4v2_tags_set_album_artist (mp4tags, FileTag->album_artist);
}else
{
- priv->mp4v2_tagssetalbumartist (mp4tags, "");
+ priv->mp4v2_tags_set_album_artist (mp4tags, "");
}
/**********************
@@ -506,17 +502,17 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
mp4disk.total = atoi(FileTag->disc_number_total);
*/
}
- priv->mp4v2_tagssetdisk (mp4tags, &mp4disk);
+ priv->mp4v2_tags_set_disk (mp4tags, &mp4disk);
/********
* Year *
********/
if (FileTag->year && g_utf8_strlen(FileTag->year, -1) > 0)
{
- priv->mp4v2_tagssetreleasedate (mp4tags, FileTag->year);
+ priv->mp4v2_tags_set_release_date (mp4tags, FileTag->year);
}else
{
- priv->mp4v2_tagssetreleasedate (mp4tags, "");
+ priv->mp4v2_tags_set_release_date (mp4tags, "");
}
/*************************
@@ -530,18 +526,18 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
if (FileTag->track_total)
mp4track.total = atoi(FileTag->track_total);
}
- priv->mp4v2_tagssettrack (mp4tags, &mp4track);
+ priv->mp4v2_tags_set_track (mp4tags, &mp4track);
/*********
* Genre *
*********/
if (FileTag->genre && g_utf8_strlen(FileTag->genre, -1) > 0 )
{
- priv->mp4v2_tagssetgenre (mp4tags, FileTag->genre);
+ priv->mp4v2_tags_set_genre (mp4tags, FileTag->genre);
}else
{
//MP4DeleteMetadataGenre(mp4tags);
- priv->mp4v2_tagssetgenre (mp4tags, "");
+ priv->mp4v2_tags_set_genre (mp4tags, "");
}
/***********
@@ -549,10 +545,10 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
***********/
if (FileTag->comment && g_utf8_strlen(FileTag->comment, -1) > 0)
{
- priv->mp4v2_tagssetcomments (mp4tags, FileTag->comment);
+ priv->mp4v2_tags_set_comments (mp4tags, FileTag->comment);
}else
{
- priv->mp4v2_tagssetcomments (mp4tags, "");
+ priv->mp4v2_tags_set_comments (mp4tags, "");
}
/**********************
@@ -560,10 +556,10 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
**********************/
if (FileTag->composer && g_utf8_strlen(FileTag->composer, -1) > 0)
{
- priv->mp4v2_tagssetcomposer (mp4tags, FileTag->composer);
+ priv->mp4v2_tags_set_composer (mp4tags, FileTag->composer);
}else
{
- priv->mp4v2_tagssetcomposer (mp4tags, "");
+ priv->mp4v2_tags_set_composer (mp4tags, "");
}
/*****************
@@ -571,10 +567,10 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
*****************/
if (FileTag->encoded_by && g_utf8_strlen(FileTag->encoded_by, -1) > 0)
{
- priv->mp4v2_tagssetencodedby (mp4tags, FileTag->encoded_by);
+ priv->mp4v2_tags_set_encoded_by (mp4tags, FileTag->encoded_by);
}else
{
- priv->mp4v2_tagssetencodedby (mp4tags, "");
+ priv->mp4v2_tags_set_encoded_by (mp4tags, "");
}
/***********
@@ -584,8 +580,8 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
// Can handle only one picture...
Picture *pic;
if (mp4tags->artworkCount && mp4tags->artwork)
- priv->mp4v2_removeartwork (mp4tags, 0);
- priv->mp4v2_setartwork (mp4tags, 0, NULL);
+ priv->mp4v2_tags_remove_artwork (mp4tags, 0);
+ priv->mp4v2_tags_set_artwork (mp4tags, 0, NULL);
for (pic = FileTag->picture; pic; pic = pic->next)
{
if (pic->type == ET_PICTURE_TYPE_FRONT_COVER)
@@ -594,29 +590,26 @@ Mp4tag_Write_File_Tag (EtMP4Tag *tag, ET_File *ETFile)
mp4artwork.size = pic->size;
switch (pic->type) {
case PICTURE_FORMAT_JPEG:
- mp4artwork.type = MP4_ART_JPEG;
+ mp4artwork.type = MP4_TAG_ARTWORK_TYPE_JPEG;
break;
case PICTURE_FORMAT_PNG:
- mp4artwork.type = MP4_ART_PNG;
+ mp4artwork.type = MP4_TAG_ARTWORK_TYPE_PNG;
break;
default:
- mp4artwork.type = MP4_ART_UNDEFINED;
+ mp4artwork.type = MP4_TAG_ARTWORK_TYPE_UNDEFINED;
}
if (mp4tags->artworkCount)
- priv->mp4v2_setartwork (mp4tags, 0, &mp4artwork);
+ priv->mp4v2_tags_set_artwork (mp4tags, 0, &mp4artwork);
else
- priv->mp4v2_addartwork (mp4tags, &mp4artwork);
+ priv->mp4v2_tags_add_artwork (mp4tags, &mp4artwork);
}
}
}
- priv->mp4v2_tagsstore (mp4tags, mp4file);
- priv->mp4v2_tagsfree (mp4tags);
+ priv->mp4v2_tags_store (mp4tags, mp4file);
+ priv->mp4v2_tags_free (mp4tags);
priv->mp4v2_close (mp4file, 0);
if (error) return FALSE;
else return TRUE;
}
-
-
-#endif /* ENABLE_MP4 */
diff --git a/src/mp4_tag_private.h b/src/mp4_tag_private.h
index 7515511..11a7373 100644
--- a/src/mp4_tag_private.h
+++ b/src/mp4_tag_private.h
@@ -17,7 +17,199 @@
*/
#include <glib.h>
-#include <mp4v2/mp4v2.h>
+
+typedef enum
+{
+ MP4_TAG_ARTWORK_TYPE_UNDEFINED,
+ MP4_TAG_ARTWORK_TYPE_BMP,
+ MP4_TAG_ARTWORK_TYPE_GIF,
+ MP4_TAG_ARTWORK_TYPE_JPEG,
+ MP4_TAG_ARTWORK_TYPE_PNG
+} MP4TagArtworkType;
+
+typedef enum
+{
+ MP4_MPEG4_INVALID_AUDIO_TYPE,
+ MP4_MPEG4_AAC_MAIN_AUDIO_TYPE,
+ MP4_MPEG4_AAC_LC_AUDIO_TYPE,
+ MP4_MPEG4_AAC_SSR_AUDIO_TYPE,
+ MP4_MPEG4_AAC_LTP_AUDIO_TYPE,
+ MP4_MPEG4_AAC_HE_AUDIO_TYPE,
+ MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE,
+ MP4_MPEG4_TWINVQ_AUDIO_TYPE, /* Not in mp4v2. */
+ MP4_MPEG4_CELP_AUDIO_TYPE,
+ MP4_MPEG4_HVXC_AUDIO_TYPE,
+ /* 10, 11 unused. */
+ MP4_MPEG4_TTSI_AUDIO_TYPE = 12,
+ MP4_MPEG4_MAIN_SYNTHETIC_AUDIO_TYPE,
+ MP4_MPEG4_WAVETABLE_AUDIO_TYPE,
+ MP4_MPEG4_MIDI_AUDIO_TYPE,
+ MP4_MPEG4_ALGORITHMIC_FX_AUDIO_TYPE,
+ MP4_MPEG4_AUDIO_TYPE = 64
+} MP4AudioType;
+
+typedef enum
+{
+ MP4_MPEG2_AAC_MAIN_AUDIO_TYPE = 102,
+ MP4_MPEG2_AAC_LC_AUDIO_TYPE = 103,
+ MP4_MPEG2_AAC_SSR_AUDIO_TYPE = 104,
+ MP4_MPEG2_AUDIO_TYPE = 105,
+ MP4_MPEG1_AUDIO_TYPE = 107,
+ // mpeg4ip's private definitions
+ MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE = 224,
+ MP4_VORBIS_AUDIO_TYPE = 225,
+ MP4_ALAW_AUDIO_TYPE = 227,
+ MP4_ULAW_AUDIO_TYPE = 228,
+ MP4_G723_AUDIO_TYPE = 229,
+ MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE = 230
+} MP4ProfileType;
+
+/* Typedefs for calling into libmp4v2. */
+typedef gpointer MP4FileHandle;
+typedef guint32 MP4TrackId;
+typedef guint64 MP4Duration;
+
+#define MP4_INVALID_FILE_HANDLE ((MP4FileHandle)NULL)
+#define MP4_AUDIO_TRACK_TYPE "soun"
+
+typedef struct
+{
+ gpointer data;
+ guint32 size;
+ MP4TagArtworkType type;
+} MP4TagArtwork;
+
+typedef struct
+{
+ guint16 index;
+ guint16 total;
+} MP4TagDisk;
+
+typedef struct
+{
+ guint16 index;
+ guint16 total;
+} MP4TagTrack;
+
+typedef struct
+{
+ void *handle;
+ const gchar *name;
+ const gchar *artist;
+ const gchar *albumArtist;
+ const gchar *album;
+ const gchar *grouping;
+ const gchar *composer;
+ const gchar *comments;
+ const gchar *genre;
+ const guint16 *genreType;
+ const char *releaseDate;
+ const MP4TagTrack *track;
+ const MP4TagDisk *disk;
+ const guint16 *tempo;
+ const guint8 *compilation;
+ const gchar *tvShow;
+ const gchar *tvNetwork;
+ const gchar *tvEpisodeID;
+ const guint32 *tvSeason;
+ const guint32 *tvEpisode;
+ const gchar *description;
+ const gchar *longDescription;
+ const gchar *lyrics;
+ const gchar *sortName;
+ const gchar *sortArtist;
+ const gchar *sortAlbumArtist;
+ const gchar *sortAlbum;
+ const gchar *sortComposer;
+ const gchar *sortTVShow;
+ const MP4TagArtwork *artwork;
+ guint32 artworkCount;
+ const gchar *copyright;
+ const gchar *encodingTool;
+ const gchar *encodedBy;
+ const gchar *purchaseDate;
+ const guint8 *podcast;
+ const gchar *keywords;
+ const gchar *category;
+ const guint8 *hdVideo;
+ const guint8 *mediaType;
+ const guint8 *contentRating;
+ const guint8 *gapless;
+ const gchar *iTunesAccount;
+ const guint8 *iTunesAccountType;
+ const guint32 *iTunesCountry;
+ const guint32 *contentID;
+ const guint32 *artistID;
+ const guint64 *playlistID;
+ const guint32 *genreID;
+ const guint32 *composerID;
+ const gchar *xid;
+} MP4Tags;
+
+typedef MP4FileHandle (*_mp4v2_read) (const gchar *filename);
+typedef MP4FileHandle (*_mp4v2_modify) (const gchar *filename, guint32 flags);
+typedef void (*_mp4v2_close) (MP4FileHandle handle, guint32 flags);
+typedef const MP4Tags * (*_mp4v2_tags_alloc) (void);
+typedef gboolean (*_mp4v2_tags_fetch) (const MP4Tags *tags,
+ MP4FileHandle handle);
+typedef void (*_mp4v2_tags_free) (const MP4Tags *tags);
+typedef gboolean (*_mp4v2_tags_store) (const MP4Tags *tags,
+ MP4FileHandle handle);
+typedef gboolean (*_mp4v2_tags_set_title) (const MP4Tags *tags,
+ const gchar *title);
+typedef gboolean (*_mp4v2_tags_set_artist) (const MP4Tags *tags,
+ const gchar *artist);
+typedef gboolean (*_mp4v2_tags_set_album) (const MP4Tags *tags,
+ const gchar *album);
+typedef gboolean (*_mp4v2_tags_set_album_artist) (const MP4Tags *tags,
+ const gchar *album_artist);
+typedef gboolean (*_mp4v2_tags_set_disk) (const MP4Tags *tags,
+ const MP4TagDisk *disk);
+typedef gboolean (*_mp4v2_tags_set_release_date) (const MP4Tags *tags,
+ const gchar *date);
+typedef gboolean (*_mp4v2_tags_set_track) (const MP4Tags *tags,
+ const MP4TagTrack *tag);
+typedef gboolean (*_mp4v2_tags_set_genre) (const MP4Tags *tags,
+ const gchar *genre);
+typedef gboolean (*_mp4v2_tags_set_comments) (const MP4Tags *tags,
+ const gchar *comments);
+typedef gboolean (*_mp4v2_tags_set_composer) (const MP4Tags *tags,
+ const gchar *composer);
+typedef gboolean (*_mp4v2_tags_set_encoded_by) (const MP4Tags *tags,
+ const gchar *encoded_by);
+typedef gboolean (*_mp4v2_tags_add_artwork) (const MP4Tags *tags,
+ const MP4TagArtwork *disk);
+typedef gboolean (*_mp4v2_tags_remove_artwork) (const MP4Tags *tags,
+ guint32 id);
+typedef gboolean (*_mp4v2_tags_set_artwork) (const MP4Tags *tags, guint32 id,
+ const MP4TagArtwork *disk);
+typedef const gchar * (*_mp4v2_get_track_media_data_name) (MP4FileHandle handle,
+ MP4TrackId id);
+typedef guint8 (*_mp4v2_get_track_esds_object_type_id) (MP4FileHandle handle,
+ MP4TrackId id);
+typedef gboolean (*_mp4v2_get_track_es_configuration) (MP4FileHandle handle,
+ MP4TrackId id,
+ guint8 **configs,
+ guint32 *config_size);
+typedef guint32 (*_mp4v2_get_n_tracks) (MP4FileHandle handle,
+ const gchar *type,
+ guint8 sub_type);
+typedef MP4TrackId (*_mp4v2_find_track_id) (MP4FileHandle handle,
+ guint16 index,
+ const gchar *type,
+ const gchar *sub_type);
+typedef guint32 (*_mp4v2_get_track_bitrate) (MP4FileHandle handle,
+ MP4TrackId id);
+typedef gint (*_mp4v2_get_track_audio_channels) (MP4FileHandle handle,
+ MP4TrackId id);
+typedef guint32 (*_mp4v2_get_track_timescale) (MP4FileHandle handle,
+ MP4TrackId id);
+typedef MP4Duration (*_mp4v2_get_track_duration) (MP4FileHandle handle,
+ MP4TrackId id);
+typedef guint64 (*_mp4v2_convert_from_track_duration) (MP4FileHandle handle,
+ MP4TrackId id,
+ MP4Duration duration,
+ guint32 timescale);
struct _EtMP4TagPrivate
{
@@ -28,52 +220,32 @@ struct _EtMP4TagPrivate
MP4FileHandle (*mp4v2_modify) (const gchar *filename, guint32 flags);
void (*mp4v2_close) (MP4FileHandle handle, guint32 flags);
- const MP4Tags* (*mp4v2_tagsalloc) (void);
- gboolean (*mp4v2_tagsfetch) (const MP4Tags *tags, MP4FileHandle handle);
- void (*mp4v2_tagsfree) (const MP4Tags *tags);
- gboolean (*mp4v2_tagsstore) (const MP4Tags *tags, MP4FileHandle handle);
-
- gboolean (*mp4v2_tagssetname) (const MP4Tags *tags, const gchar *str);
- gboolean (*mp4v2_tagssetartist) (const MP4Tags *tags, const gchar *str);
- gboolean (*mp4v2_tagssetalbum) (const MP4Tags *tags, const gchar *str);
- gboolean (*mp4v2_tagssetalbumartist) (const MP4Tags *tags,
- const gchar *str);
- gboolean (*mp4v2_tagssetdisk) (const MP4Tags *tags,
- const MP4TagDisk *disk);
- gboolean (*mp4v2_tagssetreleasedate) (const MP4Tags *tags,
- const gchar *str);
- gboolean (*mp4v2_tagssettrack) (const MP4Tags *tags,
- const MP4TagTrack *track);
- gboolean (*mp4v2_tagssetgenre) (const MP4Tags *tags, const gchar *str);
- gboolean (*mp4v2_tagssetcomments) (const MP4Tags *tags, const gchar *str);
- gboolean (*mp4v2_tagssetcomposer) (const MP4Tags *tags, const gchar *str);
- gboolean (*mp4v2_tagssetencodedby) (const MP4Tags *tags, const gchar *str);
-
- gboolean (*mp4v2_addartwork) (const MP4Tags *tags,
- const MP4TagArtwork *art);
- gboolean (*mp4v2_setartwork) (const MP4Tags *tags, guint32 artwork,
- const MP4TagArtwork *art);
- gboolean (*mp4v2_removeartwork) (const MP4Tags *tags, guint32 artwork);
-
- const gchar *(*mp4v2_gettrackmediadataname) (MP4FileHandle handle,
- MP4TrackId id);
- guint8 (*mp4v2_gettrackesdsobjecttypeid) (MP4FileHandle handle,
- MP4TrackId trackId);
- gboolean (*mp4v2_gettrackesconfiguration) (MP4FileHandle handle,
- MP4TrackId id,
- guint8 **ppconfig,
- guint32 *pconfigsize);
- guint32 (*mp4v2_getnumberoftracks) (MP4FileHandle handle,
- const gchar *type, guint8 subtype);
- MP4TrackId (*mp4v2_findtrackid) (MP4FileHandle handle, guint16 index,
- const gchar *type, guint8 subtype);
- guint32 (*mp4v2_gettrackbitrate) (MP4FileHandle handle, MP4TrackId id);
- guint32 (*mp4v2_gettracktimescale) (MP4FileHandle handle, MP4TrackId id);
- int (*mp4v2_gettrackaudiochannels) (MP4FileHandle handle, MP4TrackId id);
- MP4Duration (*mp4v2_gettrackduration) (MP4FileHandle handle,
- MP4TrackId id);
- guint64 (*mp4v2_convertfromtrackduration) (MP4FileHandle handle,
- MP4TrackId id,
- MP4Duration duration,
- guint32 timescale);
+ _mp4v2_tags_alloc mp4v2_tags_alloc;
+ _mp4v2_tags_fetch mp4v2_tags_fetch;
+ _mp4v2_tags_free mp4v2_tags_free;
+ _mp4v2_tags_store mp4v2_tags_store;
+ _mp4v2_tags_set_title mp4v2_tags_set_title;
+ _mp4v2_tags_set_artist mp4v2_tags_set_artist;
+ _mp4v2_tags_set_album mp4v2_tags_set_album;
+ _mp4v2_tags_set_album_artist mp4v2_tags_set_album_artist;
+ _mp4v2_tags_set_disk mp4v2_tags_set_disk;
+ _mp4v2_tags_set_release_date mp4v2_tags_set_release_date;
+ _mp4v2_tags_set_track mp4v2_tags_set_track;
+ _mp4v2_tags_set_genre mp4v2_tags_set_genre;
+ _mp4v2_tags_set_comments mp4v2_tags_set_comments;
+ _mp4v2_tags_set_composer mp4v2_tags_set_composer;
+ _mp4v2_tags_set_encoded_by mp4v2_tags_set_encoded_by;
+ _mp4v2_tags_add_artwork mp4v2_tags_add_artwork;
+ _mp4v2_tags_remove_artwork mp4v2_tags_remove_artwork;
+ _mp4v2_tags_set_artwork mp4v2_tags_set_artwork;
+ _mp4v2_get_track_media_data_name mp4v2_get_track_media_data_name;
+ _mp4v2_get_track_esds_object_type_id mp4v2_get_track_esds_object_type_id;
+ _mp4v2_get_track_es_configuration mp4v2_get_track_es_configuration;
+ _mp4v2_get_n_tracks mp4v2_get_n_tracks;
+ _mp4v2_find_track_id mp4v2_find_track_id;
+ _mp4v2_get_track_bitrate mp4v2_get_track_bitrate;
+ _mp4v2_get_track_duration mp4v2_get_track_duration;
+ _mp4v2_get_track_timescale mp4v2_get_track_timescale;
+ _mp4v2_get_track_audio_channels mp4v2_get_track_audio_channels;
+ _mp4v2_convert_from_track_duration mp4v2_convert_from_track_duration;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]