00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FFMPEG_AVIO_H
00022 #define FFMPEG_AVIO_H
00023
00024 #include <stdint.h>
00025
00026
00027
00028 typedef int64_t offset_t;
00029
00030
00031
00032 struct URLContext {
00033 struct URLProtocol *prot;
00034 int flags;
00035 int is_streamed;
00036 int max_packet_size;
00037 void *priv_data;
00038 #if LIBAVFORMAT_VERSION_INT >= (52<<16)
00039 char *filename;
00040 #else
00041 char filename[1];
00042 #endif
00043 };
00044
00045 typedef struct URLContext URLContext;
00046
00047 typedef struct URLPollEntry {
00048 URLContext *handle;
00049 int events;
00050 int revents;
00051 } URLPollEntry;
00052
00053 #define URL_RDONLY 0
00054 #define URL_WRONLY 1
00055 #define URL_RDWR 2
00056
00057 typedef int URLInterruptCB(void);
00058
00059 int url_open(URLContext **h, const char *filename, int flags);
00060 int url_read(URLContext *h, unsigned char *buf, int size);
00061 int url_write(URLContext *h, unsigned char *buf, int size);
00062 offset_t url_seek(URLContext *h, offset_t pos, int whence);
00063 int url_close(URLContext *h);
00064 int url_exist(const char *filename);
00065 offset_t url_filesize(URLContext *h);
00066
00075 int url_get_max_packet_size(URLContext *h);
00076 void url_get_filename(URLContext *h, char *buf, int buf_size);
00077
00084 void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
00085
00086
00087 int url_poll(URLPollEntry *poll_table, int n, int timeout);
00088
00094 #define AVSEEK_SIZE 0x10000
00095
00096 typedef struct URLProtocol {
00097 const char *name;
00098 int (*url_open)(URLContext *h, const char *filename, int flags);
00099 int (*url_read)(URLContext *h, unsigned char *buf, int size);
00100 int (*url_write)(URLContext *h, unsigned char *buf, int size);
00101 offset_t (*url_seek)(URLContext *h, offset_t pos, int whence);
00102 int (*url_close)(URLContext *h);
00103 struct URLProtocol *next;
00104 } URLProtocol;
00105
00106 extern URLProtocol *first_protocol;
00107 extern URLInterruptCB *url_interrupt_cb;
00108
00109 int register_protocol(URLProtocol *protocol);
00110
00111 typedef struct {
00112 unsigned char *buffer;
00113 int buffer_size;
00114 unsigned char *buf_ptr, *buf_end;
00115 void *opaque;
00116 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
00117 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
00118 offset_t (*seek)(void *opaque, offset_t offset, int whence);
00119 offset_t pos;
00120 int must_flush;
00121 int eof_reached;
00122 int write_flag;
00123 int is_streamed;
00124 int max_packet_size;
00125 unsigned long checksum;
00126 unsigned char *checksum_ptr;
00127 unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
00128 int error;
00129 } ByteIOContext;
00130
00131 int init_put_byte(ByteIOContext *s,
00132 unsigned char *buffer,
00133 int buffer_size,
00134 int write_flag,
00135 void *opaque,
00136 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00137 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00138 offset_t (*seek)(void *opaque, offset_t offset, int whence));
00139
00140 void put_byte(ByteIOContext *s, int b);
00141 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
00142 void put_le64(ByteIOContext *s, uint64_t val);
00143 void put_be64(ByteIOContext *s, uint64_t val);
00144 void put_le32(ByteIOContext *s, unsigned int val);
00145 void put_be32(ByteIOContext *s, unsigned int val);
00146 void put_le24(ByteIOContext *s, unsigned int val);
00147 void put_be24(ByteIOContext *s, unsigned int val);
00148 void put_le16(ByteIOContext *s, unsigned int val);
00149 void put_be16(ByteIOContext *s, unsigned int val);
00150 void put_tag(ByteIOContext *s, const char *tag);
00151
00152 void put_strz(ByteIOContext *s, const char *buf);
00153
00154 offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
00155 void url_fskip(ByteIOContext *s, offset_t offset);
00156 offset_t url_ftell(ByteIOContext *s);
00157 offset_t url_fsize(ByteIOContext *s);
00158 int url_feof(ByteIOContext *s);
00159 int url_ferror(ByteIOContext *s);
00160
00161 #define URL_EOF (-1)
00162
00163 int url_fgetc(ByteIOContext *s);
00164
00166 #ifdef __GNUC__
00167 int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
00168 #else
00169 int url_fprintf(ByteIOContext *s, const char *fmt, ...);
00170 #endif
00171
00174 char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
00175
00176 void put_flush_packet(ByteIOContext *s);
00177
00178 int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
00179 int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
00180
00183 int get_byte(ByteIOContext *s);
00184 unsigned int get_le24(ByteIOContext *s);
00185 unsigned int get_le32(ByteIOContext *s);
00186 uint64_t get_le64(ByteIOContext *s);
00187 unsigned int get_le16(ByteIOContext *s);
00188
00189 char *get_strz(ByteIOContext *s, char *buf, int maxlen);
00190 unsigned int get_be16(ByteIOContext *s);
00191 unsigned int get_be24(ByteIOContext *s);
00192 unsigned int get_be32(ByteIOContext *s);
00193 uint64_t get_be64(ByteIOContext *s);
00194
00195 uint64_t ff_get_v(ByteIOContext *bc);
00196
00197 static inline int url_is_streamed(ByteIOContext *s)
00198 {
00199 return s->is_streamed;
00200 }
00201
00204 int url_fdopen(ByteIOContext *s, URLContext *h);
00205
00207 int url_setbufsize(ByteIOContext *s, int buf_size);
00212 int url_resetbuf(ByteIOContext *s, int flags);
00213
00216 int url_fopen(ByteIOContext *s, const char *filename, int flags);
00217 int url_fclose(ByteIOContext *s);
00218 URLContext *url_fileno(ByteIOContext *s);
00219
00228 int url_fget_max_packet_size(ByteIOContext *s);
00229
00230 int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags);
00231
00233 int url_close_buf(ByteIOContext *s);
00234
00241 int url_open_dyn_buf(ByteIOContext *s);
00242
00252 int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
00253
00261 int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
00262
00263 unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len);
00264 unsigned long get_checksum(ByteIOContext *s);
00265 void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum);
00266
00267
00268 int udp_set_remote_url(URLContext *h, const char *uri);
00269 int udp_get_local_port(URLContext *h);
00270 int udp_get_file_handle(URLContext *h);
00271
00272 #endif