Statistics
| Branch: | Revision:

ffmpeg / libavformat / avio.h @ dce37564

History | View | Annotate | Download (22.8 KB)

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
 * unbuffered I/O operations
26
 *
27
 * @warning This file has to be considered an internal but installed
28
 * header, so it should not be directly included in your projects.
29
 */
30

    
31
#include <stdint.h>
32

    
33
#include "libavutil/common.h"
34
#include "libavutil/log.h"
35

    
36
#include "libavformat/version.h"
37

    
38
/* unbuffered I/O */
39

    
40
/**
41
 * URL Context.
42
 * New fields can be added to the end with minor version bumps.
43
 * Removal, reordering and changes to existing fields require a major
44
 * version bump.
45
 * sizeof(URLContext) must not be used outside libav*.
46
 */
47
typedef struct URLContext {
48
#if FF_API_URL_CLASS
49
    const AVClass *av_class; ///< information for av_log(). Set by url_open().
50
#endif
51
    struct URLProtocol *prot;
52
    int flags;
53
    int is_streamed;  /**< true if streamed (no seek possible), default = false */
54
    int max_packet_size;  /**< if non zero, the stream is packetized with this max packet size */
55
    void *priv_data;
56
    char *filename; /**< specified URL */
57
    int is_connected;
58
} URLContext;
59

    
60
#if FF_API_OLD_AVIO
61
typedef struct URLPollEntry {
62
    URLContext *handle;
63
    int events;
64
    int revents;
65
} URLPollEntry;
66
#endif
67

    
68
/**
69
 * @defgroup open_modes URL open modes
70
 * The flags argument to url_open and cosins must be one of the following
71
 * constants, optionally ORed with other flags.
72
 * @{
73
 */
74
#define URL_RDONLY 0  /**< read-only */
75
#define URL_WRONLY 1  /**< write-only */
76
#define URL_RDWR   2  /**< read-write */
77
/**
78
 * @}
79
 */
80

    
81
/**
82
 * Use non-blocking mode.
83
 * If this flag is set, operations on the context will return
84
 * AVERROR(EAGAIN) if they can not be performed immediately.
85
 * If this flag is not set, operations on the context will never return
86
 * AVERROR(EAGAIN).
87
 * Note that this flag does not affect the opening/connecting of the
88
 * context. Connecting a protocol will always block if necessary (e.g. on
89
 * network protocols) but never hang (e.g. on busy devices).
90
 * Warning: non-blocking protocols is work-in-progress; this flag may be
91
 * silently ignored.
92
 */
93
#define URL_FLAG_NONBLOCK 4
94

    
95
typedef int URLInterruptCB(void);
96

    
97
#if FF_API_OLD_AVIO
98
/**
99
 * @defgroup old_url_funcs Old url_* functions
100
 * @deprecated use the buffered API based on AVIOContext instead
101
 * @{
102
 */
103
attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up,
104
                                            const char *url, int flags);
105
attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags);
106
attribute_deprecated int url_connect(URLContext *h);
107
attribute_deprecated int url_open(URLContext **h, const char *url, int flags);
108
attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size);
109
attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size);
110
#endif
111

    
112
/**
113
 * Write size bytes from buf to the resource accessed by h.
114
 *
115
 * @return the number of bytes actually written, or a negative value
116
 * corresponding to an AVERROR code in case of failure
117
 */
118
int url_write(URLContext *h, const unsigned char *buf, int size);
119

    
120
/**
121
 * Passing this as the "whence" parameter to a seek function causes it to
122
 * return the filesize without seeking anywhere. Supporting this is optional.
123
 * If it is not supported then the seek function will return <0.
124
 */
