]> git.sesse.net Git - casparcg/blob - dependencies/ffmpeg 0.8/include/libavformat/avio.h
Subtree merge of old SVN "dependencies" folder into the "master" git branch. You...
[casparcg] / dependencies / ffmpeg 0.8 / include / libavformat / avio.h
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 #ifndef AVFORMAT_AVIO_H
21 #define AVFORMAT_AVIO_H
22
23 /**
24  * @file
25  * Buffered I/O operations
26  */
27
28 #include <stdint.h>
29
30 #include "libavutil/common.h"
31 #include "libavutil/dict.h"
32 #include "libavutil/log.h"
33
34 #include "libavformat/version.h"
35
36
37 #define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
38
39 /**
40  * Callback for checking whether to abort blocking functions.
41  * AVERROR_EXIT is returned in this case by the interrupted
42  * function. During blocking operations, callback is called with
43  * opaque as parameter. If the callback returns 1, the
44  * blocking operation will be aborted.
45  *
46  * No members can be added to this struct without a major bump, if
47  * new elements have been added after this struct in AVFormatContext
48  * or AVIOContext.
49  */
50 typedef struct {
51     int (*callback)(void*);
52     void *opaque;
53 } AVIOInterruptCB;
54
55 /**
56  * Bytestream IO Context.
57  * New fields can be added to the end with minor version bumps.
58  * Removal, reordering and changes to existing fields require a major
59  * version bump.
60  * sizeof(AVIOContext) must not be used outside libav*.
61  *
62  * @note None of the function pointers in AVIOContext should be called
63  *       directly, they should only be set by the client application
64  *       when implementing custom I/O. Normally these are set to the
65  *       function pointers specified in avio_alloc_context()
66  */
67 typedef struct {
68 #if !FF_API_OLD_AVIO
69     /**
70      * A class for private options.
71      *
72      * If this AVIOContext is created by avio_open2(), av_class is set and
73      * passes the options down to protocols.
74      *
75      * If this AVIOContext is manually allocated, then av_class may be set by
76      * the caller.
77      *
78      * warning -- this field can be NULL, be sure to not pass this AVIOContext
79      * to any av_opt_* functions in that case.
80      */
81     AVClass *av_class;
82 #endif
83     unsigned char *buffer;  /**< Start of the buffer. */
84     int buffer_size;        /**< Maximum buffer size */
85     unsigned char *buf_ptr; /**< Current position in the buffer */
86     unsigned char *buf_end; /**< End of the data, may be less than
87                                  buffer+buffer_size if the read function returned
88                                  less data than requested, e.g. for streams where
89                                  no more data has been received yet. */
90     void *opaque;           /**< A private pointer, passed to the read/write/seek/...
91                                  functions. */
92     int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
93     int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
94     int64_t (*seek)(void *opaque, int64_t offset, int whence);
95     int64_t pos;            /**< position in the file of the current buffer */
96     int must_flush;         /**< true if the next seek should flush */
97     int eof_reached;        /**< true if eof reached */
98     int write_flag;         /**< true if open for writing */
99 #if FF_API_OLD_AVIO
100     attribute_deprecated int is_streamed;
101 #endif
102     int max_packet_size;
103     unsigned long checksum;
104     unsigned char *checksum_ptr;
105     unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
106     int error;              /**< contains the error code or 0 if no error happened */
107     /**
108      * Pause or resume playback for network streaming protocols - e.g. MMS.
109      */
110     int (*read_pause)(void *opaque, int pause);
111     /**
112      * Seek to a given timestamp in stream with the specified stream_index.
113      * Needed for some network streaming protocols which don't support seeking
114      * to byte position.
115      */
116     int64_t (*read_seek)(void *opaque, int stream_index,
117                          int64_t timestamp, int flags);
118     /**
119      * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
120      */
121     int seekable;
122 } AVIOContext;
123
124 /* unbuffered I/O */
125
126 #if FF_API_OLD_AVIO
127 /**
128  * URL Context.
129  * New fields can be added to the end with minor version bumps.
130  * Removal, reordering and changes to existing fields require a major
131  * version bump.
132  * sizeof(URLContext) must not be used outside libav*.
133  * @deprecated This struct will be made private
134  */
135 typedef struct URLContext {
136     const AVClass *av_class; ///< information for av_log(). Set by url_open().
137     struct URLProtocol *prot;
138     int flags;
139     int is_streamed;  /**< true if streamed (no seek possible), default = false */
140     int max_packet_size;  /**< if non zero, the stream is packetized with this max packet size */
141     void *priv_data;
142     char *filename; /**< specified URL */
143     int is_connected;
144     AVIOInterruptCB interrupt_callback;
145 } URLContext;
146
147 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
148
149 /**
150  * @deprecated This struct is to be made private. Use the higher-level
151  *             AVIOContext-based API instead.
152  */
153 typedef struct URLProtocol {
154     const char *name;
155     int (*url_open)(URLContext *h, const char *url, int flags);
156     int (*url_read)(URLContext *h, unsigned char *buf, int size);
157     int (*url_write)(URLContext *h, const unsigned char *buf, int size);
158     int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
159     int (*url_close)(URLContext *h);
160     struct URLProtocol *next;
161     int (*url_read_pause)(URLContext *h, int pause);
162     int64_t (*url_read_seek)(URLContext *h, int stream_index,
163                              int64_t timestamp, int flags);
164     int (*url_get_file_handle)(URLContext *h);
165     int priv_data_size;
166     const AVClass *priv_data_class;
167     int flags;
168     int (*url_check)(URLContext *h, int mask);
169 } URLProtocol;
170
171 typedef struct URLPollEntry {
172     URLContext *handle;
173     int events;
174     int revents;
175 } URLPollEntry;
176
177 /* not implemented */
178 attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout);
179
180 /**
181  * @name URL open modes
182  * The flags argument to url_open and cosins must be one of the following
183  * constants, optionally ORed with other flags.
184  * @{
185  */
186 #define URL_RDONLY 1  /**< read-only */
187 #define URL_WRONLY 2  /**< write-only */
188 #define URL_RDWR   (URL_RDONLY|URL_WRONLY)  /**< read-write */
189 /**
190  * @}
191  */
192
193 /**
194  * Use non-blocking mode.
195  * If this flag is set, operations on the context will return
196  * AVERROR(EAGAIN) if they can not be performed immediately.
197  * If this flag is not set, operations on the context will never return
198  * AVERROR(EAGAIN).
199  * Note that this flag does not affect the opening/connecting of the
200  * context. Connecting a protocol will always block if necessary (e.g. on
201  * network protocols) but never hang (e.g. on busy devices).
202  * Warning: non-blocking protocols is work-in-progress; this flag may be
203  * silently ignored.
204  */
205 #define URL_FLAG_NONBLOCK 4
206
207 typedef int URLInterruptCB(void);
208 extern URLInterruptCB *url_interrupt_cb;
209
210 /**
211  * @defgroup old_url_funcs Old url_* functions
212  * The following functions are deprecated. Use the buffered API based on #AVIOContext instead.
213  * @{
214  */
215 attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up,
216                                             const char *url, int flags);
217 attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags);
218 attribute_deprecated int url_connect(URLContext *h);
219 attribute_deprecated int url_open(URLContext **h, const char *url, int flags);
220 attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size);
221 attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size);
222 attribute_deprecated int url_write(URLContext *h, const unsigned char *buf, int size);
223 attribute_deprecated int64_t url_seek(URLContext *h, int64_t pos, int whence);
224 attribute_deprecated int url_close(URLContext *h);
225 attribute_deprecated int64_t url_filesize(URLContext *h);
226 attribute_deprecated int url_get_file_handle(URLContext *h);
227 attribute_deprecated int url_get_max_packet_size(URLContext *h);
228 attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_size);
229 attribute_deprecated int av_url_read_pause(URLContext *h, int pause);
230 attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
231                                               int64_t timestamp, int flags);
232 attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void));
233
234 /**
235  * returns the next registered protocol after the given protocol (the first if
236  * NULL is given), or NULL if protocol is the last one.
237  */
238 URLProtocol *av_protocol_next(URLProtocol *p);
239
240 /**
241  * Register the URLProtocol protocol.
242  *
243  * @param size the size of the URLProtocol struct referenced
244  */
245 attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size);
246 /**
247  * @}
248  */
249
250
251 typedef attribute_deprecated AVIOContext ByteIOContext;
252
253 attribute_deprecated int init_put_byte(AVIOContext *s,
254                   unsigned char *buffer,
255                   int buffer_size,
256                   int write_flag,
257                   void *opaque,
258                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
259                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
260                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
261 attribute_deprecated AVIOContext *av_alloc_put_byte(
262                   unsigned char *buffer,
263                   int buffer_size,
264                   int write_flag,
265                   void *opaque,
266                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
267                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
268                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
269
270 /**
271  * @defgroup old_avio_funcs Old put_/get_*() functions
272  * The following functions are deprecated. Use the "avio_"-prefixed functions instead.
273  * @{
274  */
275 attribute_deprecated int          get_buffer(AVIOContext *s, unsigned char *buf, int size);
276 attribute_deprecated int          get_partial_buffer(AVIOContext *s, unsigned char *buf, int size);
277 attribute_deprecated int          get_byte(AVIOContext *s);
278 attribute_deprecated unsigned int get_le16(AVIOContext *s);
279 attribute_deprecated unsigned int get_le24(AVIOContext *s);
280 attribute_deprecated unsigned int get_le32(AVIOContext *s);
281 attribute_deprecated uint64_t     get_le64(AVIOContext *s);
282 attribute_deprecated unsigned int get_be16(AVIOContext *s);
283 attribute_deprecated unsigned int get_be24(AVIOContext *s);
284 attribute_deprecated unsigned int get_be32(AVIOContext *s);
285 attribute_deprecated uint64_t     get_be64(AVIOContext *s);
286
287 attribute_deprecated void         put_byte(AVIOContext *s, int b);
288 attribute_deprecated void         put_nbyte(AVIOContext *s, int b, int count);
289 attribute_deprecated void         put_buffer(AVIOContext *s, const unsigned char *buf, int size);
290 attribute_deprecated void         put_le64(AVIOContext *s, uint64_t val);
291 attribute_deprecated void         put_be64(AVIOContext *s, uint64_t val);
292 attribute_deprecated void         put_le32(AVIOContext *s, unsigned int val);
293 attribute_deprecated void         put_be32(AVIOContext *s, unsigned int val);
294 attribute_deprecated void         put_le24(AVIOContext *s, unsigned int val);
295 attribute_deprecated void         put_be24(AVIOContext *s, unsigned int val);
296 attribute_deprecated void         put_le16(AVIOContext *s, unsigned int val);
297 attribute_deprecated void         put_be16(AVIOContext *s, unsigned int val);
298 attribute_deprecated void         put_tag(AVIOContext *s, const char *tag);
299 /**
300  * @}
301  */
302
303 attribute_deprecated int     av_url_read_fpause(AVIOContext *h,    int pause);
304 attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h,    int stream_index,
305                                                 int64_t timestamp, int flags);
306
307 /**
308  * @defgroup old_url_f_funcs Old url_f* functions
309  * The following functions are deprecated, use the "avio_"-prefixed functions instead.
310  * @{
311  */
312 attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags);
313 attribute_deprecated int url_fclose(AVIOContext *s);
314 attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
315 attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
316 attribute_deprecated int64_t url_ftell(AVIOContext *s);
317 attribute_deprecated int64_t url_fsize(AVIOContext *s);
318 #define URL_EOF (-1)
319 attribute_deprecated int url_fgetc(AVIOContext *s);
320 attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size);
321 attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
322 attribute_deprecated void put_flush_packet(AVIOContext *s);
323 attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
324 attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
325 attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
326 attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h);
327 /**
328  * @}
329  */
330
331 attribute_deprecated int url_ferror(AVIOContext *s);
332
333 attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
334 attribute_deprecated int udp_get_local_port(URLContext *h);
335
336 attribute_deprecated void init_checksum(AVIOContext *s,
337                    unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
338                    unsigned long checksum);
339 attribute_deprecated unsigned long get_checksum(AVIOContext *s);
340 attribute_deprecated void put_strz(AVIOContext *s, const char *buf);
341 /** @note unlike fgets, the EOL character is not returned and a whole
342     line is parsed. return NULL if first char read was EOF */
343 attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size);
344 /**
345  * @deprecated use avio_get_str instead
346  */
347 attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen);
348 /**
349  * @deprecated Use AVIOContext.seekable field directly.
350  */
351 attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
352 {
353     return !s->seekable;
354 }
355 attribute_deprecated URLContext *url_fileno(AVIOContext *s);
356
357 /**
358  * @deprecated use AVIOContext.max_packet_size directly.
359  */
360 attribute_deprecated int url_fget_max_packet_size(AVIOContext *s);
361
362 attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags);
363
364 /** return the written or read size */
365 attribute_deprecated int url_close_buf(AVIOContext *s);
366
367 /**
368  * Return a non-zero value if the resource indicated by url
369  * exists, 0 otherwise.
370  * @deprecated Use avio_check instead.
371  */
372 attribute_deprecated int url_exist(const char *url);
373 #endif // FF_API_OLD_AVIO
374
375 /**
376  * Return AVIO_FLAG_* access flags corresponding to the access permissions
377  * of the resource in url, or a negative value corresponding to an
378  * AVERROR code in case of failure. The returned access flags are
379  * masked by the value in flags.
380  *
381  * @note This function is intrinsically unsafe, in the sense that the
382  * checked resource may change its existence or permission status from
383  * one call to another. Thus you should not trust the returned value,
384  * unless you are sure that no other processes are accessing the
385  * checked resource.
386  */
387 int avio_check(const char *url, int flags);
388
389 #if FF_API_OLD_INTERRUPT_CB
390 /**
391  * The callback is called in blocking functions to test regulary if
392  * asynchronous interruption is needed. AVERROR_EXIT is returned
393  * in this case by the interrupted function. 'NULL' means no interrupt
394  * callback is given.
395  * @deprecated Use interrupt_callback in AVFormatContext/avio_open2
396  *             instead.
397  */
398 attribute_deprecated void avio_set_interrupt_cb(int (*interrupt_cb)(void));
399 #endif
400
401 /**
402  * Allocate and initialize an AVIOContext for buffered I/O. It must be later
403  * freed with av_free().
404  *
405  * @param buffer Memory block for input/output operations via AVIOContext.
406  *        The buffer must be allocated with av_malloc() and friends.
407  * @param buffer_size The buffer size is very important for performance.
408  *        For protocols with fixed blocksize it should be set to this blocksize.
409  *        For others a typical size is a cache page, e.g. 4kb.
410  * @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
411  * @param opaque An opaque pointer to user-specific data.
412  * @param read_packet  A function for refilling the buffer, may be NULL.
413  * @param write_packet A function for writing the buffer contents, may be NULL.
414  * @param seek A function for seeking to specified byte position, may be NULL.
415  *
416  * @return Allocated AVIOContext or NULL on failure.
417  */
418 AVIOContext *avio_alloc_context(
419                   unsigned char *buffer,
420                   int buffer_size,
421                   int write_flag,
422                   void *opaque,
423                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
424                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
425                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
426
427 void avio_w8(AVIOContext *s, int b);
428 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
429 void avio_wl64(AVIOContext *s, uint64_t val);
430 void avio_wb64(AVIOContext *s, uint64_t val);
431 void avio_wl32(AVIOContext *s, unsigned int val);
432 void avio_wb32(AVIOContext *s, unsigned int val);
433 void avio_wl24(AVIOContext *s, unsigned int val);
434 void avio_wb24(AVIOContext *s, unsigned int val);
435 void avio_wl16(AVIOContext *s, unsigned int val);
436 void avio_wb16(AVIOContext *s, unsigned int val);
437
438 /**
439  * Write a NULL-terminated string.
440  * @return number of bytes written.
441  */
442 int avio_put_str(AVIOContext *s, const char *str);
443
444 /**
445  * Convert an UTF-8 string to UTF-16LE and write it.
446  * @return number of bytes written.
447  */
448 int avio_put_str16le(AVIOContext *s, const char *str);
449
450 /**
451  * Passing this as the "whence" parameter to a seek function causes it to
452  * return the filesize without seeking anywhere. Supporting this is optional.
453  * If it is not supported then the seek function will return <0.
454  */
455 #define AVSEEK_SIZE 0x10000
456
457 /**
458  * Oring this flag as into the "whence" parameter to a seek function causes it to
459  * seek by any means (like reopening and linear reading) or other normally unreasonble
460  * means that can be extreemly slow.
461  * This may be ignored by the seek code.
462  */
463 #define AVSEEK_FORCE 0x20000
464
465 /**
466  * fseek() equivalent for AVIOContext.
467  * @return new position or AVERROR.
468  */
469 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
470
471 /**
472  * Skip given number of bytes forward
473  * @return new position or AVERROR.
474  */
475 int64_t avio_skip(AVIOContext *s, int64_t offset);
476
477 /**
478  * ftell() equivalent for AVIOContext.
479  * @return position or AVERROR.
480  */
481 static av_always_inline int64_t avio_tell(AVIOContext *s)
482 {
483     return avio_seek(s, 0, SEEK_CUR);
484 }
485
486 /**
487  * Get the filesize.
488  * @return filesize or AVERROR
489  */
490 int64_t avio_size(AVIOContext *s);
491
492 /**
493  * feof() equivalent for AVIOContext.
494  * @return non zero if and only if end of file
495  */
496 int url_feof(AVIOContext *s);
497
498 /** @warning currently size is limited */
499 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
500
501 void avio_flush(AVIOContext *s);
502
503
504 /**
505  * Read size bytes from AVIOContext into buf.
506  * @return number of bytes read or AVERROR
507  */
508 int avio_read(AVIOContext *s, unsigned char *buf, int size);
509
510 /**
511  * @name Functions for reading from AVIOContext
512  * @{
513  *
514  * @note return 0 if EOF, so you cannot use it if EOF handling is
515  *       necessary
516  */
517 int          avio_r8  (AVIOContext *s);
518 unsigned int avio_rl16(AVIOContext *s);
519 unsigned int avio_rl24(AVIOContext *s);
520 unsigned int avio_rl32(AVIOContext *s);
521 uint64_t     avio_rl64(AVIOContext *s);
522 unsigned int avio_rb16(AVIOContext *s);
523 unsigned int avio_rb24(AVIOContext *s);
524 unsigned int avio_rb32(AVIOContext *s);
525 uint64_t     avio_rb64(AVIOContext *s);
526 /**
527  * @}
528  */
529
530 /**
531  * Read a string from pb into buf. The reading will terminate when either
532  * a NULL character was encountered, maxlen bytes have been read, or nothing
533  * more can be read from pb. The result is guaranteed to be NULL-terminated, it
534  * will be truncated if buf is too small.
535  * Note that the string is not interpreted or validated in any way, it
536  * might get truncated in the middle of a sequence for multi-byte encodings.
537  *
538  * @return number of bytes read (is always <= maxlen).
539  * If reading ends on EOF or error, the return value will be one more than
540  * bytes actually read.
541  */
542 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
543
544 /**
545  * Read a UTF-16 string from pb and convert it to UTF-8.
546  * The reading will terminate when either a null or invalid character was
547  * encountered or maxlen bytes have been read.
548  * @return number of bytes read (is always <= maxlen)
549  */
550 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
551 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
552
553
554 /**
555  * @name URL open modes
556  * The flags argument to avio_open must be one of the following
557  * constants, optionally ORed with other flags.
558  * @{
559  */
560 #define AVIO_FLAG_READ  1                                      /**< read-only */
561 #define AVIO_FLAG_WRITE 2                                      /**< write-only */
562 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE)  /**< read-write pseudo flag */
563 /**
564  * @}
565  */
566
567 /**
568  * Use non-blocking mode.
569  * If this flag is set, operations on the context will return
570  * AVERROR(EAGAIN) if they can not be performed immediately.
571  * If this flag is not set, operations on the context will never return
572  * AVERROR(EAGAIN).
573  * Note that this flag does not affect the opening/connecting of the
574  * context. Connecting a protocol will always block if necessary (e.g. on
575  * network protocols) but never hang (e.g. on busy devices).
576  * Warning: non-blocking protocols is work-in-progress; this flag may be
577  * silently ignored.
578  */
579 #define AVIO_FLAG_NONBLOCK 8
580
581 /**
582  * Create and initialize a AVIOContext for accessing the
583  * resource indicated by url.
584  * @note When the resource indicated by url has been opened in
585  * read+write mode, the AVIOContext can be used only for writing.
586  *
587  * @param s Used to return the pointer to the created AVIOContext.
588  * In case of failure the pointed to value is set to NULL.
589  * @param flags flags which control how the resource indicated by url
590  * is to be opened
591  * @return 0 in case of success, a negative value corresponding to an
592  * AVERROR code in case of failure
593  */
594 int avio_open(AVIOContext **s, const char *url, int flags);
595
596 /**
597  * Create and initialize a AVIOContext for accessing the
598  * resource indicated by url.
599  * @note When the resource indicated by url has been opened in
600  * read+write mode, the AVIOContext can be used only for writing.
601  *
602  * @param s Used to return the pointer to the created AVIOContext.
603  * In case of failure the pointed to value is set to NULL.
604  * @param flags flags which control how the resource indicated by url
605  * is to be opened
606  * @param int_cb an interrupt callback to be used at the protocols level
607  * @param options  A dictionary filled with protocol-private options. On return
608  * this parameter will be destroyed and replaced with a dict containing options
609  * that were not found. May be NULL.
610  * @return 0 in case of success, a negative value corresponding to an
611  * AVERROR code in case of failure
612  */
613 int avio_open2(AVIOContext **s, const char *url, int flags,
614                const AVIOInterruptCB *int_cb, AVDictionary **options);
615
616 /**
617  * Close the resource accessed by the AVIOContext s and free it.
618  * This function can only be used if s was opened by avio_open().
619  *
620  * @return 0 on success, an AVERROR < 0 on error.
621  */
622 int avio_close(AVIOContext *s);
623
624 /**
625  * Open a write only memory stream.
626  *
627  * @param s new IO context
628  * @return zero if no error.
629  */
630 int avio_open_dyn_buf(AVIOContext **s);
631
632 /**
633  * Return the written size and a pointer to the buffer. The buffer
634  * must be freed with av_free().
635  * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
636  *
637  * @param s IO context
638  * @param pbuffer pointer to a byte buffer
639  * @return the length of the byte buffer
640  */
641 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
642
643 /**
644  * Iterate through names of available protocols.
645  * @note it is recommanded to use av_protocol_next() instead of this
646  *
647  * @param opaque A private pointer representing current protocol.
648  *        It must be a pointer to NULL on first iteration and will
649  *        be updated by successive calls to avio_enum_protocols.
650  * @param output If set to 1, iterate over output protocols,
651  *               otherwise over input protocols.
652  *
653  * @return A static string containing the name of current protocol or NULL
654  */
655 const char *avio_enum_protocols(void **opaque, int output);
656
657 /**
658  * Pause and resume playing - only meaningful if using a network streaming
659  * protocol (e.g. MMS).
660  * @param pause 1 for pause, 0 for resume
661  */
662 int     avio_pause(AVIOContext *h, int pause);
663
664 /**
665  * Seek to a given timestamp relative to some component stream.
666  * Only meaningful if using a network streaming protocol (e.g. MMS.).
667  * @param stream_index The stream index that the timestamp is relative to.
668  *        If stream_index is (-1) the timestamp should be in AV_TIME_BASE
669  *        units from the beginning of the presentation.
670  *        If a stream_index >= 0 is used and the protocol does not support
671  *        seeking based on component streams, the call will fail with ENOTSUP.
672  * @param timestamp timestamp in AVStream.time_base units
673  *        or if there is no stream specified then in AV_TIME_BASE units.
674  * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE
675  *        and AVSEEK_FLAG_ANY. The protocol may silently ignore
676  *        AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will
677  *        fail with ENOTSUP if used and not supported.
678  * @return >= 0 on success
679  * @see AVInputFormat::read_seek
680  */
681 int64_t avio_seek_time(AVIOContext *h, int stream_index,
682                        int64_t timestamp, int flags);
683
684 #endif /* AVFORMAT_AVIO_H */