You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.7 KiB

#ifndef AVIO_H
#define AVIO_H
/*
** <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>дģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD>ͺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#define URL_EOF (-1)
typedef int64_t offset_t;
/* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>Ȩ<EFBFBD>޵Ķ<EFBFBD><EFBFBD><EFBFBD> */
#define URL_RDONLY 0
#define URL_WRONLY 1
#define URL_RDWR 2
/*
** URL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>ʾһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
** URLContext <EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĵ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>Э<EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>Э<EFBFBD><EFBFBD>е<EFBFBD>
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ)<EFBFBD>͹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
typedef struct URLContext
{
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>
struct URLProtocol *prot;
int flags;
int max_packet_size; // if non zero, the stream is packetized with this max packet size
void *priv_data; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>file<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
char filename[1]; // specified filename
} URLContext;
/*
** URLЭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
** URLProtocol <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹ<EFBFBD><EFBFBD>ܺ<EFBFBD><EFBFBD><EFBFBD>
** һ<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧһ<EFBFBD><EFBFBD> URLProtocol <EFBFBD><EFBFBD><EFBFBD>
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> pipe<EFBFBD><EFBFBD>udp<EFBFBD><EFBFBD>tcp<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> file Э<EFBFBD><EFBFBD>
*/
typedef struct URLProtocol
{
const char *name;
int(*url_open)(URLContext *h, const char *filename, int flags);
int(*url_read)(URLContext *h, unsigned char *buf, int size);
int(*url_write)(URLContext *h, unsigned char *buf, int size);
offset_t(*url_seek)(URLContext *h, offset_t pos, int whence);
int(*url_close)(URLContext *h);
struct URLProtocol *next;
} URLProtocol;
/*
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
*/
typedef struct ByteIOContext
{
// <EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned char *buffer;
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
int buffer_size;
// <EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD>ֽڷ<EFBFBD>Χ
unsigned char *buf_ptr, *buf_end;
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void *opaque;
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int (*read_buf)(void *opaque, uint8_t *buf, int buf_size);
// д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int (*write_buf)(void *opaque, uint8_t *buf, int buf_size);
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>bufferָ<EFBFBD><EFBFBD>
offset_t(*seek)(void *opaque, offset_t offset, int whence);
// λ<EFBFBD><EFBFBD>
offset_t pos; // position in the file of the current buffer
// <EFBFBD>Dz<EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ҫˢ<EFBFBD><EFBFBD>
int must_flush; // true if the next seek should flush
// <EFBFBD>Ƿ񵽴<EFBFBD><EFBFBD>ļ<EFBFBD>β<EFBFBD><EFBFBD>
int eof_reached; // true if eof reached
// <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>д
int write_flag; // true if open for writing
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD>Ĵ<EFBFBD>С
int max_packet_size;
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int error; // contains the error code or 0 if no error happened
} ByteIOContext;
int url_open(URLContext **h, const char *filename, int flags);
int url_read(URLContext *h, unsigned char *buf, int size);
int url_write(URLContext *h, unsigned char *buf, int size);
offset_t url_seek(URLContext *h, offset_t pos, int whence);
int url_close(URLContext *h);
int url_get_max_packet_size(URLContext *h);
int register_protocol(URLProtocol *protocol);
int init_put_byte(ByteIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
void *opaque,
int(*read_buf)(void *opaque, uint8_t *buf, int buf_size),
int(*write_buf)(void *opaque, uint8_t *buf, int buf_size),
offset_t(*seek)(void *opaque, offset_t offset, int whence));
offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
void url_fskip(ByteIOContext *s, offset_t offset);
offset_t url_ftell(ByteIOContext *s);
offset_t url_fsize(ByteIOContext *s);
int url_feof(ByteIOContext *s);
int url_ferror(ByteIOContext *s);
int url_fread(ByteIOContext *s, unsigned char *buf, int size); // get_buffer
int get_byte(ByteIOContext *s);
unsigned int get_le32(ByteIOContext *s);
unsigned int get_le16(ByteIOContext *s);
int url_setbufsize(ByteIOContext *s, int buf_size);
int url_fopen(ByteIOContext *s, const char *filename, int flags);
int url_fclose(ByteIOContext *s);
int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags);
int url_close_buf(ByteIOContext *s);
#endif