125
#define AVSEEK_SIZE 0x10000
126

    
127
/**
128
 * Change the position that will be used by the next read/write
129
 * operation on the resource accessed by h.
130
 *
131
 * @param pos specifies the new position to set
132
 * @param whence specifies how pos should be interpreted, it must be
133
 * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the
134
 * current position), SEEK_END (seek from the end), or AVSEEK_SIZE
135
 * (return the filesize of the requested resource, pos is ignored).
136
 * @return a negative value corresponding to an AVERROR code in case
137
 * of failure, or the resulting file position, measured in bytes from
138
 * the beginning of the file. You can use this feature together with
139
 * SEEK_CUR to read the current file position.
140
 */
141
int64_t url_seek(URLContext *h, int64_t pos, int whence);
142

    
143
/**
144
 * Close the resource accessed by the URLContext h, and free the
145
 * memory used by it.
146
 *
147
 * @return a negative value if an error condition occurred, 0
148
 * otherwise
149
 */
150
int url_close(URLContext *h);
151

    
152
/**
153
 * Return a non-zero value if the resource indicated by url
154
 * exists, 0 otherwise.
155
 */
156
int url_exist(const char *url);
157

    
158
/**
159
 * Return the filesize of the resource accessed by h, AVERROR(ENOSYS)
160
 * if the operation is not supported by h, or another negative value
161
 * corresponding to an AVERROR error code in case of failure.
162
 */
163
int64_t url_filesize(URLContext *h);
164

    
165
/**
166
 * Return the file descriptor associated with this URL. For RTP, this
167
 * will return only the RTP file descriptor, not the RTCP file descriptor.
168
 *
169
 * @return the file descriptor associated with this URL, or <0 on error.
170
 */
171
int url_get_file_handle(URLContext *h);
172

    
173
/**
174
 * Return the maximum packet size associated to packetized file
175
 * handle. If the file is not packetized (stream like HTTP or file on
176
 * disk), then 0 is returned.
177
 *
178
 * @param h file handle
179
 * @return maximum packet size in bytes
180
 */
181
int url_get_max_packet_size(URLContext *h);
182

    
183
/**
184
 * Copy the filename of the resource accessed by h to buf.
185
 *
186
 * @param buf_size size in bytes of buf
187
 */
188
void url_get_filename(URLContext *h, char *buf, int buf_size);
189

    
190
/**
191
 * The callback is called in blocking functions to test regulary if
192
 * asynchronous interruption is needed. AVERROR_EXIT is returned
193
 * in this case by the interrupted function. 'NULL' means no interrupt
194
 * callback is given.
195
 */
196
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
197

    
198
#if FF_API_OLD_AVIO
199
/* not implemented */
200
attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout);
201
#endif
202

    
203
/**
204
 * Pause and resume playing - only meaningful if using a network streaming
205
 * protocol (e.g. MMS).
206
 * @param pause 1 for pause, 0 for resume
207
 */
208
int av_url_read_pause(URLContext *h, int pause);
209

    
210
/**
211
 * Seek to a given timestamp relative to some component stream.
212
 * Only meaningful if using a network streaming protocol (e.g. MMS.).
213
 * @param stream_index The stream index that the timestamp is relative to.
214
 *        If stream_index is (-1) the timestamp should be in AV_TIME_BASE
215
 *        units from the beginning of the presentation.
216
 *        If a stream_index >= 0 is used and the protocol does not support
217
 *        seeking based on component streams, the call will fail with ENOTSUP.
218
 * @param timestamp timestamp in AVStream.time_base units
219
 *        or if there is no stream specified then in AV_TIME_BASE units.
220
 * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE
221
 *        and AVSEEK_FLAG_ANY. The protocol may silently ignore
222
 *        AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will
223
 *        fail with ENOTSUP if used and not supported.
224
 * @return >= 0 on success
225
 * @see AVInputFormat::read_seek
226
 */
227
int64_t av_url_read_seek(URLContext *h, int stream_index,
228
                         int64_t timestamp, int flags);
229

    
230
/**
231
 * Oring this flag as into the "whence" parameter to a seek function causes it to
232
 * seek by any means (like reopening and linear reading) or other normally unreasonble
233
 * means that can be extreemly slow.
234
 * This may be ignored by the seek code.
235
 */
