adaptivedemux: Don't calculate bitrate for header/index fragments
authorEdward Hervey <edward@centricular.com>
Tue, 10 Nov 2020 13:48:28 +0000 (14:48 +0100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 11 Nov 2020 20:18:11 +0000 (20:18 +0000)
They are generally substantially smaller than regular fragments, and therefore
we end up pushing totally wrong bitrates downstream.

Fixes erratic buffering issues with DASH introduced by
66f5e874352016e29f555e3ce693b23474e476db

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1021>

gst-libs/gst/adaptivedemux/gstadaptivedemux.c

index 26235d2..a66b39e 100644 (file)
@@ -1911,17 +1911,23 @@ gst_adaptive_demux_src_event (GstPad * pad, GstObject * parent,
     case GST_EVENT_QOS:{
       GstClockTimeDiff diff;
       GstClockTime timestamp;
+      GstClockTime earliest_time;
 
       gst_event_parse_qos (event, NULL, NULL, &diff, &timestamp);
       /* Only take into account lateness if late */
-      GST_OBJECT_LOCK (demux);
       if (diff > 0)
-        demux->priv->qos_earliest_time = timestamp + 2 * diff;
+        earliest_time = timestamp + 2 * diff;
       else
-        demux->priv->qos_earliest_time = timestamp;
+        earliest_time = timestamp;
+
+      GST_OBJECT_LOCK (demux);
+      if (!GST_CLOCK_TIME_IS_VALID (demux->priv->qos_earliest_time) ||
+          earliest_time > demux->priv->qos_earliest_time) {
+        demux->priv->qos_earliest_time = earliest_time;
+        GST_DEBUG_OBJECT (demux, "qos_earliest_time %" GST_TIME_FORMAT,
+            GST_TIME_ARGS (demux->priv->qos_earliest_time));
+      }
       GST_OBJECT_UNLOCK (demux);
-      GST_DEBUG_OBJECT (demux, "qos_earliest_time %" GST_TIME_FORMAT,
-          GST_TIME_ARGS (demux->priv->qos_earliest_time));
       break;
     }
     default:
@@ -4661,7 +4667,7 @@ gst_adaptive_demux_clock_callback (GstClock * clock,
  *
  * Returns: The QOS earliest time
  *
- * Since: 1.18
+ * Since: 1.20
  */
 GstClockTime
 gst_adaptive_demux_get_qos_earliest_time (GstAdaptiveDemux * demux)