summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2009-08-07 16:02:23 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2009-08-07 16:02:23 +0100
commit2e05af387614b9850a9b0782e5ee1ab1a78362fd (patch)
tree12df5b19f19252916372f3223fa051e69a31c744 /tests
parentc42f0ad5b6aefd42a8336bd73d6e856fce306908 (diff)
id3demux: fix parsing of unsync'ed ID3 v2.4 tags and frames
Reversing the unsynchronisation seems to work slightly differently for ID3 v2.3 tags and v2.4 tags: v2.3 tags don't have syncsafe frame sizes in the frame header, so the unsynchronisation is applied to the whole frame data including all the frame headers. v2.4 frames have sync-safe sizes, however, so the unsynchronisation only needs to be applied to the actual frame data, and it seems that's what's being done as well. So we need to undo the unsynchronisation on a per-frame basis for v2.4 tags for things to work properly. Fixes extraction of coverart/images from APIC frames in ID3 v2.4 tags (#588148). Add unit test for this as well.
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/id3demux.c54
-rw-r--r--tests/files/Makefile.am1
-rw-r--r--tests/files/id3-588148-unsynced-v24.tagbin0 -> 39000 bytes
3 files changed, 51 insertions, 4 deletions
diff --git a/tests/check/elements/id3demux.c b/tests/check/elements/id3demux.c
index ef1d4538..724461bd 100644
--- a/tests/check/elements/id3demux.c
+++ b/tests/check/elements/id3demux.c
@@ -198,7 +198,7 @@ GST_START_TEST (test_wcop)
GST_END_TEST;
static void
-check_unsync (const GstTagList * tags, const gchar * file)
+check_unsync_v23 (const GstTagList * tags, const gchar * file)
{
gchar *album = NULL;
gchar *title = NULL;
@@ -220,9 +220,54 @@ check_unsync (const GstTagList * tags, const gchar * file)
g_free (artist);
}
-GST_START_TEST (test_unsync)
+GST_START_TEST (test_unsync_v23)
{
- run_check_for_file ("id3-577468-unsynced-tag.tag", check_unsync);
+ run_check_for_file ("id3-577468-unsynced-tag.tag", check_unsync_v23);
+}
+
+GST_END_TEST;
+
+static void
+check_unsync_v24 (const GstTagList * tags, const gchar * file)
+{
+ const GValue *val;
+ GstBuffer *buf;
+ gchar *album = NULL;
+ gchar *title = NULL;
+ gchar *artist = NULL;
+
+ fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &title));
+ fail_unless (title != NULL);
+ fail_unless_equals_string (title, "Starlight");
+ g_free (title);
+
+ fail_unless (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &album));
+ fail_unless (album != NULL);
+ fail_unless_equals_string (album, "L'albumRockVol.4 CD1");
+ g_free (album);
+
+ fail_unless (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &artist));
+ fail_unless (artist != NULL);
+ fail_unless_equals_string (artist, "Muse");
+ g_free (artist);
+
+ val = gst_tag_list_get_value_index (tags, GST_TAG_IMAGE, 0);
+ fail_unless (val != NULL);
+ fail_unless (GST_VALUE_HOLDS_BUFFER (val));
+ buf = gst_value_get_buffer (val);
+ fail_unless (buf != NULL);
+ fail_unless (GST_BUFFER_CAPS (buf) != NULL);
+ fail_unless_equals_int (GST_BUFFER_SIZE (buf), 38022);
+ /* check for jpeg start/end markers */
+ fail_unless_equals_int (GST_BUFFER_DATA (buf)[0], 0xff);
+ fail_unless_equals_int (GST_BUFFER_DATA (buf)[1], 0xd8);
+ fail_unless_equals_int (GST_BUFFER_DATA (buf)[38020], 0xff);
+ fail_unless_equals_int (GST_BUFFER_DATA (buf)[38021], 0xd9);
+}
+
+GST_START_TEST (test_unsync_v24)
+{
+ run_check_for_file ("id3-588148-unsynced-v24.tag", check_unsync_v24);
}
GST_END_TEST;
@@ -236,7 +281,8 @@ id3demux_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_tdat_tyer);
tcase_add_test (tc_chain, test_wcop);
- tcase_add_test (tc_chain, test_unsync);
+ tcase_add_test (tc_chain, test_unsync_v23);
+ tcase_add_test (tc_chain, test_unsync_v24);
return s;
}
diff --git a/tests/files/Makefile.am b/tests/files/Makefile.am
index 73ab4f2d..a0a28293 100644
--- a/tests/files/Makefile.am
+++ b/tests/files/Makefile.am
@@ -5,6 +5,7 @@ EXTRA_DIST = \
id3-407349-2.tag \
id3-447000-wcop.tag \
id3-577468-unsynced-tag.tag \
+ id3-588148-unsynced-v24.tag \
pcm16sine.flv \
test-cert.pem \
test-key.pem
diff --git a/tests/files/id3-588148-unsynced-v24.tag b/tests/files/id3-588148-unsynced-v24.tag
new file mode 100644
index 00000000..099d930e
--- /dev/null
+++ b/tests/files/id3-588148-unsynced-v24.tag
Binary files differ