You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avformat/hls: enable http_multiple only for http/1.1 servers
Some http/1.0 implementations, like python's SimpleHTTPServer, can only support one client connection at a time. Making a second request while the first is still connected leads to a deadlock. This change enables multiple connections for http/1.1 servers only, which need to support keepalive by default and should have no problem with concurrent requests. Signed-off-by: Aman Gupta <aman@tmm1.net>
This commit is contained in:
@@ -323,7 +323,7 @@ Enabled by default.
|
|||||||
|
|
||||||
@item http_multiple
|
@item http_multiple
|
||||||
Use multiple HTTP connections for downloading HTTP segments.
|
Use multiple HTTP connections for downloading HTTP segments.
|
||||||
Enabled by default.
|
Enabled by default for HTTP/1.1 servers.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@section image2
|
@section image2
|
||||||
|
@@ -1452,7 +1452,7 @@ reload:
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (c->http_multiple && av_strstart(seg->url, "http", NULL) && v->input_next_requested) {
|
if (c->http_multiple == 1 && v->input_next_requested) {
|
||||||
FFSWAP(AVIOContext *, v->input, v->input_next);
|
FFSWAP(AVIOContext *, v->input, v->input_next);
|
||||||
v->input_next_requested = 0;
|
v->input_next_requested = 0;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@@ -1471,8 +1471,15 @@ reload:
|
|||||||
just_opened = 1;
|
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 = http_version_opt && strncmp((const char *)http_version_opt, "1.1", 3) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
seg = next_segment(v);
|
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);
|
ret = open_input(c, v, seg, &v->input_next);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (ff_check_interrupt(c->interrupt_callback))
|
if (ff_check_interrupt(c->interrupt_callback))
|
||||||
@@ -2306,7 +2313,7 @@ static const AVOption hls_options[] = {
|
|||||||
{"http_persistent", "Use persistent HTTP connections",
|
{"http_persistent", "Use persistent HTTP connections",
|
||||||
OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
|
OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
|
||||||
{"http_multiple", "Use multiple HTTP connections for fetching segments",
|
{"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_BOOL, {.i64 = -1}, -1, 1, FLAGS},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user