From 298eedad8bd735fe5ce266b8d0e16f7768dd878c Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 27 Aug 2020 11:18:56 +0200 Subject: [PATCH] adaptivedemux: Handle invalid HTTP duration The default BYTE DURATION basesrc query handler will return `-1` and TRUE. In order to properly handle cases where upstream http servers didn't return a valid Content-Length we also need to check whether it was valid when calculating bitrates. Avoids returning completely bogus bitrates with gogol's video streaming services Part-of: --- gst-libs/gst/adaptivedemux/gstadaptivedemux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index 9b5aba037b..0af6481d68 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -2662,11 +2662,11 @@ _src_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) if (stream->fragment.bitrate == 0 && stream->fragment.duration != 0 && gst_element_query_duration (stream->uri_handler, GST_FORMAT_BYTES, - &chunk_size)) { + &chunk_size) && chunk_size != -1) { guint bitrate = MIN (G_MAXUINT, gst_util_uint64_scale (chunk_size, 8 * GST_SECOND, stream->fragment.duration)); GST_LOG_OBJECT (demux, - "Fragment has size %" G_GUINT64_FORMAT " duration %" GST_TIME_FORMAT + "Fragment has size %" G_GINT64_FORMAT " duration %" GST_TIME_FORMAT " = bitrate %u", chunk_size, GST_TIME_ARGS (stream->fragment.duration), bitrate); stream->fragment.bitrate = bitrate;