summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2015-11-20 20:18:34 +0000
committerTim-Philipp Müller <tim@centricular.com>2015-11-20 20:20:25 +0000
commite8a403d181a5e37c28df2322772b3ef9cc94f864 (patch)
tree378db69d4a6bc95369e780e1344a97c0e888c575
parentdf5725e68331ca50e9d610c5d99d23fbf7c046a0 (diff)
tests: tags: add unit test for ID3v2 PRIVATE_DATA tag extraction
https://bugzilla.gnome.org/show_bug.cgi?id=730926
-rw-r--r--tests/check/libs/tag.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/check/libs/tag.c b/tests/check/libs/tag.c
index 16b5dcfac..e8244bf7b 100644
--- a/tests/check/libs/tag.c
+++ b/tests/check/libs/tag.c
@@ -686,6 +686,65 @@ GST_START_TEST (test_id3v1_utf8_tag)
GST_END_TEST;
+GST_START_TEST (test_id3v2_priv_tag)
+{
+ const guint8 id3v2[] = {
+ 0x49, 0x44, 0x33, 0x04, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3f, 0x50, 0x52, 0x49, 0x56, 0x00, 0x00,
+ 0x00, 0x35, 0x00, 0x00, 0x63, 0x6f, 0x6d, 0x2e,
+ 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x73, 0x74,
+ 0x72, 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x2e,
+ 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72,
+ 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54,
+ 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xbb,
+ 0xa0
+ };
+ const GstStructure *s;
+ GstTagList *tags;
+ GstSample *sample = NULL;
+ GstBuffer *buf;
+ GstMapInfo map;
+ gchar *owner = NULL;
+
+ buf = gst_buffer_new_allocate (NULL, sizeof (id3v2), NULL);
+ gst_buffer_fill (buf, 0, id3v2, sizeof (id3v2));
+
+ tags = gst_tag_list_from_id3v2_tag (buf);
+ gst_buffer_unref (buf);
+
+ fail_if (tags == NULL, "Failed to parse ID3 tag");
+
+ GST_LOG ("tags: %" GST_PTR_FORMAT, tags);
+
+ if (!gst_tag_list_get_sample (tags, GST_TAG_PRIVATE_DATA, &sample))
+ g_error ("Failed to get PRIVATE_DATA tag");
+
+ s = gst_sample_get_info (sample);
+ buf = gst_sample_get_buffer (sample);
+
+ if (!gst_structure_has_name (s, "ID3PrivateFrame"))
+ g_error ("wrong info name");
+
+ gst_structure_get (s, "owner", G_TYPE_STRING, &owner, NULL);
+ fail_unless (owner != NULL);
+
+ fail_unless_equals_string (owner,
+ "com.apple.streaming.transportStreamTimestamp");
+
+ fail_unless_equals_int (gst_buffer_get_size (buf), 8);
+
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ GST_MEMDUMP ("private data", map.data, map.size);
+ fail_unless_equals_uint64 (GST_READ_UINT64_BE (map.data), 0x0dbba0);
+ gst_buffer_unmap (buf, &map);
+ g_free (owner);
+
+ gst_sample_unref (sample);
+ gst_tag_list_unref (tags);
+}
+
+GST_END_TEST
GST_START_TEST (test_language_utils)
{
gchar **lang_codes, **c;
@@ -1799,6 +1858,7 @@ tag_suite (void)
tcase_add_test (tc_chain, test_vorbis_tags);
tcase_add_test (tc_chain, test_id3_tags);
tcase_add_test (tc_chain, test_id3v1_utf8_tag);
+ tcase_add_test (tc_chain, test_id3v2_priv_tag);
tcase_add_test (tc_chain, test_language_utils);
tcase_add_test (tc_chain, test_license_utils);
tcase_add_test (tc_chain, test_xmp_formatting);