From dc6e4ccbf9d23962cf39ce7bd9f9152e9d41a6e3 Mon Sep 17 00:00:00 2001 From: Alex Ashley Date: Wed, 20 Jan 2016 16:42:24 +0000 Subject: [PATCH] tests: dashdemux: add test for gst_mpd_client_get_maximum_segment_duration Add a test of the gst_mpd_client_get_maximum_segment_duration() function to check that it first checks the MPD@maxSegmentDuration and then falls back to checking all of the segment durations. https://bugzilla.gnome.org/show_bug.cgi?id=753751 --- tests/check/elements/dash_mpd.c | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/check/elements/dash_mpd.c b/tests/check/elements/dash_mpd.c index 6e49f0eb4b..ed718a27e9 100644 --- a/tests/check/elements/dash_mpd.c +++ b/tests/check/elements/dash_mpd.c @@ -44,6 +44,14 @@ duration_to_ms (guint year, guint month, guint day, guint hour, guint minute, return ms; } +static GstClockTime +duration_to_clocktime (guint year, guint month, guint day, guint hour, + guint minute, guint second, guint millisecond) +{ + return (GST_MSECOND * duration_to_ms (year, month, day, hour, minute, second, + millisecond)); +} + /* * Test to ensure a simple mpd file successfully parses. * @@ -5444,6 +5452,74 @@ GST_START_TEST (dash_mpdparser_duration) GST_END_TEST; +/* + * Test that the maximum_segment_duration correctly implements the + * rules in the DASH specification + */ +GST_START_TEST (dash_mpdparser_maximum_segment_duration) +{ + const gchar *xml_template = + "" + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " " " " "; + gboolean ret; + GstMpdClient *mpdclient; + gchar *xml; + GstClockTime dur; + GList *adapt_sets, *iter; + + xml = g_strdup_printf (xml_template, "maxSegmentDuration=\"PT4.5S\""); + mpdclient = gst_mpd_client_new (); + ret = gst_mpd_parse (mpdclient, xml, (gint) strlen (xml)); + g_free (xml); + assert_equals_int (ret, TRUE); + + assert_equals_uint64 (mpdclient->mpd_node->maxSegmentDuration, + duration_to_ms (0, 0, 0, 0, 0, 4, 500)); + dur = gst_mpd_client_get_maximum_segment_duration (mpdclient); + assert_equals_uint64 (dur, duration_to_clocktime (0, 0, 0, 0, 0, 4, 500)); + gst_mpd_client_free (mpdclient); + + /* now parse without the maxSegmentDuration attribute, to check that + gst_mpd_client_get_maximum_segment_duration uses the maximum + duration of any segment + */ + xml = g_strdup_printf (xml_template, ""); + mpdclient = gst_mpd_client_new (); + ret = gst_mpd_parse (mpdclient, xml, (gint) strlen (xml)); + g_free (xml); + assert_equals_int (ret, TRUE); + ret = + gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE, + -1, NULL); + assert_equals_int (ret, TRUE); + adapt_sets = gst_mpd_client_get_adaptation_sets (mpdclient); + for (iter = adapt_sets; iter; iter = g_list_next (iter)) { + GstAdaptationSetNode *adapt_set_node = iter->data; + + ret = gst_mpd_client_setup_streaming (mpdclient, adapt_set_node); + assert_equals_int (ret, TRUE); + } + dur = gst_mpd_client_get_maximum_segment_duration (mpdclient); + assert_equals_uint64 (dur, duration_to_clocktime (0, 0, 0, 0, 0, 4, 0)); + gst_mpd_client_free (mpdclient); +} + +GST_END_TEST; + /* * create a test suite containing all dash testcases */ @@ -5625,6 +5701,7 @@ dash_suite (void) tcase_add_test (tc_stringTests, dash_mpdparser_rfc1738_strings); tcase_add_test (tc_duration, dash_mpdparser_duration); + tcase_add_test (tc_duration, dash_mpdparser_maximum_segment_duration); suite_add_tcase (s, tc_simpleMPD); suite_add_tcase (s, tc_complexMPD);