diff --git a/ext/dash/gstdashdemux.c b/ext/dash/gstdashdemux.c index 10ebd7b3b2..9bbc5ae03f 100644 --- a/ext/dash/gstdashdemux.c +++ b/ext/dash/gstdashdemux.c @@ -310,18 +310,33 @@ gst_dash_demux_get_live_seek_range (GstAdaptiveDemux * demux, gint64 * start, gint64 * stop) { GstDashDemux *self = GST_DASH_DEMUX (demux); - GDateTime *now = gst_dash_demux_get_server_now_utc (self); - GDateTime *mstart = - gst_date_time_to_g_date_time (self->client->mpd_node-> - availabilityStartTime); + GDateTime *now; + GDateTime *mstart; GTimeSpan stream_now; + if (self->client->mpd_node->availabilityStartTime == NULL) + return FALSE; + + now = gst_dash_demux_get_server_now_utc (self); + mstart = + gst_date_time_to_g_date_time (self->client-> + mpd_node->availabilityStartTime); stream_now = g_date_time_difference (now, mstart); g_date_time_unref (now); g_date_time_unref (mstart); - *stop = stream_now * GST_USECOND; - *start = *stop - (self->client->mpd_node->timeShiftBufferDepth * GST_MSECOND); + if (stream_now <= 0) + return FALSE; + + *stop = stream_now * GST_USECOND; + if (self->client->mpd_node->timeShiftBufferDepth == GST_MPD_DURATION_NONE) { + *start = 0; + } else { + *start = + *stop - (self->client->mpd_node->timeShiftBufferDepth * GST_MSECOND); + if (*start < 0) + *start = 0; + } return TRUE; } diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index 230d206d64..e3c3b51bb3 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -1524,6 +1524,11 @@ gst_adaptive_demux_src_query (GstPad * pad, GstObject * parent, if (can_seek) { if (gst_adaptive_demux_is_live (demux)) { ret = gst_adaptive_demux_get_live_seek_range (demux, &start, &stop); + if (!ret) { + GST_MANIFEST_UNLOCK (demux); + GST_INFO_OBJECT (demux, "can't answer seeking query"); + return FALSE; + } } else { duration = demux_class->get_duration (demux); if (GST_CLOCK_TIME_IS_VALID (duration) && duration > 0)