summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2016-05-02 16:03:56 +0300
committerSebastian Dröge <sebastian@centricular.com>2016-08-11 11:56:55 +0200
commite3805e4a966e261a1f553c0a2bac3a1ff70d52ae (patch)
treece9dfc729821ad6322baaea9230d0fa23a9de0b5 /tests
parentfff814bbe5c13bdf1df2a5fb5e331feb42cf2ea3 (diff)
downloadgstreamer-plugins-bad-e3805e4a966e261a1f553c0a2bac3a1ff70d52ae.tar.gz
dash: Add unit test for ISOBFF box header parsing
https://bugzilla.gnome.org/show_bug.cgi?id=741104
Diffstat (limited to 'tests')
-rw-r--r--tests/check/Makefile.am6
-rw-r--r--tests/check/elements/dash_isoff.c127
2 files changed, 132 insertions, 1 deletions
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 04230573f..e7678b7dc 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -41,7 +41,7 @@ check_assrender =
endif
if USE_DASH
-check_dash = elements/dash_mpd
+check_dash = elements/dash_mpd elements/dash_isoff
check_dash_demux = elements/dash_demux
else
check_dash =
@@ -465,6 +465,10 @@ elements_dash_mpd_LDADD = $(LDADD) $(LIBXML2_LIBS) \
$(top_builddir)/gst-libs/gst/uridownloader/libgsturidownloader-@GST_API_VERSION@.la
elements_dash_mpd_SOURCES = elements/dash_mpd.c
+elements_dash_isoff_CFLAGS = $(AM_CFLAGS) $(GST_BASE_CFLAGS)
+elements_dash_isoff_LDADD = $(LDADD) $(GST_BASE_LIBS)
+elements_dash_isoff_SOURCES = elements/dash_isoff.c
+
elements_dash_demux_CFLAGS = $(AM_CFLAGS) $(LIBXML2_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS)
elements_dash_demux_LDADD = \
$(LDADD) $(LIBXML2_LIBS) $(GST_BASE_LIBS) \
diff --git a/tests/check/elements/dash_isoff.c b/tests/check/elements/dash_isoff.c
new file mode 100644
index 000000000..446cdf7da
--- /dev/null
+++ b/tests/check/elements/dash_isoff.c
@@ -0,0 +1,127 @@
+#include "../../ext/dash/gstisoff.c"
+#undef GST_CAT_DEFAULT
+
+#include <gst/check/gstcheck.h>
+#include <gst/base/base.h>
+
+GST_START_TEST (dash_isoff_box_header_minimal)
+{
+ /* INDENT-OFF */
+ static const guint8 data[] = {
+ 16, 32, 64, 128,
+ 't', 'e', 's', 't'
+ };
+ /* INDENT-ON */
+ GstByteReader reader = GST_BYTE_READER_INIT (data, sizeof (data));
+ guint32 type;
+ guint8 extended_type[16];
+ guint header_size;
+ guint64 size;
+
+ fail_unless (gst_isoff_parse_box_header (&reader, &type, extended_type,
+ &header_size, &size));
+ fail_unless (type == GST_MAKE_FOURCC ('t', 'e', 's', 't'));
+ fail_unless_equals_int (header_size, 8);
+ fail_unless_equals_uint64 (size, 0x10204080);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (dash_isoff_box_header_long_size)
+{
+ /* INDENT-OFF */
+ static const guint8 data[] = {
+ 0, 0, 0, 1,
+ 't', 'e', 's', 't',
+ 1, 2, 4, 8, 16, 32, 64, 128
+ };
+ /* INDENT-ON */
+ GstByteReader reader = GST_BYTE_READER_INIT (data, sizeof (data));
+ guint32 type;
+ guint8 extended_type[16];
+ guint header_size;
+ guint64 size;
+
+ fail_unless (gst_isoff_parse_box_header (&reader, &type, extended_type,
+ &header_size, &size));
+ fail_unless (type == GST_MAKE_FOURCC ('t', 'e', 's', 't'));
+ fail_unless_equals_int (header_size, 16);
+ fail_unless_equals_uint64 (size, G_GUINT64_CONSTANT (0x0102040810204080));
+}
+
+GST_END_TEST;
+
+GST_START_TEST (dash_isoff_box_header_uuid_type)
+{
+ /* INDENT-OFF */
+ static const guint8 data[] = {
+ 16, 32, 64, 128,
+ 'u', 'u', 'i', 'd',
+ 'a', 'b', 'c', 'd',
+ 'e', 'f', 'g', 'h',
+ 'i', 'j', 'k', 'l',
+ 'm', 'n', 'o', 'p'
+ };
+ /* INDENT-ON */
+ GstByteReader reader = GST_BYTE_READER_INIT (data, sizeof (data));
+ guint32 type;
+ guint8 extended_type[16];
+ guint header_size;
+ guint64 size;
+
+ fail_unless (gst_isoff_parse_box_header (&reader, &type, extended_type,
+ &header_size, &size));
+ fail_unless (type == GST_MAKE_FOURCC ('u', 'u', 'i', 'd'));
+ fail_unless_equals_int (header_size, 24);
+ fail_unless_equals_uint64 (size, 0x10204080);
+ fail_unless (memcmp (data + 8, extended_type, 16) == 0);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (dash_isoff_box_header_uuid_type_long_size)
+{
+ /* INDENT-OFF */
+ static const guint8 data[] = {
+ 0, 0, 0, 1,
+ 'u', 'u', 'i', 'd',
+ 1, 2, 4, 8, 16, 32, 64, 128,
+ 'a', 'b', 'c', 'd',
+ 'e', 'f', 'g', 'h',
+ 'i', 'j', 'k', 'l',
+ 'm', 'n', 'o', 'p'
+ };
+ /* INDENT-ON */
+ GstByteReader reader = GST_BYTE_READER_INIT (data, sizeof (data));
+ guint32 type;
+ guint8 extended_type[16];
+ guint header_size;
+ guint64 size;
+
+ fail_unless (gst_isoff_parse_box_header (&reader, &type, extended_type,
+ &header_size, &size));
+ fail_unless (type == GST_MAKE_FOURCC ('u', 'u', 'i', 'd'));
+ fail_unless_equals_int (header_size, 32);
+ fail_unless_equals_uint64 (size, G_GUINT64_CONSTANT (0x0102040810204080));
+ fail_unless (memcmp (data + 16, extended_type, 16) == 0);
+}
+
+GST_END_TEST;
+
+static Suite *
+dash_isoff_suite (void)
+{
+ Suite *s = suite_create ("dash-isoff");
+ TCase *tc_isoff_box = tcase_create ("isoff-box-parsing");
+
+ tcase_add_test (tc_isoff_box, dash_isoff_box_header_minimal);
+ tcase_add_test (tc_isoff_box, dash_isoff_box_header_long_size);
+ tcase_add_test (tc_isoff_box, dash_isoff_box_header_uuid_type);
+ tcase_add_test (tc_isoff_box, dash_isoff_box_header_uuid_type_long_size);
+
+ suite_add_tcase (s, tc_isoff_box);
+
+ return s;
+}
+
+GST_CHECK_MAIN (dash_isoff);