1 /*
2 * Concat URL protocol
3 * Copyright (c) 2006 Steve Lhomme
4 * Copyright (c) 2007 Wolfram Gloger
5 * Copyright (c) 2010 Michele Orrù
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include "config_components.h"
25
29
33
34 #define AV_CAT_SEPARATOR "|"
35
38 int64_t
size;
///< url filesize
39 };
40
43 size_t length;
///< number of cat'ed nodes
44 size_t current;
///< index of currently read node
46 };
47
49 {
50 int err = 0;
54
55 for (
i = 0;
i !=
data->length;
i++)
57
59
60 return err < 0 ? -1 : 0;
61 }
62
63 #if CONFIG_CONCAT_PROTOCOL
65 {
66 char *node_uri =
NULL;
67 int err = 0;
68 int64_t
size, total_size = 0;
73
77 }
78
79 for (
i = 0,
len = 1; uri[
i];
i++) {
82 }
83 }
84
87 else
89
90 /* handle input */
91 if (!*uri)
93 for (
i = 0; *uri;
i++) {
94 /* parsing uri */
97 break;
100
101 /* creating URLContext */
103 &
h->interrupt_callback,
NULL,
h->protocol_whitelist,
h->protocol_blacklist,
h);
104 if (err < 0)
105 break;
106
107 /* creating size */
111 break;
112 }
113
114 /* assembling */
118 }
121
122 if (err < 0)
124 else if (!(nodes =
av_realloc(nodes,
data->length *
sizeof(*nodes)))) {
127 } else
129 data->total_size = total_size;
130 return err;
131 }
132 #endif
133
135 {
139 size_t i =
data->current;
140
144 if (
i + 1 ==
data->length ||
146 break;
148 }
150 return total ? total :
result;
154 }
156 return total ? total :
result;
157 }
158
160 {
165
167 return data->total_size;
168 switch (whence) {
169 case SEEK_END:
172 break;
173 case SEEK_CUR:
174 /* get the absolute position */
175 for (
i = 0;
i !=
data->current;
i++)
178 whence = SEEK_SET;
179 /* fall through with the absolute position */
180 case SEEK_SET:
183 break;
184 default:
186 }
187
193 }
195 }
196
197 #if CONFIG_CONCAT_PROTOCOL
200 .url_open = concat_open,
205 .default_whitelist = "concat,file,subfile",
206 };
207 #endif
208
209 #if CONFIG_CONCATF_PROTOCOL
211 {
212 AVBPrint bp;
215 const char *cursor;
217 unsigned int nodes_size = 0;
219 int err;
220
224 }
225
226 /* handle input */
227 if (!*uri)
229
231 NULL,
h->protocol_whitelist,
h->protocol_blacklist);
232 if (err < 0)
233 return err;
234
238 if (err < 0) {
240 return err;
241 }
242
243 cursor = bp.str;
244 while (*cursor) {
247 char *node_uri;
250 int leading_spaces = strspn(cursor, " \n\t\r");
251
252 if (!cursor[leading_spaces])
253 break;
254
256 if (!node_uri) {
258 break;
259 }
260 if (*cursor)
261 cursor++;
262
263 if (++
len == SIZE_MAX /
sizeof(*nodes)) {
266 break;
267 }
268
269 /* creating URLContext */
271 &
h->interrupt_callback,
NULL,
h->protocol_whitelist,
h->protocol_blacklist,
h);
273 if (err < 0)
274 break;
275
276 /* creating size */
280 break;
281 }
282
284 if (!nodes) {
287 break;
288 }
290
291 /* assembling */
295 }
298
299 if (err < 0)
301
302 data->total_size = total_size;
303 return err;
304 }
305
308 .url_open = concatf_open,
313 .default_whitelist = "concatf,concat,file,subfile",
314 };
315 #endif