FFmpeg  2.8.17
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
avio.c
Go to the documentation of this file.
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 
22 #include "libavutil/avstring.h"
23 #include "libavutil/dict.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/time.h"
26 #include "libavutil/avassert.h"
27 #include "os_support.h"
28 #include "avformat.h"
29 #if CONFIG_NETWORK
30 #include "network.h"
31 #endif
32 #include "url.h"
33 
35 
37 {
38  return prev ? prev->next : first_protocol;
39 }
40 
41 /** @name Logging context. */
42 /*@{*/
43 static const char *urlcontext_to_name(void *ptr)
44 {
45  URLContext *h = (URLContext *)ptr;
46  if (h->prot)
47  return h->prot->name;
48  else
49  return "NULL";
50 }
51 
52 static void *urlcontext_child_next(void *obj, void *prev)
53 {
54  URLContext *h = obj;
55  if (!prev && h->priv_data && h->prot->priv_data_class)
56  return h->priv_data;
57  return NULL;
58 }
59 
60 static const AVClass *urlcontext_child_class_next(const AVClass *prev)
61 {
62  URLProtocol *p = NULL;
63 
64  /* find the protocol that corresponds to prev */
65  while (prev && (p = ffurl_protocol_next(p)))
66  if (p->priv_data_class == prev)
67  break;
68 
69  /* find next protocol with priv options */
70  while (p = ffurl_protocol_next(p))
71  if (p->priv_data_class)
72  return p->priv_data_class;
73  return NULL;
74 }
75 
76 static const AVOption options[] = { { NULL } };
78  .class_name = "URLContext",
79  .item_name = urlcontext_to_name,
80  .option = options,
81  .version = LIBAVUTIL_VERSION_INT,
82  .child_next = urlcontext_child_next,
83  .child_class_next = urlcontext_child_class_next,
84 };
85 /*@}*/
86 
87 const char *avio_enum_protocols(void **opaque, int output)
88 {
89  URLProtocol *p;
90  *opaque = ffurl_protocol_next(*opaque);
91  if (!(p = *opaque))
92  return NULL;
93  if ((output && p->url_write) || (!output && p->url_read))
94  return p->name;
95  return avio_enum_protocols(opaque, output);
96 }
97 
99 {
100  URLProtocol **p;
101  p = &first_protocol;
102  while (*p)
103  p = &(*p)->next;
104  *p = protocol;
105  protocol->next = NULL;
106  return 0;
107 }
108 
109 static int url_alloc_for_protocol(URLContext **puc, struct URLProtocol *up,
110  const char *filename, int flags,
111  const AVIOInterruptCB *int_cb)
112 {
113  URLContext *uc;
114  int err;
115 
116 #if CONFIG_NETWORK
118  return AVERROR(EIO);
119 #endif
120  if ((flags & AVIO_FLAG_READ) && !up->url_read) {
122  "Impossible to open the '%s' protocol for reading\n", up->name);
123  return AVERROR(EIO);
124  }
125  if ((flags & AVIO_FLAG_WRITE) && !up->url_write) {
127  "Impossible to open the '%s' protocol for writing\n", up->name);
128  return AVERROR(EIO);
129  }
130  uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1);
131  if (!uc) {
132  err = AVERROR(ENOMEM);
133  goto fail;
134  }
136  uc->filename = (char *)&uc[1];
137  strcpy(uc->filename, filename);
138  uc->prot = up;
139  uc->flags = flags;
140  uc->is_streamed = 0; /* default = not streamed */
141  uc->max_packet_size = 0; /* default: stream file */
142  if (up->priv_data_size) {
144  if (!uc->priv_data) {
145  err = AVERROR(ENOMEM);
146  goto fail;
147  }
148  if (up->priv_data_class) {
149  int proto_len= strlen(up->name);
150  char *start = strchr(uc->filename, ',');
151  *(const AVClass **)uc->priv_data = up->priv_data_class;
153  if(!strncmp(up->name, uc->filename, proto_len) && uc->filename + proto_len == start){
154  int ret= 0;
155  char *p= start;
156  char sep= *++p;
157  char *key, *val;
158  p++;
159 
160  if (strcmp(up->name, "subfile"))
161  ret = AVERROR(EINVAL);
162 
163  while(ret >= 0 && (key= strchr(p, sep)) && p<key && (val = strchr(key+1, sep))){
164  *val= *key= 0;
165  if (strcmp(p, "start") && strcmp(p, "end")) {
167  } else
168  ret= av_opt_set(uc->priv_data, p, key+1, 0);
169  if (ret == AVERROR_OPTION_NOT_FOUND)
170  av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", p);
171  *val= *key= sep;
172  p= val+1;
173  }
174  if(ret<0 || p!=key){
175  av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", start);
176  av_freep(&uc->priv_data);
177  av_freep(&uc);
178  err = AVERROR(EINVAL);
179  goto fail;
180  }
181  memmove(start, key+1, strlen(key));
182  }
183  }
184  }
185  if (int_cb)
186  uc->interrupt_callback = *int_cb;
187 
188  *puc = uc;
189  return 0;
190 fail:
191  *puc = NULL;
192  if (uc)
193  av_freep(&uc->priv_data);
194  av_freep(&uc);
195 #if CONFIG_NETWORK
198 #endif
199  return err;
200 }
201 
203 {
204  int err =
205  uc->prot->url_open2 ? uc->prot->url_open2(uc,
206  uc->filename,
207  uc->flags,
208  options) :
209  uc->prot->url_open(uc, uc->filename, uc->flags);
210  if (err)
211  return err;
212  uc->is_connected = 1;
213  /* We must be careful here as ffurl_seek() could be slow,
214  * for example for http */
215  if ((uc->flags & AVIO_FLAG_WRITE) || !strcmp(uc->prot->name, "file"))
216  if (!uc->is_streamed && ffurl_seek(uc, 0, SEEK_SET) < 0)
217  uc->is_streamed = 1;
218  return 0;
219 }
220 
222 {
223  av_assert0(!*c);
224  if (s->prot->url_accept)
225  return s->prot->url_accept(s, c);
226  return AVERROR(EBADF);
227 }
228 
230 {
231  int ret;
232  if (c->prot->url_handshake) {
233  ret = c->prot->url_handshake(c);
234  if (ret)
235  return ret;
236  }
237  c->is_connected = 1;
238  return 0;
239 }
240 
241 #define URL_SCHEME_CHARS \
242  "abcdefghijklmnopqrstuvwxyz" \
243  "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
244  "0123456789+-."
245 
246 static struct URLProtocol *url_find_protocol(const char *filename)
247 {
248  URLProtocol *up = NULL;
249  char proto_str[128], proto_nested[128], *ptr;
250  size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
251 
252  if (filename[proto_len] != ':' &&
253  (strncmp(filename, "subfile,", 8) || !strchr(filename + proto_len + 1, ':')) ||
254  is_dos_path(filename))
255  strcpy(proto_str, "file");
256  else
257  av_strlcpy(proto_str, filename,
258  FFMIN(proto_len + 1, sizeof(proto_str)));
259 
260  if ((ptr = strchr(proto_str, ',')))
261  *ptr = '\0';
262  av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));
263  if ((ptr = strchr(proto_nested, '+')))
264  *ptr = '\0';
265 
266  while (up = ffurl_protocol_next(up)) {
267  if (!strcmp(proto_str, up->name))
268  break;
270  !strcmp(proto_nested, up->name))
271  break;
272  }
273 
274  return up;
275 }
276 
277 int ffurl_alloc(URLContext **puc, const char *filename, int flags,
278  const AVIOInterruptCB *int_cb)
279 {
280  URLProtocol *p = NULL;
281 
282  if (!first_protocol) {
283  av_log(NULL, AV_LOG_WARNING, "No URL Protocols are registered. "
284  "Missing call to av_register_all()?\n");
285  }
286 
287  p = url_find_protocol(filename);
288  if (p)
289  return url_alloc_for_protocol(puc, p, filename, flags, int_cb);
290 
291  *puc = NULL;
292  if (av_strstart(filename, "https:", NULL))
293  av_log(NULL, AV_LOG_WARNING, "https protocol not found, recompile FFmpeg with "
294  "openssl, gnutls,\n"
295  "or securetransport enabled.\n");
297 }
298 
299 int ffurl_open(URLContext **puc, const char *filename, int flags,
300  const AVIOInterruptCB *int_cb, AVDictionary **options)
301 {
302  int ret = ffurl_alloc(puc, filename, flags, int_cb);
303  if (ret < 0)
304  return ret;
305  if (options && (*puc)->prot->priv_data_class &&
306  (ret = av_opt_set_dict((*puc)->priv_data, options)) < 0)
307  goto fail;
308  if ((ret = av_opt_set_dict(*puc, options)) < 0)
309  goto fail;
310  ret = ffurl_connect(*puc, options);
311  if (!ret)
312  return 0;
313 fail:
314  ffurl_close(*puc);
315  *puc = NULL;
316  return ret;
317 }
318 
320  int size, int size_min,
321  int (*transfer_func)(URLContext *h,
322  uint8_t *buf,
323  int size))
324 {
325  int ret, len;
326  int fast_retries = 5;
327  int64_t wait_since = 0;
328 
329  len = 0;
330  while (len < size_min) {
332  return AVERROR_EXIT;
333  ret = transfer_func(h, buf + len, size - len);
334  if (ret == AVERROR(EINTR))
335  continue;
336  if (h->flags & AVIO_FLAG_NONBLOCK)
337  return ret;
338  if (ret == AVERROR(EAGAIN)) {
339  ret = 0;
340  if (fast_retries) {
341  fast_retries--;
342  } else {
343  if (h->rw_timeout) {
344  if (!wait_since)
345  wait_since = av_gettime_relative();
346  else if (av_gettime_relative() > wait_since + h->rw_timeout)
347  return AVERROR(EIO);
348  }
349  av_usleep(1000);
350  }
351  } else if (ret < 1)
352  return (ret < 0 && ret != AVERROR_EOF) ? ret : len;
353  if (ret)
354  fast_retries = FFMAX(fast_retries, 2);
355  len += ret;
356  }
357  return len;
358 }
359 
360 int ffurl_read(URLContext *h, unsigned char *buf, int size)
361 {
362  if (!(h->flags & AVIO_FLAG_READ))
363  return AVERROR(EIO);
364  return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read);
365 }
366 
367 int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
368 {
369  if (!(h->flags & AVIO_FLAG_READ))
370  return AVERROR(EIO);
371  return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read);
372 }
373 
374 int ffurl_write(URLContext *h, const unsigned char *buf, int size)
375 {
376  if (!(h->flags & AVIO_FLAG_WRITE))
377  return AVERROR(EIO);
378  /* avoid sending too big packets */
379  if (h->max_packet_size && size > h->max_packet_size)
380  return AVERROR(EIO);
381 
382  return retry_transfer_wrapper(h, (unsigned char *)buf, size, size,
383  (int (*)(struct URLContext *, uint8_t *, int))
384  h->prot->url_write);
385 }
386 
387 int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
388 {
389  int64_t ret;
390 
391  if (!h->prot->url_seek)
392  return AVERROR(ENOSYS);
393  ret = h->prot->url_seek(h, pos, whence & ~AVSEEK_FORCE);
394  return ret;
395 }
396 
398 {
399  URLContext *h= *hh;
400  int ret = 0;
401  if (!h)
402  return 0; /* can happen when ffurl_open fails */
403 
404  if (h->is_connected && h->prot->url_close)
405  ret = h->prot->url_close(h);
406 #if CONFIG_NETWORK
409 #endif
410  if (h->prot->priv_data_size) {
411  if (h->prot->priv_data_class)
413  av_freep(&h->priv_data);
414  }
415  av_freep(hh);
416  return ret;
417 }
418 
420 {
421  return ffurl_closep(&h);
422 }
423 
424 
425 const char *avio_find_protocol_name(const char *url)
426 {
427  URLProtocol *p = url_find_protocol(url);
428 
429  return p ? p->name : NULL;
430 }
431 
432 int avio_check(const char *url, int flags)
433 {
434  URLContext *h;
435  int ret = ffurl_alloc(&h, url, flags, NULL);
436  if (ret < 0)
437  return ret;
438 
439  if (h->prot->url_check) {
440  ret = h->prot->url_check(h, flags);
441  } else {
442  ret = ffurl_connect(h, NULL);
443  if (ret >= 0)
444  ret = flags;
445  }
446 
447  ffurl_close(h);
448  return ret;
449 }
450 
451 int avpriv_io_move(const char *url_src, const char *url_dst)
452 {
453  URLContext *h_src, *h_dst;
454  int ret = ffurl_alloc(&h_src, url_src, AVIO_FLAG_READ_WRITE, NULL);
455  if (ret < 0)
456  return ret;
457  ret = ffurl_alloc(&h_dst, url_dst, AVIO_FLAG_WRITE, NULL);
458  if (ret < 0) {
459  ffurl_close(h_src);
460  return ret;
461  }
462 
463  if (h_src->prot == h_dst->prot && h_src->prot->url_move)
464  ret = h_src->prot->url_move(h_src, h_dst);
465  else
466  ret = AVERROR(ENOSYS);
467 
468  ffurl_close(h_src);
469  ffurl_close(h_dst);
470  return ret;
471 }
472 
473 int avpriv_io_delete(const char *url)
474 {
475  URLContext *h;
476  int ret = ffurl_alloc(&h, url, AVIO_FLAG_WRITE, NULL);
477  if (ret < 0)
478  return ret;
479 
480  if (h->prot->url_delete)
481  ret = h->prot->url_delete(h);
482  else
483  ret = AVERROR(ENOSYS);
484 
485  ffurl_close(h);
486  return ret;
487 }
488 
489 int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
490 {
491  URLContext *h = NULL;
492  AVIODirContext *ctx = NULL;
493  int ret;
494  av_assert0(s);
495 
496  ctx = av_mallocz(sizeof(*ctx));
497  if (!ctx) {
498  ret = AVERROR(ENOMEM);
499  goto fail;
500  }
501 
502  if ((ret = ffurl_alloc(&h, url, AVIO_FLAG_READ, NULL)) < 0)
503  goto fail;
504 
505  if (h->prot->url_open_dir && h->prot->url_read_dir && h->prot->url_close_dir) {
506  if (options && h->prot->priv_data_class &&
507  (ret = av_opt_set_dict(h->priv_data, options)) < 0)
508  goto fail;
509  ret = h->prot->url_open_dir(h);
510  } else
511  ret = AVERROR(ENOSYS);
512  if (ret < 0)
513  goto fail;
514 
515  h->is_connected = 1;
516  ctx->url_context = h;
517  *s = ctx;
518  return 0;
519 
520  fail:
521  av_free(ctx);
522  *s = NULL;
523  ffurl_close(h);
524  return ret;
525 }
526 
528 {
529  URLContext *h;
530  int ret;
531 
532  if (!s || !s->url_context)
533  return AVERROR(EINVAL);
534  h = s->url_context;
535  if ((ret = h->prot->url_read_dir(h, next)) < 0)
537  return ret;
538 }
539 
541 {
542  URLContext *h;
543 
544  av_assert0(s);
545  if (!(*s) || !(*s)->url_context)
546  return AVERROR(EINVAL);
547  h = (*s)->url_context;
548  h->prot->url_close_dir(h);
549  ffurl_close(h);
550  av_freep(s);
551  *s = NULL;
552  return 0;
553 }
554 
556 {
557  if (!entry || !*entry)
558  return;
559  av_free((*entry)->name);
560  av_freep(entry);
561 }
562 
564 {
565  int64_t pos, size;
566 
567  size = ffurl_seek(h, 0, AVSEEK_SIZE);
568  if (size < 0) {
569  pos = ffurl_seek(h, 0, SEEK_CUR);
570  if ((size = ffurl_seek(h, -1, SEEK_END)) < 0)
571  return size;
572  size++;
573  ffurl_seek(h, pos, SEEK_SET);
574  }
575  return size;
576 }
577 
579 {
580  if (!h->prot->url_get_file_handle)
581  return -1;
582  return h->prot->url_get_file_handle(h);
583 }
584 
585 int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
586 {
587  if (!h->prot->url_get_multi_file_handle) {
588  if (!h->prot->url_get_file_handle)
589  return AVERROR(ENOSYS);
590  *handles = av_malloc(sizeof(**handles));
591  if (!*handles)
592  return AVERROR(ENOMEM);
593  *numhandles = 1;
594  *handles[0] = h->prot->url_get_file_handle(h);
595  return 0;
596  }
597  return h->prot->url_get_multi_file_handle(h, handles, numhandles);
598 }
599 
601 {
602  if (!h->prot->url_shutdown)
603  return AVERROR(EINVAL);
604  return h->prot->url_shutdown(h, flags);
605 }
606 
608 {
609  int ret;
610  if (cb && cb->callback && (ret = cb->callback(cb->opaque)))
611  return ret;
612  return 0;
613 }
int(* url_open_dir)(URLContext *h)
Definition: url.h:92
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:634
const char * s
Definition: avisynth_c.h:631
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:35
int(* url_close_dir)(URLContext *h)
Definition: url.h:94
AVOption.
Definition: opt.h:255
int(* url_check)(URLContext *h, int mask)
Definition: url.h:91
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
int flags
Definition: url.h:90
#define LIBAVUTIL_VERSION_INT
Definition: version.h:62
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
Definition: avio.c:374
int is_streamed
true if streamed (no seek possible), default = false
Definition: url.h:46
static URLProtocol * first_protocol
Definition: avio.c:34
int ffurl_connect(URLContext *uc, AVDictionary **options)
Connect an URLContext that has been allocated by ffurl_alloc.
Definition: avio.c:202
AVIOInterruptCB interrupt_callback
Definition: url.h:48
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1178
Describes single entry of the directory.
Definition: avio.h:78
#define AVIO_FLAG_READ
read-only
Definition: avio.h:485
int64_t rw_timeout
maximum time to wait for (network) read/write operation completion, in mcs
Definition: url.h:49
struct URLProtocol * prot
Definition: url.h:41
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:486
void ff_network_close(void)
Definition: network.c:102
int flags
Definition: url.h:44
int av_usleep(unsigned usec)
Sleep for a period of time.
Definition: time.c:76
static void * urlcontext_child_next(void *obj, void *prev)
Definition: avio.c:52
int ffurl_shutdown(URLContext *h, int flags)
Signal the URLContext that we are done reading or writing the stream.
Definition: avio.c:600
#define URL_SCHEME_CHARS
Definition: avio.c:241
int avpriv_io_move(const char *url_src, const char *url_dst)
Move or rename a resource.
Definition: avio.c:451
void * opaque
Definition: avio.h:52
const AVClass * priv_data_class
Definition: url.h:89
struct URLProtocol * next
Definition: url.h:80
int avio_check(const char *url, int flags)
Return AVIO_FLAG_* access flags corresponding to the access permissions of the resource in url...
Definition: avio.c:432
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
Public dictionary API.
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:97
uint8_t
#define av_malloc(s)
int ff_network_init(void)
Definition: network.c:55
AVOptions.
miscellaneous OS support macros and functions.
static int url_alloc_for_protocol(URLContext **puc, struct URLProtocol *up, const char *filename, int flags, const AVIOInterruptCB *int_cb)
Definition: avio.c:109
int avio_read_dir(AVIODirContext *s, AVIODirEntry **next)
Get next directory entry.
Definition: avio.c:527
int(* url_get_file_handle)(URLContext *h)
Definition: url.h:84
#define AVERROR_PROTOCOL_NOT_FOUND
Protocol not found.
Definition: error.h:63
int(* url_get_multi_file_handle)(URLContext *h, int **handles, int *numhandles)
Definition: url.h:85
#define AVERROR_EOF
End of file.
Definition: error.h:55
ptrdiff_t size
Definition: opengl_enc.c:101
#define av_log(a,...)
int(* url_move)(URLContext *h_src, URLContext *h_dst)
Definition: url.h:96
Callback for checking whether to abort blocking functions.
Definition: avio.h:50
int ffurl_alloc(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb)
Create a URLContext for accessing to the resource indicated by url, but do not initiate the connectio...
Definition: avio.c:277
int(* url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options)
This callback is to be used by protocols which open further nested protocols.
Definition: url.h:60
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
Return the file descriptors associated with this URL.
Definition: avio.c:585
int(* callback)(void *)
Definition: avio.h:51
const AVIOInterruptCB int_cb
Definition: ffmpeg.c:464
#define AVERROR(e)
Definition: error.h:43
#define URL_PROTOCOL_FLAG_NESTED_SCHEME
Definition: url.h:34
simple assert() macros that are a bit more flexible than ISO C assert().
int(* url_open)(URLContext *h, const char *url, int flags)
Definition: url.h:54
#define FFMAX(a, b)
Definition: common.h:90
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:83
#define fail()
Definition: checkasm.h:57
static const char * urlcontext_to_name(void *ptr)
Definition: avio.c:43
void avio_free_directory_entry(AVIODirEntry **entry)
Free entry allocated by avio_read_dir().
Definition: avio.c:555
int(* url_write)(URLContext *h, const unsigned char *buf, int size)
Definition: url.h:77
int(* url_read)(URLContext *h, unsigned char *buf, int size)
Read data from the protocol.
Definition: url.h:76
static const AVOption options[]
Definition: avio.c:76
static int retry_transfer_wrapper(URLContext *h, uint8_t *buf, int size, int size_min, int(*transfer_func)(URLContext *h, uint8_t *buf, int size))
Definition: avio.c:319
#define FFMIN(a, b)
Definition: common.h:92
static const AVClass * urlcontext_child_class_next(const AVClass *prev)
Definition: avio.c:60
const char * avio_enum_protocols(void **opaque, int output)
Iterate through names of available protocols.
Definition: avio.c:87
int ffurl_handshake(URLContext *c)
Perform one step of the protocol handshake to accept a new client.
Definition: avio.c:229
int64_t(* url_seek)(URLContext *h, int64_t pos, int whence)
Definition: url.h:78
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
Definition: avio.c:578
int ffurl_accept(URLContext *s, URLContext **c)
Accept an URLContext c on an URLContext s.
Definition: avio.c:221
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:56
int is_connected
Definition: url.h:47
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
Definition: avio.c:397
static int is_dos_path(const char *path)
Definition: os_support.h:70
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrup a blocking function associated with cb.
Definition: avio.c:607
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
Definition: opt.c:1477
#define AVIO_FLAG_NONBLOCK
Use non-blocking mode.
Definition: avio.h:504
int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
Open directory for reading.
Definition: avio.c:489
int64_t ffurl_size(URLContext *h)
Return the filesize of the resource accessed by h, AVERROR(ENOSYS) if the operation is not supported ...
Definition: avio.c:563
URLProtocol * ffurl_protocol_next(const URLProtocol *prev)
Iterate over all available protocols.
Definition: avio.c:36
void * buf
Definition: avisynth_c.h:553
Definition: url.h:39
#define AVIO_FLAG_READ_WRITE
read-write pseudo flag
Definition: avio.h:487
Describe the class of an AVClass context structure.
Definition: log.h:67
#define AVSEEK_FORCE
Oring this flag as into the "whence" parameter to a seek function causes it to seek by any means (lik...
Definition: avio.h:372
void * priv_data
Definition: url.h:42
int(* url_handshake)(URLContext *c)
Definition: url.h:62
int(* url_read_dir)(URLContext *h, AVIODirEntry **next)
Definition: url.h:93
const char * name
Definition: url.h:53
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
Definition: avio.c:425
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
Definition: time.c:56
const AVClass * av_class
information for av_log().
Definition: url.h:40
static int flags
Definition: cpu.c:47
int ffurl_close(URLContext *h)
Definition: avio.c:419
int(* url_accept)(URLContext *s, URLContext **c)
Definition: url.h:61
const AVClass ffurl_context_class
Definition: avio.c:77
static struct URLProtocol * url_find_protocol(const char *filename)
Definition: avio.c:246
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
Definition: avstring.c:34
Main libavformat public API header.
int ffurl_register_protocol(URLProtocol *protocol)
Register the URLProtocol protocol.
Definition: avio.c:98
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1432
int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
Change the position that will be used by the next read/write operation on the resource accessed by h...
Definition: avio.c:387
int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
Definition: avio.c:299
int(* url_delete)(URLContext *h)
Definition: url.h:95
static double c[64]
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
Read as many bytes as possible (up to size), calling the read function multiple times if necessary...
Definition: avio.c:367
char * filename
specified URL
Definition: url.h:43
#define AVSEEK_SIZE
Passing this as the "whence" parameter to a seek function causes it to return the filesize without se...
Definition: avio.h:364
int avio_close_dir(AVIODirContext **s)
Close directory.
Definition: avio.c:540
#define av_free(p)
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition: error.h:61
int len
int avpriv_io_delete(const char *url)
Delete a resource.
Definition: avio.c:473
int max_packet_size
if non zero, the stream is packetized with this max packet size
Definition: url.h:45
int(* url_close)(URLContext *h)
Definition: url.h:79
#define av_freep(p)
void INT64 start
Definition: avisynth_c.h:553
unbuffered private I/O API
int(* url_shutdown)(URLContext *h, int flags)
Definition: url.h:87
struct URLContext * url_context
Definition: avio.h:96
int priv_data_size
Definition: url.h:88
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:369
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf...
Definition: avio.c:360
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:252