FFmpeg
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 <string.h>
20 
21 #include "libavutil/avstring.h"
22 #include "libavutil/log.h"
23 #include "libavutil/mem.h"
24 
25 #include "url.h"
26 
28 extern const URLProtocol ff_async_protocol;
29 extern const URLProtocol ff_bluray_protocol;
30 extern const URLProtocol ff_cache_protocol;
31 extern const URLProtocol ff_concat_protocol;
32 extern const URLProtocol ff_concatf_protocol;
33 extern const URLProtocol ff_crypto_protocol;
34 extern const URLProtocol ff_data_protocol;
35 extern const URLProtocol ff_fd_protocol;
38 extern const URLProtocol ff_file_protocol;
39 extern const URLProtocol ff_ftp_protocol;
40 extern const URLProtocol ff_gopher_protocol;
41 extern const URLProtocol ff_gophers_protocol;
42 extern const URLProtocol ff_hls_protocol;
43 extern const URLProtocol ff_http_protocol;
45 extern const URLProtocol ff_https_protocol;
46 extern const URLProtocol ff_icecast_protocol;
47 extern const URLProtocol ff_mmsh_protocol;
48 extern const URLProtocol ff_mmst_protocol;
49 extern const URLProtocol ff_md5_protocol;
50 extern const URLProtocol ff_pipe_protocol;
51 extern const URLProtocol ff_prompeg_protocol;
52 extern const URLProtocol ff_rtmp_protocol;
53 extern const URLProtocol ff_rtmpe_protocol;
54 extern const URLProtocol ff_rtmps_protocol;
55 extern const URLProtocol ff_rtmpt_protocol;
56 extern const URLProtocol ff_rtmpte_protocol;
57 extern const URLProtocol ff_rtmpts_protocol;
58 extern const URLProtocol ff_rtp_protocol;
59 extern const URLProtocol ff_sctp_protocol;
60 extern const URLProtocol ff_srtp_protocol;
61 extern const URLProtocol ff_subfile_protocol;
62 extern const URLProtocol ff_tee_protocol;
63 extern const URLProtocol ff_tcp_protocol;
64 extern const URLProtocol ff_tls_protocol;
65 extern const URLProtocol ff_udp_protocol;
66 extern const URLProtocol ff_udplite_protocol;
67 extern const URLProtocol ff_unix_protocol;
68 extern const URLProtocol ff_libamqp_protocol;
69 extern const URLProtocol ff_librist_protocol;
70 extern const URLProtocol ff_librtmp_protocol;
75 extern const URLProtocol ff_libsrt_protocol;
76 extern const URLProtocol ff_libssh_protocol;
78 extern const URLProtocol ff_libzmq_protocol;
81 
82 #include "libavformat/protocol_list.c"
83 
85 {
86  const AVClass *ret = NULL;
87  uintptr_t i;
88 
89  for (i = (uintptr_t)*iter; url_protocols[i]; i++) {
90  ret = url_protocols[i]->priv_data_class;
91  if (ret)
92  break;
93  }
94 
95  *iter = (void*)(uintptr_t)(url_protocols[i] ? i + 1 : i);
96  return ret;
97 }
98 
99 const char *avio_enum_protocols(void **opaque, int output)
100 {
101  uintptr_t i;
102 
103  for (i = (uintptr_t)*opaque; url_protocols[i]; i++) {
104  const URLProtocol *p = url_protocols[i];
105  if ((output && p->url_write) || (!output && p->url_read)) {
106  *opaque = (void*)(uintptr_t)(i + 1);
107  return p->name;
108  }
109  }
110  *opaque = NULL;
111  return NULL;
112 }
113 
115 {
116  int i = 0;
117  for (i = 0; url_protocols[i]; i++) {
118  if (!strcmp(url_protocols[i]->name, name))
119  return url_protocols[i]->priv_data_class;
120  }
121  return NULL;
122 }
123 
124 const URLProtocol **ffurl_get_protocols(const char *whitelist,
125  const char *blacklist)
126 {
127  const URLProtocol **ret;
128  int i, ret_idx = 0;
129 
130  ret = av_calloc(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));
131  if (!ret)
132  return NULL;
133 
134  for (i = 0; url_protocols[i]; i++) {
135  const URLProtocol *up = url_protocols[i];
136 
137  if (whitelist && *whitelist && !av_match_name(up->name, whitelist))
138  continue;
139  if (blacklist && *blacklist && av_match_name(up->name, blacklist))
140  continue;
141 
142  ret[ret_idx++] = up;
143  }
144 
145  return ret;
146 }
ff_librtmpte_protocol
const URLProtocol ff_librtmpte_protocol
Definition: librtmp.c:340
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
ff_md5_protocol
const URLProtocol ff_md5_protocol
Definition: md5proto.c:89
URLProtocol::url_read
int(* url_read)(URLContext *h, unsigned char *buf, int size)
Read data from the protocol.
Definition: url.h:75
ff_crypto_protocol
const URLProtocol ff_crypto_protocol
Definition: crypto.c:389
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
ff_librtmpt_protocol
const URLProtocol ff_librtmpt_protocol
Definition: librtmp.c:310
ff_subfile_protocol
const URLProtocol ff_subfile_protocol
Definition: subfile.c:150
ff_rtmpte_protocol
const URLProtocol ff_rtmpte_protocol
ff_sctp_protocol
const URLProtocol ff_sctp_protocol
Definition: sctp.c:364
ff_libamqp_protocol
const URLProtocol ff_libamqp_protocol
Definition: libamqp.c:314
ff_libzmq_protocol
const URLProtocol ff_libzmq_protocol
Definition: libzmq.c:198
ff_udplite_protocol
const URLProtocol ff_udplite_protocol
Definition: udp.c:1161
ff_mmsh_protocol
const URLProtocol ff_mmsh_protocol
Definition: mmsh.c:411
URLProtocol
Definition: url.h:51
ff_rtmpt_protocol
const URLProtocol ff_rtmpt_protocol
ff_urlcontext_child_class_iterate
const AVClass * ff_urlcontext_child_class_iterate(void **iter)
Definition: protocols.c:84
ff_httpproxy_protocol
const URLProtocol ff_httpproxy_protocol
ff_ftp_protocol
const URLProtocol ff_ftp_protocol
Definition: ftp.c:1174
ff_cache_protocol
const URLProtocol ff_cache_protocol
Definition: cache.c:335
ff_android_content_protocol
const URLProtocol ff_android_content_protocol
ff_data_protocol
const URLProtocol ff_data_protocol
Definition: data_uri.c:113
ff_fd_protocol
const URLProtocol ff_fd_protocol
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
avio_enum_protocols
const char * avio_enum_protocols(void **opaque, int output)
Iterate through names of available protocols.
Definition: protocols.c:99
ff_librtmps_protocol
const URLProtocol ff_librtmps_protocol
Definition: librtmp.c:355
ff_libsrt_protocol
const URLProtocol ff_libsrt_protocol
Definition: libsrt.c:741
ff_concat_protocol
const URLProtocol ff_concat_protocol
ff_bluray_protocol
const URLProtocol ff_bluray_protocol
Definition: bluray.c:226
ff_ipns_gateway_protocol
const URLProtocol ff_ipns_gateway_protocol
Definition: ipfsgateway.c:349
ffurl_get_protocols
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:124
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ff_rtmpts_protocol
const URLProtocol ff_rtmpts_protocol
NULL
#define NULL
Definition: coverity.c:32
ff_libssh_protocol
const URLProtocol ff_libssh_protocol
Definition: libssh.c:489
ff_hls_protocol
const URLProtocol ff_hls_protocol
Definition: hlsproto.c:310
ff_rtmp_protocol
const URLProtocol ff_rtmp_protocol
ff_mmst_protocol
const URLProtocol ff_mmst_protocol
Definition: mmst.c:632
ff_async_protocol
const URLProtocol ff_async_protocol
Definition: async.c:492
ff_icecast_protocol
const URLProtocol ff_icecast_protocol
Definition: icecast.c:215
ff_file_protocol
const URLProtocol ff_file_protocol
ff_ffrtmphttp_protocol
const URLProtocol ff_ffrtmphttp_protocol
Definition: rtmphttp.c:276
URLProtocol::name
const char * name
Definition: url.h:52
ff_rtmps_protocol
const URLProtocol ff_rtmps_protocol
ff_librtmp_protocol
const URLProtocol ff_librtmp_protocol
Definition: librtmp.c:295
ff_librtmpe_protocol
const URLProtocol ff_librtmpe_protocol
Definition: librtmp.c:325
ff_http_protocol
const URLProtocol ff_http_protocol
ff_concatf_protocol
const URLProtocol ff_concatf_protocol
ff_rtmpe_protocol
const URLProtocol ff_rtmpe_protocol
log.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
ff_prompeg_protocol
const URLProtocol ff_prompeg_protocol
Definition: prompeg.c:470
url.h
ff_tcp_protocol
const URLProtocol ff_tcp_protocol
Definition: tcp.c:365
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
ff_gophers_protocol
const URLProtocol ff_gophers_protocol
ff_pipe_protocol
const URLProtocol ff_pipe_protocol
ff_https_protocol
const URLProtocol ff_https_protocol
ff_tee_protocol
const URLProtocol ff_tee_protocol
Definition: teeproto.c:139
ret
ret
Definition: filter_design.txt:187
ff_rtp_protocol
const URLProtocol ff_rtp_protocol
Definition: rtpproto.c:569
ff_srtp_protocol
const URLProtocol ff_srtp_protocol
Definition: srtpproto.c:132
av_match_name
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:345
ff_tls_protocol
const URLProtocol ff_tls_protocol
Definition: tls_gnutls.c:302
ff_ipfs_gateway_protocol
const URLProtocol ff_ipfs_gateway_protocol
Definition: ipfsgateway.c:339
mem.h
ff_unix_protocol
const URLProtocol ff_unix_protocol
Definition: unix.c:148
ff_librist_protocol
const URLProtocol ff_librist_protocol
Definition: librist.c:260
ff_ffrtmpcrypt_protocol
const URLProtocol ff_ffrtmpcrypt_protocol
Definition: rtmpcrypt.c:328
URLProtocol::url_write
int(* url_write)(URLContext *h, const unsigned char *buf, int size)
Definition: url.h:76
ff_udp_protocol
const URLProtocol ff_udp_protocol
Definition: udp.c:1149
ff_gopher_protocol
const URLProtocol ff_gopher_protocol
avstring.h
avio_protocol_get_class
const AVClass * avio_protocol_get_class(const char *name)
Get AVClass by names of available protocols.
Definition: protocols.c:114
ff_libsmbclient_protocol
const URLProtocol ff_libsmbclient_protocol
Definition: libsmbclient.c:366