changeset 1247:aa9466963512 trunk

[svn] - tuple builder for mp4 files (not AAC, sorry but nobody uses that crap anymore)
author nenolod
date Thu, 15 Jun 2006 01:22:24 -0700
parents 4f88f4e6c123
children 6d9c45d157f9
files ChangeLog Plugins/Input/aac/src/libmp4.c Plugins/Input/aac/src/mp4_utils.c
diffstat 3 files changed, 69 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jun 15 01:04:41 2006 -0700
+++ b/ChangeLog	Thu Jun 15 01:22:24 2006 -0700
@@ -1,3 +1,13 @@
+2006-06-15 08:04:41 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [1406]
+  - tuple builder for musepack files
+  
+
+  Changes:        Modified:
+  +51 -31         trunk/Plugins/Input/musepack/libmpc.cpp  
+  +2 -1           trunk/Plugins/Input/musepack/libmpc.h  
+
+
 2006-06-15 07:18:29 +0000  William Pitcock <nenolod@nenolod.net>
   revision [1404]
   - remove some left over #if 0'd out pipian code
--- a/Plugins/Input/aac/src/libmp4.c	Thu Jun 15 01:04:41 2006 -0700
+++ b/Plugins/Input/aac/src/libmp4.c	Thu Jun 15 01:22:24 2006 -0700
@@ -75,6 +75,7 @@
 static int	mp4_IsOurFile(char *);
 static void	mp4_getSongTitle(char *filename, char **, int *);
 static void*	mp4Decode(void *);
+static TitleInput *mp4_get_song_tuple(char *);
 
 void     audmp4_file_info_box(gchar *);
 gboolean buffer_playing;
@@ -105,6 +106,7 @@
     mp4_getSongTitle,	// get song title text
     audmp4_file_info_box, // info box
     0,	// to output plugin
+    mp4_get_song_tuple,
   };
 
 typedef struct  _mp4cfg{
@@ -267,6 +269,50 @@
 }
 #endif
 
+static TitleInput   *mp4_get_song_tuple(char *fn)
+{
+	mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t));
+	VFSFile *mp4fh;
+	mp4ff_t *mp4file;
+	TitleInput *input = NULL;
+	gchar *filename = g_strdup(fn);
+
+	mp4fh = vfs_fopen(filename, "rb");
+	mp4cb->read = mp4_read_callback;
+	mp4cb->seek = mp4_seek_callback;
+	mp4cb->user_data = mp4fh;	
+
+	if (!(mp4file = mp4ff_open_read(mp4cb))) {
+		g_free(mp4cb);
+		vfs_fclose(mp4fh);
+	} else {
+		gchar *tmpval;
+
+		input = bmp_title_input_new();
+
+		mp4ff_meta_get_title(mp4file, &input->track_name);
+		mp4ff_meta_get_album(mp4file, &input->album_name);
+		mp4ff_meta_get_artist(mp4file, &input->performer);
+		mp4ff_meta_get_date(mp4file, &tmpval);
+		mp4ff_meta_get_genre(mp4file, &input->genre);
+
+		if (tmpval)
+		{
+			input->year = atoi(tmpval);
+			free(tmpval);
+		}
+
+		input->file_name = g_path_get_basename(filename);
+		input->file_path = g_path_get_dirname(filename);
+		input->file_ext = extname(filename);
+
+		free (mp4cb);
+		vfs_fclose(mp4fh);
+	}
+
+	return input;
+}
+
 static gchar   *mp4_get_song_title(char *filename)
 {
 	mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t));
--- a/Plugins/Input/aac/src/mp4_utils.c	Thu Jun 15 01:04:41 2006 -0700
+++ b/Plugins/Input/aac/src/mp4_utils.c	Thu Jun 15 01:22:24 2006 -0700
@@ -70,12 +70,11 @@
   return(-1);
 }
 
-char *getMP4title(mp4ff_t *infile, char *filename) {
-	char *ret=NULL;
+TitleInput *getMP4tuple(mp4ff_t *infile, char *filename)
+{
 	gchar *value, *path, *temp;
 
-	TitleInput *input;
-	XMMS_NEW_TITLEINPUT(input);
+	TitleInput *input = bmp_title_input_new();
 
 	// Fill in the TitleInput with the relevant data
 	// from the mp4 file that can be used to display the title.
@@ -101,19 +100,18 @@
 	if (temp) {*temp = '\0';}
 	input->file_path = g_strdup_printf("%s/", path);
 
-	// Use the default xmms title format to format the
-	// title from the above info.
+	return input;
+}
+
+char *getMP4title(mp4ff_t *infile, char *filename)
+{
+	char *ret=NULL;
+
+	TitleInput *input = getMP4tuple(infile, filename);
+
 	ret = xmms_get_titlestring(xmms_get_gentitle_format(), input);
 
-        g_free(input->track_name);
-        g_free(input->performer);
-        g_free(input->album_name);
-        g_free(input->genre);
-        g_free(input->comment);
-        g_free(input->file_name);
-        g_free(input->file_path);
-	g_free(input);
-	g_free(path);
+	bmp_title_input_free(input);
 
 	return ret;
 }