FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
protocols.c
Go to the documentation of this file.
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 "config.h"
20 
21 #include "libavutil/avstring.h"
22 #include "libavutil/mem.h"
23 
24 #include "url.h"
25 
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;
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;
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_tee_protocol;
57 extern const URLProtocol ff_tcp_protocol;
62 extern const URLProtocol ff_udp_protocol;
63 extern const URLProtocol ff_udplite_protocol;
64 extern const URLProtocol ff_unix_protocol;
65 extern const URLProtocol ff_librtmp_protocol;
70 extern const URLProtocol ff_libssh_protocol;
72 
73 #include "libavformat/protocol_list.c"
74 
76 {
77  int i;
78 
79  /* find the protocol that corresponds to prev */
80  for (i = 0; prev && url_protocols[i]; i++) {
81  if (url_protocols[i]->priv_data_class == prev) {
82  i++;
83  break;
84  }
85  }
86 
87  /* find next protocol with priv options */
88  for (; url_protocols[i]; i++)
89  if (url_protocols[i]->priv_data_class)
90  return url_protocols[i]->priv_data_class;
91  return NULL;
92 }
93 
94 
95 const char *avio_enum_protocols(void **opaque, int output)
96 {
97  const URLProtocol **p = *opaque;
98 
99  p = p ? p + 1 : url_protocols;
100  *opaque = p;
101  if (!*p) {
102  *opaque = NULL;
103  return NULL;
104  }
105  if ((output && (*p)->url_write) || (!output && (*p)->url_read))
106  return (*p)->name;
107  return avio_enum_protocols(opaque, output);
108 }
109 
110 const URLProtocol **ffurl_get_protocols(const char *whitelist,
111  const char *blacklist)
112 {
113  const URLProtocol **ret;
114  int i, ret_idx = 0;
115 
116  ret = av_mallocz_array(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));
117  if (!ret)
118  return NULL;
119 
120  for (i = 0; url_protocols[i]; i++) {
121  const URLProtocol *up = url_protocols[i];
122 
123  if (whitelist && *whitelist && !av_match_name(up->name, whitelist))
124  continue;
125  if (blacklist && *blacklist && av_match_name(up->name, blacklist))
126  continue;
127 
128  ret[ret_idx++] = up;
129  }
130 
131  return ret;
132 }
#define NULL
Definition: coverity.c:32
const URLProtocol ff_async_protocol
Definition: async.c:482
Memory handling functions.
const URLProtocol ff_srtp_protocol
Definition: srtpproto.c:135
const URLProtocol ff_http_protocol
const URLProtocol ff_rtmpts_protocol
const URLProtocol ff_libssh_protocol
Definition: libssh.c:492
const URLProtocol ff_tls_securetransport_protocol
const URLProtocol ff_unix_protocol
Definition: unix.c:146
const URLProtocol ff_librtmpt_protocol
Definition: librtmp.c:357
const URLProtocol ff_sctp_protocol
Definition: sctp.c:362
const URLProtocol ff_tcp_protocol
Definition: tcp.c:258
const URLProtocol ff_ffrtmpcrypt_protocol
Definition: rtmpcrypt.c:328
const URLProtocol ff_mmsh_protocol
Definition: mmsh.c:412
const AVClass * ff_urlcontext_child_class_next(const AVClass *prev)
Definition: protocols.c:75
const URLProtocol ff_librtmpte_protocol
Definition: librtmp.c:387
const URLProtocol ff_rtmpe_protocol
const URLProtocol ff_tls_schannel_protocol
Definition: tls_schannel.c:592
const URLProtocol ff_crypto_protocol
Definition: crypto.c:399
const URLProtocol ff_rtmp_protocol
int av_match_name(const char *name, const char *names)
Match instances of a name in a comma-separated list of names.
Definition: avstring.c:320
const URLProtocol ff_pipe_protocol
const URLProtocol ff_tee_protocol
Definition: teeproto.c:139
static void * av_mallocz_array(size_t nmemb, size_t size)
Definition: mem.h:226
const URLProtocol ff_rtp_protocol
Definition: rtpproto.c:610
const URLProtocol ff_bluray_protocol
Definition: bluray.c:227
const URLProtocol ff_file_protocol
const URLProtocol ff_ffrtmphttp_protocol
Definition: rtmphttp.c:276
const URLProtocol ff_tls_gnutls_protocol
Definition: tls_gnutls.c:250
const URLProtocol ff_httpproxy_protocol
const URLProtocol ff_subfile_protocol
Definition: subfile.c:140
#define FF_ARRAY_ELEMS(a)
const URLProtocol ff_udp_protocol
Definition: udp.c:1161
const URLProtocol ff_librtmps_protocol
Definition: librtmp.c:402
const URLProtocol ff_rtmps_protocol
Describe the class of an AVClass context structure.
Definition: log.h:67
const URLProtocol ff_md5_protocol
Definition: md5proto.c:90
const URLProtocol ff_librtmp_protocol
Definition: librtmp.c:342
const char * name
Definition: url.h:54
const URLProtocol ff_hls_protocol
Definition: hlsproto.c:321
const URLProtocol ff_rtmpte_protocol
const URLProtocol ff_cache_protocol
Definition: cache.c:322
const URLProtocol ff_data_protocol
Definition: data_uri.c:112
const URLProtocol ff_gopher_protocol
Definition: gopher.c:117
const char * avio_enum_protocols(void **opaque, int output)
Iterate through names of available protocols.
Definition: protocols.c:95
const URLProtocol ff_udplite_protocol
Definition: udp.c:1173
const URLProtocol ff_mmst_protocol
Definition: mmst.c:632
const URLProtocol ff_libsmbclient_protocol
Definition: libsmbclient.c:368
const URLProtocol ff_https_protocol
const URLProtocol ff_icecast_protocol
Definition: icecast.c:212
const URLProtocol ff_rtmpt_protocol
const URLProtocol ff_concat_protocol
Definition: concat.c:189
unbuffered private I/O API
const URLProtocol ff_tls_openssl_protocol
Definition: tls_openssl.c:335
const URLProtocol ff_librtmpe_protocol
Definition: librtmp.c:372
const URLProtocol ff_ftp_protocol
Definition: ftp.c:1106
const URLProtocol ** ffurl_get_protocols(const char *whitelist, const char *blacklist)
Construct a list of protocols matching a given whitelist and/or blacklist.
Definition: protocols.c:110