yading@11: /* yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #ifndef AVFORMAT_AVIO_INTERNAL_H yading@11: #define AVFORMAT_AVIO_INTERNAL_H yading@11: yading@11: #include "avio.h" yading@11: #include "url.h" yading@11: yading@11: #include "libavutil/log.h" yading@11: yading@11: extern const AVClass ffio_url_class; yading@11: yading@11: int ffio_init_context(AVIOContext *s, yading@11: unsigned char *buffer, yading@11: int buffer_size, yading@11: int write_flag, yading@11: void *opaque, yading@11: int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), yading@11: int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), yading@11: int64_t (*seek)(void *opaque, int64_t offset, int whence)); yading@11: yading@11: yading@11: /** yading@11: * Read size bytes from AVIOContext into buf. yading@11: * This reads at most 1 packet. If that is not enough fewer bytes will be yading@11: * returned. yading@11: * @return number of bytes read or AVERROR yading@11: */ yading@11: int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size); yading@11: yading@11: void ffio_fill(AVIOContext *s, int b, int count); yading@11: yading@11: static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s) yading@11: { yading@11: avio_wl32(pb, MKTAG(s[0], s[1], s[2], s[3])); yading@11: } yading@11: yading@11: /** yading@11: * Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file. yading@11: * Used after probing to avoid seeking. yading@11: * Joins buf and s->buffer, taking any overlap into consideration. yading@11: * @note s->buffer must overlap with buf or they can't be joined and the function fails yading@11: * yading@11: * @param s The read-only AVIOContext to rewind yading@11: * @param buf The probe buffer containing the first buf_size bytes of the file yading@11: * @param buf_size The size of buf yading@11: * @return 0 in case of success, a negative value corresponding to an yading@11: * AVERROR code in case of failure yading@11: */ yading@11: int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **buf, int buf_size); yading@11: yading@11: uint64_t ffio_read_varlen(AVIOContext *bc); yading@11: yading@11: /** @warning must be called before any I/O */ yading@11: int ffio_set_buf_size(AVIOContext *s, int buf_size); yading@11: yading@11: int ffio_limit(AVIOContext *s, int size); yading@11: yading@11: void ffio_init_checksum(AVIOContext *s, yading@11: unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), yading@11: unsigned long checksum); yading@11: unsigned long ffio_get_checksum(AVIOContext *s); yading@11: unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, yading@11: unsigned int len); yading@11: yading@11: /** yading@11: * Open a write only packetized memory stream with a maximum packet yading@11: * size of 'max_packet_size'. The stream is stored in a memory buffer yading@11: * with a big-endian 4 byte header giving the packet size in bytes. yading@11: * yading@11: * @param s new IO context yading@11: * @param max_packet_size maximum packet size (must be > 0) yading@11: * @return zero if no error. yading@11: */ yading@11: int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); yading@11: yading@11: /** yading@11: * Create and initialize a AVIOContext for accessing the yading@11: * resource referenced by the URLContext h. yading@11: * @note When the URLContext h has been opened in read+write mode, the yading@11: * AVIOContext can be used only for writing. yading@11: * yading@11: * @param s Used to return the pointer to the created AVIOContext. yading@11: * In case of failure the pointed to value is set to NULL. yading@11: * @return 0 in case of success, a negative value corresponding to an yading@11: * AVERROR code in case of failure yading@11: */ yading@11: int ffio_fdopen(AVIOContext **s, URLContext *h); yading@11: yading@11: #endif /* AVFORMAT_AVIO_INTERNAL_H */