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
00136 int64_t bytes_read;
00137
00142 int seek_count;
00143 } AVIOContext;
00144
00145
00146
00159 int avio_check(const char *url, int flags);
00160
00179 AVIOContext *avio_alloc_context(
00180 unsigned char *buffer,
00181 int buffer_size,
00182 int write_flag,
00183 void *opaque,
00184 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00185 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00186 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00187
00188 void avio_w8(AVIOContext *s, int b);
00189 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
00190 void avio_wl64(AVIOContext *s, uint64_t val);
00191 void avio_wb64(AVIOContext *s, uint64_t val);
00192 void avio_wl32(AVIOContext *s, unsigned int val);
00193 void avio_wb32(AVIOContext *s, unsigned int val);
00194 void avio_wl24(AVIOContext *s, unsigned int val);
00195 void avio_wb24(AVIOContext *s, unsigned int val);
00196 void avio_wl16(AVIOContext *s, unsigned int val);
00197 void avio_wb16(AVIOContext *s, unsigned int val);
00198
00203 int avio_put_str(AVIOContext *s, const char *str);
00204
00209 int avio_put_str16le(AVIOContext *s, const char *str);
00210
00216 #define AVSEEK_SIZE 0x10000
00217
00224 #define AVSEEK_FORCE 0x20000
00225
00230 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
00231
00236 int64_t avio_skip(AVIOContext *s, int64_t offset);
00237
00242 static av_always_inline int64_t avio_tell(AVIOContext *s)
00243 {
00244 return avio_seek(s, 0, SEEK_CUR);
00245 }
00246
00251 int64_t avio_size(AVIOContext *s);
00252
00257 int url_feof(AVIOContext *s);
00258
00260 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
00261
00268 void avio_flush(AVIOContext *s);
00269
00274 int avio_read(AVIOContext *s, unsigned char *buf, int size);
00275
00283 int avio_r8 (AVIOContext *s);
00284 unsigned int avio_rl16(AVIOContext *s);
00285 unsigned int avio_rl24(AVIOContext *s);
00286 unsigned int avio_rl32(AVIOContext *s);
00287 uint64_t avio_rl64(AVIOContext *s);
00288 unsigned int avio_rb16(AVIOContext *s);
00289 unsigned int avio_rb24(AVIOContext *s);
00290 unsigned int avio_rb32(AVIOContext *s);
00291 uint64_t avio_rb64(AVIOContext *s);
00308 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
00309
00316 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
00317 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
00318
00319
00326 #define AVIO_FLAG_READ 1
00327 #define AVIO_FLAG_WRITE 2
00328 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE)
00345 #define AVIO_FLAG_NONBLOCK 8
00346
00353 #define AVIO_FLAG_DIRECT 0x8000
00354
00368 int avio_open(AVIOContext **s, const char *url, int flags);
00369
00387 int avio_open2(AVIOContext **s, const char *url, int flags,
00388 const AVIOInterruptCB *int_cb, AVDictionary **options);
00389
00399 int avio_close(AVIOContext *s);
00400
00407 int avio_open_dyn_buf(AVIOContext **s);
00408
00418 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00419
00431 const char *avio_enum_protocols(void **opaque, int output);
00432
00438 int avio_pause(AVIOContext *h, int pause);
00439
00457 int64_t avio_seek_time(AVIOContext *h, int stream_index,
00458 int64_t timestamp, int flags);
00459
00460 #endif