[FFmpeg-devel] [PATCH v2 4/4] avformat/hls: enable http_multiple only for http/1.1 servers

Aman Gupta ffmpeg at tmm1.net
Tue Dec 26 07:23:01 EET 2017


From: Aman Gupta <aman at tmm1.net>

Signed-off-by: Aman Gupta <aman at tmm1.net>
---
 doc/demuxers.texi |  2 +-
 libavformat/hls.c | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 81ab399cdc..6080167233 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -323,7 +323,7 @@ Enabled by default.
 
 @item http_multiple
 Use multiple HTTP connections for downloading HTTP segments.
-Enabled by default.
+Enabled by default for HTTP/1.1 servers.
 @end table
 
 @section image2
diff --git a/libavformat/hls.c b/libavformat/hls.c
index c30d71a477..d2cca2ea97 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1451,7 +1451,7 @@ reload:
         if (ret)
             return ret;
 
-        if (c->http_multiple && av_strstart(seg->url, "http", NULL) && v->input_next_requested) {
+        if (c->http_multiple && v->input_next_requested) {
             FFSWAP(AVIOContext *, v->input, v->input_next);
             v->input_next_requested = 0;
             ret = 0;
@@ -1470,8 +1470,15 @@ reload:
         just_opened = 1;
     }
 
+    if (c->http_multiple == -1) {
+        uint8_t *http_version_opt = NULL;
+        av_opt_get(v->input, "http_version", AV_OPT_SEARCH_CHILDREN, &http_version_opt);
+        c->http_multiple = strncmp((const char *)http_version_opt, "1.1", 3) == 0;
+    }
+
     seg = next_segment(v);
-    if (c->http_multiple && !v->input_next_requested && seg) {
+    if (c->http_multiple == 1 && !v->input_next_requested &&
+        seg && av_strstart(seg->url, "http", NULL)) {
         ret = open_input(c, v, seg, &v->input_next);
         if (ret < 0) {
             if (ff_check_interrupt(c->interrupt_callback))
@@ -2305,7 +2312,7 @@ static const AVOption hls_options[] = {
     {"http_persistent", "Use persistent HTTP connections",
         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}, 0, 1, FLAGS},
+        OFFSET(http_multiple), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, FLAGS},
     {NULL}
 };
 
-- 
2.14.2



More information about the ffmpeg-devel mailing list