diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index 25dea0892f..b658126fe5 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -2072,7 +2072,7 @@ gst_mpdparser_get_rep_idx_with_max_bandwidth (GList * Representations, return -1; if (max_bandwidth <= 0) /* 0 => get lowest representation available */ - return 0; + return gst_mpdparser_get_rep_idx_with_min_bandwidth (Representations); for (list = g_list_first (Representations); list; list = g_list_next (list)) { representation = (GstRepresentationNode *) list->data; diff --git a/tests/check/elements/dash_mpd.c b/tests/check/elements/dash_mpd.c index faa3e58944..2abe5b0b15 100644 --- a/tests/check/elements/dash_mpd.c +++ b/tests/check/elements/dash_mpd.c @@ -350,6 +350,72 @@ GST_START_TEST (dash_mpdparser_type_dynamic) GST_END_TEST; +/* + * Test handling Representation selection + * + */ +GST_START_TEST (dash_mpdparser_representation_selection) +{ + GList *adaptationSets; + GstAdaptationSetNode *adaptationSetNode; + GList *representations; + gint represendationIndex; + + 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); + assert_equals_int (ret, TRUE); + + adaptationSets = gst_mpd_client_get_adaptation_sets (mpdclient); + fail_if (adaptationSets == NULL); + + adaptationSetNode = adaptationSets->data; + fail_if (adaptationSetNode == NULL); + assert_equals_int (adaptationSetNode->id, 1); + + representations = adaptationSetNode->Representations; + fail_if (representations == NULL); + + represendationIndex = + gst_mpdparser_get_rep_idx_with_min_bandwidth (representations); + assert_equals_int (represendationIndex, 1); + + represendationIndex = + gst_mpdparser_get_rep_idx_with_max_bandwidth (representations, 0); + assert_equals_int (represendationIndex, 1); + + represendationIndex = + gst_mpdparser_get_rep_idx_with_max_bandwidth (representations, 100000); + assert_equals_int (represendationIndex, -1); + + represendationIndex = + gst_mpdparser_get_rep_idx_with_max_bandwidth (representations, 300000); + assert_equals_int (represendationIndex, 1); + + represendationIndex = + gst_mpdparser_get_rep_idx_with_max_bandwidth (representations, 500000); + assert_equals_int (represendationIndex, 0); + + gst_mpd_client_free (mpdclient); +} + +GST_END_TEST; + /* * Test parsing empty xml string * @@ -441,6 +507,7 @@ dash_suite (void) { Suite *s = suite_create ("dash"); TCase *tc_simpleMPD = tcase_create ("simpleMPD"); + TCase *tc_complexMPD = tcase_create ("complexMPD"); TCase *tc_negativeTests = tcase_create ("negativeTests"); GST_DEBUG_CATEGORY_INIT (gst_dash_demux_debug, "gst_dash_demux_debug", 0, @@ -461,6 +528,7 @@ dash_suite (void) /* tests checking other possible values for attributes */ tcase_add_test (tc_simpleMPD, dash_mpdparser_type_dynamic); + tcase_add_test (tc_complexMPD, dash_mpdparser_representation_selection); /* tests checking the parsing of missing/incomplete attributes of xml */ tcase_add_test (tc_negativeTests, dash_mpdparser_missing_xml); tcase_add_test (tc_negativeTests, dash_mpdparser_missing_mpd); @@ -468,6 +536,7 @@ dash_suite (void) tcase_add_test (tc_negativeTests, dash_mpdparser_no_default_namespace); suite_add_tcase (s, tc_simpleMPD); + suite_add_tcase (s, tc_complexMPD); suite_add_tcase (s, tc_negativeTests); return s;