00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef AVFORMAT_AVIO_H
00021 #define AVFORMAT_AVIO_H
00022
00029 #include <stdint.h>
00030
00031 #include "libavutil/common.h"
00032 #include "libavutil/dict.h"
00033 #include "libavutil/log.h"
00034
00035 #include "libavformat/version.h"
00036
00037
00038 #define AVIO_SEEKABLE_NORMAL 0x0001
00051 typedef struct {
00052 int (*callback)(void*);
00053 void *opaque;
00054 } AVIOInterruptCB;
00055
00068 typedef struct {
00069 #if !FF_API_OLD_AVIO
00070
00082 AVClass *av_class;
00083 #endif
00084 unsigned char *buffer;
00085 int buffer_size;
00086 unsigned char *buf_ptr;
00087 unsigned char *buf_end;
00091 void *opaque;
00093 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
00094 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
00095 int64_t (*seek)(void *opaque, int64_t offset, int whence);
00096 int64_t pos;
00097 int must_flush;
00098 int eof_reached;
00099 int write_flag;
00100 #if FF_API_OLD_AVIO
00101 attribute_deprecated int is_streamed;
00102 #endif
00103 int max_packet_size;
00104 unsigned long checksum;
00105 unsigned char *checksum_ptr;
00106 unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
00107 int error;
00111 int (*read_pause)(void *opaque, int pause);
00117 int64_t (*read_seek)(void *opaque, int stream_index,
00118 int64_t timestamp, int flags);
00122 int seekable;
00123
00128 int64_t maxsize;
00129 } AVIOContext;
00130
00131
00132
00133 #if FF_API_OLD_AVIO
00134
00142 typedef struct URLContext {
00143 const AVClass *av_class;
00144 struct URLProtocol *prot;
00145 int flags;
00146 int is_streamed;
00147 int max_packet_size;
00148 void *priv_data;
00149 char *filename;
00150 int is_connected;
00151 AVIOInterruptCB interrupt_callback;
00152 } URLContext;
00153
00154 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1
00155 #define URL_PROTOCOL_FLAG_NETWORK 2
00156
00161 typedef struct URLProtocol {
00162 const char *name;
00163 int (*url_open)(URLContext *h, const char *url, int flags);
00164 int (*url_read)(URLContext *h, unsigned char *buf, int size);
00165 int (*url_write)(URLContext *h, const unsigned char *buf, int size);
00166 int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
00167 int (*url_close)(URLContext *h);
00168 struct URLProtocol *next;
00169 int (*url_read_pause)(URLContext *h, int pause);
00170 int64_t (*url_read_seek)(URLContext *h, int stream_index,
00171 int64_t timestamp, int flags);
00172 int (*url_get_file_handle)(URLContext *h);
00173 int priv_data_size;
00174 const AVClass *priv_data_class;
00175 int flags;
00176 int (*url_check)(URLContext *h, int mask);
00177 } URLProtocol;
00178
00179 typedef struct URLPollEntry {
00180 URLContext *handle;
00181 int events;
00182 int revents;
00183 } URLPollEntry;
00184
00185
00186 attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout);
00187
00194 #define URL_RDONLY 1
00195 #define URL_WRONLY 2
00196 #define URL_RDWR (URL_RDONLY|URL_WRONLY)
00213 #define URL_FLAG_NONBLOCK 8
00214
00215 typedef int URLInterruptCB(void);
00216 extern URLInterruptCB *url_interrupt_cb;
00217
00224 attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up,
00225 const char *url, int flags);
00226 attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags);
00227 attribute_deprecated int url_connect(URLContext *h);
00228 attribute_deprecated int url_open(URLContext **h, const char *url, int flags);
00229 attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size);
00230 attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size);
00231 attribute_deprecated int url_write(URLContext *h, const unsigned char *buf, int size);
00232 attribute_deprecated int64_t url_seek(URLContext *h, int64_t pos, int whence);
00233 attribute_deprecated int url_close(URLContext *h);
00234 attribute_deprecated int64_t url_filesize(URLContext *h);
00235 attribute_deprecated int url_get_file_handle(URLContext *h);
00236 attribute_deprecated int url_get_max_packet_size(URLContext *h);
00237 attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_size);
00238 attribute_deprecated int av_url_read_pause(URLContext *h, int pause);
00239 attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
00240 int64_t timestamp, int flags);
00241 attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void));
00242
00247 URLProtocol *av_protocol_next(URLProtocol *p);
00248
00254 attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size);
00260 typedef attribute_deprecated AVIOContext ByteIOContext;
00261
00262 attribute_deprecated int init_put_byte(AVIOContext *s,
00263 unsigned char *buffer,
00264 int buffer_size,
00265 int write_flag,
00266 void *opaque,
00267 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00268 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00269 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00270 attribute_deprecated AVIOContext *av_alloc_put_byte(
00271 unsigned char *buffer,
00272 int buffer_size,
00273 int write_flag,
00274 void *opaque,
00275 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00276 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00277 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00278
00285 attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size);
00286 attribute_deprecated int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size);
00287 attribute_deprecated int get_byte(AVIOContext *s);
00288 attribute_deprecated unsigned int get_le16(AVIOContext *s);
00289 attribute_deprecated unsigned int get_le24(AVIOContext *s);
00290 attribute_deprecated unsigned int get_le32(AVIOContext *s);
00291 attribute_deprecated uint64_t get_le64(AVIOContext *s);
00292 attribute_deprecated unsigned int get_be16(AVIOContext *s);
00293 attribute_deprecated unsigned int get_be24(AVIOContext *s);
00294 attribute_deprecated unsigned int get_be32(AVIOContext *s);
00295 attribute_deprecated uint64_t get_be64(AVIOContext *s);
00296
00297 attribute_deprecated void put_byte(AVIOContext *s, int b);
00298 attribute_deprecated void put_nbyte(AVIOContext *s, int b, int count);
00299 attribute_deprecated void put_buffer(AVIOContext *s, const unsigned char *buf, int size);
00300 attribute_deprecated void put_le64(AVIOContext *s, uint64_t val);
00301 attribute_deprecated void put_be64(AVIOContext *s, uint64_t val);
00302 attribute_deprecated void put_le32(AVIOContext *s, unsigned int val);
00303 attribute_deprecated void put_be32(AVIOContext *s, unsigned int val);
00304 attribute_deprecated void put_le24(AVIOContext *s, unsigned int val);
00305 attribute_deprecated void put_be24(AVIOContext *s, unsigned int val);
00306 attribute_deprecated void put_le16(AVIOContext *s, unsigned int val);
00307 attribute_deprecated void put_be16(AVIOContext *s, unsigned int val);
00308 attribute_deprecated void put_tag(AVIOContext *s, const char *tag);
00313 attribute_deprecated int av_url_read_fpause(AVIOContext *h, int pause);
00314 attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h, int stream_index,
00315 int64_t timestamp, int flags);
00316
00323 attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags);
00324 attribute_deprecated int url_fclose(AVIOContext *s);
00325 attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
00326 attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
00327 attribute_deprecated int64_t url_ftell(AVIOContext *s);
00328 attribute_deprecated int64_t url_fsize(AVIOContext *s);
00329 #define URL_EOF (-1)
00330 attribute_deprecated int url_fgetc(AVIOContext *s);
00331 attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size);
00332 attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
00333 attribute_deprecated void put_flush_packet(AVIOContext *s);
00334 attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
00335 attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
00336 attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00337 attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h);
00342 attribute_deprecated int url_ferror(AVIOContext *s);
00343
00344 attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
00345 attribute_deprecated int udp_get_local_port(URLContext *h);
00346
00347 attribute_deprecated void init_checksum(AVIOContext *s,
00348 unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
00349 unsigned long checksum);
00350 attribute_deprecated unsigned long get_checksum(AVIOContext *s);
00351 attribute_deprecated void put_strz(AVIOContext *s, const char *buf);
00354 attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size);
00358 attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen);
00362 attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
00363 {
00364 return !s->seekable;
00365 }
00366 attribute_deprecated URLContext *url_fileno(AVIOContext *s);
00367
00371 attribute_deprecated int url_fget_max_packet_size(AVIOContext *s);
00372
00373 attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags);
00374
00376 attribute_deprecated int url_close_buf(AVIOContext *s);
00377
00383 attribute_deprecated int url_exist(const char *url);
00384 #endif // FF_API_OLD_AVIO
00385
00398 int avio_check(const char *url, int flags);
00399
00400 #if FF_API_OLD_INTERRUPT_CB
00401
00409 attribute_deprecated void avio_set_interrupt_cb(int (*interrupt_cb)(void));
00410 #endif
00411
00429 AVIOContext *avio_alloc_context(
00430 unsigned char *buffer,
00431 int buffer_size,
00432 int write_flag,
00433 void *opaque,
00434 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00435 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00436 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00437
00438 void avio_w8(AVIOContext *s, int b);
00439 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
00440 void avio_wl64(AVIOContext *s, uint64_t val);
00441 void avio_wb64(AVIOContext *s, uint64_t val);
00442 void avio_wl32(AVIOContext *s, unsigned int val);
00443 void avio_wb32(AVIOContext *s, unsigned int val);
00444 void avio_wl24(AVIOContext *s, unsigned int val);
00445 void avio_wb24(AVIOContext *s, unsigned int val);
00446 void avio_wl16(AVIOContext *s, unsigned int val);
00447 void avio_wb16(AVIOContext *s, unsigned int val);
00448
00453 int avio_put_str(AVIOContext *s, const char *str);
00454
00459 int avio_put_str16le(AVIOContext *s, const char *str);
00460
00466 #define AVSEEK_SIZE 0x10000
00467
00474 #define AVSEEK_FORCE 0x20000
00475
00480 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
00481
00486 int64_t avio_skip(AVIOContext *s, int64_t offset);
00487
00492 static av_always_inline int64_t avio_tell(AVIOContext *s)
00493 {
00494 return avio_seek(s, 0, SEEK_CUR);
00495 }
00496
00501 int64_t avio_size(AVIOContext *s);
00502
00507 int url_feof(AVIOContext *s);
00508
00510 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
00511
00512 void avio_flush(AVIOContext *s);
00513
00514
00519 int avio_read(AVIOContext *s, unsigned char *buf, int size);
00520
00528 int avio_r8 (AVIOContext *s);
00529 unsigned int avio_rl16(AVIOContext *s);
00530 unsigned int avio_rl24(AVIOContext *s);
00531 unsigned int avio_rl32(AVIOContext *s);
00532 uint64_t avio_rl64(AVIOContext *s);
00533 unsigned int avio_rb16(AVIOContext *s);
00534 unsigned int avio_rb24(AVIOContext *s);
00535 unsigned int avio_rb32(AVIOContext *s);
00536 uint64_t avio_rb64(AVIOContext *s);
00553 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
00554
00561 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
00562 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
00563
00564
00571 #define AVIO_FLAG_READ 1
00572 #define AVIO_FLAG_WRITE 2
00573 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE)
00590 #define AVIO_FLAG_NONBLOCK 8
00591
00605 int avio_open(AVIOContext **s, const char *url, int flags);
00606
00624 int avio_open2(AVIOContext **s, const char *url, int flags,
00625 const AVIOInterruptCB *int_cb, AVDictionary **options);
00626
00633 int avio_close(AVIOContext *s);
00634
00641 int avio_open_dyn_buf(AVIOContext **s);
00642
00652 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00653
00666 const char *avio_enum_protocols(void **opaque, int output);
00667
00673 int avio_pause(AVIOContext *h, int pause);
00674
00692 int64_t avio_seek_time(AVIOContext *h, int stream_index,
00693 int64_t timestamp, int flags);
00694
00695 #endif