summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2020-08-27 11:18:56 +0200
committerTim-Philipp Müller <tim@centricular.com>2020-10-03 00:51:29 +0100
commit345a17c0b691aa6cbac47f8f3678be72b5481142 (patch)
treea5dea081b26a024d25adbcb029e921d68b34c1f3 /gst-libs
parent273ae7cd1e4a5a697d60d07d6da61c9c994a2169 (diff)
downloadgstreamer-plugins-bad-345a17c0b691aa6cbac47f8f3678be72b5481142.tar.gz
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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1635>
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/adaptivedemux/gstadaptivedemux.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
index 9b5aba037..0af6481d6 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;