AVbin  Version 10
Cross-platform audio/video media decoding library with long-term ABI support.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Functions
avbin.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <avbin.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libavutil/dict.h>
#include <libavutil/mathematics.h>
#include <libswscale/swscale.h>
Include dependency graph for avbin.c:

Go to the source code of this file.

Data Structures

struct  _AVbinFile
 
struct  _AVbinStream
 

Functions

int32_t avbin_get_version ()
 
AVbinInfoavbin_get_info ()
 
int32_t avbin_get_ffmpeg_revision ()
 
size_t avbin_get_audio_buffer_size ()
 
int32_t avbin_have_feature (const char *feature)
 
AVbinResult avbin_init ()
 
AVbinResult avbin_init_options (AVbinOptions *options_ptr)
 
AVbinResult avbin_set_log_level (AVbinLogLevel level)
 
AVbinResult avbin_set_log_callback (AVbinLogCallback callback)
 
AVbinFileavbin_open_filename (const char *filename)
 
AVbinFileavbin_open_filename_with_format (const char *filename, char *format)
 
void avbin_close_file (AVbinFile *file)
 
AVbinResult avbin_seek_file (AVbinFile *file, AVbinTimestamp timestamp)
 
AVbinResult avbin_file_info (AVbinFile *file, AVbinFileInfo *info)
 
int32_t avbin_stream_info (AVbinFile *file, int32_t stream_index, AVbinStreamInfo *info)
 
AVbinStreamavbin_open_stream (AVbinFile *file, int32_t index)
 
void avbin_close_stream (AVbinStream *stream)
 
int32_t avbin_read (AVbinFile *file, AVbinPacket *packet)
 
int32_t avbin_decode_audio (AVbinStream *stream, uint8_t *data_in, size_t size_in, uint8_t *data_out, int *size_out)
 
int32_t avbin_decode_video (AVbinStream *stream, uint8_t *data_in, size_t size_in, uint8_t *data_out)
 

Function Documentation

void avbin_close_file ( AVbinFile file)

Close a media file.

Definition at line 203 of file avbin.c.

void avbin_close_stream ( AVbinStream stream)

Close a file stream.

Definition at line 392 of file avbin.c.

int32_t avbin_decode_audio ( AVbinStream stream,
uint8_t *  data_in,
size_t  size_in,
uint8_t *  data_out,
int *  size_out 
)

Decode some audio data.

You must ensure that data_out is at least as big as the minimum audio buffer size (see avbin_get_audio_buffer_size()).

Parameters
[in]streamThe stream to decode.
[in]data_inIncoming data, as read from a packet
[in]size_inSize of data_in, in bytes
[out]data_outDecoded audio data buffer, provided by application
[out]size_outNumber of bytes of data_out used.
Returns
the number of bytes of data_in actually used. You should call this function repeatedly as long as the return value is greater than 0.
Return values
-1if there was an error

Definition at line 423 of file avbin.c.

int32_t avbin_decode_video ( AVbinStream stream,
uint8_t *  data_in,
size_t  size_in,
uint8_t *  data_out 
)

Decode a video frame image.

The size of data_out must be large enough to hold the entire image. This is width * height * 3 (images are always in 8-bit RGB format).

Parameters
[in]streamThe stream to decode.
[in]data_inIncoming data, as read from a packet
[in]size_inSize of data_in, in bytes
[out]data_outDecoded image data.
Returns
the number of bytes of data_in actually used. Any remaining bytes can be discarded.
Return values
-1if there was an error

Definition at line 464 of file avbin.c.

AVbinResult avbin_file_info ( AVbinFile file,
AVbinFileInfo info 
)

Get information about the opened file.

The info struct must be allocated by the application and have its structure_size member filled in correctly. On return, the structure will be filled with file details.

Definition at line 235 of file avbin.c.

size_t avbin_get_audio_buffer_size ( )

Get the minimum audio buffer size, in bytes.

