1- From 56283c5e21f324ee65159781baf7f6d00628765b Mon Sep 17 00:00:00 2001
1+ From ab8fe6d0c2de932980f6f1e9d31e24f25750da37 Mon Sep 17 00:00:00 2001
22From: qianlongxu <
[email protected] >
3- Date: Fri, 14 Mar 2025 13:08:06 +0800
3+ Date: Fri, 14 Mar 2025 17:41:28 +0800
44Subject: [PATCH 29] add 3 dummy ijkhttp protocols and use selected_http option
55 choose
66
77---
8- libavformat/avio.c | 46 +++++++++++++++++++++++++++++++++++++++--
9- libavformat/ijkutils.c | 3 +++
10- libavformat/protocols.c | 4 +++ -
11- libavformat/url.h | 16 ++++++++++++++
12- 4 files changed, 66 insertions(+), 3 deletions(-)
8+ libavformat/avio.c | 63 +++++++++++++++++++++++++++++++++++++++--
9+ libavformat/ijkutils.c | 3 ++
10+ libavformat/protocols.c | 4 ++-
11+ libavformat/url.h | 16 +++++++++++
12+ 4 files changed, 83 insertions(+), 3 deletions(-)
1313
1414diff --git a/libavformat/avio.c b/libavformat/avio.c
15- index b793a75..b02dbd2 100644
15+ index b793a75..dadfefc 100644
1616--- a/libavformat/avio.c
1717+++ b/libavformat/avio.c
18- @@ -297,6 +297,48 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags,
18+ @@ -297,6 +297,65 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags,
1919 return AVERROR_PROTOCOL_NOT_FOUND;
2020 }
2121
@@ -41,19 +41,36 @@ index b793a75..b02dbd2 100644
4141+ {
4242+ if (options && *options) {
4343+ AVDictionaryEntry *e = av_dict_get(*options, "selected_http", NULL, 0);
44- + const char *proto_str;
45- + if (e && (proto_str = e->value)) {
46- + if (!strcmp(proto_str, "ijkhttp1") || !strcmp(proto_str, "ijkhttp2") || !strcmp(proto_str, "ijkhttp3")) {
47- + const URLProtocol *p = url_find_the_protocol(proto_str);
48- + if (p)
49- + return url_alloc_for_protocol(puc, p, filename, flags, int_cb);
50- + *puc = NULL;
51- + av_log(NULL, AV_LOG_ERROR, "some thing is fault,check %s protocol\n", proto_str);
52- + return AVERROR_PROTOCOL_NOT_FOUND;
44+ + const char *selected_http;
45+ + if (e && (selected_http = e->value)) {
46+ +
47+ + char proto_str[128] = {0};
48+ + size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
49+ + if (filename[proto_len] != ':' &&
50+ + (strncmp(filename, "subfile,", 8) || !strchr(filename + proto_len + 1, ':')) ||
51+ + is_dos_path(filename))
52+ + strcpy(proto_str, "file");
53+ + else
54+ + av_strlcpy(proto_str, filename,
55+ + FFMIN(proto_len + 1, sizeof(proto_str)));
56+ + //only apply http protocol
57+ + if (!strcmp(proto_str, "http") || !strcmp(proto_str, "https")) {
58+ + if (!strcmp(selected_http, "ijkhttp1") || !strcmp(selected_http, "ijkhttp2") || !strcmp(selected_http, "ijkhttp3")) {
59+ + const URLProtocol *p = url_find_the_protocol(selected_http);
60+ + if (p) {
61+ + av_log(NULL, AV_LOG_DEBUG, "%s use %s send request\n",proto_str,selected_http);
62+ + return url_alloc_for_protocol(puc, p, filename, flags, int_cb);
63+ + }
64+ + *puc = NULL;
65+ + av_log(NULL, AV_LOG_ERROR, "some thing is fault,check %s protocol\n", selected_http);
66+ + return AVERROR_PROTOCOL_NOT_FOUND;
67+ + } else {
68+ + av_log(NULL, AV_LOG_ERROR, "invalid selected_http value: %s\n", selected_http);
69+ + av_assert0(0);
70+ + return AVERROR_PROTOCOL_NOT_FOUND;
71+ + }
5372+ } else {
54- + av_log(NULL, AV_LOG_ERROR, "invalid selected_http value: %s\n", proto_str);
55- + av_assert0(0);
56- + return AVERROR_PROTOCOL_NOT_FOUND;
73+ + av_log(NULL, AV_LOG_DEBUG, "%s not use %s\n",proto_str,selected_http);
5774+ }
5875+ }
5976+ }
@@ -64,7 +81,7 @@ index b793a75..b02dbd2 100644
6481 int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
6582 const AVIOInterruptCB *int_cb, AVDictionary **options,
6683 const char *whitelist, const char* blacklist,
67- @@ -304,7 +346 ,7 @@ int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
84+ @@ -304,7 +363 ,7 @@ int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
6885 {
6986 AVDictionary *tmp_opts = NULL;
7087 AVDictionaryEntry *e;
@@ -73,7 +90,7 @@ index b793a75..b02dbd2 100644
7390 if (ret < 0)
7491 return ret;
7592 if (parent) {
76- @@ -548,7 +590 ,7 @@ int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
93+ @@ -548,7 +607 ,7 @@ int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
7794 goto fail;
7895 }
7996
0 commit comments