236
#define AVSEEK_FORCE 0x20000
237

    
238
#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
239

    
240
typedef struct URLProtocol {
241
    const char *name;
242
    int (*url_open)(URLContext *h, const char *url, int flags);
243
    int (*url_read)(URLContext *h, unsigned char *buf, int size);
244
    int (*url_write)(URLContext *h, const unsigned char *buf, int size);
245
    int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
246
    int (*url_close)(URLContext *h);
247
    struct URLProtocol *next;
248
    int (*url_read_pause)(URLContext *h, int pause);
249
    int64_t (*url_read_seek)(URLContext *h, int stream_index,
250
                             int64_t timestamp, int flags);
251
    int (*url_get_file_handle)(URLContext *h);
252
    int priv_data_size;
253
    const AVClass *priv_data_class;
254
    int flags;
255
} URLProtocol;
256

    
257
#if FF_API_REGISTER_PROTOCOL
258
extern URLProtocol *first_protocol;
259
#endif
260

    
261
extern URLInterruptCB *url_interrupt_cb;
262

    
263
/**
264
 * If protocol is NULL, returns the first registered protocol,
265
 * if protocol is non-NULL, returns the next registered protocol after protocol,
266
 * or NULL if protocol is the last one.
267
 */
268
URLProtocol *av_protocol_next(URLProtocol *p);
269

    
270
#if FF_API_REGISTER_PROTOCOL
271
/**
272
 * @deprecated Use av_register_protocol() instead.
273
 */
274
attribute_deprecated int register_protocol(URLProtocol *protocol);
275

    
276
/**
277
 * @deprecated Use av_register_protocol2() instead.
278
 */
279
attribute_deprecated int av_register_protocol(URLProtocol *protocol);
280
#endif
281

    
282
/**
283
 * Register the URLProtocol protocol.
284
 *
285
 * @param size the size of the URLProtocol struct referenced
286
 */
287
int av_register_protocol2(URLProtocol *protocol, int size);
288

    
289
#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
290

    
291
/**
292
 * @}
293
 */
294

    
295
/**
296
 * Bytestream IO Context.
297
 * New fields can be added to the end with minor version bumps.
298
 * Removal, reordering and changes to existing fields require a major
299
 * version bump.
300
 * sizeof(AVIOContext) must not be used outside libav*.
301
 */
302
typedef struct {
303
    unsigned char *buffer;
304
    int buffer_size;
305
    unsigned char *buf_ptr, *buf_end;
306
    void *opaque;
307
    int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
308
    int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
309
    int64_t (*seek)(void *opaque, int64_t offset, int whence);
310
    int64_t pos; /**< position in the file of the current buffer */
311
    int must_flush; /**< true if the next seek should flush */
312
    int eof_reached; /**< true if eof reached */
313
    int write_flag;  /**< true if open for writing */
314
#if FF_API_OLD_AVIO
315
    attribute_deprecated int is_streamed;
316
#endif
317
    int max_packet_size;
318
    unsigned long checksum;
319
    unsigned char *checksum_ptr;
320
    unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
321
    int error;         ///< contains the error code or 0 if no error happened
322
    int (*read_pause)(void *opaque, int pause);
323
    int64_t (*read_seek)(void *opaque, int stream_index,
324
                         int64_t timestamp, int flags);
325
    /**
326
     * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
327
     */
328
    int seekable;
329
} AVIOContext;
330

    
331
#if FF_API_OLD_AVIO
332
typedef attribute_deprecated AVIOContext ByteIOContext;
333

    
334
attribute_deprecated int init_put_byte(AVIOContext *s,
335
                  unsigned char *buffer,
336
                  int buffer_size,
337
                  int write_flag,
338
                  void *opaque,
339
                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
340
                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
341
                  int64_t (*seek)(void *opaque, int64_t offset, int whence));
