PR #24836 opened by xiujunwang-dev URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24836 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24836.patch
Pass http_version, tls_verify, and ca_file to child connections opened by the HLS, DASH, and IMF demuxers. Fixes: #24752 >From 863df542f27c62c2874296019ccc64eb59f7a554 Mon Sep 17 00:00:00 2001 From: xiujunwang <[email protected]> Date: Thu, 1 Oct 2026 17:51:05 +0800 Subject: [PATCH] avformat: pass libcurl options to child connections Pass http_version, tls_verify, and ca_file to child connections opened by the HLS, DASH, and IMF demuxers. Fixes: #24752 --- libavformat/Makefile | 1 + libavformat/aviobuf.c | 3 +- libavformat/tests/url_options.c | 109 ++++++++++++++++++++++++++++++++ tests/fate/libavformat.mak | 5 ++ 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 libavformat/tests/url_options.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 24066050a5..fcdd5cf13a 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -790,6 +790,7 @@ TESTPROGS = id3v2 \ rename \ seek \ url \ + url_options \ seek_utils # async \ diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index edbbc5ffd6..6aade5c203 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -953,7 +953,8 @@ void ffio_write_lines(AVIOContext *s, const unsigned char *buf, int size, int ffio_copy_url_options(AVIOContext* pb, AVDictionary** avio_opts) { const char *opts[] = { - "headers", "user_agent", "cookies", "http_proxy", "referer", "rw_timeout", "icy", "prefer_libcurl", NULL }; + "headers", "user_agent", "cookies", "http_proxy", "referer", "rw_timeout", "icy", "prefer_libcurl", + "http_version", "tls_verify", "ca_file", NULL }; const char **opt = opts; uint8_t *buf = NULL; int ret = 0; diff --git a/libavformat/tests/url_options.c b/libavformat/tests/url_options.c new file mode 100644 index 0000000000..7eb122418d --- /dev/null +++ b/libavformat/tests/url_options.c @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2026 FFmpeg developers + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stddef.h> +#include <string.h> + +#include "libavformat/avio.h" +#include "libavformat/avio_internal.h" +#include "libavutil/dict.h" +#include "libavutil/mem.h" +#include "libavutil/opt.h" + +typedef struct TestURLContext { + const AVClass *av_class; + char *http_version; + int tls_verify; + char *ca_file; +} TestURLContext; + +static const AVOption test_url_options[] = { + { "http_version", "", offsetof(TestURLContext, http_version), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, + { "tls_verify", "", offsetof(TestURLContext, tls_verify), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, + { "ca_file", "", offsetof(TestURLContext, ca_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, + { NULL } +}; + +static const AVClass test_url_class = { + .class_name = "TestURLContext", + .item_name = av_default_item_name, + .option = test_url_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static void *test_avio_child_next(void *obj, void *prev) +{ + AVIOContext *pb = obj; + return prev ? NULL : pb->opaque; +} + +static const AVClass test_avio_class = { + .class_name = "TestAVIOContext", + .item_name = av_default_item_name, + .version = LIBAVUTIL_VERSION_INT, + .child_next = test_avio_child_next, +}; + +int main(void) +{ + TestURLContext child = { .av_class = &test_url_class }; + AVDictionary *options = NULL; + AVIOContext *pb; + unsigned char *buffer; + AVDictionaryEntry *entry; + int ret = 1; + + if (av_opt_set(&child, "http_version", "1.1", 0) < 0 || + av_opt_set_int(&child, "tls_verify", 0, 0) < 0 || + av_opt_set(&child, "ca_file", "/tmp/ca.pem", 0) < 0) + goto end; + + buffer = av_malloc(1); + if (!buffer) + goto end; + pb = avio_alloc_context(buffer, 1, 0, &child, NULL, NULL, NULL); + if (!pb) { + av_free(buffer); + goto end; + } + pb->av_class = &test_avio_class; + + if (ffio_copy_url_options(pb, &options) < 0) + goto close; + + entry = av_dict_get(options, "http_version", NULL, 0); + if (!entry || strcmp(entry->value, "1.1")) + goto close; + entry = av_dict_get(options, "tls_verify", NULL, 0); + if (!entry || strcmp(entry->value, "false")) + goto close; + entry = av_dict_get(options, "ca_file", NULL, 0); + if (!entry || strcmp(entry->value, "/tmp/ca.pem")) + goto close; + + ret = 0; +close: + avio_context_free(&pb); + av_free(buffer); +end: + av_dict_free(&options); + av_opt_free(&child); + return ret; +} diff --git a/tests/fate/libavformat.mak b/tests/fate/libavformat.mak index f306e19245..9ff6ca7c14 100644 --- a/tests/fate/libavformat.mak +++ b/tests/fate/libavformat.mak @@ -56,6 +56,11 @@ FATE_LIBAVFORMAT-yes += fate-url fate-url: libavformat/tests/url$(EXESUF) fate-url: CMD = run libavformat/tests/url$(EXESUF) +FATE_LIBAVFORMAT-yes += fate-url-options +fate-url-options: libavformat/tests/url_options$(EXESUF) +fate-url-options: CMD = run libavformat/tests/url_options$(EXESUF) +fate-url-options: CMP = null + FATE_LIBAVFORMAT-$(CONFIG_IMF_DEMUXER) += fate-imf fate-imf: libavformat/tests/imf$(EXESUF) fate-imf: CMD = run libavformat/tests/imf$(EXESUF) -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
