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