Path: blob/master/dep/ffmpeg/include/libavformat/avio.h
4216 views
/*1* copyright (c) 2001 Fabrice Bellard2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/19#ifndef AVFORMAT_AVIO_H20#define AVFORMAT_AVIO_H2122/**23* @file24* @ingroup lavf_io25* Buffered I/O operations26*/2728#include <stdint.h>29#include <stdio.h>3031#include "libavutil/attributes.h"32#include "libavutil/dict.h"33#include "libavutil/log.h"3435#include "libavformat/version_major.h"3637/**38* Seeking works like for a local file.39*/40#define AVIO_SEEKABLE_NORMAL (1 << 0)4142/**43* Seeking by timestamp with avio_seek_time() is possible.44*/45#define AVIO_SEEKABLE_TIME (1 << 1)4647/**48* Callback for checking whether to abort blocking functions.49* AVERROR_EXIT is returned in this case by the interrupted50* function. During blocking operations, callback is called with51* opaque as parameter. If the callback returns 1, the52* blocking operation will be aborted.53*54* No members can be added to this struct without a major bump, if55* new elements have been added after this struct in AVFormatContext56* or AVIOContext.57*/58typedef struct AVIOInterruptCB {59int (*callback)(void*);60void *opaque;61} AVIOInterruptCB;6263/**64* Directory entry types.65*/66enum AVIODirEntryType {67AVIO_ENTRY_UNKNOWN,68AVIO_ENTRY_BLOCK_DEVICE,69AVIO_ENTRY_CHARACTER_DEVICE,70AVIO_ENTRY_DIRECTORY,71AVIO_ENTRY_NAMED_PIPE,72AVIO_ENTRY_SYMBOLIC_LINK,73AVIO_ENTRY_SOCKET,74AVIO_ENTRY_FILE,75AVIO_ENTRY_SERVER,76AVIO_ENTRY_SHARE,77AVIO_ENTRY_WORKGROUP,78};7980/**81* Describes single entry of the directory.82*83* Only name and type fields are guaranteed be set.84* Rest of fields are protocol or/and platform dependent and might be unknown.85*/86typedef struct AVIODirEntry {87char *name; /**< Filename */88int type; /**< Type of the entry */89int utf8; /**< Set to 1 when name is encoded with UTF-8, 0 otherwise.90Name can be encoded with UTF-8 even though 0 is set. */91int64_t size; /**< File size in bytes, -1 if unknown. */92int64_t modification_timestamp; /**< Time of last modification in microseconds since unix93epoch, -1 if unknown. */94int64_t access_timestamp; /**< Time of last access in microseconds since unix epoch,95-1 if unknown. */96int64_t status_change_timestamp; /**< Time of last status change in microseconds since unix97epoch, -1 if unknown. */98int64_t user_id; /**< User ID of owner, -1 if unknown. */99int64_t group_id; /**< Group ID of owner, -1 if unknown. */100int64_t filemode; /**< Unix file mode, -1 if unknown. */101} AVIODirEntry;102103typedef struct AVIODirContext AVIODirContext;104105/**106* Different data types that can be returned via the AVIO107* write_data_type callback.108*/109enum AVIODataMarkerType {110/**111* Header data; this needs to be present for the stream to be decodeable.112*/113AVIO_DATA_MARKER_HEADER,114/**115* A point in the output bytestream where a decoder can start decoding116* (i.e. a keyframe). A demuxer/decoder given the data flagged with117* AVIO_DATA_MARKER_HEADER, followed by any AVIO_DATA_MARKER_SYNC_POINT,118* should give decodeable results.119*/120AVIO_DATA_MARKER_SYNC_POINT,121/**122* A point in the output bytestream where a demuxer can start parsing123* (for non self synchronizing bytestream formats). That is, any124* non-keyframe packet start point.125*/126AVIO_DATA_MARKER_BOUNDARY_POINT,127/**128* This is any, unlabelled data. It can either be a muxer not marking129* any positions at all, it can be an actual boundary/sync point130* that the muxer chooses not to mark, or a later part of a packet/fragment131* that is cut into multiple write callbacks due to limited IO buffer size.132*/133AVIO_DATA_MARKER_UNKNOWN,134/**135* Trailer data, which doesn't contain actual content, but only for136* finalizing the output file.137*/138AVIO_DATA_MARKER_TRAILER,139/**140* A point in the output bytestream where the underlying AVIOContext might141* flush the buffer depending on latency or buffering requirements. Typically142* means the end of a packet.143*/144AVIO_DATA_MARKER_FLUSH_POINT,145};146147/**148* Bytestream IO Context.149* New public fields can be added with minor version bumps.150* Removal, reordering and changes to existing public fields require151* a major version bump.152* sizeof(AVIOContext) must not be used outside libav*.153*154* @note None of the function pointers in AVIOContext should be called155* directly, they should only be set by the client application156* when implementing custom I/O. Normally these are set to the157* function pointers specified in avio_alloc_context()158*/159typedef struct AVIOContext {160/**161* A class for private options.162*163* If this AVIOContext is created by avio_open2(), av_class is set and164* passes the options down to protocols.165*166* If this AVIOContext is manually allocated, then av_class may be set by167* the caller.168*169* warning -- this field can be NULL, be sure to not pass this AVIOContext170* to any av_opt_* functions in that case.171*/172const AVClass *av_class;173174/*175* The following shows the relationship between buffer, buf_ptr,176* buf_ptr_max, buf_end, buf_size, and pos, when reading and when writing177* (since AVIOContext is used for both):178*179**********************************************************************************180* READING181**********************************************************************************182*183* | buffer_size |184* |---------------------------------------|185* | |186*187* buffer buf_ptr buf_end188* +---------------+-----------------------+189* |/ / / / / / / /|/ / / / / / /| |190* read buffer: |/ / consumed / | to be read /| |191* |/ / / / / / / /|/ / / / / / /| |192* +---------------+-----------------------+193*194* pos195* +-------------------------------------------+-----------------+196* input file: | | |197* +-------------------------------------------+-----------------+198*199*200**********************************************************************************201* WRITING202**********************************************************************************203*204* | buffer_size |205* |--------------------------------------|206* | |207*208* buf_ptr_max209* buffer (buf_ptr) buf_end210* +-----------------------+--------------+211* |/ / / / / / / / / / / /| |212* write buffer: | / / to be flushed / / | |213* |/ / / / / / / / / / / /| |214* +-----------------------+--------------+215* buf_ptr can be in this216* due to a backward seek217*218* pos219* +-------------+----------------------------------------------+220* output file: | | |221* +-------------+----------------------------------------------+222*223*/224unsigned char *buffer; /**< Start of the buffer. */225int buffer_size; /**< Maximum buffer size */226unsigned char *buf_ptr; /**< Current position in the buffer */227unsigned char *buf_end; /**< End of the data, may be less than228buffer+buffer_size if the read function returned229less data than requested, e.g. for streams where230no more data has been received yet. */231void *opaque; /**< A private pointer, passed to the read/write/seek/...232functions. */233int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);234int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size);235int64_t (*seek)(void *opaque, int64_t offset, int whence);236int64_t pos; /**< position in the file of the current buffer */237int eof_reached; /**< true if was unable to read due to error or eof */238int error; /**< contains the error code or 0 if no error happened */239int write_flag; /**< true if open for writing */240int max_packet_size;241int min_packet_size; /**< Try to buffer at least this amount of data242before flushing it. */243unsigned long checksum;244unsigned char *checksum_ptr;245unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);246/**247* Pause or resume playback for network streaming protocols - e.g. MMS.248*/249int (*read_pause)(void *opaque, int pause);250/**251* Seek to a given timestamp in stream with the specified stream_index.252* Needed for some network streaming protocols which don't support seeking253* to byte position.254*/255int64_t (*read_seek)(void *opaque, int stream_index,256int64_t timestamp, int flags);257/**258* A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.259*/260int seekable;261262/**263* avio_read and avio_write should if possible be satisfied directly264* instead of going through a buffer, and avio_seek will always265* call the underlying seek function directly.266*/267int direct;268269/**270* ',' separated list of allowed protocols.271*/272const char *protocol_whitelist;273274/**275* ',' separated list of disallowed protocols.276*/277const char *protocol_blacklist;278279/**280* A callback that is used instead of write_packet.281*/282int (*write_data_type)(void *opaque, const uint8_t *buf, int buf_size,283enum AVIODataMarkerType type, int64_t time);284/**285* If set, don't call write_data_type separately for AVIO_DATA_MARKER_BOUNDARY_POINT,286* but ignore them and treat them as AVIO_DATA_MARKER_UNKNOWN (to avoid needlessly287* small chunks of data returned from the callback).288*/289int ignore_boundary_point;290291/**292* Maximum reached position before a backward seek in the write buffer,293* used keeping track of already written data for a later flush.294*/295unsigned char *buf_ptr_max;296297/**298* Read-only statistic of bytes read for this AVIOContext.299*/300int64_t bytes_read;301302/**303* Read-only statistic of bytes written for this AVIOContext.304*/305int64_t bytes_written;306} AVIOContext;307308/**309* Return the name of the protocol that will handle the passed URL.310*311* NULL is returned if no protocol could be found for the given URL.312*313* @return Name of the protocol or NULL.314*/315const char *avio_find_protocol_name(const char *url);316317/**318* Return AVIO_FLAG_* access flags corresponding to the access permissions319* of the resource in url, or a negative value corresponding to an320* AVERROR code in case of failure. The returned access flags are321* masked by the value in flags.322*323* @note This function is intrinsically unsafe, in the sense that the324* checked resource may change its existence or permission status from325* one call to another. Thus you should not trust the returned value,326* unless you are sure that no other processes are accessing the327* checked resource.328*/329int avio_check(const char *url, int flags);330331/**332* Open directory for reading.333*334* @param s directory read context. Pointer to a NULL pointer must be passed.335* @param url directory to be listed.336* @param options A dictionary filled with protocol-private options. On return337* this parameter will be destroyed and replaced with a dictionary338* containing options that were not found. May be NULL.339* @return >=0 on success or negative on error.340*/341int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options);342343/**344* Get next directory entry.345*346* Returned entry must be freed with avio_free_directory_entry(). In particular347* it may outlive AVIODirContext.348*349* @param s directory read context.350* @param[out] next next entry or NULL when no more entries.351* @return >=0 on success or negative on error. End of list is not considered an352* error.353*/354int avio_read_dir(AVIODirContext *s, AVIODirEntry **next);355356/**357* Close directory.358*359* @note Entries created using avio_read_dir() are not deleted and must be360* freeded with avio_free_directory_entry().361*362* @param s directory read context.363* @return >=0 on success or negative on error.364*/365int avio_close_dir(AVIODirContext **s);366367/**368* Free entry allocated by avio_read_dir().369*370* @param entry entry to be freed.371*/372void avio_free_directory_entry(AVIODirEntry **entry);373374/**375* Allocate and initialize an AVIOContext for buffered I/O. It must be later376* freed with avio_context_free().377*378* @param buffer Memory block for input/output operations via AVIOContext.379* The buffer must be allocated with av_malloc() and friends.380* It may be freed and replaced with a new buffer by libavformat.381* AVIOContext.buffer holds the buffer currently in use,382* which must be later freed with av_free().383* @param buffer_size The buffer size is very important for performance.384* For protocols with fixed blocksize it should be set to this blocksize.385* For others a typical size is a cache page, e.g. 4kb.386* @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.387* @param opaque An opaque pointer to user-specific data.388* @param read_packet A function for refilling the buffer, may be NULL.389* For stream protocols, must never return 0 but rather390* a proper AVERROR code.391* @param write_packet A function for writing the buffer contents, may be NULL.392* The function may not change the input buffers content.393* @param seek A function for seeking to specified byte position, may be NULL.394*395* @return Allocated AVIOContext or NULL on failure.396*/397AVIOContext *avio_alloc_context(398unsigned char *buffer,399int buffer_size,400int write_flag,401void *opaque,402int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),403int (*write_packet)(void *opaque, const uint8_t *buf, int buf_size),404int64_t (*seek)(void *opaque, int64_t offset, int whence));405406/**407* Free the supplied IO context and everything associated with it.408*409* @param s Double pointer to the IO context. This function will write NULL410* into s.411*/412void avio_context_free(AVIOContext **s);413414void avio_w8(AVIOContext *s, int b);415void avio_write(AVIOContext *s, const unsigned char *buf, int size);416void avio_wl64(AVIOContext *s, uint64_t val);417void avio_wb64(AVIOContext *s, uint64_t val);418void avio_wl32(AVIOContext *s, unsigned int val);419void avio_wb32(AVIOContext *s, unsigned int val);420void avio_wl24(AVIOContext *s, unsigned int val);421void avio_wb24(AVIOContext *s, unsigned int val);422void avio_wl16(AVIOContext *s, unsigned int val);423void avio_wb16(AVIOContext *s, unsigned int val);424425/**426* Write a NULL-terminated string.427* @return number of bytes written.428*/429int avio_put_str(AVIOContext *s, const char *str);430431/**432* Convert an UTF-8 string to UTF-16LE and write it.433* @param s the AVIOContext434* @param str NULL-terminated UTF-8 string435*436* @return number of bytes written.437*/438int avio_put_str16le(AVIOContext *s, const char *str);439440/**441* Convert an UTF-8 string to UTF-16BE and write it.442* @param s the AVIOContext443* @param str NULL-terminated UTF-8 string444*445* @return number of bytes written.446*/447int avio_put_str16be(AVIOContext *s, const char *str);448449/**450* Mark the written bytestream as a specific type.451*452* Zero-length ranges are omitted from the output.453*454* @param s the AVIOContext455* @param time the stream time the current bytestream pos corresponds to456* (in AV_TIME_BASE units), or AV_NOPTS_VALUE if unknown or not457* applicable458* @param type the kind of data written starting at the current pos459*/460void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type);461462/**463* ORing this as the "whence" parameter to a seek function causes it to464* return the filesize without seeking anywhere. Supporting this is optional.465* If it is not supported then the seek function will return <0.466*/467#define AVSEEK_SIZE 0x10000468469/**470* Passing this flag as the "whence" parameter to a seek function causes it to471* seek by any means (like reopening and linear reading) or other normally unreasonable472* means that can be extremely slow.473* This may be ignored by the seek code.474*/475#define AVSEEK_FORCE 0x20000476477/**478* fseek() equivalent for AVIOContext.479* @return new position or AVERROR.480*/481int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);482483/**484* Skip given number of bytes forward485* @return new position or AVERROR.486*/487int64_t avio_skip(AVIOContext *s, int64_t offset);488489/**490* ftell() equivalent for AVIOContext.491* @return position or AVERROR.492*/493static av_always_inline int64_t avio_tell(AVIOContext *s)494{495return avio_seek(s, 0, SEEK_CUR);496}497498/**499* Get the filesize.500* @return filesize or AVERROR501*/502int64_t avio_size(AVIOContext *s);503504/**505* Similar to feof() but also returns nonzero on read errors.506* @return non zero if and only if at end of file or a read error happened when reading.507*/508int avio_feof(AVIOContext *s);509510/**511* Writes a formatted string to the context taking a va_list.512* @return number of bytes written, < 0 on error.513*/514int avio_vprintf(AVIOContext *s, const char *fmt, va_list ap);515516/**517* Writes a formatted string to the context.518* @return number of bytes written, < 0 on error.519*/520int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);521522/**523* Write a NULL terminated array of strings to the context.524* Usually you don't need to use this function directly but its macro wrapper,525* avio_print.526*/527void avio_print_string_array(AVIOContext *s, const char * const strings[]);528529/**530* Write strings (const char *) to the context.531* This is a convenience macro around avio_print_string_array and it532* automatically creates the string array from the variable argument list.533* For simple string concatenations this function is more performant than using534* avio_printf since it does not need a temporary buffer.535*/536#define avio_print(s, ...) \537avio_print_string_array(s, (const char*[]){__VA_ARGS__, NULL})538539/**540* Force flushing of buffered data.541*542* For write streams, force the buffered data to be immediately written to the output,543* without to wait to fill the internal buffer.544*545* For read streams, discard all currently buffered data, and advance the546* reported file position to that of the underlying stream. This does not547* read new data, and does not perform any seeks.548*/549void avio_flush(AVIOContext *s);550551/**552* Read size bytes from AVIOContext into buf.553* @return number of bytes read or AVERROR554*/555int avio_read(AVIOContext *s, unsigned char *buf, int size);556557/**558* Read size bytes from AVIOContext into buf. Unlike avio_read(), this is allowed559* to read fewer bytes than requested. The missing bytes can be read in the next560* call. This always tries to read at least 1 byte.561* Useful to reduce latency in certain cases.562* @return number of bytes read or AVERROR563*/564int avio_read_partial(AVIOContext *s, unsigned char *buf, int size);565566/**567* @name Functions for reading from AVIOContext568* @{569*570* @note return 0 if EOF, so you cannot use it if EOF handling is571* necessary572*/573int avio_r8 (AVIOContext *s);574unsigned int avio_rl16(AVIOContext *s);575unsigned int avio_rl24(AVIOContext *s);576unsigned int avio_rl32(AVIOContext *s);577uint64_t avio_rl64(AVIOContext *s);578unsigned int avio_rb16(AVIOContext *s);579unsigned int avio_rb24(AVIOContext *s);580unsigned int avio_rb32(AVIOContext *s);581uint64_t avio_rb64(AVIOContext *s);582/**583* @}584*/585586/**587* Read a string from pb into buf. The reading will terminate when either588* a NULL character was encountered, maxlen bytes have been read, or nothing589* more can be read from pb. The result is guaranteed to be NULL-terminated, it590* will be truncated if buf is too small.591* Note that the string is not interpreted or validated in any way, it592* might get truncated in the middle of a sequence for multi-byte encodings.593*594* @return number of bytes read (is always <= maxlen).595* If reading ends on EOF or error, the return value will be one more than596* bytes actually read.597*/598int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);599600/**601* Read a UTF-16 string from pb and convert it to UTF-8.602* The reading will terminate when either a null or invalid character was603* encountered or maxlen bytes have been read.604* @return number of bytes read (is always <= maxlen)605*/606int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);607int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);608609610/**611* @name URL open modes612* The flags argument to avio_open must be one of the following613* constants, optionally ORed with other flags.614* @{615*/616#define AVIO_FLAG_READ 1 /**< read-only */617#define AVIO_FLAG_WRITE 2 /**< write-only */618#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */619/**620* @}621*/622623/**624* Use non-blocking mode.625* If this flag is set, operations on the context will return626* AVERROR(EAGAIN) if they can not be performed immediately.627* If this flag is not set, operations on the context will never return628* AVERROR(EAGAIN).629* Note that this flag does not affect the opening/connecting of the630* context. Connecting a protocol will always block if necessary (e.g. on631* network protocols) but never hang (e.g. on busy devices).632* Warning: non-blocking protocols is work-in-progress; this flag may be633* silently ignored.634*/635#define AVIO_FLAG_NONBLOCK 8636637/**638* Use direct mode.639* avio_read and avio_write should if possible be satisfied directly640* instead of going through a buffer, and avio_seek will always641* call the underlying seek function directly.642*/643#define AVIO_FLAG_DIRECT 0x8000644645/**646* Create and initialize a AVIOContext for accessing the647* resource indicated by url.648* @note When the resource indicated by url has been opened in649* read+write mode, the AVIOContext can be used only for writing.650*651* @param s Used to return the pointer to the created AVIOContext.652* In case of failure the pointed to value is set to NULL.653* @param url resource to access654* @param flags flags which control how the resource indicated by url655* is to be opened656* @return >= 0 in case of success, a negative value corresponding to an657* AVERROR code in case of failure658*/659int avio_open(AVIOContext **s, const char *url, int flags);660661/**662* Create and initialize a AVIOContext for accessing the663* resource indicated by url.664* @note When the resource indicated by url has been opened in665* read+write mode, the AVIOContext can be used only for writing.666*667* @param s Used to return the pointer to the created AVIOContext.668* In case of failure the pointed to value is set to NULL.669* @param url resource to access670* @param flags flags which control how the resource indicated by url671* is to be opened672* @param int_cb an interrupt callback to be used at the protocols level673* @param options A dictionary filled with protocol-private options. On return674* this parameter will be destroyed and replaced with a dict containing options675* that were not found. May be NULL.676* @return >= 0 in case of success, a negative value corresponding to an677* AVERROR code in case of failure678*/679int avio_open2(AVIOContext **s, const char *url, int flags,680const AVIOInterruptCB *int_cb, AVDictionary **options);681682/**683* Close the resource accessed by the AVIOContext s and free it.684* This function can only be used if s was opened by avio_open().685*686* The internal buffer is automatically flushed before closing the687* resource.688*689* @return 0 on success, an AVERROR < 0 on error.690* @see avio_closep691*/692int avio_close(AVIOContext *s);693694/**695* Close the resource accessed by the AVIOContext *s, free it696* and set the pointer pointing to it to NULL.697* This function can only be used if s was opened by avio_open().698*699* The internal buffer is automatically flushed before closing the700* resource.701*702* @return 0 on success, an AVERROR < 0 on error.703* @see avio_close704*/705int avio_closep(AVIOContext **s);706707708/**709* Open a write only memory stream.710*711* @param s new IO context712* @return zero if no error.713*/714int avio_open_dyn_buf(AVIOContext **s);715716/**717* Return the written size and a pointer to the buffer.718* The AVIOContext stream is left intact.719* The buffer must NOT be freed.720* No padding is added to the buffer.721*722* @param s IO context723* @param pbuffer pointer to a byte buffer724* @return the length of the byte buffer725*/726int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer);727728/**729* Return the written size and a pointer to the buffer. The buffer730* must be freed with av_free().731* Padding of AV_INPUT_BUFFER_PADDING_SIZE is added to the buffer.732*733* @param s IO context734* @param pbuffer pointer to a byte buffer735* @return the length of the byte buffer736*/737int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);738739/**740* Iterate through names of available protocols.741*742* @param opaque A private pointer representing current protocol.743* It must be a pointer to NULL on first iteration and will744* be updated by successive calls to avio_enum_protocols.745* @param output If set to 1, iterate over output protocols,746* otherwise over input protocols.747*748* @return A static string containing the name of current protocol or NULL749*/750const char *avio_enum_protocols(void **opaque, int output);751752/**753* Get AVClass by names of available protocols.754*755* @return A AVClass of input protocol name or NULL756*/757const AVClass *avio_protocol_get_class(const char *name);758759/**760* Pause and resume playing - only meaningful if using a network streaming761* protocol (e.g. MMS).762*763* @param h IO context from which to call the read_pause function pointer764* @param pause 1 for pause, 0 for resume765*/766int avio_pause(AVIOContext *h, int pause);767768/**769* Seek to a given timestamp relative to some component stream.770* Only meaningful if using a network streaming protocol (e.g. MMS.).771*772* @param h IO context from which to call the seek function pointers773* @param stream_index The stream index that the timestamp is relative to.774* If stream_index is (-1) the timestamp should be in AV_TIME_BASE775* units from the beginning of the presentation.776* If a stream_index >= 0 is used and the protocol does not support777* seeking based on component streams, the call will fail.778* @param timestamp timestamp in AVStream.time_base units779* or if there is no stream specified then in AV_TIME_BASE units.780* @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE781* and AVSEEK_FLAG_ANY. The protocol may silently ignore782* AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will783* fail if used and not supported.784* @return >= 0 on success785* @see AVInputFormat::read_seek786*/787int64_t avio_seek_time(AVIOContext *h, int stream_index,788int64_t timestamp, int flags);789790/* Avoid a warning. The header can not be included because it breaks c++. */791struct AVBPrint;792793/**794* Read contents of h into print buffer, up to max_size bytes, or up to EOF.795*796* @return 0 for success (max_size bytes read or EOF reached), negative error797* code otherwise798*/799int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size);800801/**802* Accept and allocate a client context on a server context.803* @param s the server context804* @param c the client context, must be unallocated805* @return >= 0 on success or a negative value corresponding806* to an AVERROR on failure807*/808int avio_accept(AVIOContext *s, AVIOContext **c);809810/**811* Perform one step of the protocol handshake to accept a new client.812* This function must be called on a client returned by avio_accept() before813* using it as a read/write context.814* It is separate from avio_accept() because it may block.815* A step of the handshake is defined by places where the application may816* decide to change the proceedings.817* For example, on a protocol with a request header and a reply header, each818* one can constitute a step because the application may use the parameters819* from the request to change parameters in the reply; or each individual820* chunk of the request can constitute a step.821* If the handshake is already finished, avio_handshake() does nothing and822* returns 0 immediately.823*824* @param c the client context to perform the handshake on825* @return 0 on a complete and successful handshake826* > 0 if the handshake progressed, but is not complete827* < 0 for an AVERROR code828*/829int avio_handshake(AVIOContext *c);830#endif /* AVFORMAT_AVIO_H */831832833