Re: [Muine] m4a support?



On Wed, Oct 06, 2004 at 12:36:12PM +0200, Yo'av Moshe wrote:
> Okay, but then again, as Gstreamer already support *.m4a files, why
> not having Muine support it (as long as we're using Gstreamer as the
> backend)?

Your wish is my command (i finally got some .m4a files, so i needed this
working). I found i had to fix my
/usr/share/mime/packages/freedesktop.org.xml to get the mime types right
for them.

Attached is a patch that gets the metadata for m4a files fine.
Combine that with the proper gst-plugin (faad), this should now be
working. NFC what would happen with xine with this, I haven't been using
the xine backend for a while now. The one thing this doesn't yet do is
try to load any images that may be tagged to the files. If i find some
time i'll try to mess with that too.

Feedback?

-pete

> 
> 
> 
> On Tue, 5 Oct 2004 08:55:58 -0700, Brian Nickel <brian nickel gmail com> wrote:
> > 
> > 
> > On this topic, I know TagLib is the goal for Muine, but it would be
> > advantageous to use both native Xine and GStreamer  metadata back
> > ends, as Rhythmbox does. If we did this, we could remove the hard
> > coding of mime types and indiscriminately say "If the back end
> > supports you, and we can read your metadata, we'll play you." Then we
> > could use TagLib as a secondary system for writing if GStreamer and
> > Xine fail in that regard.
> > 
> > Just a thought, anyway.
> > 
> > - Brian
> > 
> > On Tue, 5 Oct 2004 11:26:17 +0200, Yo'av Moshe <bjesus gmail com> wrote:
> > > Hey,
> > > Is it just me that can't import *.m4a files to the database, or that's Muine?
> > >
> > > As far as I can see, RhythmBox supports it with no problem, so I guess
> > > that Gstreamer can handle it fine.
> > >
> > > Why not supporting it? It's becoming pretty popular (because of
> > > iTunes, I think).
> > >
> > > Yo'av.
> > > _______________________________________________
> > > muine-list mailing list
> > > muine-list gnome org
> > > http://mail.gnome.org/mailman/listinfo/muine-list
> > >
> > 
> > 
> > _______________________________________________
> > muine-list mailing list
> > muine-list gnome org
> > http://mail.gnome.org/mailman/listinfo/muine-list
> >
> _______________________________________________
> muine-list mailing list
> muine-list gnome org
> http://mail.gnome.org/mailman/listinfo/muine-list
> 

-- 
Peter Johanson
<latexer gentoo org>
Index: configure.in
===================================================================
RCS file: /cvs/gnome/muine/configure.in,v
retrieving revision 1.102
diff -a -u -r1.102 configure.in
--- configure.in	10 Jan 2005 17:59:26 -0000	1.102
+++ configure.in	15 Jan 2005 04:42:14 -0000
@@ -97,6 +97,10 @@
 AC_CHECK_HEADER(FLAC/all.h, FLAC_LIBS="-lFLAC", AC_MSG_ERROR(You need FLAC))
 AC_SUBST(FLAC_LIBS)
 
+dnl Check for FAAD 
+AC_CHECK_HEADER(mp4.h, FAAD_LIBS="-lmp4v2", AC_MSG_ERROR(You need faad2))
+AC_SUBST(FAAD_LIBS)
+
 dnl Check for Mono
 AC_PATH_PROG(MCS, mcs)
 AC_PATH_PROG(MONO, mono)
Index: libmuine/Makefile.am
===================================================================
RCS file: /cvs/gnome/muine/libmuine/Makefile.am,v
retrieving revision 1.14
diff -a -u -r1.14 Makefile.am
--- libmuine/Makefile.am	6 Jan 2005 11:04:24 -0000	1.14
+++ libmuine/Makefile.am	15 Jan 2005 04:42:17 -0000
@@ -52,4 +52,4 @@
 	mm-keys.c			\
 	mm-keys.h
 	
