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.

652 lines
23KB

  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. * @ingroup lavf_io
  25. * Buffered I/O operations
  26. */
  27. #include <stdint.h>
  28. #include "libavutil/common.h"
  29. #include "libavutil/dict.h"
  30. #include "libavutil/log.h"
  31. #include "libavformat/version.h"
  32. #define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
  33. /**
  34. * Callback for checking whether to abort blocking functions.
  35. * AVERROR_EXIT is returned in this case by the interrupted
  36. * function. During blocking operations, callback is called with
  37. * opaque as parameter. If the callback returns 1, the
  38. * blocking operation will be aborted.
  39. *
  40. * No members can be added to this struct without a major bump, if
  41. * new elements have been added after this struct in AVFormatContext
  42. * or AVIOContext.
  43. */
  44. typedef struct AVIOInterruptCB {
  45. int (*callback)(void*);
  46. void *opaque;
  47. } AVIOInterruptCB;
  48. /**
  49. * Directory entry types.
  50. */
  51. enum AVIODirEntryType {
  52. AVIO_ENTRY_UNKNOWN,
  53. AVIO_ENTRY_BLOCK_DEVICE,
  54. AVIO_ENTRY_CHARACTER_DEVICE,
  55. AVIO_ENTRY_DIRECTORY,
  56. AVIO_ENTRY_NAMED_PIPE,
  57. AVIO_ENTRY_SYMBOLIC_LINK,
  58. AVIO_ENTRY_SOCKET,
  59. AVIO_ENTRY_FILE,
  60. AVIO_ENTRY_SERVER,
  61. AVIO_ENTRY_SHARE,
  62. AVIO_ENTRY_WORKGROUP,
  63. };
  64. /**
  65. * Describes single entry of the directory.
  66. *
  67. * Only name and type fields are guaranteed be set.
  68. * Rest of fields are protocol or/and platform dependent and might be unknown.
  69. */
  70. typedef struct AVIODirEntry {
  71. char *name; /**< Filename */
  72. int type; /**< Type of the entry */
  73. int utf8; /**< Set to 1 when name is encoded with UTF-8, 0 otherwise.
  74. Name can be encoded with UTF-8 even though 0 is set. */
  75. int64_t size; /**< File size in bytes, -1 if unknown. */
  76. int64_t modification_timestamp; /**< Time of last modification in microseconds since unix
  77. epoch, -1 if unknown. */
  78. int64_t access_timestamp; /**< Time of last access in microseconds since unix epoch,
  79. -1 if unknown. */
  80. int64_t status_change_timestamp; /**< Time of last status change in microseconds since unix
  81. epoch, -1 if unknown. */
  82. int64_t user_id; /**< User ID of owner, -1 if unknown. */
  83. int64_t group_id; /**< Group ID of owner, -1 if unknown. */
  84. int64_t filemode; /**< Unix file mode, -1 if unknown. */
  85. } AVIODirEntry;
  86. typedef struct AVIODirContext {
  87. struct URLContext *url_context;
  88. } AVIODirContext;
  89. /**
  90. * Bytestream IO Context.
  91. * New fields can be added to the end with minor version bumps.
  92. * Removal, reordering and changes to existing fields require a major
  93. * version bump.
  94. * sizeof(AVIOContext) must not be used outside libav*.
  95. *
  96. * @note None of the function pointers in AVIOContext should be called
  97. * directly, they should only be set by the client application
  98. * when implementing custom I/O. Normally these are set to the
  99. * function pointers specified in avio_alloc_context()
  100. */
  101. typedef struct AVIOContext {
  102. /**
  103. * A class for private options.
  104. *
  105. * If this AVIOContext is created by avio_open2(), av_class is set and
  106. * passes the options down to protocols.
  107. *
  108. * If this AVIOContext is manually allocated, then av_class may be set by
  109. * the caller.
  110. *
  111. * warning -- this field can be NULL, be sure to not pass this AVIOContext
  112. * to any av_opt_* functions in that case.
  113. */
  114. const AVClass *av_class;
  115. unsigned char *buffer; /**< Start of the buffer. */
  116. int buffer_size; /**< Maximum buffer size */
  117. unsigned char *buf_ptr; /**< Current position in the buffer */
  118. unsigned char *buf_end; /**< End of the data, may be less than
  119. buffer+buffer_size if the read function returned
  120. less data than requested, e.g. for streams where
  121. no more data has been received yet. */
  122. void *opaque; /**< A private pointer, passed to the read/write/seek/...
  123. functions. */
  124. int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
  125. int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
  126. int64_t (*seek)(void *opaque, int64_t offset, int whence);
  127. int64_t pos; /**< position in the file of the current buffer */
  128. int must_flush; /**< true if the next seek should flush */
  129. int eof_reached; /**< true if eof reached */
  130. int write_flag; /**< true if open for writing */
  131. int max_packet_size;
  132. unsigned long checksum;
  133. unsigned char *checksum_ptr;
  134. unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
  135. int error; /**< contains the error code or 0 if no error happened */
  136. /**
  137. * Pause or resume playback for network streaming protocols - e.g. MMS.
  138. */
  139. int (*read_pause)(void *opaque, int pause);
  140. /**
  141. * Seek to a given timestamp in stream with the specified stream_index.
  142. * Needed for some network streaming protocols which don't support seeking
  143. * to byte position.
  144. */
  145. int64_t (*read_seek)(void *opaque, int stream_index,
  146. int64_t timestamp, int flags);
  147. /**
  148. * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
  149. */
  150. int seekable;
  151. /**
  152. * max filesize, used to limit allocations
  153. * This field is internal to libavformat and access from outside is not allowed.
  154. */
  155. int64_t maxsize;
  156. /**
  157. * avio_read and avio_write should if possible be satisfied directly
  158. * instead of going through a buffer, and avio_seek will always
  159. * call the underlying seek function directly.
  160. */
  161. int direct;
  162. /**
  163. * Bytes read statistic
  164. * This field is internal to libavformat and access from outside is not allowed.
  165. */
  166. int64_t bytes_read;
  167. /**
  168. * seek statistic
  169. * This field is internal to libavformat and access from outside is not allowed.
  170. */
  171. int seek_count;
  172. /**
  173. * writeout statistic
  174. * This field is internal to libavformat and access from outside is not allowed.
  175. */
  176. int writeout_count;
  177. /**
  178. * Original buffer size
  179. * used internally after probing and ensure seekback to reset the buffer size
  180. * This field is internal to libavformat and access from outside is not allowed.
  181. */
  182. int orig_buffer_size;
  183. /**
  184. * Threshold to favor readahead over seek.
  185. * This is current internal only, do not use from outside.
  186. */
  187. int short_seek_threshold;
  188. } AVIOContext;
  189. /* unbuffered I/O */
  190. /**
  191. * Return the name of the protocol that will handle the passed URL.
  192. *
  193. * NULL is returned if no protocol could be found for the given URL.
  194. *
  195. * @return Name of the protocol or NULL.
  196. */
  197. const char *avio_find_protocol_name(const char *url);
  198. /**
  199. * Return AVIO_FLAG_* access flags corresponding to the access permissions
  200. * of the resource in url, or a negative value corresponding to an
  201. * AVERROR code in case of failure. The returned access flags are
  202. * masked by the value in flags.
  203. *
  204. * @note This function is intrinsically unsafe, in the sense that the
  205. * checked resource may change its existence or permission status from
  206. * one call to another. Thus you should not trust the returned value,
  207. * unless you are sure that no other processes are accessing the
  208. * checked resource.
  209. */
  210. int avio_check(const char *url, int flags);
  211. /**
  212. * Move or rename a resource.
  213. *
  214. * @note url_src and url_dst should share the same protocol and authority.
  215. *
  216. * @param url_src url to resource to be moved
  217. * @param url_dst new url to resource if the operation succeeded
  218. * @return >=0 on success or negative on error.
  219. */
  220. int avio_move(const char *url_src, const char *url_dst);
  221. /**
  222. * Delete a resource.
  223. *
  224. * @param url resource to be deleted.
  225. * @return >=0 on success or negative on error.
  226. */
  227. int avio_delete(const char *url);
  228. /**
  229. * Open directory for reading.
  230. *
  231. * @param s directory read context. Pointer to a NULL pointer must be passed.
  232. * @param url directory to be listed.
  233. * @param options A dictionary filled with protocol-private options. On return
  234. * this parameter will be destroyed and replaced with a dictionary
  235. * containing options that were not found. May be NULL.
  236. * @return >=0 on success or negative on error.
  237. */
  238. int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options);
  239. /**
  240. * Get next directory entry.
  241. *
  242. * Returned entry must be freed with avio_free_directory_entry(). In particular
  243. * it may outlive AVIODirContext.
  244. *
  245. * @param s directory read context.
  246. * @param[out] next next entry or NULL when no more entries.
  247. * @return >=0 on success or negative on error. End of list is not considered an
  248. * error.
  249. */
  250. int avio_read_dir(AVIODirContext *s, AVIODirEntry **next);
  251. /**
  252. * Close directory.
  253. *
  254. * @note Entries created using avio_read_dir() are not deleted and must be
  255. * freeded with avio_free_directory_entry().
  256. *
  257. * @param s directory read context.
  258. * @return >=0 on success or negative on error.
  259. */
  260. int avio_close_dir(AVIODirContext **s);
  261. /**
  262. * Free entry allocated by avio_read_dir().
  263. *
  264. * @param entry entry to be freed.
  265. */
  266. void avio_free_directory_entry(AVIODirEntry **entry);
  267. /**
  268. * Allocate and initialize an AVIOContext for buffered I/O. It must be later
  269. * freed with av_free().
  270. *
  271. * @param buffer Memory block for input/output operations via AVIOContext.
  272. * The buffer must be allocated with av_malloc() and friends.
  273. * It may be freed and replaced with a new buffer by libavformat.
  274. * AVIOContext.buffer holds the buffer currently in use,
  275. * which must be later freed with av_free().
  276. * @param buffer_size The buffer size is very important for performance.
  277. * For protocols with fixed blocksize it should be set to this blocksize.
  278. * For others a typical size is a cache page, e.g. 4kb.
  279. * @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
  280. * @param opaque An opaque pointer to user-specific data.
  281. * @param read_packet A function for refilling the buffer, may be NULL.
  282. * @param write_packet A function for writing the buffer contents, may be NULL.
  283. * The function may not change the input buffers content.
  284. * @param seek A function for seeking to specified byte position, may be NULL.
  285. *
  286. * @return Allocated AVIOContext or NULL on failure.
  287. */
  288. AVIOContext *avio_alloc_context(
  289. unsigned char *buffer,
  290. int buffer_size,
  291. int write_flag,
  292. void *opaque,
  293. int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
  294. int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
  295. int64_t (*seek)(void *opaque, int64_t offset, int whence));
  296. void avio_w8(AVIOContext *s, int b);
  297. void avio_write(AVIOContext *s, const unsigned char *buf, int size);
  298. void avio_wl64(AVIOContext *s, uint64_t val);
  299. void avio_wb64(AVIOContext *s, uint64_t val);
  300. void avio_wl32(AVIOContext *s, unsigned int val);
  301. void avio_wb32(AVIOContext *s, unsigned int val);
  302. void avio_wl24(AVIOContext *s, unsigned int val);
  303. void avio_wb24(AVIOContext *s, unsigned int val);
  304. void avio_wl16(AVIOContext *s, unsigned int val);
  305. void avio_wb16(AVIOContext *s, unsigned int val);
  306. /**
  307. * Write a NULL-terminated string.
  308. * @return number of bytes written.
  309. */
  310. int avio_put_str(AVIOContext *s, const char *str);
  311. /**
  312. * Convert an UTF-8 string to UTF-16LE and write it.
  313. * @param s the AVIOContext
  314. * @param str NULL-terminated UTF-8 string
  315. *
  316. * @return number of bytes written.
  317. */
  318. int avio_put_str16le(AVIOContext *s, const char *str);
  319. /**
  320. * Convert an UTF-8 string to UTF-16BE and write it.
  321. * @param s the AVIOContext
  322. * @param str NULL-terminated UTF-8 string
  323. *
  324. * @return number of bytes written.
  325. */
  326. int avio_put_str16be(AVIOContext *s, const char *str);
  327. /**
  328. * Passing this as the "whence" parameter to a seek function causes it to
  329. * return the filesize without seeking anywhere. Supporting this is optional.
  330. * If it is not supported then the seek function will return <0.
  331. */
  332. #define AVSEEK_SIZE 0x10000
  333. /**
  334. * Oring this flag as into the "whence" parameter to a seek function causes it to
  335. * seek by any means (like reopening and linear reading) or other normally unreasonable
  336. * means that can be extremely slow.
  337. * This may be ignored by the seek code.
  338. */
  339. #define AVSEEK_FORCE 0x20000
  340. /**
  341. * fseek() equivalent for AVIOContext.
  342. * @return new position or AVERROR.
  343. */
  344. int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
  345. /**
  346. * Skip given number of bytes forward
  347. * @return new position or AVERROR.
  348. */
  349. int64_t avio_skip(AVIOContext *s, int64_t offset);
  350. /**
  351. * ftell() equivalent for AVIOContext.
  352. * @return position or AVERROR.
  353. */
  354. static av_always_inline int64_t avio_tell(AVIOContext *s)
  355. {
  356. return avio_seek(s, 0, SEEK_CUR);
  357. }
  358. /**
  359. * Get the filesize.
  360. * @return filesize or AVERROR
  361. */
  362. int64_t avio_size(AVIOContext *s);
  363. /**
  364. * feof() equivalent for AVIOContext.
  365. * @return non zero if and only if end of file
  366. */
  367. int avio_feof(AVIOContext *s);
  368. #if FF_API_URL_FEOF
  369. /**
  370. * @deprecated use avio_feof()
  371. */
  372. attribute_deprecated
  373. int url_feof(AVIOContext *s);
  374. #endif
  375. /** @warning currently size is limited */
  376. int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
  377. /**
  378. * Force flushing of buffered data.
  379. *
  380. * For write streams, force the buffered data to be immediately written to the output,
  381. * without to wait to fill the internal buffer.
  382. *
  383. * For read streams, discard all currently buffered data, and advance the
  384. * reported file position to that of the underlying stream. This does not
  385. * read new data, and does not perform any seeks.
  386. */
  387. void avio_flush(AVIOContext *s);
  388. /**
  389. * Read size bytes from AVIOContext into buf.
  390. * @return number of bytes read or AVERROR
  391. */
  392. int avio_read(AVIOContext *s, unsigned char *buf, int size);
  393. /**
  394. * @name Functions for reading from AVIOContext
  395. * @{
  396. *
  397. * @note return 0 if EOF, so you cannot use it if EOF handling is
  398. * necessary
  399. */
  400. int avio_r8 (AVIOContext *s);
  401. unsigned int avio_rl16(AVIOContext *s);
  402. unsigned int avio_rl24(AVIOContext *s);
  403. unsigned int avio_rl32(AVIOContext *s);
  404. uint64_t avio_rl64(AVIOContext *s);
  405. unsigned int avio_rb16(AVIOContext *s);
  406. unsigned int avio_rb24(AVIOContext *s);
  407. unsigned int avio_rb32(AVIOContext *s);
  408. uint64_t avio_rb64(AVIOContext *s);
  409. /**
  410. * @}
  411. */
  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. /**
  434. * @name URL open modes
  435. * The flags argument to avio_open must be one of the following
  436. * constants, optionally ORed with other flags.
  437. * @{
  438. */
  439. #define AVIO_FLAG_READ 1 /**< read-only */
  440. #define AVIO_FLAG_WRITE 2 /**< write-only */
  441. #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */
  442. /**
  443. * @}
  444. */
  445. /**
  446. * Use non-blocking mode.
  447. * If this flag is set, operations on the context will return
  448. * AVERROR(EAGAIN) if they can not be performed immediately.
  449. * If this flag is not set, operations on the context will never return
  450. * AVERROR(EAGAIN).
  451. * Note that this flag does not affect the opening/connecting of the
  452. * context. Connecting a protocol will always block if necessary (e.g. on
  453. * network protocols) but never hang (e.g. on busy devices).
  454. * Warning: non-blocking protocols is work-in-progress; this flag may be
  455. * silently ignored.
  456. */
  457. #define AVIO_FLAG_NONBLOCK 8
  458. /**
  459. * Use direct mode.
  460. * avio_read and avio_write should if possible be satisfied directly
  461. * instead of going through a buffer, and avio_seek will always
  462. * call the underlying seek function directly.
  463. */
  464. #define AVIO_FLAG_DIRECT 0x8000
  465. /**
  466. * Create and initialize a AVIOContext for accessing the
  467. * resource indicated by url.
  468. * @note When the resource indicated by url has been opened in
  469. * read+write mode, the AVIOContext can be used only for writing.
  470. *
  471. * @param s Used to return the pointer to the created AVIOContext.
  472. * In case of failure the pointed to value is set to NULL.
  473. * @param url resource to access
  474. * @param flags flags which control how the resource indicated by url
  475. * is to be opened
  476. * @return >= 0 in case of success, a negative value corresponding to an
  477. * AVERROR code in case of failure
  478. */
  479. int avio_open(AVIOContext **s, const char *url, int flags);
  480. /**
  481. * Create and initialize a AVIOContext for accessing the
  482. * resource indicated by url.
  483. * @note When the resource indicated by url has been opened in
  484. * read+write mode, the AVIOContext can be used only for writing.
  485. *
  486. * @param s Used to return the pointer to the created AVIOContext.
  487. * In case of failure the pointed to value is set to NULL.
  488. * @param url resource to access
  489. * @param flags flags which control how the resource indicated by url
  490. * is to be opened
  491. * @param int_cb an interrupt callback to be used at the protocols level
  492. * @param options A dictionary filled with protocol-private options. On return
  493. * this parameter will be destroyed and replaced with a dict containing options
  494. * that were not found. May be NULL.
  495. * @return >= 0 in case of success, a negative value corresponding to an
  496. * AVERROR code in case of failure
  497. */
  498. int avio_open2(AVIOContext **s, const char *url, int flags,
  499. const AVIOInterruptCB *int_cb, AVDictionary **options);
  500. /**
  501. * Close the resource accessed by the AVIOContext s and free it.
  502. * This function can only be used if s was opened by avio_open().
  503. *
  504. * The internal buffer is automatically flushed before closing the
  505. * resource.
  506. *
  507. * @return 0 on success, an AVERROR < 0 on error.
  508. * @see avio_closep
  509. */
  510. int avio_close(AVIOContext *s);
  511. /**
  512. * Close the resource accessed by the AVIOContext *s, free it
  513. * and set the pointer pointing to it to NULL.
  514. * This function can only be used if s was opened by avio_open().
  515. *
  516. * The internal buffer is automatically flushed before closing the
  517. * resource.
  518. *
  519. * @return 0 on success, an AVERROR < 0 on error.
  520. * @see avio_close
  521. */
  522. int avio_closep(AVIOContext **s);
  523. /**
  524. * Open a write only memory stream.
  525. *
  526. * @param s new IO context
  527. * @return zero if no error.
  528. */
  529. int avio_open_dyn_buf(AVIOContext **s);
  530. /**
  531. * Return the written size and a pointer to the buffer. The buffer
  532. * must be freed with av_free().
  533. * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
  534. *
  535. * @param s IO context
  536. * @param pbuffer pointer to a byte buffer
  537. * @return the length of the byte buffer
  538. */
  539. int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
  540. /**
  541. * Iterate through names of available protocols.
  542. *
  543. * @param opaque A private pointer representing current protocol.
  544. * It must be a pointer to NULL on first iteration and will
  545. * be updated by successive calls to avio_enum_protocols.
  546. * @param output If set to 1, iterate over output protocols,
  547. * otherwise over input protocols.
  548. *
  549. * @return A static string containing the name of current protocol or NULL
  550. */
  551. const char *avio_enum_protocols(void **opaque, int output);
  552. /**
  553. * Pause and resume playing - only meaningful if using a network streaming
  554. * protocol (e.g. MMS).
  555. *
  556. * @param h IO context from which to call the read_pause function pointer
  557. * @param pause 1 for pause, 0 for resume
  558. */
  559. int avio_pause(AVIOContext *h, int pause);
  560. /**
  561. * Seek to a given timestamp relative to some component stream.
  562. * Only meaningful if using a network streaming protocol (e.g. MMS.).
  563. *
  564. * @param h IO context from which to call the seek function pointers
  565. * @param stream_index The stream index that the timestamp is relative to.
  566. * If stream_index is (-1) the timestamp should be in AV_TIME_BASE
  567. * units from the beginning of the presentation.
  568. * If a stream_index >= 0 is used and the protocol does not support
  569. * seeking based on component streams, the call will fail.
  570. * @param timestamp timestamp in AVStream.time_base units
  571. * or if there is no stream specified then in AV_TIME_BASE units.
  572. * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE
  573. * and AVSEEK_FLAG_ANY. The protocol may silently ignore
  574. * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will
  575. * fail if used and not supported.
  576. * @return >= 0 on success
  577. * @see AVInputFormat::read_seek
  578. */
  579. int64_t avio_seek_time(AVIOContext *h, int stream_index,
  580. int64_t timestamp, int flags);
  581. /* Avoid a warning. The header can not be included because it breaks c++. */
  582. struct AVBPrint;
  583. /**
  584. * Read contents of h into print buffer, up to max_size bytes, or up to EOF.
  585. *
  586. * @return 0 for success (max_size bytes read or EOF reached), negative error
  587. * code otherwise
  588. */
  589. int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size);
  590. #endif /* AVFORMAT_AVIO_H */