]> git.sesse.net Git - ffmpeg/commitdiff
lavf/hls: add http_seekable option for HTTP partial requests
authorJun Zhao <barryjzhao@tencent.com>
Wed, 7 Aug 2019 16:12:16 +0000 (00:12 +0800)
committerJun Zhao <barryjzhao@tencent.com>
Thu, 8 Aug 2019 09:53:32 +0000 (17:53 +0800)
Add http_seekable option for HTTP partial requests, when The
EXT-X-BYTERANGE tag indicates that a Media Segment is a sub-range
of the resource identified by its URI, we can use HTTP partial
requests to get the Media Segment.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
doc/demuxers.texi
libavformat/hls.c

index 57d1532212ff56cd105591a1466cedc4e6c0af1b..fe766a5de7d80450109628d70b1ad5d62d4210c8 100644 (file)
@@ -338,6 +338,10 @@ Enabled by default.
 @item http_multiple
 Use multiple HTTP connections for downloading HTTP segments.
 Enabled by default for HTTP/1.1 servers.
+
+@item http_seekable
+Use HTTP partial requests for downloading HTTP segments.
+0 = disable, 1 = enable, -1 = auto, Default is auto.
 @end table
 
 @section image2
index 052244592ccea8a36a4ec0dfefb235c2e25ac1b8..61b6759ef53e472a938f3dd53a05b8599869fce2 100644 (file)
@@ -207,6 +207,7 @@ typedef struct HLSContext {
     int max_reload;
     int http_persistent;
     int http_multiple;
+    int http_seekable;
     AVIOContext *playlist_pb;
 } HLSContext;
 
@@ -1796,8 +1797,10 @@ static int hls_read_header(AVFormatContext *s)
     if ((ret = save_avio_options(s)) < 0)
         goto fail;
 
-    /* Some HLS servers don't like being sent the range header */
-    av_dict_set(&c->avio_opts, "seekable", "0", 0);
+    /* XXX: Some HLS servers don't like being sent the range header,
+       in this case, need to  setting http_seekable = 0 to disable
+       the range header */
+    av_dict_set_int(&c->avio_opts, "seekable", c->http_seekable, 0);
 
     if ((ret = parse_playlist(c, s->url, NULL, s->pb)) < 0)
         goto fail;
@@ -2311,6 +2314,8 @@ static const AVOption hls_options[] = {
         OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
     {"http_multiple", "Use multiple HTTP connections for fetching segments",
         OFFSET(http_multiple), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, FLAGS},
+    {"http_seekable", "Use HTTP partial requests, 0 = disable, 1 = enable, -1 = auto",
+        OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS},
     {NULL}
 };