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.

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