stream_curl: add --curl-enabled option
This commit is contained in:
1 parent
f7e0fd8f0e
commit
724b76fe0a
3 files changed
+18
-2
No files matched your search
@@ -1 +1 @@
|
||||
add libcurl-based stream backend (http, https, ftp, ftps), with new options `--curl-http-version`, `--curl-max-redirects`, `--curl-max-retries`, `--curl-connect-timeout`, `--curl-buffer-size` and `--curl-max-request-size`
|
||||
add libcurl-based stream backend (http, https, ftp, ftps), with new options `--curl-enabled`, `--curl-http-version`, `--curl-max-redirects`, `--curl-max-retries`, `--curl-connect-timeout`, `--curl-buffer-size` and `--curl-max-request-size`
|
||||
@@ -5744,6 +5744,9 @@ implementation instead.
|
||||
To inspect libcurl's debug output (requests, response headers,
|
||||
TLS/connection diagnostics), set ``--msg-level=curl=trace``.
|
||||
|
||||
``--curl-enabled=<yes|no>``
|
||||
Enable the libcurl-based network backend (default: ``yes``).
|
||||
|
||||
``--curl-http-version=<auto|1.0|1.1|2|2tls|2-prior-knowledge|3|3only>``
|
||||
Select the maximum HTTP protocol version libcurl is allowed to negotiate.
|
||||
If libcurl was built without HTTP/3 support, it will fallback to ``auto``.
|
||||
|
||||
+14
-1
@@ -65,6 +65,7 @@ static const struct curl_scheme curl_schemes[] = {
|
||||
};
|
||||
|
||||
struct curl_opts {
|
||||
bool enabled;
|
||||
int http_version;
|
||||
int max_redirects;
|
||||
int max_retries;
|
||||
@@ -84,6 +85,7 @@ struct curl_opts {
|
||||
#define OPT_BASE_STRUCT struct curl_opts
|
||||
const struct m_sub_options curl_conf = {
|
||||
.opts = (const struct m_option[]) {
|
||||
{"enabled", OPT_BOOL(enabled)},
|
||||
{"http-version", OPT_CHOICE(http_version,
|
||||
{"auto", CURL_HTTP_VERSION_NONE},
|
||||
{"1.0", CURL_HTTP_VERSION_1_0},
|
||||
@@ -104,6 +106,7 @@ const struct m_sub_options curl_conf = {
|
||||
{0}
|
||||
},
|
||||
.defaults = &(const struct curl_opts) {
|
||||
.enabled = true,
|
||||
.http_version = CURL_HTTP_VERSION_NONE,
|
||||
.max_redirects = 16,
|
||||
.max_retries = 5,
|
||||
@@ -844,6 +847,10 @@ static int curl_open(stream_t *s, const struct stream_open_args *args)
|
||||
return STREAM_ERROR;
|
||||
}
|
||||
|
||||
struct curl_opts *opts = mp_get_config_group(s, s->global, &curl_conf);
|
||||
if (!opts->enabled)
|
||||
return STREAM_NO_MATCH;
|
||||
|
||||
struct priv *p = talloc_zero(s, struct priv);
|
||||
s->priv = p;
|
||||
talloc_set_destructor(p, priv_destructor);
|
||||
@@ -852,7 +859,7 @@ static int curl_open(stream_t *s, const struct stream_open_args *args)
|
||||
p->global = s->global;
|
||||
p->ctx = s->global->curl;
|
||||
p->s = s;
|
||||
p->opts = mp_get_config_group(p, s->global, &curl_conf);
|
||||
p->opts = talloc_steal(p, opts);
|
||||
p->net_opts = mp_get_config_group(p, s->global, &mp_network_conf);
|
||||
p->url = talloc_strdup(p, s->url);
|
||||
p->scheme = curl_scheme_lookup(bstr0(p->url));
|
||||
@@ -1002,6 +1009,12 @@ int mp_curl_avio_open(struct demuxer *demuxer, AVIOContext **pb_out,
|
||||
if (!cs || !curl_has_proto(cs->scheme))
|
||||
return AVERROR(ENOSYS);
|
||||
|
||||
struct curl_opts *opts = mp_get_config_group(NULL, demuxer->global, &curl_conf);
|
||||
bool enabled = opts->enabled;
|
||||
talloc_free(opts);
|
||||
if (!enabled)
|
||||
return AVERROR(ENOSYS);
|
||||
|
||||
// The context is required to be initialized in global.
|
||||
mp_require(demuxer->global && demuxer->global->curl);
|
||||
|
||||
|
||||
Reference in new issue
Block a user