if (time_offset < 0)
return 0;
+ if (!gst_mpd_client_setup_media_presentation (client, time_offset, -1, NULL))
+ return 0;
+
for (idx = 0, iter = client->periods; iter; idx++, iter = g_list_next (iter)) {
stream_period = iter->data;
if (stream_period->start <= time_offset
return new_periods;
}
-/* TODO: Implement xlink actuation onRequest properly. Currently we download
- * each external MPD immediately when iterating over the periods. We should
- * do this only when actually switching to this period.
- */
gboolean
-gst_mpd_client_setup_media_presentation (GstMpdClient * client)
+gst_mpd_client_setup_media_presentation (GstMpdClient * client,
+ GstClockTime time, gint period_idx, const gchar * period_id)
{
GstStreamPeriod *stream_period;
GstClockTime start, duration;
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (client->mpd_node != NULL, FALSE);
+ /* Check if we set up the media presentation far enough already */
+ for (list = client->periods; list; list = list->next) {
+ GstStreamPeriod *stream_period = list->data;
+
+ if ((time != GST_CLOCK_TIME_NONE
+ && stream_period->duration != GST_CLOCK_TIME_NONE
+ && stream_period->start + stream_period->duration >= time)
+ || (time != GST_CLOCK_TIME_NONE && stream_period->start >= time))
+ return TRUE;
+
+ if (period_idx != -1 && stream_period->number >= period_idx)
+ return TRUE;
+
+ if (period_id != NULL && stream_period->period->id != NULL
+ && strcmp (stream_period->period->id, period_id) == 0)
+ return TRUE;
+
+ }
+
GST_DEBUG ("Building the list of Periods in the Media Presentation");
/* clean the old period list, if any */
+ /* TODO: In theory we could reuse the ones we have so far but that
+ * seems more complicated than the overhead caused here
+ */
if (client->periods) {
g_list_foreach (client->periods,
(GFunc) gst_mpdparser_free_stream_period, NULL);
GST_LOG (" - added Period %d start=%" GST_TIME_FORMAT " duration=%"
GST_TIME_FORMAT, idx, GST_TIME_ARGS (start), GST_TIME_ARGS (duration));
+ if ((time != GST_CLOCK_TIME_NONE
+ && stream_period->duration != GST_CLOCK_TIME_NONE
+ && stream_period->start + stream_period->duration >= time)
+ || (time != GST_CLOCK_TIME_NONE && stream_period->start >= time))
+ break;
+
+ if (period_idx != -1 && stream_period->number >= period_idx)
+ break;
+
+ if (period_id != NULL && stream_period->period->id != NULL
+ && strcmp (stream_period->period->id, period_id) == 0)
+ break;
+
list = list->next;
}
- GST_DEBUG ("Found a total of %d valid Periods in the Media Presentation",
+ GST_DEBUG
+ ("Found a total of %d valid Periods in the Media Presentation up to this point",
idx);
return ret;
g_return_val_if_fail (client->periods != NULL, FALSE);
g_return_val_if_fail (period_id != NULL, FALSE);
+ if (!gst_mpd_client_setup_media_presentation (client, GST_CLOCK_TIME_NONE, -1,
+ period_id))
+ return FALSE;
+
for (period_idx = 0, iter = client->periods; iter;
period_idx++, iter = g_list_next (iter)) {
next_stream_period = iter->data;
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (client->periods != NULL, FALSE);
+ if (!gst_mpd_client_setup_media_presentation (client, -1, period_idx, NULL))
+ return FALSE;
+
next_stream_period = g_list_nth_data (client->periods, period_idx);
if (next_stream_period != NULL) {
client->period_idx = period_idx;
ret = gst_mpd_parse (mpdclient, xml, (gint) strlen (xml));
assert_equals_int (ret, TRUE);
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ ret =
+ gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
+ -1, NULL);
assert_equals_int (ret, TRUE);
periodNode =
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ ret =
+ gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
+ -1, NULL);
assert_equals_int (ret, TRUE);
gst_mpd_client_free (mpdclient);
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ ret =
+ gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
+ -1, NULL);
assert_equals_int (ret, TRUE);
/* get the first adaptation set of the first period */
fail_unless (mpdclient->periods == NULL);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ ret =
+ gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
+ -1, NULL);
assert_equals_int (ret, TRUE);
/* check the periods */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ ret =
+ gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
+ -1, NULL);
assert_equals_int (ret, TRUE);
/* request period for a time before availabilityStartTime, expect period index 0 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ ret =
+ gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
+ -1, NULL);
assert_equals_int (ret, TRUE);
/* period0 has 1 adaptation set */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ ret =
+ gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
+ -1, NULL);
assert_equals_int (ret, TRUE);
adaptationSets = gst_mpd_client_get_adaptation_sets (mpdclient);
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
assert_equals_int (ret, TRUE);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ 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 */
fail_unless (mpdclient->periods == NULL);
/* process the xml data */
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ ret =
+ gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
+ -1, NULL);
assert_equals_int (ret, TRUE);
/* Period0 should be present */
/* process the xml data
* should fail due to wrong duration in Period0 (start > mediaPresentationDuration)
*/
- ret = gst_mpd_client_setup_media_presentation (mpdclient);
+ ret =
+ gst_mpd_client_setup_media_presentation (mpdclient, GST_CLOCK_TIME_NONE,
+ -1, NULL);
assert_equals_int (ret, FALSE);
gst_mpd_client_free (mpdclient);