avformat/avio: propagate prefer_libcurl preference from parent URLContext

Since this is consumed by e.g. protocols which open inner protocols.
This would normally be propagated by the `av_opt_copy` call, but as this
check happens *before* the inner URLContext is even allocated, we're
forced to propagate the options manually.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-06-24 17:22:26 +02:00
committed by Kacper Michajłow
parent cee0613cf7
commit d993f37a1b

View File

@@ -375,7 +375,8 @@ extern const URLProtocol ff_libcurl_protocol;
/* Decide whether an http(s) URL should be routed to the libcurl protocol instead
* of the native one. Controlled by the per-open "prefer_libcurl" option. */
static int prefer_libcurl(const char *filename, AVDictionary **options)
static int prefer_libcurl(const char *filename, AVDictionary **options,
URLContext *parent)
{
URLContext dummy = { .av_class = &url_context_class };
AVDictionaryEntry *e;
@@ -384,6 +385,9 @@ static int prefer_libcurl(const char *filename, AVDictionary **options)
!av_strstart(filename, "https://", NULL))
return 0;
if (parent && parent->prefer_libcurl)
return 1;
if (!options || !(e = av_dict_get(*options, "prefer_libcurl", NULL, 0)))
return 0;
if (av_opt_set(&dummy, "prefer_libcurl", e->value, 0) < 0)
@@ -405,7 +409,7 @@ static int url_open_whitelist(URLContext **puc, const char *filename, int flags,
#if CONFIG_LIBCURL_PROTOCOL
/* The option itself is applied to the URLContext further down; here it only
* picks the protocol, before the context exists. */
if (prefer_libcurl(filename, options))
if (prefer_libcurl(filename, options, parent))
ret = url_alloc_for_protocol(puc, &ff_libcurl_protocol, filename, flags,
int_cb);
else