diff mbox

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

Message ID 20171226052301.17509-4-ffmpeg@tmm1.net
State New
Headers show

Commit Message

Aman Karmani Dec. 26, 2017, 5:23 a.m. UTC
From: Aman Gupta <aman@tmm1.net>

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

Comments

Michael Niedermayer Dec. 27, 2017, 7:35 p.m. UTC | #1
On Mon, Dec 25, 2017 at 09:23:01PM -0800, Aman Gupta wrote:
> From: Aman Gupta <aman@tmm1.net>
> 
> Signed-off-by: Aman Gupta <aman@tmm1.net>
> ---
>  doc/demuxers.texi |  2 +-
>  libavformat/hls.c | 13 ++++++++++---
>  2 files changed, 11 insertions(+), 4 deletions(-)

segfaults fate-filter-hls

#0  0x00007ffff03259a4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x0000000000697b7c in read_data (opaque=0x21d2fc0, buf=0x21e3240 "", buf_size=32768) at libavformat/hls.c:1472
#2  0x000000000065657c in read_packet_wrapper (s=0x21d3fc0, buf=0x21e3240 "", size=32768) at libavformat/aviobuf.c:533
#3  0x000000000065680a in fill_buffer (s=0x21d3fc0) at libavformat/aviobuf.c:583
#4  0x0000000000656bc3 in avio_read (s=0x21d3fc0, buf=0x21d5ef0 "\330.Z\360\377\177", size=2048) at libavformat/aviobuf.c:676
#5  0x0000000000687e11 in av_probe_input_buffer2 (pb=0x21d3fc0, fmt=0x7fffffffdaa0, filename=0x21d53a0 "tests/data/hls-out-000.ts", logctx=0x0, offset=0, max_probe_size=1048576) at libavformat/format.c:314
#6  0x0000000000687fe6 in av_probe_input_buffer (pb=0x21d3fc0, fmt=0x7fffffffdaa0, filename=0x21d53a0 "tests/data/hls-out-000.ts", logctx=0x0, offset=0, max_probe_size=0) at libavformat/format.c:368
#7  0x0000000000698e1f in hls_read_header (s=0x21d2580) at libavformat/hls.c:1920
#8  0x00000000007c434c in avformat_open_input (ps=0x7fffffffdbd0, filename=0x7fffffffe68c "tests/data/hls-list.m3u8", fmt=0x0, options=0x21d1d18) at libavformat/utils.c:613
#9  0x000000000041528f in open_input_file (o=0x7fffffffdcd0, filename=0x7fffffffe68c "tests/data/hls-list.m3u8") at fftools/ffmpeg_opt.c:1070
#10 0x000000000041efd1 in open_files (l=0x21d1d58, inout=0x1202377 "input", open_file=0x414943 <open_input_file>) at fftools/ffmpeg_opt.c:3297
#11 0x000000000041f163 in ffmpeg_parse_options (argc=19, argv=0x7fffffffe2e8) at fftools/ffmpeg_opt.c:3337
#12 0x000000000043d3b0 in main (argc=19, argv=0x7fffffffe2e8) at fftools/ffmpeg.c:4816

[...]
Aman Karmani Dec. 27, 2017, 7:39 p.m. UTC | #2
On Wed, Dec 27, 2017 at 11:35 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> On Mon, Dec 25, 2017 at 09:23:01PM -0800, Aman Gupta wrote:
> > From: Aman Gupta <aman@tmm1.net>
> >
> > Signed-off-by: Aman Gupta <aman@tmm1.net>
> > ---
> >  doc/demuxers.texi |  2 +-
> >  libavformat/hls.c | 13 ++++++++++---
> >  2 files changed, 11 insertions(+), 4 deletions(-)
>
> segfaults fate-filter-hls


I applied an updated version of this patchset to master yesterday which
passes fate.

Also confirmed your f.m3u test case passes, as well as simplehttpd.py.

Aman



>
> #0  0x00007ffff03259a4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
> #1  0x0000000000697b7c in read_data (opaque=0x21d2fc0, buf=0x21e3240 "",
> buf_size=32768) at libavformat/hls.c:1472
> #2  0x000000000065657c in read_packet_wrapper (s=0x21d3fc0, buf=0x21e3240
> "", size=32768) at libavformat/aviobuf.c:533
> #3  0x000000000065680a in fill_buffer (s=0x21d3fc0) at
> libavformat/aviobuf.c:583
> #4  0x0000000000656bc3 in avio_read (s=0x21d3fc0, buf=0x21d5ef0
> "\330.Z\360\377\177", size=2048) at libavformat/aviobuf.c:676
> #5  0x0000000000687e11 in av_probe_input_buffer2 (pb=0x21d3fc0,
> fmt=0x7fffffffdaa0, filename=0x21d53a0 "tests/data/hls-out-000.ts",
> logctx=0x0, offset=0, max_probe_size=1048576) at libavformat/format.c:314
> #6  0x0000000000687fe6 in av_probe_input_buffer (pb=0x21d3fc0,
> fmt=0x7fffffffdaa0, filename=0x21d53a0 "tests/data/hls-out-000.ts",
> logctx=0x0, offset=0, max_probe_size=0) at libavformat/format.c:368
> #7  0x0000000000698e1f in hls_read_header (s=0x21d2580) at
> libavformat/hls.c:1920
> #8  0x00000000007c434c in avformat_open_input (ps=0x7fffffffdbd0,
> filename=0x7fffffffe68c "tests/data/hls-list.m3u8", fmt=0x0,
> options=0x21d1d18) at libavformat/utils.c:613
> #9  0x000000000041528f in open_input_file (o=0x7fffffffdcd0,
> filename=0x7fffffffe68c "tests/data/hls-list.m3u8") at
> fftools/ffmpeg_opt.c:1070
> #10 0x000000000041efd1 in open_files (l=0x21d1d58, inout=0x1202377
> "input", open_file=0x414943 <open_input_file>) at fftools/ffmpeg_opt.c:3297
> #11 0x000000000041f163 in ffmpeg_parse_options (argc=19,
> argv=0x7fffffffe2e8) at fftools/ffmpeg_opt.c:3337
> #12 0x000000000043d3b0 in main (argc=19, argv=0x7fffffffe2e8) at
> fftools/ffmpeg.c:4816
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The misfortune of the wise is better than the prosperity of the fool.
> -- Epicurus
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Michael Niedermayer Dec. 27, 2017, 7:58 p.m. UTC | #3
On Wed, Dec 27, 2017 at 07:39:12PM +0000, Aman Gupta wrote:
> On Wed, Dec 27, 2017 at 11:35 AM Michael Niedermayer <michael@niedermayer.cc>
> wrote:
> 
> > On Mon, Dec 25, 2017 at 09:23:01PM -0800, Aman Gupta wrote:
> > > From: Aman Gupta <aman@tmm1.net>
> > >
> > > Signed-off-by: Aman Gupta <aman@tmm1.net>
> > > ---
> > >  doc/demuxers.texi |  2 +-
> > >  libavformat/hls.c | 13 ++++++++++---
> > >  2 files changed, 11 insertions(+), 4 deletions(-)
> >
> > segfaults fate-filter-hls
> 
> 
> I applied an updated version of this patchset to master yesterday which
> passes fate.

ohh, ok, didnt do a pull since a few hours

thx

[...]
diff mbox

Patch

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}
 };