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
00160 typedef struct URLProtocol {
00161 const char *name;
00162 int (*url_open)(URLContext *h, const char *url, int flags);
00163 int (*url_read)(URLContext *h, unsigned char *buf, int size);
00164 int (*url_write)(URLContext *h, const unsigned char *buf, int size);
00165 int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
00166 int (*url_close)(URLContext *h);
00167 struct URLProtocol *next;
00168 int (*url_read_pause)(URLContext *h, int pause);
00169 int64_t (*url_read_seek)(URLContext *h, int stream_index,
00170 int64_t timestamp, int flags);
00171 int (*url_get_file_handle)(URLContext *h);
00172 int priv_data_size;
00173 const AVClass *priv_data_class;
00174 int flags;
00175 int (*url_check)(URLContext *h, int mask);
00176 } URLProtocol;
00177
00178 typedef struct URLPollEntry {
00179 URLContext *handle;
00180 int events;
00181 int revents;
00182 } URLPollEntry;
00183
00184
00185 attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout);
00186
00193 #define URL_RDONLY 1
00194 #define URL_WRONLY 2
00195 #define URL_RDWR (URL_RDONLY|URL_WRONLY)
00212 #define URL_FLAG_NONBLOCK 4
00213
00214 typedef int URLInterruptCB(void);
00215 extern URLInterruptCB *url_interrupt_cb;
00216
00223 attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up,
00224 const char *url, int flags);
00225 attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags);
00226 attribute_deprecated int url_connect(URLContext *h);
00227 attribute_deprecated int url_open(URLContext **h, const char *url, int flags);
00228 attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size);
00229 attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size);
00230 attribute_deprecated int url_write(URLContext *h, const unsigned char *buf, int size);
00231 attribute_deprecated int64_t url_seek(URLContext *h, int64_t pos, int whence);
00232 attribute_deprecated int url_close(URLContext *h);
00233 attribute_deprecated int64_t url_filesize(URLContext *h);
00234 attribute_deprecated int url_get_file_handle(URLContext *h);
00235 attribute_deprecated int url_get_max_packet_size(URLContext *h);
00236 attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_size);
00237 attribute_deprecated int av_url_read_pause(URLContext *h, int pause);
00238 attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
00239 int64_t timestamp, int flags);
00240 attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void));
00241
00246 URLProtocol *av_protocol_next(URLProtocol *p);
00247
00253 attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size);
00259 typedef attribute_deprecated AVIOContext ByteIOContext;
00260
00261 attribute_deprecated int init_put_byte(AVIOContext *s,
00262 unsigned char *buffer,
00263 int buffer_size,
00264 int write_flag,
00265 void *opaque,
00266 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00267 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00268 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00269 attribute_deprecated AVIOContext *av_alloc_put_byte(
00270 unsigned char *buffer,
00271 int buffer_size,
00272 int write_flag,
00273 void *opaque,
00274 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00275 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00276 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00277
00284 attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size);
00285 attribute_deprecated int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size);
00286 attribute_deprecated int get_byte(AVIOContext *s);
00287 attribute_deprecated unsigned int get_le16(AVIOContext *s);
00288 attribute_deprecated unsigned int get_le24(AVIOContext *s);
00289 attribute_deprecated unsigned int get_le32(AVIOContext *s);
00290 attribute_deprecated uint64_t get_le64(AVIOContext *s);
00291 attribute_deprecated unsigned int get_be16(AVIOContext *s);
00292 attribute_deprecated unsigned int get_be24(AVIOContext *s);
00293 attribute_deprecated unsigned int get_be32(AVIOContext *s);
00294 attribute_deprecated uint64_t get_be64(AVIOContext *s);
00295
00296 attribute_deprecated void put_byte(AVIOContext *s, int b);
00297 attribute_deprecated void put_nbyte(AVIOContext *s, int b, int count);
00298 attribute_deprecated void put_buffer(AVIOContext *s, const unsigned char *buf, int size);
00299 attribute_deprecated void put_le64(AVIOContext *s, uint64_t val);
00300 attribute_deprecated void put_be64(AVIOContext *s, uint64_t val);
00301 attribute_deprecated void put_le32(AVIOContext *s, unsigned int val);
00302 attribute_deprecated void put_be32(AVIOContext *s, unsigned int val);
00303 attribute_deprecated void put_le24(AVIOContext *s, unsigned int val);
00304 attribute_deprecated void put_be24(AVIOContext *s, unsigned int val);
00305 attribute_deprecated void put_le16(AVIOContext *s, unsigned int val);
00306 attribute_deprecated void put_be16(AVIOContext *s, unsigned int val);
00307 attribute_deprecated void put_tag(AVIOContext *s, const char *tag);
00312 attribute_deprecated int av_url_read_fpause(AVIOContext *h, int pause);
00313 attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h, int stream_index,
00314 int64_t timestamp, int flags);
00315
00322 attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags);
00323 attribute_deprecated int url_fclose(AVIOContext *s);
00324 attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
00325 attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
00326 attribute_deprecated int64_t url_ftell(AVIOContext *s);
00327 attribute_deprecated int64_t url_fsize(AVIOContext *s);
00328 #define URL_EOF (-1)
00329 attribute_deprecated int url_fgetc(AVIOContext *s);
00330 attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size);
00331 attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
00332 attribute_deprecated void put_flush_packet(AVIOContext *s);
00333 attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
00334 attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
00335 attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00336 attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h);
00341 attribute_deprecated int url_ferror(AVIOContext *s);
00342
00343 attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
00344 attribute_deprecated int udp_get_local_port(URLContext *h);
00345
00346 attribute_deprecated void init_checksum(AVIOContext *s,
00347 unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
00348 unsigned long checksum);
00349 attribute_deprecated unsigned long get_checksum(AVIOContext *s);
00350 attribute_deprecated void put_strz(AVIOContext *s, const char *buf);
00353 attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size);
00357 attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen);
00361 attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
00362 {
00363 return !s->seekable;
00364 }
00365 attribute_deprecated URLContext *url_fileno(AVIOContext *s);
00366
00370 attribute_deprecated int url_fget_max_packet_size(AVIOContext *s);
00371
00372 attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags);
00373
00375 attribute_deprecated int url_close_buf(AVIOContext *s);
00376
00382 attribute_deprecated int url_exist(const char *url);
00383 #endif // FF_API_OLD_AVIO
00384
00397 int avio_check(const char *url, int flags);
00398
00399 #if FF_API_OLD_INTERRUPT_CB
00400
00408 attribute_deprecated void avio_set_interrupt_cb(int (*interrupt_cb)(void));
00409 #endif
00410
00428 AVIOContext *avio_alloc_context(
00429 unsigned char *buffer,
00430 int buffer_size,
00431 int write_flag,
00432 void *opaque,
00433 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00434 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00435 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00436
00437 void avio_w8(AVIOContext *s, int b);
00438 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
00439 void avio_wl64(AVIOContext *s, uint64_t val);
00440 void avio_wb64(AVIOContext *s, uint64_t val);
00441 void avio_wl32(AVIOContext *s, unsigned int val);
00442 void avio_wb32(AVIOContext *s, unsigned int val);
00443 void avio_wl24(AVIOContext *s, unsigned int val);
00444 void avio_wb24(AVIOContext *s, unsigned int val);
00445 void avio_wl16(AVIOContext *s, unsigned int val);
00446 void avio_wb16(AVIOContext *s, unsigned int val);
00447
00452 int avio_put_str(AVIOContext *s, const char *str);
00453
00458 int avio_put_str16le(AVIOContext *s, const char *str);
00459
00465 #define AVSEEK_SIZE 0x10000
00466
00473 #define AVSEEK_FORCE 0x20000
00474
00479 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
00480
00485 int64_t avio_skip(AVIOContext *s, int64_t offset);
00486
00491 static av_always_inline int64_t avio_tell(AVIOContext *s)
00492 {
00493 return avio_seek(s, 0, SEEK_CUR);
00494 }
00495
00500 int64_t avio_size(AVIOContext *s);
00501
00506 int url_feof(AVIOContext *s);
00507
00509 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
00510
00511 void avio_flush(AVIOContext *s);
00512
00513
00518 int avio_read(AVIOContext *s, unsigned char *buf, int size);
00519
00527 int avio_r8 (AVIOContext *s);
00528 unsigned int avio_rl16(AVIOContext *s);
00529 unsigned int avio_rl24(AVIOContext *s);
00530 unsigned int avio_rl32(AVIOContext *s);
00531 uint64_t avio_rl64(AVIOContext *s);
00532 unsigned int avio_rb16(AVIOContext *s);
00533 unsigned int avio_rb24(AVIOContext *s);
00534 unsigned int avio_rb32(AVIOContext *s);
00535 uint64_t avio_rb64(AVIOContext *s);
00552 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
00553
00560 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
00561 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
00562
00563
00570 #define AVIO_FLAG_READ 1
00571 #define AVIO_FLAG_WRITE 2
00572 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE)
00589 #define AVIO_FLAG_NONBLOCK 8
00590
00604 int avio_open(AVIOContext **s, const char *url, int flags);
00605
00623 int avio_open2(AVIOContext **s, const char *url, int flags,
00624 const AVIOInterruptCB *int_cb, AVDictionary **options);
00625
00632 int avio_close(AVIOContext *s);
00633
00640 int avio_open_dyn_buf(AVIOContext **s);
00641
00651 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00652
00665 const char *avio_enum_protocols(void **opaque, int output);
00666
00672 int avio_pause(AVIOContext *h, int pause);
00673
00691 int64_t avio_seek_time(AVIOContext *h, int stream_index,
00692 int64_t timestamp, int flags);
00693
00694 #endif