ffmpeg / libavformat / avio.h @ fafa7290
History | View | Annotate | Download (21.7 KB)
1 |
/*
|
---|---|
2 |
* copyright (c) 2001 Fabrice Bellard
|
3 |
*
|
4 |
* This file is part of Libav.
|
5 |
*
|
6 |
* Libav 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 |
* Libav 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 Libav; 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 |
|
23 |
/**
|
24 |
* @file
|
25 |
* Buffered I/O operations
|
26 |
*/
|
27 |
|
28 |
#include <stdint.h> |
29 |
|
30 |
#include "libavutil/common.h" |
31 |
#include "libavutil/log.h" |
32 |
|
33 |
#include "libavformat/version.h" |
34 |
|
35 |
|
36 |
#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */ |
37 |
|
38 |
/**
|
39 |
* Bytestream IO Context.
|
40 |
* New fields can be added to the end with minor version bumps.
|
41 |
* Removal, reordering and changes to existing fields require a major
|
42 |
* version bump.
|
43 |
* sizeof(AVIOContext) must not be used outside libav*.
|
44 |
*/
|
45 |
typedef struct { |
46 |
unsigned char *buffer; |
47 |
int buffer_size;
|
48 |
unsigned char *buf_ptr, *buf_end; |
49 |
void *opaque;
|
50 |
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); |
51 |
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); |
52 |
int64_t (*seek)(void *opaque, int64_t offset, int whence); |
53 |
int64_t pos; /**< position in the file of the current buffer */
|
54 |
int must_flush; /**< true if the next seek should flush */ |
55 |
int eof_reached; /**< true if eof reached */ |
56 |
int write_flag; /**< true if open for writing */ |
57 |
#if FF_API_OLD_AVIO
|
58 |
attribute_deprecated int is_streamed;
|
59 |
#endif
|
60 |
int max_packet_size;
|
61 |
unsigned long checksum; |
62 |
unsigned char *checksum_ptr; |
63 |
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); |
64 |
int error; ///< contains the error code or 0 if no error happened |
65 |
int (*read_pause)(void *opaque, int pause); |
66 |
int64_t (*read_seek)(void *opaque, int stream_index, |
67 |
int64_t timestamp, int flags);
|
68 |
/**
|
69 |
* A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
|
70 |
*/
|
71 |
int seekable;
|
72 |
} AVIOContext; |
73 |
|
74 |
/* unbuffered I/O */
|
75 |
|
76 |
#if FF_API_OLD_AVIO
|
77 |
/**
|
78 |
* URL Context.
|
79 |
* New fields can be added to the end with minor version bumps.
|
80 |
* Removal, reordering and changes to existing fields require a major
|
81 |
* version bump.
|
82 |
* sizeof(URLContext) must not be used outside libav*.
|
83 |
* @deprecated This struct will be made private
|
84 |
*/
|
85 |
typedef struct URLContext { |
86 |
#if FF_API_URL_CLASS
|
87 |
const AVClass *av_class; ///< information for av_log(). Set by url_open(). |
88 |
#endif
|
89 |
struct URLProtocol *prot;
|
90 |
int flags;
|
91 |
int is_streamed; /**< true if streamed (no seek possible), default = false */ |
92 |
int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ |
93 |
void *priv_data;
|
94 |
char *filename; /**< specified URL */ |
95 |
int is_connected;
|
96 |
} URLContext; |
97 |
|
98 |
typedef struct URLPollEntry { |
99 |
URLContext *handle; |
100 |
int events;
|
101 |
int revents;
|
102 |
} URLPollEntry; |
103 |
|
104 |
/**
|
105 |
* @defgroup open_modes URL open modes
|
106 |
* The flags argument to url_open and cosins must be one of the following
|
107 |
* constants, optionally ORed with other flags.
|
108 |
* @{
|
109 |
*/
|
110 |
#define URL_RDONLY 0 /**< read-only */ |
111 |
#define URL_WRONLY 1 /**< write-only */ |
112 |
#define URL_RDWR 2 /**< read-write */ |
113 |
/**
|
114 |
* @}
|
115 |
*/
|
116 |
|
117 |
/**
|
118 |
* Use non-blocking mode.
|
119 |
* If this flag is set, operations on the context will return
|
120 |
* AVERROR(EAGAIN) if they can not be performed immediately.
|
121 |
* If this flag is not set, operations on the context will never return
|
122 |
* AVERROR(EAGAIN).
|
123 |
* Note that this flag does not affect the opening/connecting of the
|
124 |
* context. Connecting a protocol will always block if necessary (e.g. on
|
125 |
* network protocols) but never hang (e.g. on busy devices).
|
126 |
* Warning: non-blocking protocols is work-in-progress; this flag may be
|
127 |
* silently ignored.
|
128 |
*/
|
129 |
#define URL_FLAG_NONBLOCK 4 |
130 |
|
131 |
typedef int URLInterruptCB(void); |
132 |
|
133 |
/**
|
134 |
* @defgroup old_url_funcs Old url_* functions
|
135 |
* @deprecated use the buffered API based on AVIOContext instead
|
136 |
* @{
|
137 |
*/
|
138 |
attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up, |
139 |
const char *url, int flags); |
140 |
attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags); |
141 |
attribute_deprecated int url_connect(URLContext *h);
|
142 |
attribute_deprecated int url_open(URLContext **h, const char *url, int flags); |
143 |
attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size); |
144 |
attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size); |
145 |
attribute_deprecated int url_write(URLContext *h, const unsigned char *buf, int size); |
146 |
attribute_deprecated int64_t url_seek(URLContext *h, int64_t pos, int whence);
|
147 |
attribute_deprecated int url_close(URLContext *h);
|
148 |
attribute_deprecated int64_t url_filesize(URLContext *h); |
149 |
attribute_deprecated int url_get_file_handle(URLContext *h);
|
150 |
attribute_deprecated int url_get_max_packet_size(URLContext *h);
|
151 |
attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_size); |
152 |
attribute_deprecated int av_url_read_pause(URLContext *h, int pause); |
153 |
attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
|
154 |
int64_t timestamp, int flags);
|
155 |
attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void)); |
156 |
#endif
|
157 |
|
158 |
/**
|
159 |
* Return a non-zero value if the resource indicated by url
|
160 |
* exists, 0 otherwise.
|
161 |
*/
|
162 |
int url_exist(const char *url); |
163 |
|
164 |
/**
|
165 |
* The callback is called in blocking functions to test regulary if
|
166 |
* asynchronous interruption is needed. AVERROR_EXIT is returned
|
167 |
* in this case by the interrupted function. 'NULL' means no interrupt
|
168 |
* callback is given.
|
169 |
*/
|
170 |
void avio_set_interrupt_cb(int (*interrupt_cb)(void)); |
171 |
|
172 |
#if FF_API_OLD_AVIO
|
173 |
/* not implemented */
|
174 |
attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); |
175 |
|
176 |
|
177 |
#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */ |
178 |
|
179 |
/**
|
180 |
* @deprecated This struct is to be made private. Use the higher-level
|
181 |
* AVIOContext-based API instead.
|
182 |
*/
|
183 |
typedef struct URLProtocol { |
184 |
const char *name; |
185 |
int (*url_open)(URLContext *h, const char *url, int flags); |
186 |
int (*url_read)(URLContext *h, unsigned char *buf, int size); |
187 |
int (*url_write)(URLContext *h, const unsigned char *buf, int size); |
188 |
int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
|
189 |
int (*url_close)(URLContext *h);
|
190 |
struct URLProtocol *next;
|
191 |
int (*url_read_pause)(URLContext *h, int pause); |
192 |
int64_t (*url_read_seek)(URLContext *h, int stream_index,
|
193 |
int64_t timestamp, int flags);
|
194 |
int (*url_get_file_handle)(URLContext *h);
|
195 |
int priv_data_size;
|
196 |
const AVClass *priv_data_class;
|
197 |
int flags;
|
198 |
} URLProtocol; |
199 |
#endif
|
200 |
|
201 |
#if FF_API_REGISTER_PROTOCOL
|
202 |
extern URLProtocol *first_protocol;
|
203 |
#endif
|
204 |
|
205 |
#if FF_API_OLD_AVIO
|
206 |
extern URLInterruptCB *url_interrupt_cb;
|
207 |
#endif
|
208 |
|
209 |
#if FF_API_OLD_AVIO
|
210 |
/**
|
211 |
* If protocol is NULL, returns the first registered protocol,
|
212 |
* if protocol is non-NULL, returns the next registered protocol after protocol,
|
213 |
* or NULL if protocol is the last one.
|
214 |
*/
|
215 |
attribute_deprecated URLProtocol *av_protocol_next(URLProtocol *p); |
216 |
#endif
|
217 |
|
218 |
#if FF_API_REGISTER_PROTOCOL
|
219 |
/**
|
220 |
* @deprecated Use av_register_protocol() instead.
|
221 |
*/
|
222 |
attribute_deprecated int register_protocol(URLProtocol *protocol);
|
223 |
|
224 |
/**
|
225 |
* @deprecated Use av_register_protocol2() instead.
|
226 |
*/
|
227 |
attribute_deprecated int av_register_protocol(URLProtocol *protocol);
|
228 |
#endif
|
229 |
|
230 |
#if FF_API_OLD_AVIO
|
231 |
/**
|
232 |
* Register the URLProtocol protocol.
|
233 |
*
|
234 |
* @param size the size of the URLProtocol struct referenced
|
235 |
*/
|
236 |
attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size); |
237 |
#endif
|
238 |
|
239 |
/**
|
240 |
* @}
|
241 |
*/
|
242 |
|
243 |
#if FF_API_OLD_AVIO
|
244 |
typedef attribute_deprecated AVIOContext ByteIOContext;
|
245 |
|
246 |
attribute_deprecated int init_put_byte(AVIOContext *s,
|
247 |
unsigned char *buffer, |
248 |
int buffer_size,
|
249 |
int write_flag,
|
250 |
void *opaque,
|
251 |
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), |
252 |
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), |
253 |
int64_t (*seek)(void *opaque, int64_t offset, int whence)); |
254 |
attribute_deprecated AVIOContext *av_alloc_put_byte( |
255 |
unsigned char *buffer, |
256 |
int buffer_size,
|
257 |
int write_flag,
|
258 |
void *opaque,
|
259 |
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), |
260 |
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), |
261 |
int64_t (*seek)(void *opaque, int64_t offset, int whence)); |
262 |
|
263 |
/**
|
264 |
* @defgroup old_avio_funcs Old put_/get_*() functions
|
265 |
* @deprecated use the avio_ -prefixed functions instead.
|
266 |
* @{
|
267 |
*/
|
268 |
attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size); |
269 |
attribute_deprecated int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size); |
270 |
attribute_deprecated int get_byte(AVIOContext *s);
|
271 |
attribute_deprecated unsigned int get_le16(AVIOContext *s); |
272 |
attribute_deprecated unsigned int get_le24(AVIOContext *s); |
273 |
attribute_deprecated unsigned int get_le32(AVIOContext *s); |
274 |
attribute_deprecated uint64_t get_le64(AVIOContext *s); |
275 |
attribute_deprecated unsigned int get_be16(AVIOContext *s); |
276 |
attribute_deprecated unsigned int get_be24(AVIOContext *s); |
277 |
attribute_deprecated unsigned int get_be32(AVIOContext *s); |
278 |
attribute_deprecated uint64_t get_be64(AVIOContext *s); |
279 |
|
280 |
attribute_deprecated void put_byte(AVIOContext *s, int b); |
281 |
attribute_deprecated void put_nbyte(AVIOContext *s, int b, int count); |
282 |
attribute_deprecated void put_buffer(AVIOContext *s, const unsigned char *buf, int size); |
283 |
attribute_deprecated void put_le64(AVIOContext *s, uint64_t val);
|
284 |
attribute_deprecated void put_be64(AVIOContext *s, uint64_t val);
|
285 |
attribute_deprecated void put_le32(AVIOContext *s, unsigned int val); |
286 |
attribute_deprecated void put_be32(AVIOContext *s, unsigned int val); |
287 |
attribute_deprecated void put_le24(AVIOContext *s, unsigned int val); |
288 |
attribute_deprecated void put_be24(AVIOContext *s, unsigned int val); |
289 |
attribute_deprecated void put_le16(AVIOContext *s, unsigned int val); |
290 |
attribute_deprecated void put_be16(AVIOContext *s, unsigned int val); |
291 |
attribute_deprecated void put_tag(AVIOContext *s, const char *tag); |
292 |
/**
|
293 |
* @}
|
294 |
*/
|
295 |
|
296 |
attribute_deprecated int av_url_read_fpause(AVIOContext *h, int pause); |
297 |
attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h, int stream_index,
|
298 |
int64_t timestamp, int flags);
|
299 |
|
300 |
/**
|
301 |
* @defgroup old_url_f_funcs Old url_f* functions
|
302 |
* @deprecated use the avio_ -prefixed functions instead.
|
303 |
* @{
|
304 |
*/
|
305 |
attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags); |
306 |
attribute_deprecated int url_fclose(AVIOContext *s);
|
307 |
attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
|
308 |
attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
|
309 |
attribute_deprecated int64_t url_ftell(AVIOContext *s); |
310 |
attribute_deprecated int64_t url_fsize(AVIOContext *s); |
311 |
#define URL_EOF (-1) |
312 |
attribute_deprecated int url_fgetc(AVIOContext *s);
|
313 |
attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size); |
314 |
#ifdef __GNUC__
|
315 |
attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); |
316 |
#else
|
317 |
attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); |
318 |
#endif
|
319 |
attribute_deprecated void put_flush_packet(AVIOContext *s);
|
320 |
attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
|
321 |
attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); |
322 |
attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
|
323 |
attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h);
|
324 |
/**
|
325 |
* @}
|
326 |
*/
|
327 |
|
328 |
/**
|
329 |
* @deprecated use AVIOContext.eof_reached
|
330 |
*/
|
331 |
attribute_deprecated int url_feof(AVIOContext *s);
|
332 |
attribute_deprecated int url_ferror(AVIOContext *s);
|
333 |
|
334 |
attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri); |
335 |
attribute_deprecated int udp_get_local_port(URLContext *h);
|
336 |
|
337 |
attribute_deprecated void init_checksum(AVIOContext *s,
|
338 |
unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), |
339 |
unsigned long checksum); |
340 |
attribute_deprecated unsigned long get_checksum(AVIOContext *s); |
341 |
#endif
|
342 |
|
343 |
/**
|
344 |
* Allocate and initialize an AVIOContext for buffered I/O. It must be later
|
345 |
* freed with av_free().
|
346 |
*
|
347 |
* @param buffer Memory block for input/output operations via AVIOContext.
|
348 |
* @param buffer_size The buffer size is very important for performance.
|
349 |
* For protocols with fixed blocksize it should be set to this blocksize.
|
350 |
* For others a typical size is a cache page, e.g. 4kb.
|
351 |
* @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
|
352 |
* @param opaque An opaque pointer to user-specific data.
|
353 |
* @param read_packet A function for refilling the buffer, may be NULL.
|
354 |
* @param write_packet A function for writing the buffer contents, may be NULL.
|
355 |
* @param seek A function for seeking to specified byte position, may be NULL.
|
356 |
*
|
357 |
* @return Allocated AVIOContext or NULL on failure.
|
358 |
*/
|
359 |
AVIOContext *avio_alloc_context( |
360 |
unsigned char *buffer, |
361 |
int buffer_size,
|
362 |
int write_flag,
|
363 |
void *opaque,
|
364 |
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), |
365 |
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), |
366 |
int64_t (*seek)(void *opaque, int64_t offset, int whence)); |
367 |
|
368 |
void avio_w8(AVIOContext *s, int b); |
369 |
void avio_write(AVIOContext *s, const unsigned char *buf, int size); |
370 |
void avio_wl64(AVIOContext *s, uint64_t val);
|
371 |
void avio_wb64(AVIOContext *s, uint64_t val);
|
372 |
void avio_wl32(AVIOContext *s, unsigned int val); |
373 |
void avio_wb32(AVIOContext *s, unsigned int val); |
374 |
void avio_wl24(AVIOContext *s, unsigned int val); |
375 |
void avio_wb24(AVIOContext *s, unsigned int val); |
376 |
void avio_wl16(AVIOContext *s, unsigned int val); |
377 |
void avio_wb16(AVIOContext *s, unsigned int val); |
378 |
|
379 |
#if FF_API_OLD_AVIO
|
380 |
attribute_deprecated void put_strz(AVIOContext *s, const char *buf); |
381 |
#endif
|
382 |
|
383 |
/**
|
384 |
* Write a NULL-terminated string.
|
385 |
* @return number of bytes written.
|
386 |
*/
|
387 |
int avio_put_str(AVIOContext *s, const char *str); |
388 |
|
389 |
/**
|
390 |
* Convert an UTF-8 string to UTF-16LE and write it.
|
391 |
* @return number of bytes written.
|
392 |
*/
|
393 |
int avio_put_str16le(AVIOContext *s, const char *str); |
394 |
|
395 |
/**
|
396 |
* Passing this as the "whence" parameter to a seek function causes it to
|
397 |
* return the filesize without seeking anywhere. Supporting this is optional.
|
398 |
* If it is not supported then the seek function will return <0.
|
399 |
*/
|
400 |
#define AVSEEK_SIZE 0x10000 |
401 |
|
402 |
/**
|
403 |
* Oring this flag as into the "whence" parameter to a seek function causes it to
|
404 |
* seek by any means (like reopening and linear reading) or other normally unreasonble
|
405 |
* means that can be extreemly slow.
|
406 |
* This may be ignored by the seek code.
|
407 |
*/
|
408 |
#define AVSEEK_FORCE 0x20000 |
409 |
|
410 |
/**
|
411 |
* fseek() equivalent for AVIOContext.
|
412 |
* @return new position or AVERROR.
|
413 |
*/
|
414 |
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
|
415 |
|
416 |
/**
|
417 |
* Skip given number of bytes forward
|
418 |
* @return new position or AVERROR.
|
419 |
*/
|
420 |
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
|
421 |
{ |
422 |
return avio_seek(s, offset, SEEK_CUR);
|
423 |
} |
424 |
|
425 |
/**
|
426 |
* ftell() equivalent for AVIOContext.
|
427 |
* @return position or AVERROR.
|
428 |
*/
|
429 |
static av_always_inline int64_t avio_tell(AVIOContext *s)
|
430 |
{ |
431 |
return avio_seek(s, 0, SEEK_CUR); |
432 |
} |
433 |
|
434 |
/**
|
435 |
* Get the filesize.
|
436 |
* @return filesize or AVERROR
|
437 |
*/
|
438 |
int64_t avio_size(AVIOContext *s); |
439 |
|
440 |
/** @warning currently size is limited */
|
441 |
#ifdef __GNUC__
|
442 |
int avio_printf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); |
443 |
#else
|
444 |
int avio_printf(AVIOContext *s, const char *fmt, ...); |
445 |
#endif
|
446 |
|
447 |
#if FF_API_OLD_AVIO
|
448 |
/** @note unlike fgets, the EOL character is not returned and a whole
|
449 |
line is parsed. return NULL if first char read was EOF */
|
450 |
attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size); |
451 |
#endif
|
452 |
|
453 |
void avio_flush(AVIOContext *s);
|
454 |
|
455 |
|
456 |
/**
|
457 |
* Read size bytes from AVIOContext into buf.
|
458 |
* @return number of bytes read or AVERROR
|
459 |
*/
|
460 |
int avio_read(AVIOContext *s, unsigned char *buf, int size); |
461 |
|
462 |
/** @note return 0 if EOF, so you cannot use it if EOF handling is
|
463 |
necessary */
|
464 |
int avio_r8 (AVIOContext *s);
|
465 |
unsigned int avio_rl16(AVIOContext *s); |
466 |
unsigned int avio_rl24(AVIOContext *s); |
467 |
unsigned int avio_rl32(AVIOContext *s); |
468 |
uint64_t avio_rl64(AVIOContext *s); |
469 |
|
470 |
/**
|
471 |
* Read a string from pb into buf. The reading will terminate when either
|
472 |
* a NULL character was encountered, maxlen bytes have been read, or nothing
|
473 |
* more can be read from pb. The result is guaranteed to be NULL-terminated, it
|
474 |
* will be truncated if buf is too small.
|
475 |
* Note that the string is not interpreted or validated in any way, it
|
476 |
* might get truncated in the middle of a sequence for multi-byte encodings.
|
477 |
*
|
478 |
* @return number of bytes read (is always <= maxlen).
|
479 |
* If reading ends on EOF or error, the return value will be one more than
|
480 |
* bytes actually read.
|
481 |
*/
|
482 |
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen); |
483 |
|
484 |
/**
|
485 |
* Read a UTF-16 string from pb and convert it to UTF-8.
|
486 |
* The reading will terminate when either a null or invalid character was
|
487 |
* encountered or maxlen bytes have been read.
|
488 |
* @return number of bytes read (is always <= maxlen)
|
489 |
*/
|
490 |
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen); |
491 |
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); |
492 |
|
493 |
#if FF_API_OLD_AVIO
|
494 |
/**
|
495 |
* @deprecated use avio_get_str instead
|
496 |
*/
|
497 |
attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen); |
498 |
#endif
|
499 |
unsigned int avio_rb16(AVIOContext *s); |
500 |
unsigned int avio_rb24(AVIOContext *s); |
501 |
unsigned int avio_rb32(AVIOContext *s); |
502 |
uint64_t avio_rb64(AVIOContext *s); |
503 |
|
504 |
#if FF_API_OLD_AVIO
|
505 |
/**
|
506 |
* @deprecated Use AVIOContext.seekable field directly.
|
507 |
*/
|
508 |
attribute_deprecated static inline int url_is_streamed(AVIOContext *s) |
509 |
{ |
510 |
return !s->seekable;
|
511 |
} |
512 |
#endif
|
513 |
|
514 |
#if FF_API_URL_RESETBUF
|
515 |
/** Reset the buffer for reading or writing.
|
516 |
* @note Will drop any data currently in the buffer without transmitting it.
|
517 |
* @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY
|
518 |
* to set up the buffer for writing. */
|
519 |
int url_resetbuf(AVIOContext *s, int flags); |
520 |
#endif
|
521 |
|
522 |
/**
|
523 |
* @defgroup open_modes URL open modes
|
524 |
* The flags argument to avio_open must be one of the following
|
525 |
* constants, optionally ORed with other flags.
|
526 |
* @{
|
527 |
*/
|
528 |
#define AVIO_RDONLY 0 /**< read-only */ |
529 |
#define AVIO_WRONLY 1 /**< write-only */ |
530 |
#define AVIO_RDWR 2 /**< read-write */ |
531 |
/**
|
532 |
* @}
|
533 |
*/
|
534 |
|
535 |
/**
|
536 |
* Use non-blocking mode.
|
537 |
* If this flag is set, operations on the context will return
|
538 |
* AVERROR(EAGAIN) if they can not be performed immediately.
|
539 |
* If this flag is not set, operations on the context will never return
|
540 |
* AVERROR(EAGAIN).
|
541 |
* Note that this flag does not affect the opening/connecting of the
|
542 |
* context. Connecting a protocol will always block if necessary (e.g. on
|
543 |
* network protocols) but never hang (e.g. on busy devices).
|
544 |
* Warning: non-blocking protocols is work-in-progress; this flag may be
|
545 |
* silently ignored.
|
546 |
*/
|
547 |
#define AVIO_FLAG_NONBLOCK 4 |
548 |
|
549 |
/**
|
550 |
* Create and initialize a AVIOContext for accessing the
|
551 |
* resource indicated by url.
|
552 |
* @note When the resource indicated by url has been opened in
|
553 |
* read+write mode, the AVIOContext can be used only for writing.
|
554 |
*
|
555 |
* @param s Used to return the pointer to the created AVIOContext.
|
556 |
* 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 |
int avio_open(AVIOContext **s, const char *url, int flags); |
563 |
|
564 |
int avio_close(AVIOContext *s);
|
565 |
|
566 |
#if FF_API_OLD_AVIO
|
567 |
attribute_deprecated URLContext *url_fileno(AVIOContext *s); |
568 |
|
569 |
/**
|
570 |
* @deprecated use AVIOContext.max_packet_size directly.
|
571 |
*/
|
572 |
attribute_deprecated int url_fget_max_packet_size(AVIOContext *s);
|
573 |
|
574 |
attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags); |
575 |
|
576 |
/** return the written or read size */
|
577 |
attribute_deprecated int url_close_buf(AVIOContext *s);
|
578 |
#endif
|
579 |
|
580 |
/**
|
581 |
* Open a write only memory stream.
|
582 |
*
|
583 |
* @param s new IO context
|
584 |
* @return zero if no error.
|
585 |
*/
|
586 |
int avio_open_dyn_buf(AVIOContext **s);
|
587 |
|
588 |
/**
|
589 |
* Return the written size and a pointer to the buffer. The buffer
|
590 |
* must be freed with av_free().
|
591 |
* Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
|
592 |
*
|
593 |
* @param s IO context
|
594 |
* @param pbuffer pointer to a byte buffer
|
595 |
* @return the length of the byte buffer
|
596 |
*/
|
597 |
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
|
598 |
|
599 |
#if FF_API_UDP_GET_FILE
|
600 |
int udp_get_file_handle(URLContext *h);
|
601 |
#endif
|
602 |
|
603 |
/**
|
604 |
* Iterate through names of available protocols.
|
605 |
*
|
606 |
* @param opaque A private pointer representing current protocol.
|
607 |
* It must be a pointer to NULL on first iteration and will
|
608 |
* be updated by successive calls to avio_enum_protocols.
|
609 |
* @param output If set to 1, iterate over output protocols,
|
610 |
* otherwise over input protocols.
|
611 |
*
|
612 |
* @return A static string containing the name of current protocol or NULL
|
613 |
*/
|
614 |
const char *avio_enum_protocols(void **opaque, int output); |
615 |
|
616 |
#endif /* AVFORMAT_AVIO_H */ |