Commit e8a403d1 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller

tests: tags: add unit test for ID3v2 PRIVATE_DATA tag extraction

https://bugzilla.gnome.org/show_bug.cgi?id=730926
parent df5725e6
......@@ -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);
......
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