Statistics
| Branch: | Revision:

ffmpeg / libav / avio.h @ 41568e4a

History | View | Annotate | Download (4.86 KB)

1 f031df23 Fabrice Bellard
#ifndef AVIO_H
2
#define AVIO_H
3
4 de6d9b64 Fabrice Bellard
/* output byte stream handling */
5
6 8be1c656 Fabrice Bellard
typedef INT64 offset_t;
7 de6d9b64 Fabrice Bellard
8
/* unbuffered I/O */
9
10
struct URLContext {
11
    struct URLProtocol *prot;
12
    int flags;        
13
    int is_streamed;  /* true if streamed (no seek possible), default = false */
14 f031df23 Fabrice Bellard
    int max_packet_size;  /* if non zero, the stream is packetized with this max packet size */
15 de6d9b64 Fabrice Bellard
    void *priv_data;
16
};
17
18
typedef struct URLContext URLContext;
19
20
typedef struct URLPollEntry {
21
    URLContext *handle;
22
    int events;
23
    int revents;
24
} URLPollEntry;
25
26
#define URL_RDONLY 0
27
#define URL_WRONLY 1
28 f031df23 Fabrice Bellard
#define URL_RDWR   2
29
30 de6d9b64 Fabrice Bellard
int url_open(URLContext **h, const char *filename, int flags);
31
int url_read(URLContext *h, unsigned char *buf, int size);
32
int url_write(URLContext *h, unsigned char *buf, int size);
33
offset_t url_seek(URLContext *h, offset_t pos, int whence);
34
int url_close(URLContext *h);
35
int url_exist(const char *filename);
36
offset_t url_filesize(URLContext *h);
37 f031df23 Fabrice Bellard
int url_get_max_packet_size(URLContext *h);
38 de6d9b64 Fabrice Bellard
/* not implemented */
39
int url_poll(URLPollEntry *poll_table, int n, int timeout);
40
41
typedef struct URLProtocol {
42
    const char *name;
43
    int (*url_open)(URLContext *h, const char *filename, int flags);
44
    int (*url_read)(URLContext *h, unsigned char *buf, int size);
45
    int (*url_write)(URLContext *h, unsigned char *buf, int size);
46
    offset_t (*url_seek)(URLContext *h, offset_t pos, int whence);
47
    int (*url_close)(URLContext *h);
48
    struct URLProtocol *next;
49
} URLProtocol;
50
51
extern URLProtocol *first_protocol;
52
53
int register_protocol(URLProtocol *protocol);
54
55
typedef struct {
56
    unsigned char *buffer;
57
    int buffer_size;
58
    unsigned char *buf_ptr, *buf_end;
59
    void *opaque;
60
    int (*read_packet)(void *opaque, UINT8 *buf, int buf_size);
61
    void (*write_packet)(void *opaque, UINT8 *buf, int buf_size);
62
    int (*seek)(void *opaque, offset_t offset, int whence);
63
    offset_t pos; /* position in the file of the current buffer */
64
    int must_flush; /* true if the next seek should flush */
65
    int eof_reached; /* true if eof reached */
66
    int write_flag;  /* true if open for writing */
67
    int is_streamed;
68 f031df23 Fabrice Bellard
    int max_packet_size;
69 de6d9b64 Fabrice Bellard
} ByteIOContext;
70
71
int init_put_byte(ByteIOContext *s,
72
                  unsigned char *buffer,
73
                  int buffer_size,
74
                  int write_flag,
75
                  void *opaque,
76
                  int (*read_packet)(void *opaque, UINT8 *buf, int buf_size),
77
                  void (*write_packet)(void *opaque, UINT8 *buf, int buf_size),
78
                  int (*seek)(void *opaque, offset_t offset, int whence));
79
80
void put_byte(ByteIOContext *s, int b);
81 75bdb984 Philip Gladstone
void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
82 8be1c656 Fabrice Bellard
void put_le64(ByteIOContext *s, UINT64 val);
83
void put_be64(ByteIOContext *s, UINT64 val);
84 de6d9b64 Fabrice Bellard
void put_le32(ByteIOContext *s, unsigned int val);
85
void put_be32(ByteIOContext *s, unsigned int val);
86
void put_le16(ByteIOContext *s, unsigned int val);
87
void put_be16(ByteIOContext *s, unsigned int val);
88
void put_tag(ByteIOContext *s, char *tag);
89
90 3b4b29dc Fabrice Bellard
void put_be64_double(ByteIOContext *s, double val);
91
void put_strz(ByteIOContext *s, const char *buf);
92 75bdb984 Philip Gladstone
93 de6d9b64 Fabrice Bellard
offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
94
void url_fskip(ByteIOContext *s, offset_t offset);
95
offset_t url_ftell(ByteIOContext *s);
96
int url_feof(ByteIOContext *s);
97
98 f031df23 Fabrice Bellard
#define URL_EOF (-1)
99
int url_fgetc(ByteIOContext *s);
100
int url_fprintf(ByteIOContext *s, const char *fmt, ...);
101
char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
102
103 de6d9b64 Fabrice Bellard
void put_flush_packet(ByteIOContext *s);
104
105
int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
106
int get_byte(ByteIOContext *s);
107
unsigned int get_le32(ByteIOContext *s);
108 8be1c656 Fabrice Bellard
UINT64 get_le64(ByteIOContext *s);
109 de6d9b64 Fabrice Bellard
unsigned int get_le16(ByteIOContext *s);
110
111 3b4b29dc Fabrice Bellard
double get_be64_double(ByteIOContext *s);
112
char *get_strz(ByteIOContext *s, char *buf, int maxlen);
113 de6d9b64 Fabrice Bellard
unsigned int get_be16(ByteIOContext *s);
114
unsigned int get_be32(ByteIOContext *s);
115 8be1c656 Fabrice Bellard
UINT64 get_be64(ByteIOContext *s);
116 de6d9b64 Fabrice Bellard
117 7ac13f0c Philip Gladstone
static inline int url_is_streamed(ByteIOContext *s)
118 de6d9b64 Fabrice Bellard
{
119
    return s->is_streamed;
120
}
121
122
int url_fdopen(ByteIOContext *s, URLContext *h);
123
int url_setbufsize(ByteIOContext *s, int buf_size);
124
int url_fopen(ByteIOContext *s, const char *filename, int flags);
125
int url_fclose(ByteIOContext *s);
126
URLContext *url_fileno(ByteIOContext *s);
127 f031df23 Fabrice Bellard
int url_fget_max_packet_size(ByteIOContext *s);
128 de6d9b64 Fabrice Bellard
129
int url_open_buf(ByteIOContext *s, UINT8 *buf, int buf_size, int flags);
130
int url_close_buf(ByteIOContext *s);
131
132 f031df23 Fabrice Bellard
int url_open_dyn_buf(ByteIOContext *s);
133
int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
134
int url_close_dyn_buf(ByteIOContext *s, UINT8 **pbuffer);
135
136 de6d9b64 Fabrice Bellard
/* file.c */
137
extern URLProtocol file_protocol;
138
extern URLProtocol pipe_protocol;
139
140
/* udp.c */
141
extern URLProtocol udp_protocol;
142 f031df23 Fabrice Bellard
int udp_set_remote_url(URLContext *h, const char *uri);
143
int udp_get_local_port(URLContext *h);
144
int udp_get_file_handle(URLContext *h);
145
146
/* tcp.c  */
147
extern URLProtocol tcp_protocol;
148 de6d9b64 Fabrice Bellard
149
/* http.c */
150
extern URLProtocol http_protocol;
151 f031df23 Fabrice Bellard
152
#endif