1
- From 56283c5e21f324ee65159781baf7f6d00628765b Mon Sep 17 00:00:00 2001
1
+ From ab8fe6d0c2de932980f6f1e9d31e24f25750da37 Mon Sep 17 00:00:00 2001
2
2
From: qianlongxu <qianlongxu@gmail.com>
3
- Date: Fri, 14 Mar 2025 13:08:06 +0800
3
+ Date: Fri, 14 Mar 2025 17:41:28 +0800
4
4
Subject: [PATCH 29] add 3 dummy ijkhttp protocols and use selected_http option
5
5
choose
6
6
7
7
---
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(-)
13
13
14
14
diff --git a/libavformat/avio.c b/libavformat/avio.c
15
- index b793a75..b02dbd2 100644
15
+ index b793a75..dadfefc 100644
16
16
--- a/libavformat/avio.c
17
17
+++ 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,
19
19
return AVERROR_PROTOCOL_NOT_FOUND;
20
20
}
21
21
@@ -41,19 +41,36 @@ index b793a75..b02dbd2 100644
41
41
+ {
42
42
+ if (options && *options) {
43
43
+ 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
+ + }
53
72
+ } 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);
57
74
+ }
58
75
+ }
59
76
+ }
@@ -64,7 +81,7 @@ index b793a75..b02dbd2 100644
64
81
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
65
82
const AVIOInterruptCB *int_cb, AVDictionary **options,
66
83
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,
68
85
{
69
86
AVDictionary *tmp_opts = NULL;
70
87
AVDictionaryEntry *e;
@@ -73,7 +90,7 @@ index b793a75..b02dbd2 100644
73
90
if (ret < 0)
74
91
return ret;
75
92
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)
77
94
goto fail;
78
95
}
79
96
0 commit comments