summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2017-05-25 09:48:53 +0200
committerEdward Hervey <bilboed@bilboed.com>2017-06-12 16:07:29 +0200
commitff924fbdc687b224bf3744fd9ef6b5ff32eb99d1 (patch)
tree392e0f677b36ffac1d9214fe6cab2fa53fa80c30
parente1bbea8355bce5917710b4e18ea8533b37a3d616 (diff)
downloadgstreamer-plugins-bad-ff924fbdc687b224bf3744fd9ef6b5ff32eb99d1.tar.gz
adaptivedemux: Check live seeking range more often
The live seeking range was only checked when doing actual seeks. This was assuming that the rate would always be 1.0 (i.e. the playback would advance in realtime, and therefore fragments would always be available since the seeking window moves at the same rate). With non-1.0 rates, this no longer becomes valid, and therefore we need to check whether we are still within the live seeking range when advancing. https://bugzilla.gnome.org/show_bug.cgi?id=783075
-rw-r--r--gst-libs/gst/adaptivedemux/gstadaptivedemux.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
index b573b705d..68e0d5aaa 100644
--- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
+++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
@@ -1441,6 +1441,25 @@ gst_adaptive_demux_get_live_seek_range (GstAdaptiveDemux * demux,
/* must be called with manifest_lock taken */
static gboolean
+gst_adaptive_demux_stream_in_live_seek_range (GstAdaptiveDemux * demux,
+ GstAdaptiveDemuxStream * stream)
+{
+ gint64 range_start, range_stop;
+ if (gst_adaptive_demux_get_live_seek_range (demux, &range_start, &range_stop)) {
+ GST_LOG_OBJECT (stream->pad,
+ "stream position %" GST_STIME_FORMAT " live seek range %"
+ GST_STIME_FORMAT " - %" GST_STIME_FORMAT,
+ GST_STIME_ARGS (stream->segment.position), GST_STIME_ARGS (range_start),
+ GST_STIME_ARGS (range_stop));
+ return (stream->segment.position >= range_start
+ && stream->segment.position <= range_stop);
+ }
+
+ return FALSE;
+}
+
+/* must be called with manifest_lock taken */
+static gboolean
gst_adaptive_demux_can_seek (GstAdaptiveDemux * demux)
{
GstAdaptiveDemuxClass *klass;
@@ -3567,7 +3586,8 @@ gst_adaptive_demux_stream_download_loop (GstAdaptiveDemuxStream * stream)
case GST_FLOW_EOS:
GST_DEBUG_OBJECT (stream->pad, "EOS, checking to stop download loop");
/* we push the EOS after releasing the object lock */
- if (gst_adaptive_demux_is_live (demux)) {
+ if (gst_adaptive_demux_is_live (demux)
+ && gst_adaptive_demux_stream_in_live_seek_range (demux, stream)) {
GstAdaptiveDemuxClass *demux_class =
GST_ADAPTIVE_DEMUX_GET_CLASS (demux);
@@ -3974,7 +3994,15 @@ gst_adaptive_demux_stream_advance_fragment_unlocked (GstAdaptiveDemux * demux,
}
GST_ADAPTIVE_DEMUX_SEGMENT_UNLOCK (demux);
- if (gst_adaptive_demux_is_live (demux)
+ /* When advancing with a non 1.0 rate on live streams, we need to check
+ * the live seeking range again to make sure we can still advance to
+ * that position */
+ if (demux->segment.rate != 1.0 && gst_adaptive_demux_is_live (demux)) {
+ if (!gst_adaptive_demux_stream_in_live_seek_range (demux, stream))
+ ret = GST_FLOW_EOS;
+ else
+ ret = klass->stream_advance_fragment (stream);
+ } else if (gst_adaptive_demux_is_live (demux)
|| gst_adaptive_demux_stream_has_next_fragment (demux, stream)) {
ret = klass->stream_advance_fragment (stream);
} else {