36 #define IO_BUFFER_SIZE 32768
43 #define SHORT_SEEK_THRESHOLD 4096
53 return prev ?
NULL :
internal->h;
61 #define OFFSET(x) offsetof(AVIOContext,x)
62 #define E AV_OPT_FLAG_ENCODING_PARAM
63 #define D AV_OPT_FLAG_DECODING_PARAM
65 {
"protocol_whitelist",
"List of protocols that are allowed to be used",
OFFSET(protocol_whitelist),
AV_OPT_TYPE_STRING, { .str =
NULL }, CHAR_MIN, CHAR_MAX,
D },
88 int64_t (*seek)(
void *opaque, int64_t
offset,
int whence))
113 s->
pos = buffer_size;
130 unsigned char *buffer,
136 int64_t (*seek)(
void *opaque, int64_t
offset,
int whence))
251 whence &= ~AVSEEK_FORCE;
260 if (whence != SEEK_CUR && whence != SEEK_SET)
263 if (whence == SEEK_CUR) {
267 if (offset > INT64_MAX - offset1)
282 offset1 = offset - pos;
289 offset1 <= buffer_size + short_seek) &&
292 (whence != SEEK_END || force)) {
298 }
else if(!s->
write_flag && offset1 < 0 && -offset1 < buffer_size>>1 && s->
seek && offset > 0) {
301 pos -=
FFMIN(buffer_size>>1, pos);
302 if ((res = s->
seek(s->
opaque, pos, SEEK_SET)) < 0)
309 return avio_seek(s, offset, SEEK_SET | force);
317 if ((res = s->
seek(s->
opaque, offset, SEEK_SET)) < 0)
348 if ((size = s->
seek(s->
opaque, -1, SEEK_END)) < 0)
395 avio_write(s, (
const unsigned char *) str, len);
416 av_log(s,
AV_LOG_ERROR,
"Invalid UTF8 sequence in avio_put_str16%s\n", be ?
"be" :
"le");
431 #define PUT_STR16(type, big_endian) \
432 int avio_put_str16 ## type(AVIOContext *s, const char *str) \
434 return put_str16(s, str, big_endian); \
464 avio_wl32(s, (uint32_t)(val & 0xffffffff));
471 avio_wb32(s, (uint32_t)(val & 0xffffffff));
617 unsigned long (*update_checksum)(
unsigned long c,
const uint8_t *p,
unsigned int len),
805 if (c && i < maxlen-1)
807 }
while (c !=
'\n' && c !=
'\r' && c);
822 buflen =
FFMIN(buflen - 1, maxlen);
823 for (i = 0; i < buflen; i++)
827 for (; i < maxlen; i++)
833 #define GET_STR16(type, read) \
834 int avio_get_str16 ##type(AVIOContext *pb, int maxlen, char *buf, int buflen)\
839 return AVERROR(EINVAL); \
840 while (ret + 1 < maxlen) {\
843 GET_UTF16(ch, (ret += 2) <= maxlen ? read(pb) : 0, break;)\
846 PUT_UTF8(ch, tmp, if (q - buf < buflen - 1) *q++ = tmp;)\
871 val= (val<<7) + (tmp&127);
879 return ffurl_read(internal->h, buf, buf_size);
891 return ffurl_seek(internal->h, offset, whence);
903 if (!internal->h->prot->url_read_pause)
905 return internal->h->prot->url_read_pause(internal->h, pause);
911 if (!internal->h->prot->url_read_seek)
913 return internal->h->prot->url_read_seek(internal->h, stream_index, timestamp, flags);
920 int buffer_size, max_packet_size;
923 if (max_packet_size) {
924 buffer_size = max_packet_size;
956 (*s)->max_packet_size = max_packet_size;
984 if (buf_size < filled || s->seekable || !s->
read_packet)
992 memcpy(buffer, s->
buffer, filled);
998 if (checksum_ptr_offset >= 0)
1035 int64_t buffer_start;
1037 int overlap, new_size, alloc_size;
1048 if ((buffer_start = s->
pos - buffer_size) > buf_size) {
1053 overlap = buf_size - buffer_start;
1054 new_size = buf_size + buffer_size - overlap;
1057 if (alloc_size > buf_size)
1058 if (!(buf = (*bufp) =
av_realloc_f(buf, 1, alloc_size)))
1061 if (new_size > buf_size) {
1062 memcpy(buf + buf_size, s->
buffer + overlap, buffer_size - overlap);
1063 buf_size = new_size;
1083 const char *whitelist,
const char *blacklist
1151 ret =
vsnprintf(buf,
sizeof(buf), fmt, ap);
1165 int64_t timestamp,
int flags)
1177 else if (pos !=
AVERROR(ENOSYS))
1232 unsigned new_size, new_allocated_size;
1235 new_size = d->
pos + buf_size;
1237 if (new_size < d->pos || new_size > INT_MAX/2)
1239 while (new_size > new_allocated_size) {
1240 if (!new_allocated_size)
1241 new_allocated_size = new_size;
1243 new_allocated_size += new_allocated_size / 2 + 1;
1255 memcpy(d->
buffer + d->
pos, buf, buf_size);
1264 unsigned char buf1[4];
1281 if (whence == SEEK_CUR)
1283 else if (whence == SEEK_END)
1285 if (offset < 0 || offset > 0x7fffffffLL)
1294 unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
1296 if (
sizeof(
DynBuffer) + io_buffer_size < io_buffer_size)
1309 (*s)->max_packet_size = max_packet_size;
1320 if (max_packet_size <= 0)
1369 return size - padding;
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
void avio_wl64(AVIOContext *s, uint64_t val)
const char const char void * val
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Allocate and initialize an AVIOContext for buffered I/O.
static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint64_t avio_rb64(AVIOContext *s)
int64_t(* read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp in stream with the specified stream_index.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
#define av_realloc_f(p, o, n)
void avio_wb16(AVIOContext *s, unsigned int val)
static int64_t io_read_seek(void *opaque, int stream_index, int64_t timestamp, int flags)
ptrdiff_t const GLvoid * data
int(* short_seek_get)(void *opaque)
A callback that is used instead of short_seek_threshold.
#define AV_LOG_WARNING
Something somehow does not look correct.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
#define LIBAVUTIL_VERSION_INT
unsigned char * buf_ptr
Current position in the buffer.
int writeout_count
writeout statistic This field is internal to libavformat and access from outside is not allowed...
unsigned char * buf_end
End of the data, may be less than buffer+buffer_size if the read function returned less data than req...
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
int write_flag
true if open for writing
int is_streamed
true if streamed (no seek possible), default = false
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
#define AVIO_SEEKABLE_TIME
Seeking by timestamp with avio_seek_time() is possible.
void ffio_fill(AVIOContext *s, int b, int count)
#define AVIO_FLAG_READ
read-only
unsigned int avio_rl24(AVIOContext *s)
int min_packet_size
Try to buffer at least this amount of data before flushing it.
int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
#define AVIO_FLAG_WRITE
write-only
unsigned char * buffer
Start of the buffer.
void avio_wl24(AVIOContext *s, unsigned int val)
void avio_w8(AVIOContext *s, int b)
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
int64_t(* seek)(void *opaque, int64_t offset, int whence)
void * opaque
A private pointer, passed to the read/write/seek/...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void avio_wb32(AVIOContext *s, unsigned int val)
static const AVClass * ff_avio_child_class_next(const AVClass *prev)
static int io_read_packet(void *opaque, uint8_t *buf, int buf_size)
Trailer data, which doesn't contain actual content, but only for finalizing the output file...
int avio_accept(AVIOContext *s, AVIOContext **c)
Accept and allocate a client context on a server context.
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
void avio_wl32(AVIOContext *s, unsigned int val)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
A point in the output bytestream where the underlying AVIOContext might flush the buffer depending on...
static void fill_buffer(AVIOContext *s)
static int io_read_pause(void *opaque, int pause)
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
unsigned long ffio_get_checksum(AVIOContext *s)
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
int ffio_open_null_buf(AVIOContext **s)
Open a write-only fake memory stream.
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
A point in the output bytestream where a demuxer can start parsing (for non self synchronizing bytest...
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
Public header for CRC hash function implementation.
int64_t bytes_read
Bytes read statistic This field is internal to libavformat and access from outside is not allowed...
char * protocol_whitelist
',' separated list of allowed protocols.
#define AVERROR_EOF
End of file.
int ffio_set_buf_size(AVIOContext *s, int buf_size)
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
Read size bytes from AVIOContext, returning a pointer.
void avio_wb24(AVIOContext *s, unsigned int val)
void avio_wl16(AVIOContext *s, unsigned int val)
int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
unsigned long ff_crcEDB88320_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
const OptionDef options[]
static void flush_buffer(AVIOContext *s)
Callback for checking whether to abort blocking functions.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int(* write_packet)(void *opaque, uint8_t *buf, int buf_size)
unsigned int avio_rb24(AVIOContext *s)
const AVIOInterruptCB int_cb
static int dyn_packet_buf_write(void *opaque, uint8_t *buf, int buf_size)
const char * protocol_whitelist
int(* read_packet)(void *opaque, uint8_t *buf, int buf_size)
static const AVOption ff_avio_options[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
simple assert() macros that are a bit more flexible than ISO C assert().
static void * ff_avio_child_next(void *obj, void *prev)
#define SHORT_SEEK_THRESHOLD
Do seeks within this distance ahead of the current buffer by skipping data instead of calling the pro...
static const uint8_t offset[127][2]
int direct
avio_read and avio_write should if possible be satisfied directly instead of going through a buffer...
unsigned int avio_rl16(AVIOContext *s)
int seek_count
seek statistic This field is internal to libavformat and access from outside is not allowed...
int avio_pause(AVIOContext *s, int pause)
Pause and resume playing - only meaningful if using a network streaming protocol (e.g.
int(* write_data_type)(void *opaque, uint8_t *buf, int buf_size, enum AVIODataMarkerType type, int64_t time)
A callback that is used instead of write_packet.
unsigned int avio_rl32(AVIOContext *s)
This is any, unlabelled data.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int ffurl_get_short_seek(URLContext *h)
Return the current short seek threshold value for this URL.
const AVClass ff_avio_class
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
unsigned char * checksum_ptr
int avio_printf(AVIOContext *s, const char *fmt,...)
AVIODataMarkerType
Different data types that can be returned via the AVIO write_data_type callback.
int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
int ffurl_handshake(URLContext *c)
Perform one step of the protocol handshake to accept a new client.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
void avio_context_free(AVIOContext **ps)
Free the supplied IO context and everything associated with it.
static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
#define GET_STR16(type, read)
static volatile int checksum
unsigned long(* update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size)
int ffurl_accept(URLContext *s, URLContext **c)
Accept an URLContext c on an URLContext s.
int buffer_size
Maximum buffer size.
void avio_wb64(AVIOContext *s, uint64_t val)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
Open a write only packetized memory stream with a maximum packet size of 'max_packet_size'.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
char * av_strdup(const char *s)
Duplicate a string.
const char * protocol_blacklist
#define PUT_STR16(type, big_endian)
int avio_open(AVIOContext **s, const char *filename, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
static int io_short_seek(void *opaque)
int64_t(* url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags)
int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **bufp, int buf_size)
Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file...
static int url_resetbuf(AVIOContext *s, int flags)
uint64_t avio_rl64(AVIOContext *s)
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
Describe the class of an AVClass context structure.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
#define AVSEEK_FORCE
Passing this flag as the "whence" parameter to a seek function causes it to seek by any means (like r...
#define AVIO_FLAG_DIRECT
Use direct mode.
unsigned int avio_rb16(AVIOContext *s)
int short_seek_threshold
Threshold to favor readahead over seek.
#define PUT_UTF16(val, tmp, PUT_16BIT)
Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
int ignore_boundary_point
If set, don't call write_data_type separately for AVIO_DATA_MARKER_BOUNDARY_POINT, but ignore them and treat them as AVIO_DATA_MARKER_UNKNOWN (to avoid needlessly small chunks of data returned from the callback).
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
int error
contains the error code or 0 if no error happened
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int(* read_pause)(void *opaque, int pause)
Pause or resume playback for network streaming protocols - e.g.
int ff_get_v_length(uint64_t val)
Get the length in bytes which is needed to store val as v.
int ffurl_close(URLContext *h)
const AVClass ffurl_context_class
int orig_buffer_size
Original buffer size used internally after probing and ensure seekback to reset the buffer size This ...
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
enum AVIODataMarkerType current_type
Internal, not meant to be used from outside of AVIOContext.
int avio_handshake(AVIOContext *c)
Perform one step of the protocol handshake to accept a new client.
int avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
int64_t avio_size(AVIOContext *s)
Get the filesize.
void av_opt_free(void *obj)
Free all allocated objects in obj.
int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
Change the position that will be used by the next read/write operation on the resource accessed by h...
const struct URLProtocol * prot
int ffio_fdopen(AVIOContext **s, URLContext *h)
Create and initialize a AVIOContext for accessing the resource referenced by the URLContext h...
void ffio_init_checksum(AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
int64_t pos
position in the file of the current buffer
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
uint64_t ffio_read_varlen(AVIOContext *bc)
unsigned int avio_rb32(AVIOContext *s)
unsigned char * buf_ptr_max
Maximum reached position before a backward seek in the write buffer, used keeping track of already wr...
A point in the output bytestream where a decoder can start decoding (i.e.
static int put_str16(AVIOContext *s, const char *str, const int be)
int eof_reached
true if eof reached
static int io_write_packet(void *opaque, uint8_t *buf, int buf_size)
void ff_put_v(AVIOContext *bc, uint64_t val)
Put val using a variable number of bytes.
int ffio_close_null_buf(AVIOContext *s)
Close a null buffer.
static int null_buf_write(void *opaque, uint8_t *buf, int buf_size)
static void writeout(AVIOContext *s, const uint8_t *data, int len)
int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
char * protocol_blacklist
',' separated list of disallowed protocols.
int max_packet_size
if non zero, the stream is packetized with this max packet size
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
unbuffered private I/O API
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
int avio_r8(AVIOContext *s)
int min_packet_size
if non zero, the stream is packetized with this min packet size
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf...
static int64_t io_seek(void *opaque, int64_t offset, int whence)
Header data; this needs to be present for the stream to be decodeable.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int64_t avio_seek_time(AVIOContext *s, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp relative to some component stream.
unsigned long ff_crcA001_update(unsigned long checksum, const uint8_t *buf, unsigned int len)