1 /*
2 * unbuffered I/O
3 * Copyright (c) 2001 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
28 #if CONFIG_NETWORK
30 #endif
32
34
36 {
38 }
39
40 /** @name Logging context. */
41 /*@{*/
43 {
46 else return "NULL";
47 }
48
50 {
54 return NULL;
55 }
56
58 {
60
61 /* find the protocol that corresponds to prev */
64 break;
65
66 /* find next protocol with priv options */
70 return NULL;
71
72 }
73
82 };
83 /*@}*/
84
85
87 {
90 if (!(p = *opaque)) return NULL;
94 }
95
97 {
101 memcpy(temp, protocol, size);
103 }
105 while (*p != NULL) p = &(*p)->
next;
106 *p = protocol;
107 protocol->
next = NULL;
108 return 0;
109 }
110
112 const char *filename,
int flags,
114 {
116 int err;
117
118 #if CONFIG_NETWORK
121 #endif
124 "Impossible to open the '%s' protocol for reading\n", up->
name);
126 }
129 "Impossible to open the '%s' protocol for writing\n", up->
name);
131 }
133 if (!uc) {
135 goto fail;
136 }
147 int proto_len= strlen(up->
name);
154 char sep= *++p;
156 p++;
157 while(ret >= 0 && (key= strchr(p, sep)) && p<key && (val = strchr(key+1, sep))){
158 *val= *key= 0;
162 *val= *key= sep;
163 p= val+1;
164 }
165 if(ret<0 || p!=key){
170 goto fail;
171 }
172 memmove(start, key+1, strlen(key));
173 }
174 }
175 }
176 if (int_cb)
178
179 *puc = uc;
180 return 0;
181 fail:
182 *puc = NULL;
183 #if CONFIG_NETWORK
186 #endif
187 return err;
188 }
189
191 {
192 int err =
195 if (err)
196 return err;
198 //We must be careful here as ffurl_seek() could be slow, for example for http
203 return 0;
204 }
205
206 #define URL_SCHEME_CHARS \
207 "abcdefghijklmnopqrstuvwxyz" \
208 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
209 "0123456789+-."
210
213 {
215 char proto_str[128], proto_nested[128], *ptr;
217
218 if (!first_protocol) {
220 "Missing call to av_register_all()?\n");
221 }
222
223 if (filename[proto_len] != ':' &&
224 (filename[proto_len] != ',' || !strchr(filename + proto_len + 1, ':')) ||
226 strcpy(proto_str, "file");
227 else
228 av_strlcpy(proto_str, filename,
FFMIN(proto_len+1,
sizeof(proto_str)));
229
230 if ((ptr = strchr(proto_str, ',')))
231 *ptr = '0円';
232 av_strlcpy(proto_nested, proto_str,
sizeof(proto_nested));
233 if ((ptr = strchr(proto_nested, '+')))
234 *ptr = '0円';
235
237 if (!strcmp(proto_str, up->
name))
240 !strcmp(proto_nested, up->
name))
242 }
243 *puc = NULL;
245 }
246
249 {
251 if (ret)
253 if (options && (*puc)->prot->priv_data_class &&
255 goto fail;
257 if (!ret)
258 return 0;
259 fail:
261 *puc = NULL;
263 }
264
266 int (*transfer_func)(
URLContext *h,
unsigned char *buf,
int size))
267 {
269 int fast_retries = 5;
270 int64_t wait_since = 0;
271
272 len = 0;
273 while (len < size_min) {
274 ret = transfer_func(h, buf+len, size-len);
276 continue;
280 ret = 0;
281 if (fast_retries) {
282 fast_retries--;
283 } else {
285 if (!wait_since)
289 }
291 }
292 } else if (ret < 1)
294 if (ret)
295 fast_retries =
FFMAX(fast_retries, 2);
299 }
301 }
302
304 {
308 }
309
311 {
315 }
316
318 {
321 /* avoid sending too big packets */
324
326 }
327
329 {
331
336 }
337
339 {
342 if (!h) return 0; /* can happen when ffurl_open fails */
343
346 #if CONFIG_NETWORK
349 #endif
354 }
357 }
358
360 {
362 }
363
364
366 {
369 if (ret)
371
374 } else {
376 if (ret >= 0)
378 }
379
382 }
383
385 {
387
389 if(size<0){
393 size++;
395 }
397 }
398
400 {
402 return -1;
404 }
405
407 {
412 if (!*handles)
414 *numhandles = 1;
416 return 0;
417 }
419 }
420
422 {
426 }
427
429 {
433 return 0;
434 }