From 7d8cc26c9166e3548d3603123e301add79dc130f Mon Sep 17 00:00:00 2001 From: Florin Apostol Date: Thu, 10 Sep 2015 13:22:58 +0100 Subject: [PATCH] dashdemux: unit testing reproducing segment duration overflow unit test reproducing https://bugzilla.gnome.org/show_bug.cgi?id=751792 With minor changes by Vincent Penquerc'h. --- tests/check/elements/dash_mpd.c | 98 +++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/tests/check/elements/dash_mpd.c b/tests/check/elements/dash_mpd.c index 348b65cf8e..6e49f0eb4b 100644 --- a/tests/check/elements/dash_mpd.c +++ b/tests/check/elements/dash_mpd.c @@ -4820,6 +4820,103 @@ GST_START_TEST (dash_mpdparser_multiple_inherited_segmentURL) GST_END_TEST; +/* + * Test SegmentList with multiple segmentURL + * + */ +GST_START_TEST (dash_mpdparser_multipleSegmentURL) +{ + GList *adaptationSets; + GstAdaptationSetNode *adapt_set; + GstActiveStream *activeStream; + GstMediaFragmentInfo fragment; + GstClockTime expectedDuration; + GstClockTime expectedTimestamp; + GstFlowReturn flow; + + /* + * Period duration is 30 seconds + * Period start is 10 seconds. Thus, period duration is 20 seconds. + * + * Segment duration is 25 seconds. There are 2 segments in the list. + * We expect first segment to have a duration of 20 seconds (limited by the period) + * and the second segment to not exist. + */ + 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); + + /* process the xml data */ + ret = + gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE, + -1, NULL); + assert_equals_int (ret, TRUE); + + /* get the list of adaptation sets of the first period */ + adaptationSets = gst_mpd_client_get_adaptation_sets (mpdclient); + fail_if (adaptationSets == NULL); + + /* setup streaming from the first adaptation set */ + adapt_set = (GstAdaptationSetNode *) g_list_nth_data (adaptationSets, 0); + fail_if (adapt_set == NULL); + ret = gst_mpd_client_setup_streaming (mpdclient, adapt_set); + assert_equals_int (ret, TRUE); + + activeStream = gst_mpdparser_get_active_stream_by_index (mpdclient, 0); + fail_if (activeStream == NULL); + + expectedDuration = duration_to_ms (0, 0, 0, 0, 0, 20, 0); + expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 0, 0); + + /* the representation contains 2 segments. The first is partially + * clipped, and the second entirely (and thus discarded). + */ + + /* check first segment */ + ret = gst_mpd_client_get_next_fragment (mpdclient, 0, &fragment); + assert_equals_int (ret, TRUE); + assert_equals_string (fragment.uri, "/TestMedia0"); + assert_equals_int64 (fragment.range_start, 10); + assert_equals_int64 (fragment.range_end, 20); + assert_equals_string (fragment.index_uri, "/TestIndex0"); + assert_equals_int64 (fragment.index_range_start, 100); + assert_equals_int64 (fragment.index_range_end, 200); + assert_equals_uint64 (fragment.duration, expectedDuration * GST_MSECOND); + assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND); + gst_media_fragment_info_clear (&fragment); + + /* advance to next segment */ + flow = gst_mpd_client_advance_segment (mpdclient, activeStream, TRUE); + assert_equals_int (flow, GST_FLOW_EOS); + + gst_mpd_client_free (mpdclient); +} + +GST_END_TEST; + /* * Test parsing empty xml string * @@ -5482,6 +5579,7 @@ dash_suite (void) tcase_add_test (tc_complexMPD, dash_mpdparser_get_period_at_time); tcase_add_test (tc_complexMPD, dash_mpdparser_adaptationSet_handling); tcase_add_test (tc_complexMPD, dash_mpdparser_representation_selection); + tcase_add_test (tc_complexMPD, dash_mpdparser_multipleSegmentURL); tcase_add_test (tc_complexMPD, dash_mpdparser_activeStream_selection); tcase_add_test (tc_complexMPD, dash_mpdparser_activeStream_parameters); tcase_add_test (tc_complexMPD, dash_mpdparser_get_audio_languages);