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