Skip to content

Commit f0a8406

Browse files
committed
add 3 dummy ijkhttp protocols and use selected_http option
1 parent 8f338bd commit f0a8406

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
From 56283c5e21f324ee65159781baf7f6d00628765b Mon Sep 17 00:00:00 2001
2+
From: qianlongxu <qianlongxu@gmail.com>
3+
Date: Fri, 14 Mar 2025 13:08:06 +0800
4+
Subject: [PATCH 29] add 3 dummy ijkhttp protocols and use selected_http option
5+
choose
6+
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(-)
13+
14+
diff --git a/libavformat/avio.c b/libavformat/avio.c
15+
index b793a75..b02dbd2 100644
16+
--- a/libavformat/avio.c
17+
+++ b/libavformat/avio.c
18+
@@ -297,6 +297,48 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags,
19+
return AVERROR_PROTOCOL_NOT_FOUND;
20+
}
21+
22+
+
23+
+static const struct URLProtocol *url_find_the_protocol(const char *proto_str)
24+
+{
25+
+ const URLProtocol **protocols = ffurl_get_protocols(NULL, NULL);
26+
+ if (!protocols)
27+
+ return NULL;
28+
+ for (int i = 0; protocols[i]; i++) {
29+
+ const URLProtocol *up = protocols[i];
30+
+ if (!strcmp(proto_str, up->name)) {
31+
+ av_freep(&protocols);
32+
+ return up;
33+
+ }
34+
+ }
35+
+ av_freep(&protocols);
36+
+ return NULL;
37+
+}
38+
+
39+
+int ffurl_alloc2(URLContext **puc, const char *filename, int flags,
40+
+ const AVIOInterruptCB *int_cb, AVDictionary **options)
41+
+{
42+
+ if (options && *options) {
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;
53+
+ } 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;
57+
+ }
58+
+ }
59+
+ }
60+
+
61+
+ return ffurl_alloc(puc, filename, flags, int_cb);
62+
+}
63+
+
64+
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
65+
const AVIOInterruptCB *int_cb, AVDictionary **options,
66+
const char *whitelist, const char* blacklist,
67+
@@ -304,7 +346,7 @@ int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags,
68+
{
69+
AVDictionary *tmp_opts = NULL;
70+
AVDictionaryEntry *e;
71+
- int ret = ffurl_alloc(puc, filename, flags, int_cb);
72+
+ int ret = ffurl_alloc2(puc, filename, flags, int_cb, options);
73+
if (ret < 0)
74+
return ret;
75+
if (parent) {
76+
@@ -548,7 +590,7 @@ int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
77+
goto fail;
78+
}
79+
80+
- if ((ret = ffurl_alloc(&h, url, AVIO_FLAG_READ, NULL)) < 0)
81+
+ if ((ret = ffurl_alloc2(&h, url, AVIO_FLAG_READ, NULL, options)) < 0)
82+
goto fail;
83+
84+
if (h->prot->url_open_dir && h->prot->url_read_dir && h->prot->url_close_dir) {
85+
diff --git a/libavformat/ijkutils.c b/libavformat/ijkutils.c
86+
index 5999101..18b81af 100644
87+
--- a/libavformat/ijkutils.c
88+
+++ b/libavformat/ijkutils.c
89+
@@ -65,6 +65,9 @@ IJK_DUMMY_PROTOCOL(ijkhttphook);
90+
IJK_DUMMY_PROTOCOL(ijksegment);
91+
IJK_DUMMY_PROTOCOL(ijktcphook);
92+
IJK_DUMMY_PROTOCOL(ijkio);
93+
+IJK_DUMMY_PROTOCOL(ijkhttp1);
94+
+IJK_DUMMY_PROTOCOL(ijkhttp2);
95+
+IJK_DUMMY_PROTOCOL(ijkhttp3);
96+
97+
#define IJK_FF_DEMUXER(x) \
98+
extern AVInputFormat ff_##x##_demuxer; \
99+
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
100+
index 2bda874..8c1cab6 100644
101+
--- a/libavformat/protocols.c
102+
+++ b/libavformat/protocols.c
103+
@@ -84,7 +84,9 @@ extern const URLProtocol ff_ijkmediadatasource_protocol;
104+
extern const URLProtocol ff_ijksegment_protocol;
105+
extern const URLProtocol ff_ijktcphook_protocol;
106+
extern const URLProtocol ff_ijkio_protocol;
107+
-
108+
+extern const URLProtocol ff_ijkhttp1_protocol;
109+
+extern const URLProtocol ff_ijkhttp2_protocol;
110+
+extern const URLProtocol ff_ijkhttp3_protocol;
111+
extern const URLProtocol ff_dvd_protocol;
112+
113+
#include "libavformat/protocol_list.c"
114+
diff --git a/libavformat/url.h b/libavformat/url.h
115+
index b9c9028..0781691 100644
116+
--- a/libavformat/url.h
117+
+++ b/libavformat/url.h
118+
@@ -116,6 +116,22 @@ typedef struct URLProtocol {
119+
int ffurl_alloc(URLContext **puc, const char *filename, int flags,
120+
const AVIOInterruptCB *int_cb);
121+
122+
+ /**
123+
+ * Create a URLContext for accessing to the resource indicated by
124+
+ * url, but do not initiate the connection yet.
125+
+ *
126+
+ * @param puc pointer to the location where, in case of success, the
127+
+ * function puts the pointer to the created URLContext
128+
+ * @param flags flags which control how the resource indicated by url
129+
+ * is to be opened
130+
+ * @param int_cb interrupt callback to use for the URLContext, may be
131+
+ * NULL
132+
+ * @param options A dictionary filled with options for replace http protocol
133+
+ * @return >= 0 in case of success, a negative value corresponding to an
134+
+ * AVERROR code in case of failure
135+
+ */
136+
+int ffurl_alloc2(URLContext **puc, const char *filename, int flags,
137+
+ const AVIOInterruptCB *int_cb, AVDictionary **options);
138+
/**
139+
* Connect an URLContext that has been allocated by ffurl_alloc
140+
*
141+
--
142+
2.39.5 (Apple Git-154)
143+

0 commit comments

Comments
 (0)