From 7ca6d9634a8df45e9ad28f572e36a8d5e697b413 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Thu, 12 Feb 2015 22:06:17 +0100 Subject: [PATCH] dashdemux: Fix handling of live streams with timeshift buffers. By implementing get_live_seek_range. As shown by : gst-validate-1.0 playbin \ uri=http://dev-iplatforms.kw.bbc.co.uk/dash/news24-avc3/news24.php This patch handles live seeking, by setting a live seek range comprised between now - timeShiftBufferDepth and now. The inteersting thing with this stream is that one can actually ask fragments up to availabilityStartTime, but it seems quite clear in the spec that content is only guaranteed to exist up to timeShiftBufferDepth. One can test live seeking this way : gst-validate-1.0 playbin \ uri=http://dev-iplatforms.kw.bbc.co.uk/dash/news24-avc3/news24.php \ --set-scenario seek_back.scenario with scenario being: description, seek=true seek, playback-time=position+5.0, start="position-600.0", flags=accurate+flush This example will play the stream, wait for five seconds, then seek back to a position 10 minutes earlier. https://bugzilla.gnome.org/show_bug.cgi?id=744362 --- ext/dash/gstdashdemux.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ext/dash/gstdashdemux.c b/ext/dash/gstdashdemux.c index 12f5d6069a..fca120c1b5 100644 --- a/ext/dash/gstdashdemux.c +++ b/ext/dash/gstdashdemux.c @@ -262,6 +262,25 @@ gst_dash_demux_dispose (GObject * obj) G_OBJECT_CLASS (parent_class)->dispose (obj); } +static gboolean +gst_dash_demux_get_live_seek_range (GstAdaptiveDemux * demux, gint64 * start, + gint64 * stop) +{ + GstDashDemux *self = GST_DASH_DEMUX (demux); + GDateTime *now = g_date_time_new_now_utc (); + GDateTime *mstart = + gst_date_time_to_g_date_time (self->client->mpd_node->availabilityStartTime); + GTimeSpan stream_now; + + 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); + return TRUE; +} + static void gst_dash_demux_class_init (GstDashDemuxClass * klass) { @@ -338,6 +357,7 @@ gst_dash_demux_class_init (GstDashDemuxClass * klass) gstadaptivedemux_class->stream_update_fragment_info = gst_dash_demux_stream_update_fragment_info; gstadaptivedemux_class->stream_free = gst_dash_demux_stream_free; + gstadaptivedemux_class->get_live_seek_range = gst_dash_demux_get_live_seek_range; } static void