World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
avio.h
См. документацию.
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 
40 #define AVIO_SEEKABLE_NORMAL (1 << 0)
41 
45 #define AVIO_SEEKABLE_TIME (1 << 1)
46 
58 typedef struct AVIOInterruptCB {
59  int (*callback)(void*);
60  void *opaque;
62 
78 };
79 
86 typedef struct AVIODirEntry {
87  char *name;
88  int type;
89  int utf8;
101 } AVIODirEntry;
102 
103 typedef struct AVIODirContext {
104  struct URLContext *url_context;
106 
147 };
148 
161 typedef struct AVIOContext {
175 
176  /*
177  * The following shows the relationship between buffer, buf_ptr,
178  * buf_ptr_max, buf_end, buf_size, and pos, when reading and when writing
179  * (since AVIOContext is used for both):
180  *
181  **********************************************************************************
182  * READING
183  **********************************************************************************
184  *
185  * | buffer_size |
186  * |---------------------------------------|
187  * | |
188  *
189  * buffer buf_ptr buf_end
190  * +---------------+-----------------------+
191  * |/ / / / / / / /|/ / / / / / /| |
192  * read buffer: |/ / consumed / | to be read /| |
193  * |/ / / / / / / /|/ / / / / / /| |
194  * +---------------+-----------------------+
195  *
196  * pos
197  * +-------------------------------------------+-----------------+
198  * input file: | | |
199  * +-------------------------------------------+-----------------+
200  *
201  *
202  **********************************************************************************
203  * WRITING
204  **********************************************************************************
205  *
206  * | buffer_size |
207  * |--------------------------------------|
208  * | |
209  *
210  * buf_ptr_max
211  * buffer (buf_ptr) buf_end
212  * +-----------------------+--------------+
213  * |/ / / / / / / / / / / /| |
214  * write buffer: | / / to be flushed / / | |
215  * |/ / / / / / / / / / / /| |
216  * +-----------------------+--------------+
217  * buf_ptr can be in this
218  * due to a backward seek
219  *
220  * pos
221  * +-------------+----------------------------------------------+
222  * output file: | | |
223  * +-------------+----------------------------------------------+
224  *
225  */
226  unsigned char *buffer;
228  unsigned char *buf_ptr;
229  unsigned char *buf_end;
233  void *opaque;
235  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
236  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
237  int64_t (*seek)(void *opaque, int64_t offset, int whence);
242  unsigned long checksum;
243  unsigned char *checksum_ptr;
244  unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
245  int error;
249  int (*read_pause)(void *opaque, int pause);
255  int64_t (*read_seek)(void *opaque, int stream_index,
256  int64_t timestamp, int flags);
260  int seekable;
261 
267 
273  int direct;
274 
280 
286 
292 
299 
305 
309  const char *protocol_whitelist;
310 
314  const char *protocol_blacklist;
315 
319  int (*write_data_type)(void *opaque, uint8_t *buf, int buf_size,
320  enum AVIODataMarkerType type, int64_t time);
327 
333 
338  int (*short_seek_get)(void *opaque);
339 
341 
346  unsigned char *buf_ptr_max;
347 
352 } AVIOContext;
353 
361 const char *avio_find_protocol_name(const char *url);
362 
375 int avio_check(const char *url, int flags);
376 
386 int avpriv_io_move(const char *url_src, const char *url_dst);
387 
394 int avpriv_io_delete(const char *url);
395 
406 int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options);
407 
420 
431 
438 
463  unsigned char *buffer,
464  int buffer_size,
465  int write_flag,
466  void *opaque,
467  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
468  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
469  int64_t (*seek)(void *opaque, int64_t offset, int whence));
470 
478 
479 void avio_w8(AVIOContext *s, int b);
480 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
483 void avio_wl32(AVIOContext *s, unsigned int val);
484 void avio_wb32(AVIOContext *s, unsigned int val);
485 void avio_wl24(AVIOContext *s, unsigned int val);
486 void avio_wb24(AVIOContext *s, unsigned int val);
487 void avio_wl16(AVIOContext *s, unsigned int val);
488 void avio_wb16(AVIOContext *s, unsigned int val);
489 
494 int avio_put_str(AVIOContext *s, const char *str);
495 
503 int avio_put_str16le(AVIOContext *s, const char *str);
504 
512 int avio_put_str16be(AVIOContext *s, const char *str);
513 
525 
531 #define AVSEEK_SIZE 0x10000
532 
539 #define AVSEEK_FORCE 0x20000
540 
546 
552 
557 static av_always_inline int64_t avio_tell(AVIOContext *s)
558 {
559  return avio_seek(s, 0, SEEK_CUR);
560 }
561 
567 
572 int avio_feof(AVIOContext *s);
573 
575 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
576 
587 void avio_flush(AVIOContext *s);
588 
593 int avio_read(AVIOContext *s, unsigned char *buf, int size);
594 
602 int avio_read_partial(AVIOContext *s, unsigned char *buf, int size);
603 
611 int avio_r8 (AVIOContext *s);
612 unsigned int avio_rl16(AVIOContext *s);
613 unsigned int avio_rl24(AVIOContext *s);
614 unsigned int avio_rl32(AVIOContext *s);
616 unsigned int avio_rb16(AVIOContext *s);
617 unsigned int avio_rb24(AVIOContext *s);
618 unsigned int avio_rb32(AVIOContext *s);
636 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
637 
644 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
645 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
646 
647 
654 #define AVIO_FLAG_READ 1
655 #define AVIO_FLAG_WRITE 2
656 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE)
673 #define AVIO_FLAG_NONBLOCK 8
674 
681 #define AVIO_FLAG_DIRECT 0x8000
682 
697 int avio_open(AVIOContext **s, const char *url, int flags);
698 
717 int avio_open2(AVIOContext **s, const char *url, int flags,
718  const AVIOInterruptCB *int_cb, AVDictionary **options);
719 
730 int avio_close(AVIOContext *s);
731 
743 int avio_closep(AVIOContext **s);
744 
745 
753 
764 int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
765 
775 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
776 
788 const char *avio_enum_protocols(void **opaque, int output);
789 
797 int avio_pause(AVIOContext *h, int pause);
798 
818 int64_t avio_seek_time(AVIOContext *h, int stream_index,
819  int64_t timestamp, int flags);
820 
821 /* Avoid a warning. The header can not be included because it breaks c++. */
822 struct AVBPrint;
823 
830 int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size);
831 
840 
861 #endif /* AVFORMAT_AVIO_H */
AVIODirEntry::size
int64_t size
Definition: avio.h:91
AVIOContext::read_seek
int64_t(* read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags)
Definition: avio.h:255
AVIOContext::current_type
enum AVIODataMarkerType current_type
Definition: avio.h:331
s
GLdouble s
Definition: SDL_opengl.h:2063
AVIO_DATA_MARKER_BOUNDARY_POINT
@ AVIO_DATA_MARKER_BOUNDARY_POINT
Definition: avio.h:128
AVIODirEntry::modification_timestamp
int64_t modification_timestamp
Definition: avio.h:92
avio_close
int avio_close(AVIOContext *s)
AVIOContext
struct AVIOContext AVIOContext
AVIODirEntry::group_id
int64_t group_id
Definition: avio.h:99
AVIOContext::opaque
void * opaque
Definition: avio.h:233
avio_context_free
void avio_context_free(AVIOContext **s)
AVIOContext
Definition: avio.h:161
avio_get_str16be
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen)
avio_read_dir
int avio_read_dir(AVIODirContext *s, AVIODirEntry **next)
AVIO_ENTRY_NAMED_PIPE
@ AVIO_ENTRY_NAMED_PIPE
Definition: avio.h:71
AVIOInterruptCB
Definition: avio.h:58
avio_enum_protocols
const char * avio_enum_protocols(void **opaque, int output)
avio_wl64
void avio_wl64(AVIOContext *s, uint64_t val)
AVIOContext::checksum
unsigned long checksum
Definition: avio.h:242
AVIOContext::buf_end
unsigned char * buf_end
Definition: avio.h:229
AVIOContext::read_pause
int(* read_pause)(void *opaque, int pause)
Definition: avio.h:249
AVIOContext::write_data_type
int(* write_data_type)(void *opaque, uint8_t *buf, int buf_size, enum AVIODataMarkerType type, int64_t time)
Definition: avio.h:319
AVIODataMarkerType
AVIODataMarkerType
Definition: avio.h:111
avio_size
int64_t avio_size(AVIOContext *s)
avio_get_dyn_buf
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
AVIO_ENTRY_UNKNOWN
@ AVIO_ENTRY_UNKNOWN
Definition: avio.h:67
AVIOContext::protocol_whitelist
const char * protocol_whitelist
Definition: avio.h:309
avio_wl16
void avio_wl16(AVIOContext *s, unsigned int val)
avio_handshake
int avio_handshake(AVIOContext *c)
avio_write_marker
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
avio_open2
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
int64_t
__int64 int64_t
Definition: alext.h:31
avio_close_dir
int avio_close_dir(AVIODirContext **s)
AVIO_ENTRY_DIRECTORY
@ AVIO_ENTRY_DIRECTORY
Definition: avio.h:70
AVIOContext::ignore_boundary_point
int ignore_boundary_point
Definition: avio.h:326
avio_seek_time
int64_t avio_seek_time(AVIOContext *h, int stream_index, int64_t timestamp, int flags)
AVIO_ENTRY_CHARACTER_DEVICE
@ AVIO_ENTRY_CHARACTER_DEVICE
Definition: avio.h:69
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
Definition: avio.h:557
uint64_t
unsigned __int64 uint64_t
Definition: alext.h:32
avio_rl16
unsigned int avio_rl16(AVIOContext *s)
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1949
avio_close_dyn_buf
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
AVIODirEntry::user_id
int64_t user_id
Definition: avio.h:98
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
AVIODirContext::url_context
struct URLContext * url_context
Definition: avio.h:104
AVIO_ENTRY_SYMBOLIC_LINK
@ AVIO_ENTRY_SYMBOLIC_LINK
Definition: avio.h:72
AVIOContext::error
int error
Definition: avio.h:245
avio_get_str16le
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen)
avio_open_dyn_buf
int avio_open_dyn_buf(AVIOContext **s)
AVIOInterruptCB::opaque
void * opaque
Definition: avio.h:60
avio_free_directory_entry
void avio_free_directory_entry(AVIODirEntry **entry)
avio_read_to_bprint
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size)
AVIOContext::av_class
const AVClass * av_class
Definition: avio.h:174
buffer
EGLContext EGLenum EGLClientBuffer buffer
Definition: SDL_egl.h:952
AVIODirEntry::utf8
int utf8
Definition: avio.h:89
AVIOContext::buf_ptr
unsigned char * buf_ptr
Definition: avio.h:228
AVIODirEntry::access_timestamp
int64_t access_timestamp
Definition: avio.h:94
buf
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: SDL_opengl_glext.h:2483
AVIOContext::bytes_read
int64_t bytes_read
Definition: avio.h:279
AVIODirEntryType
AVIODirEntryType
Definition: avio.h:66
AVIOContext::buf_ptr_max
unsigned char * buf_ptr_max
Definition: avio.h:346
AVIOContext::min_packet_size
int min_packet_size
Definition: avio.h:351
AVIO_DATA_MARKER_TRAILER
@ AVIO_DATA_MARKER_TRAILER
Definition: avio.h:140
AVIOContext::max_packet_size
int max_packet_size
Definition: avio.h:241
AVIODirContext
struct AVIODirContext AVIODirContext
log.h
avio_rb64
uint64_t avio_rb64(AVIOContext *s)
avio_accept
int avio_accept(AVIOContext *s, AVIOContext **c)
AVIO_ENTRY_FILE
@ AVIO_ENTRY_FILE
Definition: avio.h:74
avio_pause
int avio_pause(AVIOContext *h, int pause)
avio_w8
void avio_w8(AVIOContext *s, int b)
AVIODirEntry::filemode
int64_t filemode
Definition: avio.h:100
AVIOContext::buffer_size
int buffer_size
Definition: avio.h:227
AVIODirEntry::name
char * name
Definition: avio.h:87
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
avio_rb24
unsigned int avio_rb24(AVIOContext *s)
type
EGLenum type
Definition: SDL_egl.h:850
avio_get_str
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
AVIODirEntry
struct AVIODirEntry AVIODirEntry
AVIOContext::seek
int64_t(* seek)(void *opaque, int64_t offset, int whence)
Definition: avio.h:237
AVIOContext::maxsize
int64_t maxsize
Definition: avio.h:266
AVClass
Definition: log.h:67
AVIO_DATA_MARKER_SYNC_POINT
@ AVIO_DATA_MARKER_SYNC_POINT
Definition: avio.h:122
AVIOContext::seek_count
int seek_count
Definition: avio.h:285
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
avio_r8
int avio_r8(AVIOContext *s)
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
AVIODirEntry
Definition: avio.h:86
AVIO_ENTRY_SOCKET
@ AVIO_ENTRY_SOCKET
Definition: avio.h:73
AVIOContext::pos
int64_t pos
Definition: avio.h:238
avio_closep
int avio_closep(AVIOContext **s)
AVIOContext::buffer
unsigned char * buffer
Definition: avio.h:226
avio_rl24
unsigned int avio_rl24(AVIOContext *s)
AVIOContext::protocol_blacklist
const char * protocol_blacklist
Definition: avio.h:314
uint8_t
unsigned __int8 uint8_t
Definition: SDL_config.h:35
AVIOContext::short_seek_threshold
int short_seek_threshold
Definition: avio.h:304
common.h
AVIODirEntry::status_change_timestamp
int64_t status_change_timestamp
Definition: avio.h:96
avio_alloc_context
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
AVIOContext::seekable
int seekable
Definition: avio.h:260
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1112
AVIOContext::orig_buffer_size
int orig_buffer_size
Definition: avio.h:298
AVIOContext::written
int64_t written
Definition: avio.h:340
val
GLuint GLfloat * val
Definition: SDL_opengl_glext.h:1495
avio_check
int avio_check(const char *url, int flags)
AVIO_DATA_MARKER_UNKNOWN
@ AVIO_DATA_MARKER_UNKNOWN
Definition: avio.h:135
version.h
AVIO_ENTRY_BLOCK_DEVICE
@ AVIO_ENTRY_BLOCK_DEVICE
Definition: avio.h:68
avpriv_io_delete
int avpriv_io_delete(const char *url)
avpriv_io_move
int avpriv_io_move(const char *url_src, const char *url_dst)
c
const GLubyte * c
Definition: SDL_opengl_glext.h:11096
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
avio_rb16
unsigned int avio_rb16(AVIOContext *s)
AVIOContext::checksum_ptr
unsigned char * checksum_ptr
Definition: avio.h:243
dict.h
AVIOContext::direct
int direct
Definition: avio.h:273
AVIODirEntry::type
int type
Definition: avio.h:88
avio_printf
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
avio_put_str16be
int avio_put_str16be(AVIOContext *s, const char *str)
flags
EGLSyncKHR EGLint flags
Definition: SDL_egl.h:898
AVIO_DATA_MARKER_HEADER
@ AVIO_DATA_MARKER_HEADER
Definition: avio.h:115
AVDictionary
struct AVDictionary AVDictionary
Definition: dict.h:86
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
avio_open
int avio_open(AVIOContext **s, const char *url, int flags)
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
AVIO_ENTRY_WORKGROUP
@ AVIO_ENTRY_WORKGROUP
Definition: avio.h:77
AVIOContext::last_time
int64_t last_time
Definition: avio.h:332
avio_wb64
void avio_wb64(AVIOContext *s, uint64_t val)
AVIOInterruptCB
struct AVIOInterruptCB AVIOInterruptCB
avio_find_protocol_name
const char * avio_find_protocol_name(const char *url)
AVIOContext::read_packet
int(* read_packet)(void *opaque, uint8_t *buf, int buf_size)
Definition: avio.h:235
AVIOContext::eof_reached
int eof_reached
Definition: avio.h:239
AVIOInterruptCB::callback
int(* callback)(void *)
Definition: avio.h:59
AVIOContext::write_packet
int(* write_packet)(void *opaque, uint8_t *buf, int buf_size)
Definition: avio.h:236
avio_wb24
void avio_wb24(AVIOContext *s, unsigned int val)
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:540
avio_flush
int void avio_flush(AVIOContext *s)
offset
GLintptr offset
Definition: SDL_opengl_glext.h:541
AVIOContext::short_seek_get
int(* short_seek_get)(void *opaque)
Definition: avio.h:338
avio_rl64
uint64_t avio_rl64(AVIOContext *s)
AVIO_ENTRY_SERVER
@ AVIO_ENTRY_SERVER
Definition: avio.h:75
avio_put_str16le
int avio_put_str16le(AVIOContext *s, const char *str)
avio_wb16
void avio_wb16(AVIOContext *s, unsigned int val)
avio_wl24
void avio_wl24(AVIOContext *s, unsigned int val)
AVIOContext::write_flag
int write_flag
Definition: avio.h:240
avio_open_dir
int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
avio_put_str
int avio_put_str(AVIOContext *s, const char *str)
avio_read_partial
int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
AVIOContext::update_checksum
unsigned long(* update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size)
Definition: avio.h:244
AVIODirContext
Definition: avio.h:103
AVIO_ENTRY_SHARE
@ AVIO_ENTRY_SHARE
Definition: avio.h:76
AVIOContext::writeout_count
int writeout_count
Definition: avio.h:291
avio_feof
int avio_feof(AVIOContext *s)
AVIO_DATA_MARKER_FLUSH_POINT
@ AVIO_DATA_MARKER_FLUSH_POINT
Definition: avio.h:146