FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
avio_internal.h File Reference
#include "avio.h"
#include "url.h"
#include "libavutil/log.h"

Go to the source code of this file.

Functions

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))
 
int ffio_read_indirect (AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
 Read size bytes from AVIOContext, returning a pointer. More...
 
void ffio_fill (AVIOContext *s, int b, int count)
 
static av_always_inline void ffio_wfourcc (AVIOContext *pb, const uint8_t *s)
 
int ffio_rewind_with_probe_data (AVIOContext *s, unsigned char **buf, int buf_size)
 Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file. More...
 
uint64_t ffio_read_varlen (AVIOContext *bc)
 
int ffio_read_size (AVIOContext *s, unsigned char *buf, int size)
 Read size bytes from AVIOContext into buf. More...
 
int ffio_set_buf_size (AVIOContext *s, int buf_size)
 
int ffio_ensure_seekback (AVIOContext *s, int64_t buf_size)
 Ensures that the requested seekback buffer size will be available. More...
 
int ffio_limit (AVIOContext *s, int size)
 
void ffio_init_checksum (AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
 
unsigned long ffio_get_checksum (AVIOContext *s)
 
unsigned long ff_crc04C11DB7_update (unsigned long checksum, const uint8_t *buf, unsigned int len)
 
unsigned long ff_crcEDB88320_update (unsigned long checksum, const uint8_t *buf, unsigned int len)
 
unsigned long ff_crcA001_update (unsigned long checksum, const uint8_t *buf, unsigned int len)
 
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'. More...
 
int ffio_fdopen (AVIOContext **s, URLContext *h)
 Create and initialize a AVIOContext for accessing the resource referenced by the URLContext h. More...
 
URLContextffio_geturlcontext (AVIOContext *s)
 Return the URLContext associated with the AVIOContext. More...
 
int ffio_open_null_buf (AVIOContext **s)
 Open a write-only fake memory stream. More...
 
int ffio_open_whitelist (AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
 
int ffio_close_null_buf (AVIOContext *s)
 Close a null buffer. More...
 
void ffio_free_dyn_buf (AVIOContext **s)
 Free a dynamic buffer. More...
 

Variables

const AVClass ff_avio_class
 

Function Documentation

int ffio_init_context ( AVIOContext s,
unsigned char *  buffer,
int  buffer_size,
int  write_flag,
void opaque,
int(*)(void *opaque, uint8_t *buf, int buf_size)  read_packet,
int(*)(void *opaque, uint8_t *buf, int buf_size)  write_packet,
int64_t(*)(void *opaque, int64_t offset, int whence)  seek 
)
int ffio_read_indirect ( AVIOContext s,
unsigned char *  buf,
int  size,
const unsigned char **  data 
)

Read size bytes from AVIOContext, returning a pointer.

Note that the data pointed at by the returned pointer is only valid until the next call that references the same IO context.

Parameters
sIO context
bufpointer to buffer into which to assemble the requested data if it is not available in contiguous addresses in the underlying buffer
sizenumber of bytes requested
dataaddress at which to store pointer: this will be a a direct pointer into the underlying buffer if the requested number of bytes are available at contiguous addresses, otherwise will be a copy of buf
Returns
number of bytes read or AVERROR

Definition at line 705 of file aviobuf.c.

Referenced by read_packet().

void ffio_fill ( AVIOContext s,
int  b,
int  count 
)
static av_always_inline void ffio_wfourcc ( AVIOContext pb,
const uint8_t s 
)
static

Definition at line 58 of file avio_internal.h.

Referenced by aiff_write_header(), ast_write_header(), ast_write_packet(), avi_start_new_riff(), avi_write_header(), avi_write_idx1(), avi_write_ix(), avi_write_trailer(), caf_write_header(), caf_write_trailer(), ff_mov_cenc_write_sinf_tag(), ff_riff_write_info(), ff_riff_write_info_tag(), ff_start_tag(), film_write_header(), mov_cenc_write_saio_tag(), mov_cenc_write_saiz_tag(), mov_cenc_write_schi_tag(), mov_cenc_write_senc_tag(), mov_create_chapter_track(), mov_flush_fragment(), mov_preroll_write_stbl_atoms(), mov_write_3gp_udta_tag(), mov_write_ac3_tag(), mov_write_amr_tag(), mov_write_audio_tag(), mov_write_av1c_tag(), mov_write_avcc_tag(), mov_write_avid_tag(), mov_write_chan_tag(), mov_write_chpl_tag(), mov_write_clap_tag(), mov_write_colr_tag(), mov_write_covr(), mov_write_ctts_tag(), mov_write_d263_tag(), mov_write_dfla_tag(), mov_write_dinf_tag(), mov_write_dops_tag(), mov_write_dpxe_tag(), mov_write_dref_tag(), mov_write_dvc1_tag(), mov_write_eac3_tag(), mov_write_edts_tag(), mov_write_enda_tag(), mov_write_enda_tag_be(), mov_write_esds_tag(), mov_write_fiel_tag(), mov_write_ftyp_tag(), mov_write_gama_tag(), mov_write_glbl_tag(), mov_write_gmhd_tag(), mov_write_gpmd_tag(), mov_write_hdlr_tag(), mov_write_hmhd_tag(), mov_write_hvcc_tag(), mov_write_ilst_tag(), mov_write_int8_metadata(), mov_write_iods_tag(), mov_write_isml_manifest(), mov_write_itunes_hdlr_tag(), mov_write_loci_tag(), mov_write_mdat_tag(), mov_write_mdhd_tag(), mov_write_mdia_tag(), mov_write_mdta_hdlr_tag(), mov_write_mdta_ilst_tag(), mov_write_mdta_keys_tag(), mov_write_meta_tag(), mov_write_mfhd_tag(), mov_write_mfra_tag(), mov_write_minf_tag(), mov_write_moof_tag_internal(), mov_write_moov_tag(), mov_write_mvex_tag(), mov_write_mvhd_tag(), mov_write_nmhd_tag(), mov_write_pasp_tag(), mov_write_prft_tag(), mov_write_raw_metadata_tag(), mov_write_rtp_tag(), mov_write_sdtp_tag(), mov_write_sidx_tag(), mov_write_smhd_tag(), mov_write_source_reference_tag(), mov_write_st3d_tag(), mov_write_stbl_tag(), mov_write_stco_tag(), mov_write_string_data_tag(), mov_write_string_tag(), mov_write_stsc_tag(), mov_write_stsd_tag(), mov_write_stss_tag(), mov_write_stsz_tag(), mov_write_stts_tag(), mov_write_sv3d_tag(), mov_write_tapt_tag(), mov_write_tcmi_tag(), mov_write_tfdt_tag(), mov_write_tfhd_tag(), mov_write_tfra_tag(), mov_write_tfrf_tag(), mov_write_tfxd_tag(), mov_write_tkhd_tag(), mov_write_tmcd_tag(), mov_write_tmpo_tag(), mov_write_track_metadata(), mov_write_track_udta_tag(), mov_write_traf_tag(), mov_write_trailer(), mov_write_trak_tag(), mov_write_tref_tag(), mov_write_trex_tag(), mov_write_trkn_tag(), mov_write_trun_tag(), mov_write_udta_sdp(), mov_write_udta_tag(), mov_write_uuid_tag_ipod(), mov_write_uuid_tag_psp(), mov_write_uuidprof_tag(), mov_write_uuidusmt_tag(), mov_write_video_tag(), mov_write_vmhd_tag(), mov_write_vpcc_tag(), mov_write_wave_tag(), mov_write_wfex_tag(), mp3_write_xing(), ogg_write_page(), oma_write_header(), rv10_write_header(), sox_write_header(), update_odml_entry(), write_odml_master(), and write_styp().

int ffio_rewind_with_probe_data ( AVIOContext s,
unsigned char **  buf,
int  buf_size 
)

Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file.

Used after probing to avoid seeking. Joins buf and s->buffer, taking any overlap into consideration.

Note
s->buffer must overlap with buf or they can't be joined and the function fails
Parameters
sThe read-only AVIOContext to rewind
bufThe probe buffer containing the first buf_size bytes of the file
buf_sizeThe size of buf
Returns
>= 0 in case of success, a negative value corresponding to an AVERROR code in case of failure

Definition at line 1111 of file aviobuf.c.

Referenced by av_probe_input_buffer2(), and ff_img_read_header().

uint64_t ffio_read_varlen ( AVIOContext bc)
int ffio_read_size ( AVIOContext s,
unsigned char *  buf,
int  size 
)

Read size bytes from AVIOContext into buf.

Check that exactly size bytes have been read.

Returns
number of bytes read or AVERROR

Definition at line 697 of file aviobuf.c.

Referenced by codec2_read_header(), mov_parse_uuid_spherical(), mov_read_atom_into_extradata(), mov_read_chpl(), mov_read_cmov(), mov_read_colr(), mov_read_custom(), mov_read_dref(), mov_read_ftyp(), mov_read_hdlr(), mov_read_stsz(), and mov_read_udta_string().

int ffio_set_buf_size ( AVIOContext s,
int  buf_size 
)
Warning
must be called before any I/O

Definition at line 1081 of file aviobuf.c.

Referenced by ff_configure_buffers_for_index(), and fill_buffer().

int ffio_ensure_seekback ( AVIOContext s,
int64_t  buf_size 
)

Ensures that the requested seekback buffer size will be available.

Will ensure that when reading sequentially up to buf_size, seeking within the current pos and pos+buf_size is possible. Once the stream position moves outside this window this guarantee is lost.

Definition at line 1052 of file aviobuf.c.

Referenced by apng_read_header(), apng_read_packet(), id3v2_parse(), id3v2_read_internal(), ivr_read_header(), mov_read_wave(), mp3_read_header(), mpegps_read_pes_header(), mpegts_read_header(), mpjpeg_read_packet(), rm_read_header(), and set_spdif().

int ffio_limit ( AVIOContext s,
int  size 
)
void ffio_init_checksum ( AVIOContext s,
unsigned long(*)(unsigned long c, const uint8_t *p, unsigned int len update_checksum,
unsigned long  checksum 
)
unsigned long ffio_get_checksum ( AVIOContext s)
unsigned long ff_crc04C11DB7_update ( unsigned long  checksum,
const uint8_t buf,
unsigned int  len 
)

Definition at line 601 of file aviobuf.c.

Referenced by get_packetheader(), nut_write_packet(), ogg_write_page(), and put_packet().

unsigned long ff_crcEDB88320_update ( unsigned long  checksum,
const uint8_t buf,
unsigned int  len 
)

Definition at line 607 of file aviobuf.c.

Referenced by tta_read_header(), and tta_write_header().

unsigned long ff_crcA001_update ( unsigned long  checksum,
const uint8_t buf,
unsigned int  len 
)

Definition at line 613 of file aviobuf.c.

Referenced by mp3_parse_vbr_tags().

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'.

The stream is stored in a memory buffer with a big-endian 4 byte header giving the packet size in bytes.

Parameters
snew IO context
max_packet_sizemaximum packet size (must be > 0)
Returns
zero if no error.

Definition at line 1396 of file aviobuf.c.

Referenced by ff_mov_add_hinted_packet(), ff_rtp_chain_mux_open(), and ff_rtsp_tcp_write_packet().

int ffio_fdopen ( AVIOContext **  s,
URLContext h 
)

Create and initialize a AVIOContext for accessing the resource referenced by the URLContext h.

Note
When the URLContext h has been opened in read+write mode, the AVIOContext can be used only for writing.
Parameters
sUsed to return the pointer to the created AVIOContext. In case of failure the pointed to value is set to NULL.
Returns
>= 0 in case of success, a negative value corresponding to an AVERROR code in case of failure

Definition at line 981 of file aviobuf.c.

Referenced by avio_accept(), ff_rtp_chain_mux_open(), and ffio_open_whitelist().

URLContext* ffio_geturlcontext ( AVIOContext s)

Return the URLContext associated with the AVIOContext.

Parameters
sIO context
Returns
pointer to URLContext or NULL.

Definition at line 1039 of file aviobuf.c.

Referenced by dashenc_io_close(), dashenc_io_open(), hlsenc_io_close(), hlsenc_io_open(), and open_url_keepalive().

int ffio_open_null_buf ( AVIOContext **  s)

Open a write-only fake memory stream.

The written data is not stored anywhere - this is only used for measuring the amount of data written.

Parameters
snew IO context
Returns
zero if no error.

Definition at line 1470 of file aviobuf.c.

Referenced by get_moov_size(), get_sidx_size(), mov_write_moof_tag(), and mov_write_sidx_tags().

int ffio_open_whitelist ( AVIOContext **  s,
const char *  url,
int  flags,
const AVIOInterruptCB int_cb,
AVDictionary **  options,
const char *  whitelist,
const char *  blacklist 
)
int ffio_close_null_buf ( AVIOContext s)

Close a null buffer.

Parameters
san IO context opened by ffio_open_null_buf
Returns
the number of bytes written to the null buffer

Definition at line 1480 of file aviobuf.c.

Referenced by get_moov_size(), get_sidx_size(), mov_write_moof_tag(), and mov_write_sidx_tags().

void ffio_free_dyn_buf ( AVIOContext **  s)

Variable Documentation

const AVClass ff_avio_class

Definition at line 69 of file aviobuf.c.

Referenced by ffio_fdopen(), and format_child_class_next().