diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index 3a1cb82569..d307f2d41e 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -1570,6 +1570,7 @@ gst_mpdparser_parse_segment_list_node (GstSegmentListNode ** pointer, xmlNode *cur_node; GstSegmentListNode *new_segment_list; gchar *actuate; + gboolean segment_urls_inherited_from_parent = FALSE; gst_mpdparser_free_segment_list_node (*pointer); new_segment_list = g_slice_new0 (GstSegmentListNode); @@ -1584,6 +1585,7 @@ gst_mpdparser_parse_segment_list_node (GstSegmentListNode ** pointer, new_segment_list->SegmentURL = g_list_append (new_segment_list->SegmentURL, gst_mpdparser_clone_segment_url (seg_url)); + segment_urls_inherited_from_parent = TRUE; } } @@ -1607,6 +1609,23 @@ gst_mpdparser_parse_segment_list_node (GstSegmentListNode ** pointer, for (cur_node = a_node->children; cur_node; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { if (xmlStrcmp (cur_node->name, (xmlChar *) "SegmentURL") == 0) { + if (segment_urls_inherited_from_parent) { + /* + * SegmentBase, SegmentTemplate and SegmentList shall inherit + * attributes and elements from the same element on a higher level. + * If the same attribute or element is present on both levels, + * the one on the lower level shall take precedence over the one + * on the higher level. + */ + + /* Clear the list of inherited segment URLs */ + g_list_free_full (new_segment_list->SegmentURL, + (GDestroyNotify) gst_mpdparser_free_segment_url_node); + new_segment_list->SegmentURL = NULL; + + /* mark the fact that we cleared the list, so that it is not tried again */ + segment_urls_inherited_from_parent = FALSE; + } gst_mpdparser_parse_segment_url_node (&new_segment_list->SegmentURL, cur_node); } diff --git a/tests/check/elements/dash_mpd.c b/tests/check/elements/dash_mpd.c index 8200d77cf6..6ea64bcb87 100644 --- a/tests/check/elements/dash_mpd.c +++ b/tests/check/elements/dash_mpd.c @@ -4163,36 +4163,11 @@ GST_START_TEST (dash_mpdparser_inherited_segmentURL) expectedDuration = duration_to_ms (0, 0, 0, 0, 0, 110, 0); expectedTimestamp = duration_to_ms (0, 0, 0, 0, 0, 0, 0); - /* the representation contains 2 segments - * - one inherited from AdaptationSet (duration 100) - * - the second defined in the Representation (duration 110) - * - * Both will have the duration specified in the Representation (110) - */ + /* the representation contains 1 segment (the one from Representation) */ /* check first segment */ ret = gst_mpd_client_get_next_fragment (mpdclient, 0, &fragment); assert_equals_int (ret, TRUE); - assert_equals_string (fragment.uri, "/TestMediaAdaptation"); - assert_equals_int64 (fragment.range_start, 10); - assert_equals_int64 (fragment.range_end, 20); - assert_equals_string (fragment.index_uri, "/TestIndexAdaptation"); - assert_equals_int64 (fragment.index_range_start, 30); - assert_equals_int64 (fragment.index_range_end, 40); - 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_OK); - - /* second segment starts after first ends */ - expectedTimestamp = expectedTimestamp + expectedDuration; - - /* check second segment */ - ret = gst_mpd_client_get_next_fragment (mpdclient, 0, &fragment); - assert_equals_int (ret, TRUE); assert_equals_string (fragment.uri, "/TestMediaRep"); assert_equals_int64 (fragment.range_start, 100); assert_equals_int64 (fragment.range_end, 200); @@ -4203,6 +4178,10 @@ GST_START_TEST (dash_mpdparser_inherited_segmentURL) assert_equals_uint64 (fragment.timestamp, expectedTimestamp * GST_MSECOND); gst_media_fragment_info_clear (&fragment); + /* try to advance to next segment. Should fail */ + flow = gst_mpd_client_advance_segment (mpdclient, activeStream, TRUE); + assert_equals_int (flow, GST_FLOW_EOS); + gst_mpd_client_free (mpdclient); }