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 {
00081 const AVClass *av_class;
00082 unsigned char *buffer;
00083 int buffer_size;
00084 unsigned char *buf_ptr;
00085 unsigned char *buf_end;
00089 void *opaque;
00091 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
00092 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
00093 int64_t (*seek)(void *opaque, int64_t offset, int whence);
00094 int64_t pos;
00095 int must_flush;
00096 int eof_reached;
00097 int write_flag;
00098 int max_packet_size;
00099 unsigned long checksum;
00100 unsigned char *checksum_ptr;
00101 unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
00102 int error;
00106 int (*read_pause)(void *opaque, int pause);
00112 int64_t (*read_seek)(void *opaque, int stream_index,
00113 int64_t timestamp, int flags);
00117 int seekable;
00118
00123 int64_t maxsize;
00124
00130 int direct;
00131 } AVIOContext;
00132
00133
00134
00147 int avio_check(const char *url, int flags);
00148
00166 AVIOContext *avio_alloc_context(
00167 unsigned char *buffer,
00168 int buffer_size,
00169 int write_flag,
00170 void *opaque,
00171 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00172 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00173 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00174
00175 void avio_w8(AVIOContext *s, int b);
00176 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
00177 void avio_wl64(AVIOContext *s, uint64_t val);
00178 void avio_wb64(AVIOContext *s, uint64_t val);
00179 void avio_wl32(AVIOContext *s, unsigned int val);
00180 void avio_wb32(AVIOContext *s, unsigned int val);
00181 void avio_wl24(AVIOContext *s, unsigned int val);
00182 void avio_wb24(AVIOContext *s, unsigned int val);
00183 void avio_wl16(AVIOContext *s, unsigned int val);
00184 void avio_wb16(AVIOContext *s, unsigned int val);
00185
00190 int avio_put_str(AVIOContext *s, const char *str);
00191
00196 int avio_put_str16le(AVIOContext *s, const char *str);
00197
00203 #define AVSEEK_SIZE 0x10000
00204
00211 #define AVSEEK_FORCE 0x20000
00212
00217 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
00218
00223 int64_t avio_skip(AVIOContext *s, int64_t offset);
00224
00229 static av_always_inline int64_t avio_tell(AVIOContext *s)
00230 {
00231 return avio_seek(s, 0, SEEK_CUR);
00232 }
00233
00238 int64_t avio_size(AVIOContext *s);
00239
00244 int url_feof(AVIOContext *s);
00245
00247 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
00248
00249 void avio_flush(AVIOContext *s);
00250
00251
00256 int avio_read(AVIOContext *s, unsigned char *buf, int size);
00257
00265 int avio_r8 (AVIOContext *s);
00266 unsigned int avio_rl16(AVIOContext *s);
00267 unsigned int avio_rl24(AVIOContext *s);
00268 unsigned int avio_rl32(AVIOContext *s);
00269 uint64_t avio_rl64(AVIOContext *s);
00270 unsigned int avio_rb16(AVIOContext *s);
00271 unsigned int avio_rb24(AVIOContext *s);
00272 unsigned int avio_rb32(AVIOContext *s);
00273 uint64_t avio_rb64(AVIOContext *s);
00290 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
00291
00298 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
00299 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
00300
00301
00308 #define AVIO_FLAG_READ 1
00309 #define AVIO_FLAG_WRITE 2
00310 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE)
00327 #define AVIO_FLAG_NONBLOCK 8
00328
00335 #define AVIO_FLAG_DIRECT 0x8000
00336
00350 int avio_open(AVIOContext **s, const char *url, int flags);
00351
00369 int avio_open2(AVIOContext **s, const char *url, int flags,
00370 const AVIOInterruptCB *int_cb, AVDictionary **options);
00371
00378 int avio_close(AVIOContext *s);
00379
00386 int avio_open_dyn_buf(AVIOContext **s);
00387
00397 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00398
00411 const char *avio_enum_protocols(void **opaque, int output);
00412
00418 int avio_pause(AVIOContext *h, int pause);
00419
00437 int64_t avio_seek_time(AVIOContext *h, int stream_index,
00438 int64_t timestamp, int flags);
00439
00440 #endif