Commit 8ecfe1ce authored by Mikael Ottela's avatar Mikael Ottela

Mp3 extraction can now handle id3v2 tags split into several frames

svn path=/trunk/; revision=2966
parent 4e490c2f
2009-02-24 Mikael Ottela <mikael.ottela@ixonos.com>
* src/tracker-extract/tracker-extract-mp3.c: Handle id3v2 tags
split into several frames.
* tests/tracker-extract/tracker-extract-mp3-test.c: Fix the
test-cases.
Fixes NB#102606
2009-02-24 Carlos Garnacho <carlos@imendio.com>
* src/tracker-extract/tracker-extract.c:
......
......@@ -505,7 +505,7 @@ mp3_parse_header (const gchar *data,
}
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 @@ static void
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 @@ get_id3v24_tags (const gchar *data,
pos += ehdrSize;
}
filedata->audio_offset = tsize + 10;
*offset_delta = tsize + 10;
while (pos < tsize) {
size_t csize;
......@@ -912,7 +913,8 @@ static void
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 @@ get_id3v23_tags (const gchar *data,
}
}
filedata->audio_offset = tsize + 10;
*offset_delta = tsize + 10;
while (pos < tsize) {
size_t csize;
......@@ -1179,10 +1181,11 @@ get_id3v23_tags (const gchar *data,
}
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 @@ get_id3v2_tags (const gchar *data,
pos = 10;
filedata->audio_offset = tsize + 10;
*offset_delta = tsize + 10;
while (pos < tsize) {
size_t csize;
......@@ -1341,6 +1344,30 @@ get_id3v2_tags (const gchar *data,
}
}
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 @@ extract_mp3 (const gchar *filename,
/* 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);
......
......@@ -68,7 +68,7 @@ main (int argc, char **argv) {
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment