FFmpeg  1.2.4
avio.h
Go to the documentation of this file.
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 #ifndef AVFORMAT_AVIO_H
21 #define AVFORMAT_AVIO_H
22 
29 #include <stdint.h>
30 
31 #include "libavutil/common.h"
32 #include "libavutil/dict.h"
33 #include "libavutil/log.h"
34 
35 #include "libavformat/version.h"
36 
37 
38 #define AVIO_SEEKABLE_NORMAL 0x0001
51 typedef struct AVIOInterruptCB {
52  int (*callback)(void*);
53  void *opaque;
55 
68 typedef struct AVIOContext {
81  const AVClass *av_class;
82  unsigned char *buffer;
83  int buffer_size;
84  unsigned char *buf_ptr;
85  unsigned char *buf_end;
89  void *opaque;
91  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
92  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
93  int64_t (*seek)(void *opaque, int64_t offset, int whence);
94  int64_t pos;
95  int must_flush;
96  int eof_reached;
97  int write_flag;
98  int max_packet_size;
99  unsigned long checksum;
100  unsigned char *checksum_ptr;
101  unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
102  int error;
106  int (*read_pause)(void *opaque, int pause);
112  int64_t (*read_seek)(void *opaque, int stream_index,
113  int64_t timestamp, int flags);
117  int seekable;
118 
123  int64_t maxsize;
124 
130  int direct;
131 
136  int64_t bytes_read;
137 
142  int seek_count;
143 } AVIOContext;
144 
145 /* unbuffered I/O */
146 
159 int avio_check(const char *url, int flags);
160 
180  unsigned char *buffer,
181  int buffer_size,
182  int write_flag,
183  void *opaque,
184  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
185  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
186  int64_t (*seek)(void *opaque, int64_t offset, int whence));
187 
188 void avio_w8(AVIOContext *s, int b);
189 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
190 void avio_wl64(AVIOContext *s, uint64_t val);
191 void avio_wb64(AVIOContext *s, uint64_t val);
192 void avio_wl32(AVIOContext *s, unsigned int val);
193 void avio_wb32(AVIOContext *s, unsigned int val);
194 void avio_wl24(AVIOContext *s, unsigned int val);
195 void avio_wb24(AVIOContext *s, unsigned int val);
196 void avio_wl16(AVIOContext *s, unsigned int val);
197 void avio_wb16(AVIOContext *s, unsigned int val);
198 
203 int avio_put_str(AVIOContext *s, const char *str);
204 
209 int avio_put_str16le(AVIOContext *s, const char *str);
210 
216 #define AVSEEK_SIZE 0x10000
217 
224 #define AVSEEK_FORCE 0x20000
225 
230 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
231 
236 int64_t avio_skip(AVIOContext *s, int64_t offset);
237 
243 {
244  return avio_seek(s, 0, SEEK_CUR);
245 }
246 
251 int64_t avio_size(AVIOContext *s);
252 
257 int url_feof(AVIOContext *s);
258 
260 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
261 
268 void avio_flush(AVIOContext *s);
269 
274 int avio_read(AVIOContext *s, unsigned char *buf, int size);
275 
283 int avio_r8 (AVIOContext *s);
284 unsigned int avio_rl16(AVIOContext *s);
285 unsigned int avio_rl24(AVIOContext *s);
286 unsigned int avio_rl32(AVIOContext *s);
287 uint64_t avio_rl64(AVIOContext *s);
288 unsigned int avio_rb16(AVIOContext *s);
289 unsigned int avio_rb24(AVIOContext *s);
290 unsigned int avio_rb32(AVIOContext *s);
291 uint64_t avio_rb64(AVIOContext *s);
308 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
309 
316 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
317 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
318 
319 
326 #define AVIO_FLAG_READ 1
327 #define AVIO_FLAG_WRITE 2
328 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE)
345 #define AVIO_FLAG_NONBLOCK 8
346 
353 #define AVIO_FLAG_DIRECT 0x8000
354 
368 int avio_open(AVIOContext **s, const char *url, int flags);
369 
387 int avio_open2(AVIOContext **s, const char *url, int flags,
389 
400 int avio_close(AVIOContext *s);
401 
413 int avio_closep(AVIOContext **s);
414 
415 
423 
433 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
434 
446 const char *avio_enum_protocols(void **opaque, int output);
447 
453 int avio_pause(AVIOContext *h, int pause);
454 
472 int64_t avio_seek_time(AVIOContext *h, int stream_index,
473  int64_t timestamp, int flags);
474 
475 #endif /* AVFORMAT_AVIO_H */