-libmuine_la_LIBADD = id3-vfs/libid3-vfs.la egg/libegg.la $(MUINE_LIBS) $(OGG_LIBS) $(VORBIS_LIBS) $(VORBISFILE_LIBS) $(GDBM_LIBS) $(ID3TAG_LIBS) $(FLAC_LIBS)
+libmuine_la_LIBADD = id3-vfs/libid3-vfs.la egg/libegg.la $(MUINE_LIBS) $(OGG_LIBS) $(VORBIS_LIBS) $(VORBISFILE_LIBS) $(GDBM_LIBS) $(ID3TAG_LIBS) $(FLAC_LIBS) $(FAAD_LIBS)
Index: libmuine/metadata.c
===================================================================
RCS file: /cvs/gnome/muine/libmuine/metadata.c,v
retrieving revision 1.14
diff -a -u -r1.14 metadata.c
--- libmuine/metadata.c	26 Dec 2004 11:00:28 -0000	1.14
+++ libmuine/metadata.c	15 Jan 2005 04:42:17 -0000
@@ -22,6 +22,7 @@
 #include <id3tag.h>
 #include <FLAC/metadata.h>
 #include <FLAC/stream_decoder.h>
+#include <mp4.h>
 #include <glib.h>
 #include <stdlib.h>
 #include <string.h>
@@ -373,6 +374,80 @@
 	return metadata;
 }
 
+static Metadata *
+assign_metadata_mp4 (const char *filename,
+		      char **error_message_return)
+{
+	Metadata *m = NULL;
+	MP4FileHandle mp4_file_handle;
+	MP4TrackId mp4_track_id;
+	const char *mp4_track_type;
+
+	mp4_file_handle = MP4Read(filename, 0);
+	if (mp4_file_handle == MP4_INVALID_FILE_HANDLE)
+	{
+		*error_message_return = g_strdup("Unable to open m4a file!");
+		return NULL;
+	}
+
+	mp4_track_id = MP4FindTrackId(mp4_file_handle, 0, NULL, 0);
+	mp4_track_type = MP4GetTrackType(mp4_file_handle, mp4_track_id);
+
+	if (mp4_track_type && (strcmp(mp4_track_type, MP4_AUDIO_TRACK_TYPE) == 0))
+	{
+		gchar *value;
+		guint16 numval, numval2;
+		MP4Duration mp4_duration;
+		m = g_new0 (Metadata, 1);
+
+		if (MP4GetMetadataName(mp4_file_handle, &value) && value != NULL)
+		{
+			m->title = g_strdup(value);
+			g_free(value);
+		}
+		if (MP4GetMetadataArtist(mp4_file_handle, &value) && value != NULL)
+		{
+			m->artists = g_new (char *, 1);
+			m->artists[0] = g_strdup(value);
+			m->artists_count = 1;
+			g_free(value);
+		}
+		if (MP4GetMetadataYear(mp4_file_handle, &value) && value != NULL)
+		{       
+			m->year = g_strdup(value);
+			g_free(value);
+		}
+		if (MP4GetMetadataAlbum(mp4_file_handle, &value) && value != NULL)
+		{
+			m->album = g_strdup(value);
+			g_free(value);
+		}
+		if (MP4GetMetadataTrack(mp4_file_handle, &numval, &numval2) && value != NULL)
+		{
+			m->track_number = numval;
+		}
+		if (MP4GetMetadataDisk(mp4_file_handle, &numval, &numval2) && value != NULL)
+		{
+			m->disc_number = numval;
+		}
+		mp4_duration = MP4GetTrackDuration (mp4_file_handle, mp4_track_id);
+		m->duration =
+			(int)MP4ConvertFromTrackDuration(mp4_file_handle,
+							 mp4_track_id,
+							 mp4_duration,
+							 MP4_SECONDS_TIME_SCALE);
+
+	}
+	else
+	{
+		*error_message_return = g_strdup ("Not an AAC music file");
+	}
+
+	MP4Close (mp4_file_handle);
+
+	return m;
+}
+
 static ov_callbacks file_info_callbacks =
 {
         ogg_helper_read,
@@ -693,6 +768,9 @@
 	else if (!strcmp (info->mime_type, "application/x-flac") ||
 		 !strcmp (info->mime_type, "audio/x-flac"))
 		m = assign_metadata_flac (escaped, error_message_return);
+	else if (!strcmp (info->mime_type, "application/x-m4a") ||
+		 !strcmp (info->mime_type, "audio/x-m4a"))
+		m = assign_metadata_mp4 (filename, error_message_return);
 	else
 		*error_message_return = g_strdup ("Unknown format");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]