1/* 2 * This file is part of FFmpeg. 3 * 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. 8 * 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. 13 * 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 17 */ 18 19#include "libavutil/avstring.h" 20#include "libavutil/mem.h" 21 22#include "url.h" 23 24extern const URLProtocol ff_async_protocol; 25extern const URLProtocol ff_bluray_protocol; 26extern const URLProtocol ff_cache_protocol; 27extern const URLProtocol ff_concat_protocol; 28extern const URLProtocol ff_concatf_protocol; 29extern const URLProtocol ff_crypto_protocol; 30extern const URLProtocol ff_data_protocol; 31extern const URLProtocol ff_ffrtmpcrypt_protocol; 32extern const URLProtocol ff_ffrtmphttp_protocol; 33extern const URLProtocol ff_file_protocol; 34extern const URLProtocol ff_ftp_protocol; 35extern const URLProtocol ff_gopher_protocol; 36extern const URLProtocol ff_gophers_protocol; 37extern const URLProtocol ff_hls_protocol; 38extern const URLProtocol ff_http_protocol; 39extern const URLProtocol ff_httpproxy_protocol; 40extern const URLProtocol ff_https_protocol; 41extern const URLProtocol ff_icecast_protocol; 42extern const URLProtocol ff_mmsh_protocol; 43extern const URLProtocol ff_mmst_protocol; 44extern const URLProtocol ff_md5_protocol; 45extern const URLProtocol ff_pipe_protocol; 46extern const URLProtocol ff_prompeg_protocol; 47extern const URLProtocol ff_rtmp_protocol; 48extern const URLProtocol ff_rtmpe_protocol; 49extern const URLProtocol ff_rtmps_protocol; 50extern const URLProtocol ff_rtmpt_protocol; 51extern const URLProtocol ff_rtmpte_protocol; 52extern const URLProtocol ff_rtmpts_protocol; 53extern const URLProtocol ff_rtp_protocol; 54extern const URLProtocol ff_sctp_protocol; 55extern const URLProtocol ff_srtp_protocol; 56extern const URLProtocol ff_subfile_protocol; 57extern const URLProtocol ff_tee_protocol; 58extern const URLProtocol ff_tcp_protocol; 59extern const URLProtocol ff_tls_protocol; 60extern const URLProtocol ff_udp_protocol; 61extern const URLProtocol ff_udplite_protocol; 62extern const URLProtocol ff_unix_protocol; 63extern const URLProtocol ff_libamqp_protocol; 64extern const URLProtocol ff_librist_protocol; 65extern const URLProtocol ff_librtmp_protocol; 66extern const URLProtocol ff_librtmpe_protocol; 67extern const URLProtocol ff_librtmps_protocol; 68extern const URLProtocol ff_librtmpt_protocol; 69extern const URLProtocol ff_librtmpte_protocol; 70extern const URLProtocol ff_libsrt_protocol; 71extern const URLProtocol ff_libssh_protocol; 72extern const URLProtocol ff_libsmbclient_protocol; 73extern const URLProtocol ff_libzmq_protocol; 74extern const URLProtocol ff_ipfs_protocol; 75extern const URLProtocol ff_ipns_protocol; 76 77#include "libavformat/protocol_list.c" 78 79const AVClass *ff_urlcontext_child_class_iterate(void **iter) 80{ 81 const AVClass *ret = NULL; 82 uintptr_t i; 83 84 for (i = (uintptr_t)*iter; url_protocols[i]; i++) { 85 ret = url_protocols[i]->priv_data_class; 86 if (ret) 87 break; 88 } 89 90 *iter = (void*)(uintptr_t)(url_protocols[i] ? i + 1 : i); 91 return ret; 92} 93 94const char *avio_enum_protocols(void **opaque, int output) 95{ 96 uintptr_t i; 97 98 for (i = (uintptr_t)*opaque; url_protocols[i]; i++) { 99 const URLProtocol *p = url_protocols[i]; 100 if ((output && p->url_write) || (!output && p->url_read)) { 101 *opaque = (void*)(uintptr_t)(i + 1); 102 return p->name; 103 } 104 } 105 *opaque = NULL; 106 return NULL; 107} 108 109const AVClass *avio_protocol_get_class(const char *name) 110{ 111 int i = 0; 112 for (i = 0; url_protocols[i]; i++) { 113 if (!strcmp(url_protocols[i]->name, name)) 114 return url_protocols[i]->priv_data_class; 115 } 116 return NULL; 117} 118 119const URLProtocol **ffurl_get_protocols(const char *whitelist, 120 const char *blacklist) 121{ 122 const URLProtocol **ret; 123 int i, ret_idx = 0; 124 125 ret = av_calloc(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret)); 126 if (!ret) 127 return NULL; 128 129 for (i = 0; url_protocols[i]; i++) { 130 const URLProtocol *up = url_protocols[i]; 131 132 if (whitelist && *whitelist && !av_match_name(up->name, whitelist)) 133 continue; 134 if (blacklist && *blacklist && av_match_name(up->name, blacklist)) 135 continue; 136 137 ret[ret_idx++] = up; 138 } 139 140 return ret; 141} 142