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 | Macros | Typedefs | Enumerations
avbin.h File Reference
#include <stdint.h>
Include dependency graph for avbin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _AVbinFileInfo
 
struct  _AVbinStreamInfo
 
struct  _AVbinStreamInfo8
 
struct  _AVbinPacket
 
struct  _AVbinInfo
 
struct  _AVbinOptions
 

Macros

#define AVBIN_H
 

Typedefs

typedef enum _AVbinResult AVbinResult
 
typedef enum _AVbinStreamType AVbinStreamType
 
typedef enum _AVbinSampleFormat AVbinSampleFormat
 
typedef enum _AVbinLogLevel AVbinLogLevel
 
typedef struct _AVbinFile AVbinFile
 
typedef struct _AVbinStream AVbinStream
 
typedef int64_t AVbinTimestamp
 
typedef struct _AVbinFileInfo AVbinFileInfo
 
typedef struct _AVbinStreamInfo AVbinStreamInfo
 
typedef struct _AVbinStreamInfo8 AVbinStreamInfo8
 
typedef struct _AVbinPacket AVbinPacket
 
typedef struct _AVbinInfo AVbinInfo
 
typedef struct _AVbinOptions AVbinOptions
 
typedef void(* AVbinLogCallback )(const char *module, AVbinLogLevel level, const char *message)
 

Enumerations

enum  _AVbinResult { AVBIN_RESULT_ERROR = -1, AVBIN_RESULT_OK = 0 }
 
enum  _AVbinStreamType { AVBIN_STREAM_TYPE_UNKNOWN = 0, AVBIN_STREAM_TYPE_VIDEO = 1, AVBIN_STREAM_TYPE_AUDIO = 2 }
 
enum  _AVbinSampleFormat {
  AVBIN_SAMPLE_FORMAT_U8 = 0, AVBIN_SAMPLE_FORMAT_S16 = 1, AVBIN_SAMPLE_FORMAT_S24 = 2, AVBIN_SAMPLE_FORMAT_S32 = 3,
  AVBIN_SAMPLE_FORMAT_FLOAT = 4
}
 
enum  _AVbinLogLevel {
  AVBIN_LOG_QUIET = -8, AVBIN_LOG_PANIC = 0, AVBIN_LOG_FATAL = 8, AVBIN_LOG_ERROR = 16,
  AVBIN_LOG_WARNING = 24, AVBIN_LOG_INFO = 32, AVBIN_LOG_VERBOSE = 40, AVBIN_LOG_DEBUG = 48
}
 

Functions

Information about AVbin
int32_t avbin_get_version ()
 
AVbinInfoavbin_get_info ()
 
int32_t avbin_get_ffmpeg_revision () __attribute__((deprecated))
 
size_t avbin_get_audio_buffer_size ()
 
int32_t avbin_have_feature (const char *feature)
 
Global AVbin functions
AVbinResult avbin_init ()
 
AVbinResult avbin_init_options (AVbinOptions *options)
 
AVbinResult avbin_set_log_level (AVbinLogLevel level)
 
AVbinResult avbin_set_log_callback (AVbinLogCallback callback)
 
File handling functions
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)
 
Stream functions
AVbinResult avbin_stream_info (AVbinFile *file, int32_t stream_index, AVbinStreamInfo *info)
 
AVbinStreamavbin_open_stream (AVbinFile *file, int32_t stream_index)
 
void avbin_close_stream (AVbinStream *stream)
 
Reading and decoding functions
AVbinResult 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)
 

Detailed Description

AVbin functions and structures.

Definition in file avbin.h.

Macro Definition Documentation

#define AVBIN_H

This stuff is required to use avbin.h in C++ programs (yes, compilers are unable to distinguish C code from C++)

Definition at line 79 of file avbin.h.

Typedef Documentation

typedef struct _AVbinFile AVbinFile

Opaque open file handle.

Definition at line 136 of file avbin.h.

typedef struct _AVbinFileInfo AVbinFileInfo

File details. The info struct is filled in by avbin_get_file_info.

typedef struct _AVbinInfo AVbinInfo

Information about the AVbin library. See avbin_get_info()

typedef void(* AVbinLogCallback)(const char *module, AVbinLogLevel level, const char *message)

Callback for log information.

Parameters
moduleThe name of the module where this message originated
levelThe log verbosity level of this message
messageThe formatted message. The message may or may not contain newline characters.

Definition at line 472 of file avbin.h.

Threshold of logging verbosity.

typedef struct _AVbinOptions AVbinOptions

Initialization Options

typedef struct _AVbinPacket AVbinPacket

A single packet of stream data.

The structure size must be initialised before passing to avbin_read. The data will point to a block of memory allocated by AVbin – you must not free it. The data will be valid until the next time you call avbin_read, or until the file is closed.

typedef enum _AVbinResult AVbinResult

Error-checked function result.

The sample format for audio data.

typedef struct _AVbinStream AVbinStream

Opaque open stream handle.

Definition at line 141 of file avbin.h.

Stream details.

A stream is a single audio track or video. Most audio files contain one audio stream. Most video files contain one audio stream and one video stream. More than one audio stream may indicate the presence of multiple languages which can be selected (however at this time AVbin does not provide language information).

Stream details, version 8.

A stream is a single audio track or video. Most audio files contain one audio stream. Most video files contain one audio stream and one video stream. More than one audio stream may indicate the presence of multiple languages which can be selected (however at this time AVbin does not provide language information).

Type of a stream; currently only video and audio streams are supported.

typedef int64_t AVbinTimestamp

Point in time, or a time range; given in microseconds.

Definition at line 146 of file avbin.h.

Enumeration Type Documentation

Threshold of logging verbosity.

Enumerator:
AVBIN_LOG_QUIET 
AVBIN_LOG_PANIC 
AVBIN_LOG_FATAL 
AVBIN_LOG_ERROR 
AVBIN_LOG_WARNING 
AVBIN_LOG_INFO 
AVBIN_LOG_VERBOSE 
AVBIN_LOG_DEBUG 

Definition at line 122 of file avbin.h.

Error-checked function result.

Enumerator:
AVBIN_RESULT_ERROR 
AVBIN_RESULT_OK 

Definition at line 86 of file avbin.h.

The sample format for audio data.

Enumerator:
AVBIN_SAMPLE_FORMAT_U8 

Unsigned byte

AVBIN_SAMPLE_FORMAT_S16 

Signed 16-bit integer

AVBIN_SAMPLE_FORMAT_S24 

Signed 24-bit integer

\xrefitem deprecated 1.
AVBIN_SAMPLE_FORMAT_S32 

Signed 32-bit integer

AVBIN_SAMPLE_FORMAT_FLOAT 

32-bit IEEE floating-point

Definition at line 103 of file avbin.h.

Type of a stream; currently only video and audio streams are supported.

Enumerator:
AVBIN_STREAM_TYPE_UNKNOWN 
AVBIN_STREAM_TYPE_VIDEO 
AVBIN_STREAM_TYPE_AUDIO 

Definition at line 94 of file avbin.h.

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.

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

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