You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

591 lines
21KB

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