tracker r2966 - in trunk: . src/tracker-extract tests/tracker-extract



Author: mottela
Date: Tue Feb 24 20:26:21 2009
New Revision: 2966
URL: http://svn.gnome.org/viewvc/tracker?rev=2966&view=rev

Log:
Mp3 extraction can now handle id3v2 tags split into several frames

Modified:
   trunk/ChangeLog
   trunk/src/tracker-extract/tracker-extract-mp3.c
   trunk/tests/tracker-extract/tracker-extract-mp3-test.c

Modified: trunk/src/tracker-extract/tracker-extract-mp3.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-mp3.c	(original)
+++ trunk/src/tracker-extract/tracker-extract-mp3.c	Tue Feb 24 20:26:21 2009
@@ -505,7 +505,7 @@
 	}
 
 	if (!layer_ver || !mpeg_ver) {
-		//g_debug ("Unknown mpeg type: %d, %d", mpeg_ver, layer_ver);
+		/* g_debug ("Unknown mpeg type: %d, %d", mpeg_ver, layer_ver); */
 		/* Unknown mpeg type */
 		return FALSE;
 	}
@@ -632,7 +632,8 @@
 get_id3v24_tags (const gchar *data,
 		 size_t       size,
 		 GHashTable  *metadata,
-		 file_data   *filedata)
+		 file_data   *filedata,
+		 size_t      *offset_delta)
 {
 	gint	unsync;
 	gint	extendedHdr;
@@ -698,7 +699,7 @@
 		pos += ehdrSize;
 	}
 
-	filedata->audio_offset = tsize + 10;
+	*offset_delta = tsize + 10;
 
 	while (pos < tsize) {
 		size_t csize;
@@ -912,7 +913,8 @@
 get_id3v23_tags (const gchar *data,
 		 size_t       size,
 		 GHashTable  *metadata,
-		 file_data   *filedata)
+		 file_data   *filedata,
+		 size_t      *offset_delta)
 {
 	gint	unsync;
 	gint	extendedHdr;
@@ -987,7 +989,7 @@
 		}
 	}
 
-	filedata->audio_offset = tsize + 10;
+	*offset_delta = tsize + 10;
 
 	while (pos < tsize) {
 		size_t csize;
@@ -1179,10 +1181,11 @@
 }
 
 static void
-get_id3v2_tags (const gchar *data,
-		size_t	     size,
-		GHashTable  *metadata,
-		file_data   *filedata)
+get_id3v20_tags (const gchar *data,
+		 size_t	      size,
+		 GHashTable  *metadata,
+		 file_data   *filedata,
+		 size_t      *offset_delta)
 {
 	gint	unsync;
 	guint	tsize;
@@ -1236,7 +1239,7 @@
 
 	pos = 10;
 
-	filedata->audio_offset = tsize + 10;
+	*offset_delta = tsize + 10;
 
 	while (pos < tsize) {
 		size_t csize;
@@ -1341,6 +1344,30 @@
 	}
 }
 
+static void
+get_id3v2_tags (const gchar *data,
+		size_t	     size,
+		GHashTable  *metadata,
+		file_data   *filedata)
+{
+	gboolean done = FALSE;
+	size_t   offset = 0;
+
+	do {
+		size_t offset_delta = 0;
+		get_id3v24_tags(data+offset, size-offset, metadata, filedata, &offset_delta);
+		get_id3v23_tags(data+offset, size-offset, metadata, filedata, &offset_delta);
+		get_id3v20_tags(data+offset, size-offset, metadata, filedata, &offset_delta);		
+
+		if (offset_delta == 0) {
+			done = TRUE;
+			filedata->audio_offset = offset;
+		} else {
+			offset += offset_delta;
+		}
+
+	} while (!done);
+}
 
 static void
 extract_mp3 (const gchar *filename,
@@ -1453,8 +1480,6 @@
 
 	/* Get other embedded tags */
 	get_id3v2_tags (buffer, size, metadata, &filedata);
-	get_id3v23_tags (buffer, size, metadata, &filedata);
-	get_id3v24_tags (buffer, size, metadata, &filedata);
 
 	/* Get mp3 stream info */
 	mp3_parse (buffer, size, metadata, &filedata);

Modified: trunk/tests/tracker-extract/tracker-extract-mp3-test.c
==============================================================================
--- trunk/tests/tracker-extract/tracker-extract-mp3-test.c	(original)
+++ trunk/tests/tracker-extract/tracker-extract-mp3-test.c	Tue Feb 24 20:26:21 2009
@@ -68,7 +68,7 @@
 
 	if (g_test_perf()) {
 		g_test_add_data_func ("/tracker-extract/tracker-extract-mp3/performance_cbr",
-				      data, performance_tracker_extract_mp3);	
+				      data, test_tracker_extract_mp3_performance);	
 	}
 
 #endif



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