2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "libavutil/avstring.h"
22 #include "libavutil/mem.h"
26 extern const URLProtocol ff_async_protocol;
27 extern const URLProtocol ff_bluray_protocol;
28 extern const URLProtocol ff_cache_protocol;
29 extern const URLProtocol ff_concat_protocol;
30 extern const URLProtocol ff_crypto_protocol;
31 extern const URLProtocol ff_data_protocol;
32 extern const URLProtocol ff_ffrtmpcrypt_protocol;
33 extern const URLProtocol ff_ffrtmphttp_protocol;
34 extern const URLProtocol ff_file_protocol;
35 extern const URLProtocol ff_ftp_protocol;
36 extern const URLProtocol ff_gopher_protocol;
37 extern const URLProtocol ff_hls_protocol;
38 extern const URLProtocol ff_http_protocol;
39 extern const URLProtocol ff_httpproxy_protocol;
40 extern const URLProtocol ff_https_protocol;
41 extern const URLProtocol ff_icecast_protocol;
42 extern const URLProtocol ff_mmsh_protocol;
43 extern const URLProtocol ff_mmst_protocol;
44 extern const URLProtocol ff_md5_protocol;
45 extern const URLProtocol ff_pipe_protocol;
46 extern const URLProtocol ff_rtmp_protocol;
47 extern const URLProtocol ff_rtmpe_protocol;
48 extern const URLProtocol ff_rtmps_protocol;
49 extern const URLProtocol ff_rtmpt_protocol;
50 extern const URLProtocol ff_rtmpte_protocol;
51 extern const URLProtocol ff_rtmpts_protocol;
52 extern const URLProtocol ff_rtp_protocol;
53 extern const URLProtocol ff_sctp_protocol;
54 extern const URLProtocol ff_srtp_protocol;
55 extern const URLProtocol ff_subfile_protocol;
56 extern const URLProtocol ff_tcp_protocol;
57 extern const URLProtocol ff_tls_gnutls_protocol;
58 extern const URLProtocol ff_tls_schannel_protocol;
59 extern const URLProtocol ff_tls_securetransport_protocol;
60 extern const URLProtocol ff_tls_openssl_protocol;
61 extern const URLProtocol ff_udp_protocol;
62 extern const URLProtocol ff_udplite_protocol;
63 extern const URLProtocol ff_unix_protocol;
64 extern const URLProtocol ff_librtmp_protocol;
65 extern const URLProtocol ff_librtmpe_protocol;
66 extern const URLProtocol ff_librtmps_protocol;
67 extern const URLProtocol ff_librtmpt_protocol;
68 extern const URLProtocol ff_librtmpte_protocol;
69 extern const URLProtocol ff_libssh_protocol;
70 extern const URLProtocol ff_libsmbclient_protocol;
72 static const URLProtocol *url_protocols[] = {
73 #if CONFIG_ASYNC_PROTOCOL
76 #if CONFIG_BLURAY_PROTOCOL
79 #if CONFIG_CACHE_PROTOCOL
82 #if CONFIG_CONCAT_PROTOCOL
85 #if CONFIG_CRYPTO_PROTOCOL
88 #if CONFIG_DATA_PROTOCOL
91 #if CONFIG_FFRTMPCRYPT_PROTOCOL
92 &ff_ffrtmpcrypt_protocol,
94 #if CONFIG_FFRTMPHTTP_PROTOCOL
95 &ff_ffrtmphttp_protocol,
97 #if CONFIG_FILE_PROTOCOL
100 #if CONFIG_FTP_PROTOCOL
103 #if CONFIG_GOPHER_PROTOCOL
106 #if CONFIG_HLS_PROTOCOL
109 #if CONFIG_HTTP_PROTOCOL
112 #if CONFIG_HTTPPROXY_PROTOCOL
113 &ff_httpproxy_protocol,
115 #if CONFIG_HTTPS_PROTOCOL
118 #if CONFIG_ICECAST_PROTOCOL
119 &ff_icecast_protocol,
121 #if CONFIG_MMSH_PROTOCOL
124 #if CONFIG_MMST_PROTOCOL
127 #if CONFIG_MD5_PROTOCOL
130 #if CONFIG_PIPE_PROTOCOL
133 #if CONFIG_RTMP_PROTOCOL
136 #if CONFIG_RTMPE_PROTOCOL
139 #if CONFIG_RTMPS_PROTOCOL
142 #if CONFIG_RTMPT_PROTOCOL
145 #if CONFIG_RTMPTE_PROTOCOL
148 #if CONFIG_RTMPTS_PROTOCOL
151 #if CONFIG_RTP_PROTOCOL
154 #if CONFIG_SCTP_PROTOCOL
157 #if CONFIG_SRTP_PROTOCOL
160 #if CONFIG_SUBFILE_PROTOCOL
161 &ff_subfile_protocol,
163 #if CONFIG_TCP_PROTOCOL
166 #if CONFIG_TLS_GNUTLS_PROTOCOL
167 &ff_tls_gnutls_protocol,
169 #if CONFIG_TLS_SCHANNEL_PROTOCOL
170 &ff_tls_schannel_protocol,
172 #if CONFIG_TLS_SECURETRANSPORT_PROTOCOL
173 &ff_tls_securetransport_protocol,
175 #if CONFIG_TLS_OPENSSL_PROTOCOL
176 &ff_tls_openssl_protocol,
178 #if CONFIG_UDP_PROTOCOL
181 #if CONFIG_UDPLITE_PROTOCOL
182 &ff_udplite_protocol,
184 #if CONFIG_UNIX_PROTOCOL
188 /* external libraries */
189 #if CONFIG_LIBRTMP_PROTOCOL
190 &ff_librtmp_protocol,
192 #if CONFIG_LIBRTMPE_PROTOCOL
193 &ff_librtmpe_protocol,
195 #if CONFIG_LIBRTMPS_PROTOCOL
196 &ff_librtmps_protocol,
198 #if CONFIG_LIBRTMPT_PROTOCOL
199 &ff_librtmpt_protocol,
201 #if CONFIG_LIBRTMPTE_PROTOCOL
202 &ff_librtmpte_protocol,
204 #if CONFIG_LIBSSH_PROTOCOL
207 #if CONFIG_LIBSMBCLIENT_PROTOCOL
208 &ff_libsmbclient_protocol,
213 const AVClass *ff_urlcontext_child_class_next(const AVClass *prev)
217 /* find the protocol that corresponds to prev */
218 for (i = 0; prev && url_protocols[i]; i++) {
219 if (url_protocols[i]->priv_data_class == prev) {
225 /* find next protocol with priv options */
226 for (; url_protocols[i]; i++)
227 if (url_protocols[i]->priv_data_class)
228 return url_protocols[i]->priv_data_class;
233 const char *avio_enum_protocols(void **opaque, int output)
235 const URLProtocol **p = *opaque;
237 p = p ? p + 1 : url_protocols;
243 if ((output && (*p)->url_write) || (!output && (*p)->url_read))
245 return avio_enum_protocols(opaque, output);
248 const URLProtocol **ffurl_get_protocols(const char *whitelist,
249 const char *blacklist)
251 const URLProtocol **ret;
254 ret = av_mallocz_array(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));
258 for (i = 0; url_protocols[i]; i++) {
259 const URLProtocol *up = url_protocols[i];
261 if (whitelist && *whitelist && !av_match_name(up->name, whitelist))
263 if (blacklist && *blacklist && av_match_name(up->name, blacklist))