From 6ce65709bda5ab6915ef7f080ea959b02d2f12f6 Mon Sep 17 00:00:00 2001 From: Florin Apostol Date: Thu, 23 Jul 2015 10:54:36 +0100 Subject: [PATCH] dashdemux: tests: added duration format test https://bugzilla.gnome.org/show_bug.cgi?id=752776 --- tests/check/elements/dash_mpd.c | 84 +++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/tests/check/elements/dash_mpd.c b/tests/check/elements/dash_mpd.c index dc3dd54550..b7333dfc02 100644 --- a/tests/check/elements/dash_mpd.c +++ b/tests/check/elements/dash_mpd.c @@ -2336,6 +2336,89 @@ GST_START_TEST (dash_mpdparser_GstDateTime) GST_END_TEST; +/* + * Test various duration formats + */ +GST_START_TEST (dash_mpdparser_various_duration_formats) +{ + GstPeriodNode *periodNode; + const gchar *xml = + "" + "" + " " + " " + " " + " " + " " + " " + " " + " "; + + gboolean ret; + GstMpdClient *mpdclient = gst_mpd_client_new (); + + ret = gst_mpd_parse (mpdclient, xml, (gint) strlen (xml)); + assert_equals_int (ret, TRUE); + + ret = gst_mpd_client_setup_media_presentation (mpdclient); + assert_equals_int (ret, TRUE); + + periodNode = + (GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 0); + assert_equals_string (periodNode->id, "Period0"); + assert_equals_int64 (periodNode->start, + (gint64) duration_to_ms (0, 0, 0, 0, 0, 1, 0)); + + periodNode = + (GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 1); + assert_equals_string (periodNode->id, "Period1"); + assert_equals_int64 (periodNode->start, + (gint64) duration_to_ms (0, 0, 0, 0, 0, 1, 500)); + + periodNode = + (GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 2); + assert_equals_string (periodNode->id, "Period2"); + assert_equals_int64 (periodNode->start, + (gint64) duration_to_ms (0, 0, 0, 0, 0, 1, 700)); + + periodNode = + (GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 3); + assert_equals_string (periodNode->id, "Period3"); + assert_equals_int64 (periodNode->start, + (gint64) duration_to_ms (0, 0, 0, 0, 1, 0, 0)); + + periodNode = + (GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 4); + assert_equals_string (periodNode->id, "Period4"); + assert_equals_int64 (periodNode->start, + (gint64) duration_to_ms (0, 0, 0, 1, 0, 0, 0)); + + periodNode = + (GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 5); + assert_equals_string (periodNode->id, "Period5"); + assert_equals_int64 (periodNode->start, + (gint64) duration_to_ms (0, 0, 1, 0, 0, 0, 0)); + + periodNode = + (GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 6); + assert_equals_string (periodNode->id, "Period6"); + assert_equals_int64 (periodNode->start, + (gint64) duration_to_ms (0, 1, 0, 0, 0, 0, 0)); + + periodNode = + (GstPeriodNode *) g_list_nth_data (mpdclient->mpd_node->Periods, 7); + assert_equals_string (periodNode->id, "Period7"); + assert_equals_int64 (periodNode->start, + (gint64) duration_to_ms (1, 0, 0, 0, 0, 0, 0)); + + gst_mpd_client_free (mpdclient); +} + +GST_END_TEST; + /* * Test media presentation setup * @@ -4096,6 +4179,7 @@ dash_suite (void) tcase_add_test (tc_simpleMPD, dash_mpdparser_template_parsing); tcase_add_test (tc_simpleMPD, dash_mpdparser_isoff_ondemand_profile); tcase_add_test (tc_simpleMPD, dash_mpdparser_GstDateTime); + tcase_add_test (tc_simpleMPD, dash_mpdparser_various_duration_formats); /* tests checking the MPD management * (eg. setting active streams, obtaining attributes values)