ffmpeg / libavformat / avio.h @ e731b8d8
History | View | Annotate | Download (21.1 KB)
1 | 04d7f601 | Diego Biurrun | /*
|
---|---|---|---|
2 | * copyright (c) 2001 Fabrice Bellard
|
||
3 | *
|
||
4 | b78e7197 | Diego Biurrun | * This file is part of FFmpeg.
|
5 | *
|
||
6 | * FFmpeg is free software; you can redistribute it and/or
|
||
7 | 04d7f601 | Diego Biurrun | * modify it under the terms of the GNU Lesser General Public
|
8 | * License as published by the Free Software Foundation; either
|
||
9 | b78e7197 | Diego Biurrun | * version 2.1 of the License, or (at your option) any later version.
|
10 | 04d7f601 | Diego Biurrun | *
|
11 | b78e7197 | Diego Biurrun | * FFmpeg is distributed in the hope that it will be useful,
|
12 | 04d7f601 | Diego Biurrun | * 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 | b78e7197 | Diego Biurrun | * License along with FFmpeg; if not, write to the Free Software
|
18 | 04d7f601 | Diego Biurrun | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
19 | */
|
||
20 | 98790382 | Stefano Sabatini | #ifndef AVFORMAT_AVIO_H
|
21 | #define AVFORMAT_AVIO_H
|
||
22 | f031df23 | Fabrice Bellard | |
23 | aafe9b63 | Stefano Sabatini | /**
|
24 | ba87f080 | Diego Biurrun | * @file
|
25 | aafe9b63 | Stefano Sabatini | * unbuffered I/O operations
|
26 | 3f4c2bf9 | Stefano Sabatini | *
|
27 | * @warning This file has to be considered an internal but installed
|
||
28 | * header, so it should not be directly included in your projects.
|
||
29 | aafe9b63 | Stefano Sabatini | */
|
30 | |||
31 | 99545457 | Måns Rullgård | #include <stdint.h> |
32 | |||
33 | 30f68128 | Diego Biurrun | #include "libavutil/common.h" |
34 | ed8d5766 | Martin Storsjö | #include "libavutil/log.h" |
35 | 30f68128 | Diego Biurrun | |
36 | 50196a98 | Anton Khirnov | #include "libavformat/version.h" |
37 | |||
38 | de6d9b64 | Fabrice Bellard | /* unbuffered I/O */
|
39 | |||
40 | 1308f273 | Michael Niedermayer | /**
|
41 | * URL Context.
|
||
42 | * New fields can be added to the end with minor version bumps.
|
||
43 | 8bfb108b | Diego Biurrun | * Removal, reordering and changes to existing fields require a major
|
44 | 1308f273 | Michael Niedermayer | * version bump.
|
45 | 8bfb108b | Diego Biurrun | * sizeof(URLContext) must not be used outside libav*.
|
46 | 1308f273 | Michael Niedermayer | */
|
47 | 597b4b3f | Stefano Sabatini | typedef struct URLContext { |
48 | 404eba44 | Aurelien Jacobs | #if FF_API_URL_CLASS
|
49 | 5acef35f | Björn Axelsson | const AVClass *av_class; ///< information for av_log(). Set by url_open(). |
50 | #endif
|
||
51 | de6d9b64 | Fabrice Bellard | struct URLProtocol *prot;
|
52 | 115329f1 | Diego Biurrun | int flags;
|
53 | c3316802 | Panagiotis Issaris | int is_streamed; /**< true if streamed (no seek possible), default = false */ |
54 | int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ |
||
55 | de6d9b64 | Fabrice Bellard | void *priv_data;
|
56 | 725b3da9 | Stefano Sabatini | char *filename; /**< specified URL */ |
57 | ffbb289a | Martin Storsjö | int is_connected;
|
58 | 597b4b3f | Stefano Sabatini | } URLContext; |
59 | de6d9b64 | Fabrice Bellard | |
60 | typedef struct URLPollEntry { |
||
61 | URLContext *handle; |
||
62 | int events;
|
||
63 | int revents;
|
||
64 | } URLPollEntry; |
||
65 | |||
66 | fe174fc8 | Nicolas George | /**
|
67 | * @defgroup open_modes URL open modes
|
||
68 | * The flags argument to url_open and cosins must be one of the following
|
||
69 | * constants, optionally ORed with other flags.
|
||
70 | * @{
|
||
71 | */
|
||
72 | #define URL_RDONLY 0 /**< read-only */ |
||
73 | #define URL_WRONLY 1 /**< write-only */ |
||
74 | #define URL_RDWR 2 /**< read-write */ |
||
75 | /**
|
||
76 | * @}
|
||
77 | */
|
||
78 | |||
79 | /**
|
||
80 | * Use non-blocking mode.
|
||
81 | * If this flag is set, operations on the context will return
|
||
82 | * AVERROR(EAGAIN) if they can not be performed immediately.
|
||
83 | * If this flag is not set, operations on the context will never return
|
||
84 | * AVERROR(EAGAIN).
|
||
85 | * Note that this flag does not affect the opening/connecting of the
|
||
86 | * context. Connecting a protocol will always block if necessary (e.g. on
|
||
87 | * network protocols) but never hang (e.g. on busy devices).
|
||
88 | * Warning: non-blocking protocols is work-in-progress; this flag may be
|
||
89 | * silently ignored.
|
||
90 | */
|
||
91 | #define URL_FLAG_NONBLOCK 4 |
||
92 | f031df23 | Fabrice Bellard | |
93 | 019ac05a | Fabrice Bellard | typedef int URLInterruptCB(void); |
94 | |||
95 | 333146dd | Stefano Sabatini | /**
|
96 | 49bd8e4b | Måns Rullgård | * Create a URLContext for accessing to the resource indicated by
|
97 | * url, and open it using the URLProtocol up.
|
||
98 | 333146dd | Stefano Sabatini | *
|
99 | * @param puc pointer to the location where, in case of success, the
|
||
100 | * function puts the pointer to the created URLContext
|
||
101 | 725b3da9 | Stefano Sabatini | * @param flags flags which control how the resource indicated by url
|
102 | 333146dd | Stefano Sabatini | * is to be opened
|
103 | * @return 0 in case of success, a negative value corresponding to an
|
||
104 | * AVERROR code in case of failure
|
||
105 | */
|
||
106 | ba99cfc2 | Ronald S. Bultje | int url_open_protocol (URLContext **puc, struct URLProtocol *up, |
107 | 725b3da9 | Stefano Sabatini | const char *url, int flags); |
108 | 333146dd | Stefano Sabatini | |
109 | b0634fd1 | Stefano Sabatini | /**
|
110 | 49bd8e4b | Måns Rullgård | * Create a URLContext for accessing to the resource indicated by
|
111 | * url, but do not initiate the connection yet.
|
||
112 | ffbb289a | Martin Storsjö | *
|
113 | * @param puc pointer to the location where, in case of success, the
|
||
114 | * function puts the pointer to the created URLContext
|
||
115 | * @param flags flags which control how the resource indicated by url
|
||
116 | * is to be opened
|
||
117 | * @return 0 in case of success, a negative value corresponding to an
|
||
118 | * AVERROR code in case of failure
|
||
119 | */
|
||
120 | int url_alloc(URLContext **h, const char *url, int flags); |
||
121 | |||
122 | /**
|
||
123 | * Connect an URLContext that has been allocated by url_alloc
|
||
124 | */
|
||
125 | int url_connect(URLContext *h);
|
||
126 | |||
127 | /**
|
||
128 | 49bd8e4b | Måns Rullgård | * Create an URLContext for accessing to the resource indicated by
|
129 | * url, and open it.
|
||
130 | b0634fd1 | Stefano Sabatini | *
|
131 | * @param puc pointer to the location where, in case of success, the
|
||
132 | * function puts the pointer to the created URLContext
|
||
133 | * @param flags flags which control how the resource indicated by url
|
||
134 | * is to be opened
|
||
135 | * @return 0 in case of success, a negative value corresponding to an
|
||
136 | * AVERROR code in case of failure
|
||
137 | */
|
||
138 | 725b3da9 | Stefano Sabatini | int url_open(URLContext **h, const char *url, int flags); |
139 | 1f8ad15a | Stefano Sabatini | |
140 | /**
|
||
141 | 49bd8e4b | Måns Rullgård | * Read up to size bytes from the resource accessed by h, and store
|
142 | 1f8ad15a | Stefano Sabatini | * the read bytes in buf.
|
143 | *
|
||
144 | * @return The number of bytes actually read, or a negative value
|
||
145 | * corresponding to an AVERROR code in case of error. A value of zero
|
||
146 | * indicates that it is not possible to read more from the accessed
|
||
147 | * resource (except if the value of the size argument is also zero).
|
||
148 | */
|
||
149 | de6d9b64 | Fabrice Bellard | int url_read(URLContext *h, unsigned char *buf, int size); |
150 | 1f8ad15a | Stefano Sabatini | |
151 | ddb901b7 | Reimar Döffinger | /**
|
152 | * Read as many bytes as possible (up to size), calling the
|
||
153 | * read function multiple times if necessary.
|
||
154 | * This makes special short-read handling in applications
|
||
155 | * unnecessary, if the return value is < size then it is
|
||
156 | * certain there was either an error or the end of file was reached.
|
||
157 | */
|
||
158 | 0e848977 | Kostya Shishkov | int url_read_complete(URLContext *h, unsigned char *buf, int size); |
159 | 267ff3ae | Stefano Sabatini | |
160 | /**
|
||
161 | * Write size bytes from buf to the resource accessed by h.
|
||
162 | *
|
||
163 | * @return the number of bytes actually written, or a negative value
|
||
164 | * corresponding to an AVERROR code in case of failure
|
||
165 | */
|
||
166 | 27241cbf | Martin Storsjö | int url_write(URLContext *h, const unsigned char *buf, int size); |
167 | 9bee2459 | Stefano Sabatini | |
168 | /**
|
||
169 | 85c15960 | Stefano Sabatini | * Passing this as the "whence" parameter to a seek function causes it to
|
170 | * return the filesize without seeking anywhere. Supporting this is optional.
|
||
171 | * If it is not supported then the seek function will return <0.
|
||
172 | */
|
||
173 | #define AVSEEK_SIZE 0x10000 |
||
174 | |||
175 | /**
|
||
176 | 49bd8e4b | Måns Rullgård | * Change the position that will be used by the next read/write
|
177 | 9bee2459 | Stefano Sabatini | * operation on the resource accessed by h.
|
178 | *
|
||
179 | * @param pos specifies the new position to set
|
||
180 | * @param whence specifies how pos should be interpreted, it must be
|
||
181 | * one of SEEK_SET (seek from the beginning), SEEK_CUR (seek from the
|
||
182 | * current position), SEEK_END (seek from the end), or AVSEEK_SIZE
|
||
183 | * (return the filesize of the requested resource, pos is ignored).
|
||
184 | * @return a negative value corresponding to an AVERROR code in case
|
||
185 | * of failure, or the resulting file position, measured in bytes from
|
||
186 | * the beginning of the file. You can use this feature together with
|
||
187 | * SEEK_CUR to read the current file position.
|
||
188 | */
|
||
189 | bc5c918e | Diego Biurrun | int64_t url_seek(URLContext *h, int64_t pos, int whence);
|
190 | f1f78a9d | Stefano Sabatini | |
191 | /**
|
||
192 | 49bd8e4b | Måns Rullgård | * Close the resource accessed by the URLContext h, and free the
|
193 | f1f78a9d | Stefano Sabatini | * memory used by it.
|
194 | *
|
||
195 | * @return a negative value if an error condition occurred, 0
|
||
196 | * otherwise
|
||
197 | */
|
||
198 | de6d9b64 | Fabrice Bellard | int url_close(URLContext *h);
|
199 | f1f78a9d | Stefano Sabatini | |
200 | 8a36b59b | Stefano Sabatini | /**
|
201 | 49bd8e4b | Måns Rullgård | * Return a non-zero value if the resource indicated by url
|
202 | 8a36b59b | Stefano Sabatini | * exists, 0 otherwise.
|
203 | */
|
||
204 | 725b3da9 | Stefano Sabatini | int url_exist(const char *url); |
205 | 8a36b59b | Stefano Sabatini | |
206 | f3f5eb6e | Stefano Sabatini | /**
|
207 | * Return the filesize of the resource accessed by h, AVERROR(ENOSYS)
|
||
208 | * if the operation is not supported by h, or another negative value
|
||
209 | * corresponding to an AVERROR error code in case of failure.
|
||
210 | */
|
||
211 | bc5c918e | Diego Biurrun | int64_t url_filesize(URLContext *h); |
212 | c306748c | Panagiotis Issaris | |
213 | c3316802 | Panagiotis Issaris | /**
|
214 | f0a80394 | Ronald S. Bultje | * Return the file descriptor associated with this URL. For RTP, this
|
215 | * will return only the RTP file descriptor, not the RTCP file descriptor.
|
||
216 | *
|
||
217 | * @return the file descriptor associated with this URL, or <0 on error.
|
||
218 | */
|
||
219 | int url_get_file_handle(URLContext *h);
|
||
220 | |||
221 | /**
|
||
222 | c306748c | Panagiotis Issaris | * Return the maximum packet size associated to packetized file
|
223 | 8bfb108b | Diego Biurrun | * handle. If the file is not packetized (stream like HTTP or file on
|
224 | c306748c | Panagiotis Issaris | * disk), then 0 is returned.
|
225 | *
|
||
226 | * @param h file handle
|
||
227 | * @return maximum packet size in bytes
|
||
228 | */
|
||
229 | f031df23 | Fabrice Bellard | int url_get_max_packet_size(URLContext *h);
|
230 | 8bf256bc | Stefano Sabatini | |
231 | /**
|
||
232 | * Copy the filename of the resource accessed by h to buf.
|
||
233 | *
|
||
234 | * @param buf_size size in bytes of buf
|
||
235 | */
|
||
236 | f746a046 | Fabrice Bellard | void url_get_filename(URLContext *h, char *buf, int buf_size); |
237 | |||
238 | c3316802 | Panagiotis Issaris | /**
|
239 | 8bfb108b | Diego Biurrun | * The callback is called in blocking functions to test regulary if
|
240 | c3316802 | Panagiotis Issaris | * asynchronous interruption is needed. AVERROR(EINTR) is returned
|
241 | * in this case by the interrupted function. 'NULL' means no interrupt
|
||
242 | 8bfb108b | Diego Biurrun | * callback is given.
|
243 | c3316802 | Panagiotis Issaris | */
|
244 | 019ac05a | Fabrice Bellard | void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
|
245 | |||
246 | de6d9b64 | Fabrice Bellard | /* not implemented */
|
247 | int url_poll(URLPollEntry *poll_table, int n, int timeout); |
||
248 | |||
249 | 502bdf68 | Michael Niedermayer | /**
|
250 | * Pause and resume playing - only meaningful if using a network streaming
|
||
251 | * protocol (e.g. MMS).
|
||
252 | * @param pause 1 for pause, 0 for resume
|
||
253 | */
|
||
254 | int av_url_read_pause(URLContext *h, int pause); |
||
255 | 8bfb108b | Diego Biurrun | |
256 | 536333a0 | Björn Axelsson | /**
|
257 | * Seek to a given timestamp relative to some component stream.
|
||
258 | 8bfb108b | Diego Biurrun | * Only meaningful if using a network streaming protocol (e.g. MMS.).
|
259 | 536333a0 | Björn Axelsson | * @param stream_index The stream index that the timestamp is relative to.
|
260 | * If stream_index is (-1) the timestamp should be in AV_TIME_BASE
|
||
261 | * units from the beginning of the presentation.
|
||
262 | * If a stream_index >= 0 is used and the protocol does not support
|
||
263 | * seeking based on component streams, the call will fail with ENOTSUP.
|
||
264 | 00ef4f58 | Diego Biurrun | * @param timestamp timestamp in AVStream.time_base units
|
265 | 536333a0 | Björn Axelsson | * or if there is no stream specified then in AV_TIME_BASE units.
|
266 | * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE
|
||
267 | * and AVSEEK_FLAG_ANY. The protocol may silently ignore
|
||
268 | * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will
|
||
269 | * fail with ENOTSUP if used and not supported.
|
||
270 | * @return >= 0 on success
|
||
271 | * @see AVInputFormat::read_seek
|
||
272 | */
|
||
273 | 7f37f568 | Diego Biurrun | int64_t av_url_read_seek(URLContext *h, int stream_index,
|
274 | int64_t timestamp, int flags);
|
||
275 | 536333a0 | Björn Axelsson | |
276 | aa38b097 | Michael Niedermayer | /**
|
277 | 493f54ad | Michael Niedermayer | * Oring this flag as into the "whence" parameter to a seek function causes it to
|
278 | * seek by any means (like reopening and linear reading) or other normally unreasonble
|
||
279 | * means that can be extreemly slow.
|
||
280 | * This may be ignored by the seek code.
|
||
281 | */
|
||
282 | #define AVSEEK_FORCE 0x20000 |
||
283 | |||
284 | de6d9b64 | Fabrice Bellard | typedef struct URLProtocol { |
285 | const char *name; |
||
286 | 725b3da9 | Stefano Sabatini | int (*url_open)(URLContext *h, const char *url, int flags); |
287 | de6d9b64 | Fabrice Bellard | int (*url_read)(URLContext *h, unsigned char *buf, int size); |
288 | 27241cbf | Martin Storsjö | int (*url_write)(URLContext *h, const unsigned char *buf, int size); |
289 | bc5c918e | Diego Biurrun | int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
|
290 | de6d9b64 | Fabrice Bellard | int (*url_close)(URLContext *h);
|
291 | struct URLProtocol *next;
|
||
292 | 502bdf68 | Michael Niedermayer | int (*url_read_pause)(URLContext *h, int pause); |
293 | 7f37f568 | Diego Biurrun | int64_t (*url_read_seek)(URLContext *h, int stream_index,
|
294 | int64_t timestamp, int flags);
|
||
295 | f0a80394 | Ronald S. Bultje | int (*url_get_file_handle)(URLContext *h);
|
296 | 735cf6b2 | Martin Storsjö | int priv_data_size;
|
297 | const AVClass *priv_data_class;
|
||
298 | de6d9b64 | Fabrice Bellard | } URLProtocol; |
299 | |||
300 | 838b27b4 | Aurelien Jacobs | #if FF_API_REGISTER_PROTOCOL
|
301 | de6d9b64 | Fabrice Bellard | extern URLProtocol *first_protocol;
|
302 | d1037c12 | Stefano Sabatini | #endif
|
303 | |||
304 | 019ac05a | Fabrice Bellard | extern URLInterruptCB *url_interrupt_cb;
|
305 | de6d9b64 | Fabrice Bellard | |
306 | 9075d1e0 | Stefano Sabatini | /**
|
307 | * If protocol is NULL, returns the first registered protocol,
|
||
308 | c1b02101 | Stefano Sabatini | * if protocol is non-NULL, returns the next registered protocol after protocol,
|
309 | 9075d1e0 | Stefano Sabatini | * or NULL if protocol is the last one.
|
310 | */
|
||
311 | 84be6e72 | Michael Niedermayer | URLProtocol *av_protocol_next(URLProtocol *p); |
312 | |||
313 | 838b27b4 | Aurelien Jacobs | #if FF_API_REGISTER_PROTOCOL
|
314 | 65c40e4e | Stefano Sabatini | /**
|
315 | * @deprecated Use av_register_protocol() instead.
|
||
316 | */
|
||
317 | attribute_deprecated int register_protocol(URLProtocol *protocol);
|
||
318 | 9b07a2dc | Martin Storsjö | |
319 | /**
|
||
320 | * @deprecated Use av_register_protocol2() instead.
|
||
321 | */
|
||
322 | attribute_deprecated int av_register_protocol(URLProtocol *protocol);
|
||
323 | 65c40e4e | Stefano Sabatini | #endif
|
324 | |||
325 | d19a046e | Stefano Sabatini | /**
|
326 | 49bd8e4b | Måns Rullgård | * Register the URLProtocol protocol.
|
327 | 9b07a2dc | Martin Storsjö | *
|
328 | * @param size the size of the URLProtocol struct referenced
|
||
329 | d19a046e | Stefano Sabatini | */
|
330 | 9b07a2dc | Martin Storsjö | int av_register_protocol2(URLProtocol *protocol, int size); |
331 | de6d9b64 | Fabrice Bellard | |
332 | 1308f273 | Michael Niedermayer | /**
|
333 | * Bytestream IO Context.
|
||
334 | * New fields can be added to the end with minor version bumps.
|
||
335 | 8bfb108b | Diego Biurrun | * Removal, reordering and changes to existing fields require a major
|
336 | 1308f273 | Michael Niedermayer | * version bump.
|
337 | ae628ec1 | Anton Khirnov | * sizeof(AVIOContext) must not be used outside libav*.
|
338 | 1308f273 | Michael Niedermayer | */
|
339 | de6d9b64 | Fabrice Bellard | typedef struct { |
340 | unsigned char *buffer; |
||
341 | int buffer_size;
|
||
342 | unsigned char *buf_ptr, *buf_end; |
||
343 | void *opaque;
|
||
344 | 0c1a9eda | Zdenek Kabelac | int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); |
345 | 576ae256 | Michael Niedermayer | int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); |
346 | bc5c918e | Diego Biurrun | int64_t (*seek)(void *opaque, int64_t offset, int whence); |
347 | int64_t pos; /**< position in the file of the current buffer */
|
||
348 | c3316802 | Panagiotis Issaris | int must_flush; /**< true if the next seek should flush */ |
349 | int eof_reached; /**< true if eof reached */ |
||
350 | int write_flag; /**< true if open for writing */ |
||
351 | de6d9b64 | Fabrice Bellard | int is_streamed;
|
352 | f031df23 | Fabrice Bellard | int max_packet_size;
|
353 | ee9f36a8 | Michael Niedermayer | unsigned long checksum; |
354 | unsigned char *checksum_ptr; |
||
355 | unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); |
||
356 | 576ae256 | Michael Niedermayer | int error; ///< contains the error code or 0 if no error happened |
357 | 502bdf68 | Michael Niedermayer | int (*read_pause)(void *opaque, int pause); |
358 | 7f37f568 | Diego Biurrun | int64_t (*read_seek)(void *opaque, int stream_index, |
359 | int64_t timestamp, int flags);
|
||
360 | ae628ec1 | Anton Khirnov | } AVIOContext; |
361 | de6d9b64 | Fabrice Bellard | |
362 | ae628ec1 | Anton Khirnov | #if FF_API_OLD_AVIO
|
363 | typedef attribute_deprecated AVIOContext ByteIOContext;
|
||
364 | |||
365 | e731b8d8 | Anton Khirnov | attribute_deprecated int init_put_byte(AVIOContext *s,
|
366 | de6d9b64 | Fabrice Bellard | unsigned char *buffer, |
367 | int buffer_size,
|
||
368 | int write_flag,
|
||
369 | void *opaque,
|
||
370 | 1e0f3468 | Reimar Döffinger | int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), |
371 | int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), |
||
372 | bc5c918e | Diego Biurrun | int64_t (*seek)(void *opaque, int64_t offset, int whence)); |
373 | e731b8d8 | Anton Khirnov | #endif
|
374 | ae628ec1 | Anton Khirnov | AVIOContext *av_alloc_put_byte( |
375 | 1e0f3468 | Reimar Döffinger | unsigned char *buffer, |
376 | int buffer_size,
|
||
377 | int write_flag,
|
||
378 | void *opaque,
|
||
379 | 0c1a9eda | Zdenek Kabelac | int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), |
380 | 576ae256 | Michael Niedermayer | int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), |
381 | bc5c918e | Diego Biurrun | int64_t (*seek)(void *opaque, int64_t offset, int whence)); |
382 | de6d9b64 | Fabrice Bellard | |
383 | ae628ec1 | Anton Khirnov | void put_byte(AVIOContext *s, int b); |
384 | void put_nbyte(AVIOContext *s, int b, int count); |
||
385 | void put_buffer(AVIOContext *s, const unsigned char *buf, int size); |
||
386 | void put_le64(AVIOContext *s, uint64_t val);
|
||
387 | void put_be64(AVIOContext *s, uint64_t val);
|
||
388 | void put_le32(AVIOContext *s, unsigned int val); |
||
389 | void put_be32(AVIOContext *s, unsigned int val); |
||
390 | void put_le24(AVIOContext *s, unsigned int val); |
||
391 | void put_be24(AVIOContext *s, unsigned int val); |
||
392 | void put_le16(AVIOContext *s, unsigned int val); |
||
393 | void put_be16(AVIOContext *s, unsigned int val); |
||
394 | void put_tag(AVIOContext *s, const char *tag); |
||
395 | de6d9b64 | Fabrice Bellard | |
396 | 4efd5cf3 | Anton Khirnov | #if FF_API_OLD_AVIO
|
397 | ae628ec1 | Anton Khirnov | attribute_deprecated void put_strz(AVIOContext *s, const char *buf); |
398 | 4efd5cf3 | Anton Khirnov | #endif
|
399 | |||
400 | /**
|
||
401 | * Write a NULL-terminated string.
|
||
402 | * @return number of bytes written.
|
||
403 | */
|
||
404 | ae628ec1 | Anton Khirnov | int avio_put_str(AVIOContext *s, const char *str); |
405 | 75bdb984 | Philip Gladstone | |
406 | 67e21020 | Michael Niedermayer | /**
|
407 | dccbd97d | Anton Khirnov | * Convert an UTF-8 string to UTF-16LE and write it.
|
408 | * @return number of bytes written.
|
||
409 | */
|
||
410 | ae628ec1 | Anton Khirnov | int avio_put_str16le(AVIOContext *s, const char *str); |
411 | dccbd97d | Anton Khirnov | |
412 | /**
|
||
413 | ae628ec1 | Anton Khirnov | * fseek() equivalent for AVIOContext.
|
414 | 67e21020 | Michael Niedermayer | * @return new position or AVERROR.
|
415 | */
|
||
416 | ae628ec1 | Anton Khirnov | int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
|
417 | 67e21020 | Michael Niedermayer | |
418 | /**
|
||
419 | * Skip given number of bytes forward.
|
||
420 | * @param offset number of bytes
|
||
421 | d5e9ddeb | Martin Storsjö | * @return 0 on success, <0 on error
|
422 | 67e21020 | Michael Niedermayer | */
|
423 | ae628ec1 | Anton Khirnov | int url_fskip(AVIOContext *s, int64_t offset);
|
424 | 67e21020 | Michael Niedermayer | |
425 | /**
|
||
426 | ae628ec1 | Anton Khirnov | * ftell() equivalent for AVIOContext.
|
427 | 67e21020 | Michael Niedermayer | * @return position or AVERROR.
|
428 | */
|
||
429 | ae628ec1 | Anton Khirnov | int64_t url_ftell(AVIOContext *s); |
430 | 67e21020 | Michael Niedermayer | |
431 | /**
|
||
432 | 49bd8e4b | Måns Rullgård | * Get the filesize.
|
433 | 67e21020 | Michael Niedermayer | * @return filesize or AVERROR
|
434 | */
|
||
435 | ae628ec1 | Anton Khirnov | int64_t url_fsize(AVIOContext *s); |
436 | 67e21020 | Michael Niedermayer | |
437 | /**
|
||
438 | ae628ec1 | Anton Khirnov | * feof() equivalent for AVIOContext.
|
439 | 67e21020 | Michael Niedermayer | * @return non zero if and only if end of file
|
440 | */
|
||
441 | ae628ec1 | Anton Khirnov | int url_feof(AVIOContext *s);
|
442 | 67e21020 | Michael Niedermayer | |
443 | ae628ec1 | Anton Khirnov | int url_ferror(AVIOContext *s);
|
444 | de6d9b64 | Fabrice Bellard | |
445 | ae628ec1 | Anton Khirnov | int av_url_read_fpause(AVIOContext *h, int pause); |
446 | int64_t av_url_read_fseek(AVIOContext *h, int stream_index,
|
||
447 | 7f37f568 | Diego Biurrun | int64_t timestamp, int flags);
|
448 | e7e4810a | Björn Axelsson | |
449 | f031df23 | Fabrice Bellard | #define URL_EOF (-1) |
450 | c3316802 | Panagiotis Issaris | /** @note return URL_EOF (-1) if EOF */
|
451 | ae628ec1 | Anton Khirnov | int url_fgetc(AVIOContext *s);
|
452 | a8c5ab27 | Panagiotis Issaris | |
453 | c3316802 | Panagiotis Issaris | /** @warning currently size is limited */
|
454 | 572f992e | Michael Niedermayer | #ifdef __GNUC__
|
455 | ae628ec1 | Anton Khirnov | int url_fprintf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); |
456 | 572f992e | Michael Niedermayer | #else
|
457 | ae628ec1 | Anton Khirnov | int url_fprintf(AVIOContext *s, const char *fmt, ...); |
458 | 572f992e | Michael Niedermayer | #endif
|
459 | a8c5ab27 | Panagiotis Issaris | |
460 | c3316802 | Panagiotis Issaris | /** @note unlike fgets, the EOL character is not returned and a whole
|
461 | 7f37f568 | Diego Biurrun | line is parsed. return NULL if first char read was EOF */
|
462 | ae628ec1 | Anton Khirnov | char *url_fgets(AVIOContext *s, char *buf, int buf_size); |
463 | f031df23 | Fabrice Bellard | |
464 | ae628ec1 | Anton Khirnov | void put_flush_packet(AVIOContext *s);
|
465 | de6d9b64 | Fabrice Bellard | |
466 | 4edfcecc | Michael Niedermayer | |
467 | /**
|
||
468 | ae628ec1 | Anton Khirnov | * Read size bytes from AVIOContext into buf.
|
469 | 32e543f8 | Benoit Fouet | * @return number of bytes read or AVERROR
|
470 | 4edfcecc | Michael Niedermayer | */
|
471 | ae628ec1 | Anton Khirnov | int get_buffer(AVIOContext *s, unsigned char *buf, int size); |
472 | 4edfcecc | Michael Niedermayer | |
473 | /**
|
||
474 | ae628ec1 | Anton Khirnov | * Read size bytes from AVIOContext into buf.
|
475 | 4477dedc | Diego Biurrun | * This reads at most 1 packet. If that is not enough fewer bytes will be
|
476 | 4edfcecc | Michael Niedermayer | * returned.
|
477 | 32e543f8 | Benoit Fouet | * @return number of bytes read or AVERROR
|
478 | 4edfcecc | Michael Niedermayer | */
|
479 | ae628ec1 | Anton Khirnov | int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size); |
480 | a8c5ab27 | Panagiotis Issaris | |
481 | c3316802 | Panagiotis Issaris | /** @note return 0 if EOF, so you cannot use it if EOF handling is
|
482 | 7f37f568 | Diego Biurrun | necessary */
|
483 | ae628ec1 | Anton Khirnov | int get_byte(AVIOContext *s);
|
484 | unsigned int get_le24(AVIOContext *s); |
||
485 | unsigned int get_le32(AVIOContext *s); |
||
486 | uint64_t get_le64(AVIOContext *s); |
||
487 | unsigned int get_le16(AVIOContext *s); |
||
488 | de6d9b64 | Fabrice Bellard | |
489 | 93b78d12 | Anton Khirnov | /**
|
490 | * Read a UTF-16 string from pb and convert it to UTF-8.
|
||
491 | * The reading will terminate when either a null or invalid character was
|
||
492 | * encountered or maxlen bytes have been read.
|
||
493 | * @return number of bytes read (is always <= maxlen)
|
||
494 | */
|
||
495 | ae628ec1 | Anton Khirnov | int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen); |
496 | int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); |
||
497 | 93b78d12 | Anton Khirnov | |
498 | ae628ec1 | Anton Khirnov | char *get_strz(AVIOContext *s, char *buf, int maxlen); |
499 | unsigned int get_be16(AVIOContext *s); |
||
500 | unsigned int get_be24(AVIOContext *s); |
||
501 | unsigned int get_be32(AVIOContext *s); |
||
502 | uint64_t get_be64(AVIOContext *s); |
||
503 | de6d9b64 | Fabrice Bellard | |
504 | ae628ec1 | Anton Khirnov | uint64_t ff_get_v(AVIOContext *bc); |
505 | 897d3eef | Kostya Shishkov | |
506 | ae628ec1 | Anton Khirnov | static inline int url_is_streamed(AVIOContext *s) |
507 | de6d9b64 | Fabrice Bellard | { |
508 | return s->is_streamed;
|
||
509 | } |
||
510 | |||
511 | 4e38c094 | Stefano Sabatini | /**
|
512 | ae628ec1 | Anton Khirnov | * Create and initialize a AVIOContext for accessing the
|
513 | 4e38c094 | Stefano Sabatini | * resource referenced by the URLContext h.
|
514 | * @note When the URLContext h has been opened in read+write mode, the
|
||
515 | ae628ec1 | Anton Khirnov | * AVIOContext can be used only for writing.
|
516 | 4e38c094 | Stefano Sabatini | *
|
517 | ae628ec1 | Anton Khirnov | * @param s Used to return the pointer to the created AVIOContext.
|
518 | 4e38c094 | Stefano Sabatini | * In case of failure the pointed to value is set to NULL.
|
519 | * @return 0 in case of success, a negative value corresponding to an
|
||
520 | * AVERROR code in case of failure
|
||
521 | */
|
||
522 | ae628ec1 | Anton Khirnov | int url_fdopen(AVIOContext **s, URLContext *h);
|
523 | a8c5ab27 | Panagiotis Issaris | |
524 | c3316802 | Panagiotis Issaris | /** @warning must be called before any I/O */
|
525 | ae628ec1 | Anton Khirnov | int url_setbufsize(AVIOContext *s, int buf_size); |
526 | 364cacc7 | Aurelien Jacobs | #if FF_API_URL_RESETBUF
|
527 | 770d9daf | Björn Axelsson | /** Reset the buffer for reading or writing.
|
528 | * @note Will drop any data currently in the buffer without transmitting it.
|
||
529 | * @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY
|
||
530 | * to set up the buffer for writing. */
|
||
531 | ae628ec1 | Anton Khirnov | int url_resetbuf(AVIOContext *s, int flags); |
532 | 08580cb0 | Benoit Fouet | #endif
|
533 | a8c5ab27 | Panagiotis Issaris | |
534 | fe4fbb58 | Stefano Sabatini | /**
|
535 | ae628ec1 | Anton Khirnov | * Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file.
|
536 | 01d91b9b | Tomas Härdin | * Used after probing to avoid seeking.
|
537 | * Joins buf and s->buffer, taking any overlap into consideration.
|
||
538 | * @note s->buffer must overlap with buf or they can't be joined and the function fails
|
||
539 | * @note This function is NOT part of the public API
|
||
540 | *
|
||
541 | ae628ec1 | Anton Khirnov | * @param s The read-only AVIOContext to rewind
|
542 | 01d91b9b | Tomas Härdin | * @param buf The probe buffer containing the first buf_size bytes of the file
|
543 | * @param buf_size The size of buf
|
||
544 | * @return 0 in case of success, a negative value corresponding to an
|
||
545 | * AVERROR code in case of failure
|
||
546 | */
|
||
547 | ae628ec1 | Anton Khirnov | int ff_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size); |
548 | 01d91b9b | Tomas Härdin | |
549 | /**
|
||
550 | ae628ec1 | Anton Khirnov | * Create and initialize a AVIOContext for accessing the
|
551 | fe4fbb58 | Stefano Sabatini | * resource indicated by url.
|
552 | * @note When the resource indicated by url has been opened in
|
||
553 | ae628ec1 | Anton Khirnov | * read+write mode, the AVIOContext can be used only for writing.
|
554 | fe4fbb58 | Stefano Sabatini | *
|
555 | ae628ec1 | Anton Khirnov | * @param s Used to return the pointer to the created AVIOContext.
|
556 | fe4fbb58 | Stefano Sabatini | * In case of failure the pointed to value is set to NULL.
|
557 | * @param flags flags which control how the resource indicated by url
|
||
558 | * is to be opened
|
||
559 | * @return 0 in case of success, a negative value corresponding to an
|
||
560 | * AVERROR code in case of failure
|
||
561 | */
|
||
562 | ae628ec1 | Anton Khirnov | int url_fopen(AVIOContext **s, const char *url, int flags); |
563 | fe4fbb58 | Stefano Sabatini | |
564 | ae628ec1 | Anton Khirnov | int url_fclose(AVIOContext *s);
|
565 | URLContext *url_fileno(AVIOContext *s); |
||
566 | a8c5ab27 | Panagiotis Issaris | |
567 | c3316802 | Panagiotis Issaris | /**
|
568 | a8c5ab27 | Panagiotis Issaris | * Return the maximum packet size associated to packetized buffered file
|
569 | * handle. If the file is not packetized (stream like http or file on
|
||
570 | * disk), then 0 is returned.
|
||
571 | *
|
||
572 | abfe87d4 | Panagiotis Issaris | * @param s buffered file handle
|
573 | a8c5ab27 | Panagiotis Issaris | * @return maximum packet size in bytes
|
574 | */
|
||
575 | ae628ec1 | Anton Khirnov | int url_fget_max_packet_size(AVIOContext *s);
|
576 | de6d9b64 | Fabrice Bellard | |
577 | ae628ec1 | Anton Khirnov | int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags); |
578 | a8c5ab27 | Panagiotis Issaris | |
579 | c3316802 | Panagiotis Issaris | /** return the written or read size */
|
580 | ae628ec1 | Anton Khirnov | int url_close_buf(AVIOContext *s);
|
581 | de6d9b64 | Fabrice Bellard | |
582 | c3316802 | Panagiotis Issaris | /**
|
583 | a8c5ab27 | Panagiotis Issaris | * Open a write only memory stream.
|
584 | *
|
||
585 | * @param s new IO context
|
||
586 | * @return zero if no error.
|
||
587 | */
|
||
588 | ae628ec1 | Anton Khirnov | int url_open_dyn_buf(AVIOContext **s);
|
589 | a8c5ab27 | Panagiotis Issaris | |
590 | c3316802 | Panagiotis Issaris | /**
|
591 | a8c5ab27 | Panagiotis Issaris | * Open a write only packetized memory stream with a maximum packet
|
592 | * size of 'max_packet_size'. The stream is stored in a memory buffer
|
||
593 | * with a big endian 4 byte header giving the packet size in bytes.
|
||
594 | *
|
||
595 | * @param s new IO context
|
||
596 | * @param max_packet_size maximum packet size (must be > 0)
|
||
597 | * @return zero if no error.
|
||
598 | */
|
||
599 | ae628ec1 | Anton Khirnov | int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); |
600 | a8c5ab27 | Panagiotis Issaris | |
601 | c3316802 | Panagiotis Issaris | /**
|
602 | a8c5ab27 | Panagiotis Issaris | * Return the written size and a pointer to the buffer. The buffer
|
603 | de1807bb | Josh Allmann | * must be freed with av_free(). If the buffer is opened with
|
604 | * url_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is
|
||
605 | * added; if opened with url_open_dyn_packet_buf, no padding is added.
|
||
606 | *
|
||
607 | a8c5ab27 | Panagiotis Issaris | * @param s IO context
|
608 | e8b7c70f | Panagiotis Issaris | * @param pbuffer pointer to a byte buffer
|
609 | a8c5ab27 | Panagiotis Issaris | * @return the length of the byte buffer
|
610 | */
|
||
611 | ae628ec1 | Anton Khirnov | int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
|
612 | f031df23 | Fabrice Bellard | |
613 | 7f37f568 | Diego Biurrun | unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, |
614 | unsigned int len); |
||
615 | ae628ec1 | Anton Khirnov | unsigned long get_checksum(AVIOContext *s); |
616 | void init_checksum(AVIOContext *s,
|
||
617 | 7f37f568 | Diego Biurrun | unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), |
618 | unsigned long checksum); |
||
619 | ee9f36a8 | Michael Niedermayer | |
620 | de6d9b64 | Fabrice Bellard | /* udp.c */
|
621 | f031df23 | Fabrice Bellard | int udp_set_remote_url(URLContext *h, const char *uri); |
622 | int udp_get_local_port(URLContext *h);
|
||
623 | 8ef30ac1 | Aurelien Jacobs | #if FF_API_UDP_GET_FILE
|
624 | f031df23 | Fabrice Bellard | int udp_get_file_handle(URLContext *h);
|
625 | f0a80394 | Ronald S. Bultje | #endif
|
626 | f031df23 | Fabrice Bellard | |
627 | 98790382 | Stefano Sabatini | #endif /* AVFORMAT_AVIO_H */ |