adaptivedemux: Enable bitrate selection for trick mode streaming again
authorSebastian Dröge <sebastian@centricular.com>
Thu, 25 Aug 2016 16:35:13 +0000 (19:35 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 25 Aug 2016 16:52:37 +0000 (19:52 +0300)
And scale the bitrate with the absolute rate (if it's bigger than 1.0) to get
to the real bitrate due to faster playback.

This allowed in my tests to play a stream with 10x speed without buffering as
the lowest bitrate is chosen, instead of staying/selecting the highest bitrate
and then buffering all the time.

It was previously disabled for not very well specified reasons, which seem to
be not valid anymore nowadays.

ext/dash/gstdashdemux.c
ext/hls/gsthlsdemux.c
ext/smoothstreaming/gstmssdemux.c
gst-libs/gst/adaptivedemux/gstadaptivedemux.c

index 5fe629c..2b29a1d 100644 (file)
@@ -1437,6 +1437,7 @@ gst_dash_demux_stream_select_bitrate (GstAdaptiveDemuxStream * stream,
   GstActiveStream *active_stream = NULL;
   GList *rep_list = NULL;
   gint new_index;
+  GstAdaptiveDemux *base_demux = stream->demux;
   GstDashDemux *demux = GST_DASH_DEMUX_CAST (stream->demux);
   GstDashDemuxStream *dashstream = (GstDashDemuxStream *) stream;
   gboolean ret = FALSE;
@@ -1457,7 +1458,15 @@ gst_dash_demux_stream_select_bitrate (GstAdaptiveDemuxStream * stream,
       "Trying to change to bitrate: %" G_GUINT64_FORMAT, bitrate);
 
   /* get representation index with current max_bandwidth */
-  new_index = gst_mpdparser_get_rep_idx_with_max_bandwidth (rep_list, bitrate);
+  if ((base_demux->segment.flags & GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS) ||
+      ABS (base_demux->segment.rate) <= 1.0) {
+    new_index =
+        gst_mpdparser_get_rep_idx_with_max_bandwidth (rep_list, bitrate);
+  } else {
+    new_index =
+        gst_mpdparser_get_rep_idx_with_max_bandwidth (rep_list,
+        bitrate / ABS (base_demux->segment.rate));
+  }
 
   /* if no representation has the required bandwidth, take the lowest one */
   if (new_index == -1)
index 4cf5b81..a4eaacd 100644 (file)
@@ -1086,11 +1086,8 @@ gst_hls_demux_select_bitrate (GstAdaptiveDemuxStream * stream, guint64 bitrate)
     return FALSE;
   }
 
-  /* Bitrate adaptation during trick modes does not work well */
-  if (demux->segment.rate != 1.0)
-    return FALSE;
-
-  gst_hls_demux_change_playlist (hlsdemux, bitrate, &changed);
+  gst_hls_demux_change_playlist (hlsdemux, bitrate / MAX (1.0,
+          ABS (demux->segment.rate)), &changed);
   if (changed)
     gst_hls_demux_setup_streams (GST_ADAPTIVE_DEMUX_CAST (hlsdemux));
   return changed;
index 27725ca..9d0aece 100644 (file)
@@ -543,7 +543,8 @@ gst_mss_demux_stream_select_bitrate (GstAdaptiveDemuxStream * stream,
   GST_DEBUG_OBJECT (stream->pad,
       "Using stream download bitrate %" G_GUINT64_FORMAT, bitrate);
 
-  if (gst_mss_stream_select_bitrate (mssstream->manifest_stream, bitrate)) {
+  if (gst_mss_stream_select_bitrate (mssstream->manifest_stream,
+          bitrate / MAX (1.0, ABS (stream->demux->segment.rate)))) {
     GstCaps *caps;
     GstCaps *msscaps;
     GstMssDemux *mssdemux = GST_MSS_DEMUX_CAST (stream->demux);
index 536d512..e51f6dd 100644 (file)
@@ -3710,12 +3710,6 @@ gst_adaptive_demux_stream_select_bitrate (GstAdaptiveDemux *
 {
   GstAdaptiveDemuxClass *klass = GST_ADAPTIVE_DEMUX_GET_CLASS (demux);
 
-  /* FIXME: Currently several issues have be found when letting bitrate adaptation
-   * happen using trick modes (such as 'All streams finished without buffers') and
-   * the adaptive algorithm does not properly behave. */
-  if (demux->segment.rate != 1.0)
-    return FALSE;
-
   if (klass->stream_select_bitrate)
     return klass->stream_select_bitrate (stream, bitrate);
   return FALSE;