342
attribute_deprecated AVIOContext *av_alloc_put_byte(
343
                  unsigned char *buffer,
344
                  int buffer_size,
345
                  int write_flag,
346
                  void *opaque,
347
                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
348
                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
349
                  int64_t (*seek)(void *opaque, int64_t offset, int whence));
350

    
351
/**
352
 * @defgroup old_avio_funcs Old put_/get_*() functions
353
 * @deprecated use the avio_ -prefixed functions instead.
354
 * @{
355
 */
356
attribute_deprecated int          get_buffer(AVIOContext *s, unsigned char *buf, int size);
357
attribute_deprecated int          get_partial_buffer(AVIOContext *s, unsigned char *buf, int size);
358
attribute_deprecated int          get_byte(AVIOContext *s);
359
attribute_deprecated unsigned int get_le16(AVIOContext *s);
360
attribute_deprecated unsigned int get_le24(AVIOContext *s);
361
attribute_deprecated unsigned int get_le32(AVIOContext *s);
362
attribute_deprecated uint64_t     get_le64(AVIOContext *s);
363
attribute_deprecated unsigned int get_be16(AVIOContext *s);
364
attribute_deprecated unsigned int get_be24(AVIOContext *s);
365
attribute_deprecated unsigned int get_be32(AVIOContext *s);
366
attribute_deprecated uint64_t     get_be64(AVIOContext *s);
367

    
368
attribute_deprecated void         put_byte(AVIOContext *s, int b);
369
attribute_deprecated void         put_nbyte(AVIOContext *s, int b, int count);
370
attribute_deprecated void         put_buffer(AVIOContext *s, const unsigned char *buf, int size);
371
attribute_deprecated void         put_le64(AVIOContext *s, uint64_t val);
372
attribute_deprecated void         put_be64(AVIOContext *s, uint64_t val);
373
attribute_deprecated void         put_le32(AVIOContext *s, unsigned int val);
374
attribute_deprecated void         put_be32(AVIOContext *s, unsigned int val);
375
attribute_deprecated void         put_le24(AVIOContext *s, unsigned int val);
376
attribute_deprecated void         put_be24(AVIOContext *s, unsigned int val);
377
attribute_deprecated void         put_le16(AVIOContext *s, unsigned int val);
378
attribute_deprecated void         put_be16(AVIOContext *s, unsigned int val);
379
attribute_deprecated void         put_tag(AVIOContext *s, const char *tag);
380
/**
381
 * @}
382
 */
383

    
384
attribute_deprecated int     av_url_read_fpause(AVIOContext *h,    int pause);
385
attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h,    int stream_index,
386
                                                int64_t timestamp, int flags);
387

    
388
/**
389
 * @defgroup old_url_f_funcs Old url_f* functions
390
 * @deprecated use the avio_ -prefixed functions instead.
391
 * @{
392
 */
393
attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags);
394
attribute_deprecated int url_fclose(AVIOContext *s);
395
attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
396
attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
397
attribute_deprecated int64_t url_ftell(AVIOContext *s);
398
attribute_deprecated int64_t url_fsize(AVIOContext *s);
399
#define URL_EOF (-1)
400
attribute_deprecated int url_fgetc(AVIOContext *s);
401
attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size);
402
#ifdef __GNUC__
403
attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
404
#else
405
attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...);
406
#endif
407
attribute_deprecated void put_flush_packet(AVIOContext *s);
408
attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
409
attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
410
attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
411
attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h);
412
/**
413
 * @}
414
 */
415

    
416
/**
417
 * @deprecated use AVIOContext.eof_reached
418
 */
419
attribute_deprecated int url_feof(AVIOContext *s);
420
attribute_deprecated int url_ferror(AVIOContext *s);
421

    
422
attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
423
attribute_deprecated int udp_get_local_port(URLContext *h);
424

    
425
attribute_deprecated void init_checksum(AVIOContext *s,
426
                   unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
427
                   unsigned long checksum);
