From ff395a75655e2664601aeee029f615b73ee4fe29 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 28 Apr 2014 19:10:02 -0300 Subject: [PATCH] hlsdemux: Track fragments duration When receving EOS from the internal src, increase the current positon by the fragment duration to allow correct restoring of download position if the bitrate changes --- ext/hls/gsthlsdemux.c | 8 ++++++-- ext/hls/gsthlsdemux.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c index 86db8bd5be..450d2739e6 100644 --- a/ext/hls/gsthlsdemux.c +++ b/ext/hls/gsthlsdemux.c @@ -912,6 +912,8 @@ _src_event (GstPad * pad, GstObject * parent, GstEvent * event) demux->pending_buffer = NULL; } + if (demux->segment.rate > 0) + demux->segment.position += demux->current_duration; g_cond_signal (&demux->fragment_download_cond); break; default: @@ -1815,11 +1817,13 @@ gst_hls_demux_get_next_fragment (GstHLSDemux * demux, g_mutex_lock (&demux->fragment_download_lock); GST_DEBUG_OBJECT (demux, - "Fetching next fragment %s (range=%" G_GINT64_FORMAT "-%" G_GINT64_FORMAT - ")", next_fragment_uri, range_start, range_end); + "Fetching next fragment %s %" GST_TIME_FORMAT "(range=%" G_GINT64_FORMAT + "-%" G_GINT64_FORMAT ")", next_fragment_uri, GST_TIME_ARGS (timestamp), + range_start, range_end); /* set up our source for download */ demux->current_timestamp = timestamp; + demux->current_duration = duration; demux->starting_fragment = TRUE; demux->current_key = key; demux->current_iv = iv; diff --git a/ext/hls/gsthlsdemux.h b/ext/hls/gsthlsdemux.h index f6c425be49..9e0a796edd 100644 --- a/ext/hls/gsthlsdemux.h +++ b/ext/hls/gsthlsdemux.h @@ -115,6 +115,7 @@ struct _GstHLSDemux GMutex fragment_download_lock; GCond fragment_download_cond; GstClockTime current_timestamp; + GstClockTime current_duration; gboolean starting_fragment; gint64 download_start_time; gint64 download_total_time;