FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/protocols.c
Date: 2026-08-29 16:27:19
Exec Total Coverage
Lines: 18 35 51.4%
Functions: 2 4 50.0%
Branches: 11 36 30.6%

Line Branch Exec Source
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
27 extern const URLProtocol ff_android_content_protocol;
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;
36 extern const URLProtocol ff_ffrtmpcrypt_protocol;
37 extern const URLProtocol ff_ffrtmphttp_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_http_protocol;
43 extern const URLProtocol ff_httpproxy_protocol;
44 extern const URLProtocol ff_https_protocol;
45 extern const URLProtocol ff_icecast_protocol;
46 extern const URLProtocol ff_mmsh_protocol;
47 extern const URLProtocol ff_mmst_protocol;
48 extern const URLProtocol ff_md5_protocol;
49 extern const URLProtocol ff_pipe_protocol;
50 extern const URLProtocol ff_prompeg_protocol;
51 extern const URLProtocol ff_rtmp_protocol;
52 extern const URLProtocol ff_rtmpe_protocol;
53 extern const URLProtocol ff_rtmps_protocol;
54 extern const URLProtocol ff_rtmpt_protocol;
55 extern const URLProtocol ff_rtmpte_protocol;
56 extern const URLProtocol ff_rtmpts_protocol;
57 extern const URLProtocol ff_rtp_protocol;
58 extern const URLProtocol ff_shared_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_dtls_protocol;
66 extern const URLProtocol ff_udp_protocol;
67 extern const URLProtocol ff_udplite_protocol;
68 extern const URLProtocol ff_unix_protocol;
69 extern const URLProtocol ff_libamqp_protocol;
70 extern const URLProtocol ff_libcurl_protocol;
71 extern const URLProtocol ff_librist_protocol;
72 extern const URLProtocol ff_librtmp_protocol;
73 extern const URLProtocol ff_librtmpe_protocol;
74 extern const URLProtocol ff_librtmps_protocol;
75 extern const URLProtocol ff_librtmpt_protocol;
76 extern const URLProtocol ff_librtmpte_protocol;
77 extern const URLProtocol ff_libsrt_protocol;
78 extern const URLProtocol ff_libssh_protocol;
79 extern const URLProtocol ff_libsmbclient_protocol;
80 extern const URLProtocol ff_libzmq_protocol;
81 extern const URLProtocol ff_ipfs_gateway_protocol;
82 extern const URLProtocol ff_ipns_gateway_protocol;
83
84 #include "libavformat/protocol_list.c"
85
86 2804521 const AVClass *ff_urlcontext_child_class_iterate(void **iter)
87 {
88 2804521 const AVClass *ret = NULL;
89 uintptr_t i;
90
91
2/2
✓ Branch 0 taken 3780013 times.
✓ Branch 1 taken 121934 times.
3901947 for (i = (uintptr_t)*iter; url_protocols[i]; i++) {
92 3780013 ret = url_protocols[i]->priv_data_class;
93
2/2
✓ Branch 0 taken 2682587 times.
✓ Branch 1 taken 1097426 times.
3780013 if (ret)
94 2682587 break;
95 }
96
97
2/2
✓ Branch 0 taken 2682587 times.
✓ Branch 1 taken 121934 times.
2804521 *iter = (void*)(uintptr_t)(url_protocols[i] ? i + 1 : i);
98 2804521 return ret;
99 }
100
101 const char *avio_enum_protocols(void **opaque, int output)
102 {
103 uintptr_t i;
104
105 for (i = (uintptr_t)*opaque; url_protocols[i]; i++) {
106 const URLProtocol *p = url_protocols[i];
107 if ((output && p->url_write) || (!output && p->url_read)) {
108 *opaque = (void*)(uintptr_t)(i + 1);
109 return p->name;
110 }
111 }
112 *opaque = NULL;
113 return NULL;
114 }
115
116 const AVClass *avio_protocol_get_class(const char *name)
117 {
118 int i = 0;
119 for (i = 0; url_protocols[i]; i++) {
120 if (!strcmp(url_protocols[i]->name, name))
121 return url_protocols[i]->priv_data_class;
122 }
123 return NULL;
124 }
125
126 180678 const URLProtocol **ffurl_get_protocols(const char *whitelist,
127 const char *blacklist)
128 {
129 const URLProtocol **ret;
130 180678 int i, ret_idx = 0;
131
132 180678 ret = av_calloc(FF_ARRAY_ELEMS(url_protocols), sizeof(*ret));
133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180678 times.
180678 if (!ret)
134 return NULL;
135
136
2/2
✓ Branch 0 taken 5601018 times.
✓ Branch 1 taken 180678 times.
5781696 for (i = 0; url_protocols[i]; i++) {
137 5601018 const URLProtocol *up = url_protocols[i];
138
139
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5601018 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
5601018 if (whitelist && *whitelist && !av_match_name(up->name, whitelist))
140 continue;
141
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5601018 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
5601018 if (blacklist && *blacklist && av_match_name(up->name, blacklist))
142 continue;
143
144 5601018 ret[ret_idx++] = up;
145 }
146
147 180678 return ret;
148 }
149