Miam-Player  0.8.0
A nice music player
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 #define AVIO_SEEKABLE_NORMAL 0x0001
50 typedef struct AVIOInterruptCB {
51  int (*callback)(void*);
52  void *opaque;
54 
70 };
71 
78 typedef struct AVIODirEntry {
79  char *name;
80  int type;
81  int utf8;
83  int64_t size;
86  int64_t access_timestamp;
90  int64_t user_id;
91  int64_t group_id;
92  int64_t filemode;
93 } AVIODirEntry;
94 
95 typedef struct AVIODirContext {
96  struct URLContext *url_context;
98 
133 };
134 
147 typedef struct AVIOContext {
161 
162  /*
163  * The following shows the relationship between buffer, buf_ptr, buf_end, buf_size,
164  * and pos, when reading and when writing (since AVIOContext is used for both):
165  *
166  **********************************************************************************
167  * READING
168  **********************************************************************************
169  *
170  * | buffer_size |
171  * |---------------------------------------|
172  * | |
173  *
174  * buffer buf_ptr buf_end
175  * +---------------+-----------------------+
176  * |/ / / / / / / /|/ / / / / / /| |
177  * read buffer: |/ / consumed / | to be read /| |
178  * |/ / / / / / / /|/ / / / / / /| |
179  * +---------------+-----------------------+
180  *
181  * pos
182  * +-------------------------------------------+-----------------+
183  * input file: | | |
184  * +-------------------------------------------+-----------------+
185  *
186  *
187  **********************************************************************************
188  * WRITING
189  **********************************************************************************
190  *
191  * | buffer_size |
192  * |-------------------------------|
193  * | |
194  *
195  * buffer buf_ptr buf_end
196  * +-------------------+-----------+
197  * |/ / / / / / / / / /| |
198  * write buffer: | / to be flushed / | |
199  * |/ / / / / / / / / /| |
200  * +-------------------+-----------+
201  *
202  * pos
203  * +--------------------------+-----------------------------------+
204  * output file: | | |
205  * +--------------------------+-----------------------------------+
206  *
207  */
208  unsigned char *buffer;
210  unsigned char *buf_ptr;
211  unsigned char *buf_end;
215  void *opaque;
217  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
218  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
219  int64_t (*seek)(void *opaque, int64_t offset, int whence);
220  int64_t pos;
225  unsigned long checksum;
226  unsigned char *checksum_ptr;
227  unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
228  int error;
232  int (*read_pause)(void *opaque, int pause);
238  int64_t (*read_seek)(void *opaque, int stream_index,
239  int64_t timestamp, int flags);
243  int seekable;
244 
249  int64_t maxsize;
250 
256  int direct;
257 
262  int64_t bytes_read;
263 
269 
275 
282 
288 
292  const char *protocol_whitelist;
293 
297  const char *protocol_blacklist;
298 
302  int (*write_data_type)(void *opaque, uint8_t *buf, int buf_size,
303  enum AVIODataMarkerType type, int64_t time);
310 
314  enum AVIODataMarkerType current_type;
315  int64_t last_time;
316 } AVIOContext;
317 
325 const char *avio_find_protocol_name(const char *url);
326 
339 int avio_check(const char *url, int flags);
340 
350 int avpriv_io_move(const char *url_src, const char *url_dst);
351 
358 int avpriv_io_delete(const char *url);
359 
370 int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options);
371 
384 
395 
402 
425  unsigned char *buffer,
426  int buffer_size,
427  int write_flag,
428  void *opaque,
429  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
430  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
431  int64_t (*seek)(void *opaque, int64_t offset, int whence));
432 
433 void avio_w8(AVIOContext *s, int b);
434 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
435 void avio_wl64(AVIOContext *s, uint64_t val);
436 void avio_wb64(AVIOContext *s, uint64_t val);
437 void avio_wl32(AVIOContext *s, unsigned int val);
438 void avio_wb32(AVIOContext *s, unsigned int val);
439 void avio_wl24(AVIOContext *s, unsigned int val);
440 void avio_wb24(AVIOContext *s, unsigned int val);
441 void avio_wl16(AVIOContext *s, unsigned int val);
442 void avio_wb16(AVIOContext *s, unsigned int val);
443 
448 int avio_put_str(AVIOContext *s, const char *str);
449 
457 int avio_put_str16le(AVIOContext *s, const char *str);
458 
466 int avio_put_str16be(AVIOContext *s, const char *str);
467 
478 void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type);
479 
485 #define AVSEEK_SIZE 0x10000
486 
493 #define AVSEEK_FORCE 0x20000
494 
499 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
500 
505 int64_t avio_skip(AVIOContext *s, int64_t offset);
506 
511 static av_always_inline int64_t avio_tell(AVIOContext *s)
512 {
513  return avio_seek(s, 0, SEEK_CUR);
514 }
515 
520 int64_t avio_size(AVIOContext *s);
521 
526 int avio_feof(AVIOContext *s);
527 #if FF_API_URL_FEOF
528 
532 int url_feof(AVIOContext *s);
533 #endif
534 
536 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
537 
548 void avio_flush(AVIOContext *s);
549 
554 int avio_read(AVIOContext *s, unsigned char *buf, int size);
555 
563 int avio_r8 (AVIOContext *s);
564 unsigned int avio_rl16(AVIOContext *s);
565 unsigned int avio_rl24(AVIOContext *s);
566 unsigned int avio_rl32(AVIOContext *s);
567 uint64_t avio_rl64(AVIOContext *s);
568 unsigned int avio_rb16(AVIOContext *s);
569 unsigned int avio_rb24(AVIOContext *s);
570 unsigned int avio_rb32(AVIOContext *s);
571 uint64_t avio_rb64(AVIOContext *s);
588 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
589 
596 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
597 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
598 
599 
606 #define AVIO_FLAG_READ 1
607 #define AVIO_FLAG_WRITE 2
608 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE)
625 #define AVIO_FLAG_NONBLOCK 8
626 
633 #define AVIO_FLAG_DIRECT 0x8000
634 
649 int avio_open(AVIOContext **s, const char *url, int flags);
650 
669 int avio_open2(AVIOContext **s, const char *url, int flags,
670  const AVIOInterruptCB *int_cb, AVDictionary **options);
671 
682 int avio_close(AVIOContext *s);
683 
695 int avio_closep(AVIOContext **s);
696 
697 
705 
715 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
716 
728 const char *avio_enum_protocols(void **opaque, int output);
729 
737 int avio_pause(AVIOContext *h, int pause);
738 
758 int64_t avio_seek_time(AVIOContext *h, int stream_index,
759  int64_t timestamp, int flags);
760 
761 /* Avoid a warning. The header can not be included because it breaks c++. */
762 struct AVBPrint;
763 
770 int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size);
771 
779 int avio_accept(AVIOContext *s, AVIOContext **c);
780 
801 #endif /* AVFORMAT_AVIO_H */
int avio_open(AVIOContext **s, const char *url, int flags)
void avio_wb64(AVIOContext *s, uint64_t val)
unsigned long checksum
Definition: avio.h:225
void avio_wl16(AVIOContext *s, unsigned int val)
int64_t filemode
Definition: avio.h:92
int64_t modification_timestamp
Definition: avio.h:84
int64_t avio_size(AVIOContext *s)
int64_t last_time
Definition: avio.h:315
struct AVIODirEntry AVIODirEntry
int avpriv_io_delete(const char *url)
int avio_put_str16be(AVIOContext *s, const char *str)
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Definition: avio.h:67
Definition: avio.h:64
int write_flag
Definition: avio.h:223
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size)
Definition: avio.h:69
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Definition: avio.h:68
Definition: avio.h:95
int error
Definition: avio.h:228
unsigned int avio_rb16(AVIOContext *s)
Definition: avio.h:50
int writeout_count
Definition: avio.h:274
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen)
int avio_open_dyn_buf(AVIOContext **s)
int ignore_boundary_point
Definition: avio.h:309
Definition: avio.h:132
const AVClass * av_class
Definition: avio.h:160
int64_t group_id
Definition: avio.h:91
int avio_accept(AVIOContext *s, AVIOContext **c)
Definition: avio.h:66
void avio_wl32(AVIOContext *s, unsigned int val)
unsigned int avio_rb32(AVIOContext *s)
struct AVIODirContext AVIODirContext
Definition: avio.h:78
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Definition: avio.h:63
Definition: avio.h:120
unsigned char * buf_end
Definition: avio.h:211
uint64_t avio_rb64(AVIOContext *s)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
const char * protocol_whitelist
Definition: avio.h:292
int avio_read(AVIOContext *s, unsigned char *buf, int size)
int avio_check(const char *url, int flags)
void avio_wl64(AVIOContext *s, uint64_t val)
unsigned char * buf_ptr
Definition: avio.h:210
int buffer_size
Definition: avio.h:209
int64_t bytes_read
Definition: avio.h:262
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))
unsigned int avio_rl32(AVIOContext *s)
int utf8
Definition: avio.h:81
const char * avio_enum_protocols(void **opaque, int output)
int avio_close(AVIOContext *s)
int64_t access_timestamp
Definition: avio.h:86
struct AVDictionary AVDictionary
Definition: dict.h:90
int64_t user_id
Definition: avio.h:90
int64_t maxsize
Definition: avio.h:249
#define av_printf_format(fmtpos, attrpos)
Definition: attributes.h:159
int avio_r8(AVIOContext *s)
void * opaque
Definition: avio.h:52
struct AVIOInterruptCB AVIOInterruptCB
Definition: avio.h:62
Definition: avio.h:127
int void avio_flush(AVIOContext *s)
unsigned int avio_rb24(AVIOContext *s)
void avio_free_directory_entry(AVIODirEntry **entry)
Definition: avio.h:61
AVIODataMarkerType
Definition: avio.h:103
void avio_wb24(AVIOContext *s, unsigned int val)
Definition: log.h:67
int seekable
Definition: avio.h:243
int avpriv_io_move(const char *url_src, const char *url_dst)
int avio_put_str(AVIOContext *s, const char *str)
int direct
Definition: avio.h:256
int max_packet_size
Definition: avio.h:224
struct URLContext * url_context
Definition: avio.h:96
int must_flush
Definition: avio.h:221
int short_seek_threshold
Definition: avio.h:287
void avio_w8(AVIOContext *s, int b)
char * name
Definition: avio.h:79
struct AVIOContext AVIOContext
const char * avio_find_protocol_name(const char *url)
int avio_put_str16le(AVIOContext *s, const char *str)
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
int avio_handshake(AVIOContext *c)
int avio_close_dir(AVIODirContext **s)
const char * protocol_blacklist
Definition: avio.h:297
void avio_wl24(AVIOContext *s, unsigned int val)
int avio_pause(AVIOContext *h, int pause)
void avio_wb16(AVIOContext *s, unsigned int val)
#define attribute_deprecated
Definition: attributes.h:98
int64_t pos
Definition: avio.h:220
int orig_buffer_size
Definition: avio.h:281
int seek_count
Definition: avio.h:268
unsigned int avio_rl16(AVIOContext *s)
Definition: avio.h:147
unsigned char * buffer
Definition: avio.h:208
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen)
AVIODirEntryType
Definition: avio.h:58
int eof_reached
Definition: avio.h:222
int64_t avio_seek_time(AVIOContext *h, int stream_index, int64_t timestamp, int flags)
int64_t status_change_timestamp
Definition: avio.h:88
int avio_read_dir(AVIODirContext *s, AVIODirEntry **next)
Definition: avio.h:114
int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
Definition: avio.h:65
Definition: avio.h:60
void avio_wb32(AVIOContext *s, unsigned int val)
void * opaque
Definition: avio.h:215
#define av_always_inline
Definition: attributes.h:43
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
int avio_feof(AVIOContext *s)
unsigned int avio_rl24(AVIOContext *s)
int type
Definition: avio.h:80
Definition: avio.h:59
unsigned char * checksum_ptr
Definition: avio.h:226
int avio_closep(AVIOContext **s)
uint64_t avio_rl64(AVIOContext *s)
Definition: avio.h:107
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
int64_t size
Definition: avio.h:83