428
attribute_deprecated unsigned long get_checksum(AVIOContext *s);
429
#endif
430

    
431
/**
432
 * Allocate and initialize an AVIOContext for buffered I/O. It must be later
433
 * freed with av_free().
434
 *
435
 * @param buffer Memory block for input/output operations via AVIOContext.
436
 * @param buffer_size The buffer size is very important for performance.
437
 *        For protocols with fixed blocksize it should be set to this blocksize.
438
 *        For others a typical size is a cache page, e.g. 4kb.
439
 * @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
440
 * @param opaque An opaque pointer to user-specific data.
441
 * @param read_packet  A function for refilling the buffer, may be NULL.
442
 * @param write_packet A function for writing the buffer contents, may be NULL.
443
 * @param seek A function for seeking to specified byte position, may be NULL.
444
 *
445
 * @return Allocated AVIOContext or NULL on failure.
446
 */
447
AVIOContext *avio_alloc_context(
448
                  unsigned char *buffer,
449
                  int buffer_size,
450
                  int write_flag,
451
                  void *opaque,
452
                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
453
                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
454
                  int64_t (*seek)(void *opaque, int64_t offset, int whence));
455

    
456
void avio_w8(AVIOContext *s, int b);
457
void avio_write(AVIOContext *s, const unsigned char *buf, int size);
458
void avio_wl64(AVIOContext *s, uint64_t val);
459
void avio_wb64(AVIOContext *s, uint64_t val);
460
void avio_wl32(AVIOContext *s, unsigned int val);
461
void avio_wb32(AVIOContext *s, unsigned int val);
462
void avio_wl24(AVIOContext *s, unsigned int val);
463
void avio_wb24(AVIOContext *s, unsigned int val);
464
void avio_wl16(AVIOContext *s, unsigned int val);
465
void avio_wb16(AVIOContext *s, unsigned int val);
466

    
467
#if FF_API_OLD_AVIO
468
attribute_deprecated void put_strz(AVIOContext *s, const char *buf);
469
#endif
470

    
471
/**
472
 * Write a NULL-terminated string.
473
 * @return number of bytes written.
474
 */
475
int avio_put_str(AVIOContext *s, const char *str);
476

    
477
/**
478
 * Convert an UTF-8 string to UTF-16LE and write it.
479
 * @return number of bytes written.
480
 */
481
int avio_put_str16le(AVIOContext *s, const char *str);
482

    
483
/**
484
 * fseek() equivalent for AVIOContext.
485
 * @return new position or AVERROR.
486
 */
487
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
488

    
489
/**
490
 * Skip given number of bytes forward
491
 * @return new position or AVERROR.
492
 */
493
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
494
{
495
    return avio_seek(s, offset, SEEK_CUR);
496
}
497

    
498
/**
499
 * ftell() equivalent for AVIOContext.
500
 * @return position or AVERROR.
501
 */
502
static av_always_inline int64_t avio_tell(AVIOContext *s)
503
{
504
    return avio_seek(s, 0, SEEK_CUR);
505
}
506

    
507
/**
508
 * Get the filesize.
509
 * @return filesize or AVERROR
510
 */
511
int64_t avio_size(AVIOContext *s);
512

    
513
/** @warning currently size is limited */
514
#ifdef __GNUC__
515
int avio_printf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
516
#else
517
int avio_printf(AVIOContext *s, const char *fmt, ...);
518
#endif
519

    
520
#if FF_API_OLD_AVIO
521
/** @note unlike fgets, the EOL character is not returned and a whole
522
    line is parsed. return NULL if first char read was EOF */
523
attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size);
524
#endif
525

    
526
void avio_flush(AVIOContext *s);
527

    
528

    
529
/**
530
 * Read size bytes from AVIOContext into buf.
531
 * @return number of bytes read or AVERROR
532
 */
533
int avio_read(AVIOContext *s, unsigned char *buf, int size);
534

    
535
/** @note return 0 if EOF, so you cannot use it if EOF handling is
536
    necessary */
