set pict_type & key_frame on decoding too
[libav.git] / libav / avio.h
CommitLineData
f031df23
FB
1#ifndef AVIO_H
2#define AVIO_H
3
de6d9b64
FB
4/* output byte stream handling */
5
8be1c656 6typedef INT64 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
FB
15 void *priv_data;
16};
17
de6d9b64
FB
18typedef struct URLContext URLContext;
19
20typedef struct URLPollEntry {
21 URLContext *handle;
22 int events;
23 int revents;
24} URLPollEntry;
25
26#define URL_RDONLY 0
27#define URL_WRONLY 1
f031df23
FB
28#define URL_RDWR 2
29
de6d9b64
FB
30int url_open(URLContext **h, const char *filename, int flags);
31int url_read(URLContext *h, unsigned char *buf, int size);
32int url_write(URLContext *h, unsigned char *buf, int size);
33offset_t url_seek(URLContext *h, offset_t pos, int whence);
de6d9b64
FB
34int url_close(URLContext *h);
35int url_exist(const char *filename);
36offset_t url_filesize(URLContext *h);
f031df23 37int url_get_max_packet_size(URLContext *h);
de6d9b64
FB
38/* not implemented */
39int url_poll(URLPollEntry *poll_table, int n, int timeout);
40
41typedef 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);
de6d9b64
FB
48 struct URLProtocol *next;
49} URLProtocol;
50
51extern URLProtocol *first_protocol;
52
53int register_protocol(URLProtocol *protocol);
54
55typedef 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;
f031df23 68 int max_packet_size;
de6d9b64
FB
69} ByteIOContext;
70
71int 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
80void put_byte(ByteIOContext *s, int b);
81void put_buffer(ByteIOContext *s, unsigned char *buf, int size);
8be1c656
FB
82void put_le64(ByteIOContext *s, UINT64 val);
83void put_be64(ByteIOContext *s, UINT64 val);
de6d9b64
FB
84void put_le32(ByteIOContext *s, unsigned int val);
85void put_be32(ByteIOContext *s, unsigned int val);
86void put_le16(ByteIOContext *s, unsigned int val);
87void put_be16(ByteIOContext *s, unsigned int val);
88void put_tag(ByteIOContext *s, char *tag);
89
90offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
91void url_fskip(ByteIOContext *s, offset_t offset);
92offset_t url_ftell(ByteIOContext *s);
93int url_feof(ByteIOContext *s);
94
f031df23
FB
95#define URL_EOF (-1)
96int url_fgetc(ByteIOContext *s);
97int url_fprintf(ByteIOContext *s, const char *fmt, ...);
98char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
99
de6d9b64
FB
100void put_flush_packet(ByteIOContext *s);
101
102int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
103int get_byte(ByteIOContext *s);
104unsigned int get_le32(ByteIOContext *s);
8be1c656 105UINT64 get_le64(ByteIOContext *s);
de6d9b64
FB
106unsigned int get_le16(ByteIOContext *s);
107
108unsigned int get_be16(ByteIOContext *s);
109unsigned int get_be32(ByteIOContext *s);
8be1c656 110UINT64 get_be64(ByteIOContext *s);
de6d9b64 111
7ac13f0c 112static inline int url_is_streamed(ByteIOContext *s)
de6d9b64
FB
113{
114 return s->is_streamed;
115}
de6d9b64
FB
116
117int url_fdopen(ByteIOContext *s, URLContext *h);
118int url_setbufsize(ByteIOContext *s, int buf_size);
119int url_fopen(ByteIOContext *s, const char *filename, int flags);
120int url_fclose(ByteIOContext *s);
121URLContext *url_fileno(ByteIOContext *s);
f031df23 122int url_fget_max_packet_size(ByteIOContext *s);
de6d9b64
FB
123
124int url_open_buf(ByteIOContext *s, UINT8 *buf, int buf_size, int flags);
125int url_close_buf(ByteIOContext *s);
126
f031df23
FB
127int url_open_dyn_buf(ByteIOContext *s);
128int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
129int url_close_dyn_buf(ByteIOContext *s, UINT8 **pbuffer);
130
de6d9b64
FB
131/* file.c */
132extern URLProtocol file_protocol;
133extern URLProtocol pipe_protocol;
134
135/* udp.c */
136extern URLProtocol udp_protocol;
f031df23
FB
137int udp_set_remote_url(URLContext *h, const char *uri);
138int udp_get_local_port(URLContext *h);
139int udp_get_file_handle(URLContext *h);
140
141/* tcp.c */
142extern URLProtocol tcp_protocol;
de6d9b64
FB
143
144/* http.c */
145extern URLProtocol http_protocol;
f031df23
FB
146
147#endif
148