Generate the lists of enabled protocols/bsfs from configure.
[libav.git] / libavformat / protocols.c
CommitLineData
2758cded
AK
1/*
2 * This file is part of Libav.
3 *
4 * Libav 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.
8 *
9 * Libav 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.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "config.h"
20
832a202c
AK
21#include "libavutil/avstring.h"
22#include "libavutil/mem.h"
23
2758cded
AK
24#include "url.h"
25
26extern const URLProtocol ff_concat_protocol;
27extern const URLProtocol ff_crypto_protocol;
28extern const URLProtocol ff_ffrtmpcrypt_protocol;
29extern const URLProtocol ff_ffrtmphttp_protocol;
30extern const URLProtocol ff_file_protocol;
31extern const URLProtocol ff_gopher_protocol;
32extern const URLProtocol ff_hls_protocol;
33extern const URLProtocol ff_http_protocol;
34extern const URLProtocol ff_httpproxy_protocol;
35extern const URLProtocol ff_https_protocol;
36extern const URLProtocol ff_icecast_protocol;
37extern const URLProtocol ff_mmsh_protocol;
38extern const URLProtocol ff_mmst_protocol;
39extern const URLProtocol ff_md5_protocol;
40extern const URLProtocol ff_pipe_protocol;
41extern const URLProtocol ff_rtmp_protocol;
42extern const URLProtocol ff_rtmpe_protocol;
43extern const URLProtocol ff_rtmps_protocol;
44extern const URLProtocol ff_rtmpt_protocol;
45extern const URLProtocol ff_rtmpte_protocol;
46extern const URLProtocol ff_rtmpts_protocol;
47extern const URLProtocol ff_rtp_protocol;
48extern const URLProtocol ff_sctp_protocol;
49extern const URLProtocol ff_srtp_protocol;
50extern const URLProtocol ff_tcp_protocol;
51extern const URLProtocol ff_tls_gnutls_protocol;
52extern const URLProtocol ff_tls_openssl_protocol;
53extern const URLProtocol ff_udp_protocol;
54extern const URLProtocol ff_unix_protocol;
55extern const URLProtocol ff_librtmp_protocol;
56extern const URLProtocol ff_librtmpe_protocol;
57extern const URLProtocol ff_librtmps_protocol;
58extern const URLProtocol ff_librtmpt_protocol;
59extern const URLProtocol ff_librtmpte_protocol;
60
06edef3d 61#include "libavformat/protocol_list.c"
0fa00d05 62
7d61dc95
AK
63const AVClass *ff_urlcontext_child_class_next(const AVClass *prev)
64{
65 int i;
66
67 /* find the protocol that corresponds to prev */
832a202c
AK
68 for (i = 0; url_protocols[i]; i++) {
69 if (url_protocols[i]->priv_data_class == prev) {
7d61dc95
AK
70 i++;
71 break;
72 }
73 }
74
75 /* find next protocol with priv options */
832a202c
AK
76 for (; url_protocols[i]; i++)
77 if (url_protocols[i]->priv_data_class)
78 return url_protocols[i]->priv_data_class;
7d61dc95
AK
79 return NULL;
80}
81
82
0fa00d05
AK
83const char *avio_enum_protocols(void **opaque, int output)
84{
85 const URLProtocol **p = *opaque;
86
832a202c 87 p = p ? p + 1 : url_protocols;
0fa00d05
AK
88 *opaque = p;
89 if (!*p) {
90 *opaque = NULL;
91 return NULL;
92 }
93 if ((output && (*p)->url_write) || (!output && (*p)->url_read))
94 return (*p)->name;
95 return avio_enum_protocols(opaque, output);
96}
832a202c
AK
97
98const URLProtocol **ffurl_get_protocols(const char *whitelist,
99 const char *blacklist)
100{
101 const URLProtocol **ret;
102 int i, ret_idx = 0;
103
104 ret = av_mallocz_array(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));
105 if (!ret)
106 return NULL;
107
108 for (i = 0; url_protocols[i]; i++) {
109 const URLProtocol *up = url_protocols[i];
110
111 if (whitelist && *whitelist && !av_match_name(up->name, whitelist))
112 continue;
113 if (blacklist && *blacklist && av_match_name(up->name, blacklist))
114 continue;
115
116 ret[ret_idx++] = up;
117 }
118
119 return ret;
120}