mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 05:59:10 +00:00
dashdemux: fixed getting representation based on max bandwidth
The gst_mpdparser_get_rep_idx_with_max_bandwidth function assumes representations are ordered by bandwidth and incorrectly returns the first one when wanting the one with minimum bandwidth. Corrected gst_mpdparser_get_rep_idx_with_max_bandwidth function to get the correct representation in case max_bandwidth parameter is 0. https://bugzilla.gnome.org/show_bug.cgi?id=751153
This commit is contained in:
parent
6b2800e324
commit
9f56cc27ab
2 changed files with 70 additions and 1 deletions
|
@ -2072,7 +2072,7 @@ gst_mpdparser_get_rep_idx_with_max_bandwidth (GList * Representations,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (max_bandwidth <= 0) /* 0 => get lowest representation available */
|
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)) {
|
for (list = g_list_first (Representations); list; list = g_list_next (list)) {
|
||||||
representation = (GstRepresentationNode *) list->data;
|
representation = (GstRepresentationNode *) list->data;
|
||||||
|
|
|
@ -350,6 +350,72 @@ GST_START_TEST (dash_mpdparser_type_dynamic)
|
||||||
|
|
||||||
GST_END_TEST;
|
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 =
|
||||||
|
"<?xml version=\"1.0\"?>"
|
||||||
|
"<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\""
|
||||||
|
" profiles=\"urn:mpeg:dash:profile:isoff-main:2011\">"
|
||||||
|
"<Period id=\"Period0\" duration=\"P0Y0M1DT1H1M1S\">"
|
||||||
|
"<AdaptationSet id=\"1\" mimeType=\"video/mp4\">"
|
||||||
|
"<Representation id=\"v0\" bandwidth=\"500000\"></Representation>"
|
||||||
|
"<Representation id=\"v1\" bandwidth=\"250000\"></Representation>"
|
||||||
|
"</AdaptationSet></Period></MPD>";
|
||||||
|
|
||||||
|
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
|
* Test parsing empty xml string
|
||||||
*
|
*
|
||||||
|
@ -441,6 +507,7 @@ dash_suite (void)
|
||||||
{
|
{
|
||||||
Suite *s = suite_create ("dash");
|
Suite *s = suite_create ("dash");
|
||||||
TCase *tc_simpleMPD = tcase_create ("simpleMPD");
|
TCase *tc_simpleMPD = tcase_create ("simpleMPD");
|
||||||
|
TCase *tc_complexMPD = tcase_create ("complexMPD");
|
||||||
TCase *tc_negativeTests = tcase_create ("negativeTests");
|
TCase *tc_negativeTests = tcase_create ("negativeTests");
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_dash_demux_debug, "gst_dash_demux_debug", 0,
|
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 */
|
/* tests checking other possible values for attributes */
|
||||||
tcase_add_test (tc_simpleMPD, dash_mpdparser_type_dynamic);
|
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 */
|
/* 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_xml);
|
||||||
tcase_add_test (tc_negativeTests, dash_mpdparser_missing_mpd);
|
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);
|
tcase_add_test (tc_negativeTests, dash_mpdparser_no_default_namespace);
|
||||||
|
|
||||||
suite_add_tcase (s, tc_simpleMPD);
|
suite_add_tcase (s, tc_simpleMPD);
|
||||||
|
suite_add_tcase (s, tc_complexMPD);
|
||||||
suite_add_tcase (s, tc_negativeTests);
|
suite_add_tcase (s, tc_negativeTests);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
Loading…
Reference in a new issue