]> git.sesse.net Git - ffmpeg/commitdiff
libavformat/hls: Reset options after open_url_keepalive() fails
authorEd Martin <edman007@edman007.com>
Wed, 10 Mar 2021 21:43:10 +0000 (21:43 +0000)
committerSteven Liu <liuqi05@kuaishou.com>
Mon, 15 Mar 2021 07:16:20 +0000 (15:16 +0800)
open_url_keepalive() unsets the options when it uses them, this
includes the offsets for the Range: header. When using the HLS
tag #EXT-X-BYTERANGE along with multiple files, the range options
must be preserved after open_url_keepalive() returns EOF so that
the new file can be opened. Failure to do this results in ignoring
the #EXT-X-BYTERANGE tag and reading the wrong bytes of the file.

To fix it, reset the options before calling io_open() following
open_url_keepalive() reaching EOF

Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
libavformat/hls.c

index af2468ad9beb3722379c002ab2b6bbda96a35032..d08d00cf24df97e299ea289fb32cbf4350394fbf 100644 (file)
@@ -677,6 +677,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
                 av_log(s, AV_LOG_WARNING,
                     "keepalive request failed for '%s' with error: '%s' when opening url, retrying with new connection\n",
                     url, av_err2str(ret));
+            av_dict_copy(&tmp, *opts, 0);
+            av_dict_copy(&tmp, opts2, 0);
             ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);
         }
     } else {