537
int          avio_r8  (AVIOContext *s);
538
unsigned int avio_rl16(AVIOContext *s);
539
unsigned int avio_rl24(AVIOContext *s);
540
unsigned int avio_rl32(AVIOContext *s);
541
uint64_t     avio_rl64(AVIOContext *s);
542

    
543
/**
544
 * Read a string from pb into buf. The reading will terminate when either
545
 * a NULL character was encountered, maxlen bytes have been read, or nothing
546
 * more can be read from pb. The result is guaranteed to be NULL-terminated, it
547
 * will be truncated if buf is too small.
548
 * Note that the string is not interpreted or validated in any way, it
549
 * might get truncated in the middle of a sequence for multi-byte encodings.
550
 *
551
 * @return number of bytes read (is always <= maxlen).
552
 * If reading ends on EOF or error, the return value will be one more than
553
 * bytes actually read.
554
 */
555
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
556

    
557
/**
558
 * Read a UTF-16 string from pb and convert it to UTF-8.
559
 * The reading will terminate when either a null or invalid character was
560
 * encountered or maxlen bytes have been read.
561
 * @return number of bytes read (is always <= maxlen)
562
 */
563
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
564
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
565

    
566
#if FF_API_OLD_AVIO
567
/**
568
 * @deprecated use avio_get_str instead
569
 */
570
attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen);
571
#endif
572
unsigned int avio_rb16(AVIOContext *s);
573
unsigned int avio_rb24(AVIOContext *s);
574
unsigned int avio_rb32(AVIOContext *s);
575
uint64_t     avio_rb64(AVIOContext *s);
576

    
577
#if FF_API_OLD_AVIO
578
/**
579
 * @deprecated Use AVIOContext.seekable field directly.
580
 */
581
attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
582
{
583
    return !s->seekable;
584
}
585
#endif
586

    
587
#if FF_API_URL_RESETBUF
588
/** Reset the buffer for reading or writing.
589
 * @note Will drop any data currently in the buffer without transmitting it.
590
 * @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY
591
 *        to set up the buffer for writing. */
592
int url_resetbuf(AVIOContext *s, int flags);
593
#endif
594

    
595
/**
596
 * Create and initialize a AVIOContext for accessing the
597
 * resource indicated by url.
598
 * @note When the resource indicated by url has been opened in
599
 * read+write mode, the AVIOContext can be used only for writing.
600
 *
601
 * @param s Used to return the pointer to the created AVIOContext.
602
 * In case of failure the pointed to value is set to NULL.
603
 * @param flags flags which control how the resource indicated by url
604
 * is to be opened
605
 * @return 0 in case of success, a negative value corresponding to an
606
 * AVERROR code in case of failure
607
 */
608
int avio_open(AVIOContext **s, const char *url, int flags);
609

    
610
int avio_close(AVIOContext *s);
611

    
612
#if FF_API_OLD_AVIO
613
attribute_deprecated URLContext *url_fileno(AVIOContext *s);
614

    
615
/**
616
 * @deprecated use AVIOContext.max_packet_size directly.
617
 */
618
attribute_deprecated int url_fget_max_packet_size(AVIOContext *s);
619

    
620
attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags);
621

    
622
/** return the written or read size */
623
attribute_deprecated int url_close_buf(AVIOContext *s);
624
#endif
625

    
626
/**
627
 * Open a write only memory stream.
628
 *
629
 * @param s new IO context
630
 * @return zero if no error.
631
 */
632
int avio_open_dyn_buf(AVIOContext **s);
633

    
634
/**
635
 * Return the written size and a pointer to the buffer. The buffer
636
 * must be freed with av_free().
637
 * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
638
 *
639
 * @param s IO context
640
 * @param pbuffer pointer to a byte buffer
641
 * @return the length of the byte buffer
642
 */
643
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
644

    
645
#if FF_API_UDP_GET_FILE
646
int udp_get_file_handle(URLContext *h);
647
#endif
648

    
649
#endif /* AVFORMAT_AVIO_H */