Definition at line 104 of file avbin.c.

int32_t avbin_get_ffmpeg_revision ( )

Get the SVN revision of FFmpeg.

This is built into AVbin as it is built.

DEPRECATED: Use avbin_get_libav_commit or avbin_get_libav_version instead. This always returns 0 now that we use Libav from Git. This function will be removed in AVbin 12.

Definition at line 99 of file avbin.c.

AVbinInfo* avbin_get_info ( )

Get information about the linked version of AVbin.

See the AVbinInfo definition.

Definition at line 82 of file avbin.c.

int32_t avbin_get_version ( )

Get the linked version of AVbin.

Version numbers are always integer, there are no "minor" or "patch" revisions. All AVbin versions are backward and forward compatible, modulo the required feature set.

Definition at line 77 of file avbin.c.

int32_t avbin_have_feature ( const char *  feature)

Determine if AVbin includes a requested feature.

When future versions of AVbin include more functionality, that functionality can be tested for by calling this function. The following features can be tested for:

Return values
1The feature is present
0The feature is not present

Definition at line 109 of file avbin.c.

AVbinResult avbin_init ( )

One of the avbin_init* functions must be called before opening a file to initialize AVbin. Check the return value for success before continuing. Initialize AVbin with basic features. Consider instead avbin_init_options()

Definition at line 120 of file avbin.c.

AVbinResult avbin_init_options ( AVbinOptions options)

Initialize AVbin with options.

Parameters
optionsIf NULL, use defaults. Otherwise create and populate an instance of AVbinOptions to supply.

Definition at line 125 of file avbin.c.

AVbinFile* avbin_open_filename ( const char *  filename)

Open a media file given its filename.

Return values
NULLif the file could not be opened, or is not of a recognised file format.

Definition at line 180 of file avbin.c.

AVbinFile* avbin_open_filename_with_format ( const char *  filename,
char *  format 
)

Definition at line 182 of file avbin.c.

AVbinStream* avbin_open_stream ( AVbinFile file,
int32_t  stream_index 
)

Open a stream for decoding.

If you intend to decode audio or video from a file, you must open the stream first. The returned opaque handle should be passed to the relevant decode function when a packet for that stream is read.

Definition at line 362 of file avbin.c.

int32_t avbin_read ( AVbinFile file,
AVbinPacket packet 
)

Read a packet from the file.

The packet struct must be allocated by the application and have its structure_size member filled in correctly. On return, the structure will be filled with a packet of data. The actual data pointer within the packet must not be freed, and is valid until the next call to avbin_read.

Applications should examine the packet's stream index to match it with an appropriate open stream handle, or discard it if none match. The packet data can then be passed to the relevant decode function.

Definition at line 400 of file avbin.c.

AVbinResult avbin_seek_file ( AVbinFile file,
AVbinTimestamp  timestamp 
)

Seek to a timestamp within a file.

For video files, the first keyframe before the requested timestamp will be seeked to. For audio files, the first audio packet before the requested timestamp is used.

Definition at line 215 of file avbin.c.

AVbinResult avbin_set_log_callback ( AVbinLogCallback  callback)

Set a custom log callback. By default, log messages are printed to standard error. Providing a NULL callback restores this default handler.

Definition at line 165 of file avbin.c.

AVbinResult avbin_set_log_level ( AVbinLogLevel  level)

Set the log level verbosity.

Definition at line 159 of file avbin.c.

int32_t avbin_stream_info ( AVbinFile file,
int32_t  stream_index,
AVbinStreamInfo info 
)

Get information about a stream within the file.

The info struct must be allocated by the application and have its structure_size member filled in correctly. On return, the structure will be filled with stream details.

Ensure that stream_index is less than n_streams given in the file info.

Parameters
[in]fileThe file to examine
[in]stream_indexThe number of the stream within the file
[out]infoReturned stream information

Definition at line 285 of file avbin.c.