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
00039 struct URLContext {
00040 struct URLProtocol *prot;
00041 int flags;
00042 int is_streamed;
00043 int max_packet_size;
00044 void *priv_data;
00045 char *filename;
00046 };
00047
00048 typedef struct URLContext URLContext;
00049
00050 typedef struct URLPollEntry {
00051 URLContext *handle;
00052 int events;
00053 int revents;
00054 } URLPollEntry;
00055
00056 #define URL_RDONLY 0
00057 #define URL_WRONLY 1
00058 #define URL_RDWR 2
00059
00060 typedef int URLInterruptCB(void);
00061
00062 int url_open(URLContext **h, const char *filename, int flags);
00063 int url_read(URLContext *h, unsigned char *buf, int size);
00064 int url_write(URLContext *h, unsigned char *buf, int size);
00065 offset_t url_seek(URLContext *h, offset_t pos, int whence);
00066 int url_close(URLContext *h);
00067 int url_exist(const char *filename);
00068 offset_t url_filesize(URLContext *h);
00069
00078 int url_get_max_packet_size(URLContext *h);
00079 void url_get_filename(URLContext *h, char *buf, int buf_size);
00080
00087 void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
00088
00089
00090 int url_poll(URLPollEntry *poll_table, int n, int timeout);
00091
00097 int av_url_read_pause(URLContext *h, int pause);
00098
00116 offset_t av_url_read_seek(URLContext *h,
00117 int stream_index, int64_t timestamp, int flags);
00118
00124 #define AVSEEK_SIZE 0x10000
00125
00126 typedef struct URLProtocol {
00127 const char *name;
00128 int (*url_open)(URLContext *h, const char *filename, int flags);
00129 int (*url_read)(URLContext *h, unsigned char *buf, int size);
00130 int (*url_write)(URLContext *h, unsigned char *buf, int size);
00131 offset_t (*url_seek)(URLContext *h, offset_t pos, int whence);
00132 int (*url_close)(URLContext *h);
00133 struct URLProtocol *next;
00134 int (*url_read_pause)(URLContext *h, int pause);
00135 offset_t (*url_read_seek)(URLContext *h,
00136 int stream_index, int64_t timestamp, int flags);
00137 } URLProtocol;
00138
00139 extern URLProtocol *first_protocol;
00140 extern URLInterruptCB *url_interrupt_cb;
00141
00142 URLProtocol *av_protocol_next(URLProtocol *p);
00143
00144 int register_protocol(URLProtocol *protocol);
00145
00153 typedef struct {
00154 unsigned char *buffer;
00155 int buffer_size;
00156 unsigned char *buf_ptr, *buf_end;
00157 void *opaque;
00158 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
00159 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
00160 offset_t (*seek)(void *opaque, offset_t offset, int whence);
00161 offset_t pos;
00162 int must_flush;
00163 int eof_reached;
00164 int write_flag;
00165 int is_streamed;
00166 int max_packet_size;
00167 unsigned long checksum;
00168 unsigned char *checksum_ptr;
00169 unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
00170 int error;
00171 int (*read_pause)(void *opaque, int pause);
00172 offset_t (*read_seek)(void *opaque,
00173 int stream_index, int64_t timestamp, int flags);
00174 } ByteIOContext;
00175
00176 int init_put_byte(ByteIOContext *s,
00177 unsigned char *buffer,
00178 int buffer_size,
00179 int write_flag,
00180 void *opaque,
00181 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00182 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00183 offset_t (*seek)(void *opaque, offset_t offset, int whence));
00184 ByteIOContext *av_alloc_put_byte(
00185 unsigned char *buffer,
00186 int buffer_size,
00187 int write_flag,
00188 void *opaque,
00189 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00190 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00191 offset_t (*seek)(void *opaque, offset_t offset, int whence));
00192
00193 void put_byte(ByteIOContext *s, int b);
00194 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
00195 void put_le64(ByteIOContext *s, uint64_t val);
00196 void put_be64(ByteIOContext *s, uint64_t val);
00197 void put_le32(ByteIOContext *s, unsigned int val);
00198 void put_be32(ByteIOContext *s, unsigned int val);
00199 void put_le24(ByteIOContext *s, unsigned int val);
00200 void put_be24(ByteIOContext *s, unsigned int val);
00201 void put_le16(ByteIOContext *s, unsigned int val);
00202 void put_be16(ByteIOContext *s, unsigned int val);
00203 void put_tag(ByteIOContext *s, const char *tag);
00204
00205 void put_strz(ByteIOContext *s, const char *buf);
00206
00207 offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
00208 void url_fskip(ByteIOContext *s, offset_t offset);
00209 offset_t url_ftell(ByteIOContext *s);
00210 offset_t url_fsize(ByteIOContext *s);
00211 int url_feof(ByteIOContext *s);
00212 int url_ferror(ByteIOContext *s);
00213
00214 int av_url_read_fpause(ByteIOContext *h, int pause);
00215 offset_t av_url_read_fseek(ByteIOContext *h,
00216 int stream_index, int64_t timestamp, int flags);
00217
00218 #define URL_EOF (-1)
00219
00220 int url_fgetc(ByteIOContext *s);
00221
00223 #ifdef __GNUC__
00224 int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
00225 #else
00226 int url_fprintf(ByteIOContext *s, const char *fmt, ...);
00227 #endif
00228
00231 char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
00232
00233 void put_flush_packet(ByteIOContext *s);
00234
00235 int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
00236 int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
00237
00240 int get_byte(ByteIOContext *s);
00241 unsigned int get_le24(ByteIOContext *s);
00242 unsigned int get_le32(ByteIOContext *s);
00243 uint64_t get_le64(ByteIOContext *s);
00244 unsigned int get_le16(ByteIOContext *s);
00245
00246 char *get_strz(ByteIOContext *s, char *buf, int maxlen);
00247 unsigned int get_be16(ByteIOContext *s);
00248 unsigned int get_be24(ByteIOContext *s);
00249 unsigned int get_be32(ByteIOContext *s);
00250 uint64_t get_be64(ByteIOContext *s);
00251
00252 uint64_t ff_get_v(ByteIOContext *bc);
00253
00254 static inline int url_is_streamed(ByteIOContext *s)
00255 {
00256 return s->is_streamed;
00257 }
00258
00261 int url_fdopen(ByteIOContext **s, URLContext *h);
00262
00264 int url_setbufsize(ByteIOContext *s, int buf_size);
00269 int url_resetbuf(ByteIOContext *s, int flags);
00270
00273 int url_fopen(ByteIOContext **s, const char *filename, int flags);
00274 int url_fclose(ByteIOContext *s);
00275 URLContext *url_fileno(ByteIOContext *s);
00276
00285 int url_fget_max_packet_size(ByteIOContext *s);
00286
00287 int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags);
00288
00290 int url_close_buf(ByteIOContext *s);
00291
00298 int url_open_dyn_buf(ByteIOContext **s);
00299
00309 int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size);
00310
00318 int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
00319
00320 unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len);
00321 unsigned long get_checksum(ByteIOContext *s);
00322 void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum);
00323
00324
00325 int udp_set_remote_url(URLContext *h, const char *uri);
00326 int udp_get_local_port(URLContext *h);
00327 int udp_get_file_handle(URLContext *h);
00328
00329 #endif