gavl
|
Macros | |
#define | GAVL_SOURCE_SRC_ALLOC (1<<0) |
Source provides a pointer to an internal structure. More... | |
#define | GAVL_SOURCE_SRC_FRAMESIZE_MAX (1<<2) |
Samples per frame is just an upper bound. Frames can have smaller sizes also. The last frame is always allowed to have fewer samples, even if this flag is not set. More... | |
#define | GAVL_SOURCE_SRC_DISCONTINUOUS (1<<3) |
Stream is discontinuous. Set this for video sources delivering graphical subtitles. More... | |
Typedefs | |
typedef struct gavl_video_source_s | gavl_video_source_t |
Forward declaration of the video source. More... | |
typedef struct gavl_audio_source_s | gavl_audio_source_t |
Forward declaration of the audio source. More... | |
typedef struct gavl_packet_source_s | gavl_packet_source_t |
Forward declaration of the packet source. More... | |
typedef gavl_source_status_t(* | gavl_audio_source_func_t) (void *priv, gavl_audio_frame_t **frame) |
Prototype for obtaining one audio frame. More... | |
typedef gavl_source_status_t(* | gavl_video_source_func_t) (void *priv, gavl_video_frame_t **frame) |
Prototype for obtaining one video frame. More... | |
typedef gavl_source_status_t(* | gavl_packet_source_func_t) (void *priv, gavl_packet_t **p) |
Prototype for obtaining one packet. More... | |
Enumerations | |
enum | gavl_source_status_t { GAVL_SOURCE_EOF = 0 , GAVL_SOURCE_OK = 1 , GAVL_SOURCE_AGAIN = 2 } |
Return value of the source function. More... | |
Functions | |
GAVL_PUBLIC gavl_video_source_t * | gavl_video_source_create (gavl_video_source_func_t func, void *priv, int src_flags, const gavl_video_format_t *src_format) |
Create a video source. More... | |
GAVL_PUBLIC void | gavl_video_source_set_eof (gavl_video_source_t *src, int eof) |
GAVL_PUBLIC int | gavl_video_source_get_eof (gavl_video_source_t *src) |
GAVL_PUBLIC void | gavl_video_source_drain (gavl_video_source_t *s) |
GAVL_PUBLIC void | gavl_video_source_drain_nolock (gavl_video_source_t *s) |
GAVL_PUBLIC gavl_video_source_t * | gavl_video_source_create_source (gavl_video_source_func_t func, void *priv, int src_flags, gavl_video_source_t *src) |
Create a video source from another source. More... | |
GAVL_PUBLIC void | gavl_video_source_set_lock_funcs (gavl_video_source_t *src, gavl_connector_lock_func_t lock_func, gavl_connector_lock_func_t unlock_func, void *priv) |
Set lock functions. More... | |
GAVL_PUBLIC void | gavl_video_source_set_free_func (gavl_video_source_t *src, gavl_connector_free_func_t free_func) |
Set free function. More... | |
GAVL_PUBLIC gavl_video_options_t * | gavl_video_source_get_options (gavl_video_source_t *s) |
Get coversion options of a video source. More... | |
GAVL_PUBLIC void | gavl_video_source_reset (gavl_video_source_t *s) |
Reset a video source. More... | |
GAVL_PUBLIC void | gavl_video_source_destroy (gavl_video_source_t *s) |
Destroy a video source. More... | |
GAVL_PUBLIC void | gavl_video_source_support_hw (gavl_video_source_t *s) |
Enable hardware surfaces. More... | |
GAVL_PUBLIC const gavl_video_format_t * | gavl_video_source_get_src_format (gavl_video_source_t *s) |
Get the native format. More... | |
GAVL_PUBLIC const gavl_video_format_t * | gavl_video_source_get_dst_format (gavl_video_source_t *s) |
Get the output format. More... | |
GAVL_PUBLIC void | gavl_video_source_set_dst (gavl_video_source_t *s, int dst_flags, const gavl_video_format_t *dst_format) |
Set the destination mode. More... | |
GAVL_PUBLIC gavl_source_status_t | gavl_video_source_read_frame (void *s, gavl_video_frame_t **frame) |
Read a video frame. More... | |
GAVL_PUBLIC gavl_audio_source_t * | gavl_audio_source_create (gavl_audio_source_func_t func, void *priv, int src_flags, const gavl_audio_format_t *src_format) |
Create an audio source. More... | |
GAVL_PUBLIC void | gavl_audio_source_set_eof (gavl_audio_source_t *src, int eof) |
GAVL_PUBLIC int | gavl_audio_source_get_eof (gavl_audio_source_t *src) |
GAVL_PUBLIC void | gavl_audio_source_drain (gavl_audio_source_t *s) |
GAVL_PUBLIC void | gavl_audio_source_drain_nolock (gavl_audio_source_t *s) |
GAVL_PUBLIC gavl_audio_source_t * | gavl_audio_source_create_source (gavl_audio_source_func_t func, void *priv, int src_flags, gavl_audio_source_t *src) |
Create an audio source from another source. More... | |
GAVL_PUBLIC void | gavl_audio_source_set_lock_funcs (gavl_audio_source_t *src, gavl_connector_lock_func_t lock_func, gavl_connector_lock_func_t unlock_func, void *priv) |
Set lock functions. More... | |
GAVL_PUBLIC void | gavl_audio_source_set_free_func (gavl_audio_source_t *src, gavl_connector_free_func_t free_func) |
Set free function. More... | |
GAVL_PUBLIC const gavl_audio_format_t * | gavl_audio_source_get_src_format (gavl_audio_source_t *s) |
Get the native format. More... | |
GAVL_PUBLIC const gavl_audio_format_t * | gavl_audio_source_get_dst_format (gavl_audio_source_t *s) |
Get the output format. More... | |
GAVL_PUBLIC int | gavl_audio_source_get_dst_flags (gavl_audio_source_t *s) |
Get the output flags. More... | |
GAVL_PUBLIC void | gavl_audio_source_set_dst (gavl_audio_source_t *s, int dst_flags, const gavl_audio_format_t *dst_format) |
Set the destination mode. More... | |
GAVL_PUBLIC gavl_source_status_t | gavl_audio_source_read_frame (void *s, gavl_audio_frame_t **frame) |
Read an audio frame. More... | |
GAVL_PUBLIC void | gavl_audio_source_skip (gavl_audio_source_t *s, int num_samples) |
Skip audio samples at the input. More... | |
GAVL_PUBLIC void | gavl_audio_source_skip_to (gavl_audio_source_t *s, int64_t t, int scale) |
GAVL_PUBLIC int | gavl_audio_source_read_samples (void *s, gavl_audio_frame_t *frame, int num_samples) |
Read audio samples. More... | |
GAVL_PUBLIC gavl_audio_options_t * | gavl_audio_source_get_options (gavl_audio_source_t *s) |
Get coversion options of an audio source. More... | |
GAVL_PUBLIC void | gavl_audio_source_reset (gavl_audio_source_t *s) |
Reset an audio source. More... | |
GAVL_PUBLIC void | gavl_audio_source_destroy (gavl_audio_source_t *s) |
Destroy an audio source. More... | |
GAVL_PUBLIC gavl_packet_source_t * | gavl_packet_source_create (gavl_packet_source_func_t func, void *priv, int src_flags) |
Create a packet source. More... | |
GAVL_PUBLIC void | gavl_packet_source_set_eof (gavl_packet_source_t *src, int eof) |
GAVL_PUBLIC int | gavl_packet_source_get_eof (gavl_packet_source_t *src) |
GAVL_PUBLIC void | gavl_packet_source_drain (gavl_packet_source_t *src) |
GAVL_PUBLIC void | gavl_packet_source_drain_nolock (gavl_packet_source_t *src) |
GAVL_PUBLIC gavl_packet_source_t * | gavl_packet_source_create_audio (gavl_packet_source_func_t func, void *priv, int src_flags, const gavl_compression_info_t *ci, const gavl_audio_format_t *afmt) |
Create an audio packet source. More... | |
GAVL_PUBLIC gavl_packet_source_t * | gavl_packet_source_create_video (gavl_packet_source_func_t func, void *priv, int src_flags, const gavl_compression_info_t *ci, const gavl_video_format_t *vfmt) |
Create a video packet source. More... | |
GAVL_PUBLIC gavl_packet_source_t * | gavl_packet_source_create_text (gavl_packet_source_func_t func, void *priv, int src_flags, int timescale) |
Create a text packet source. More... | |
GAVL_PUBLIC gavl_packet_source_t * | gavl_packet_source_create_source (gavl_packet_source_func_t func, void *priv, int src_flags, gavl_packet_source_t *src) |
Create a packet source from another packet source. More... | |
GAVL_PUBLIC void | gavl_packet_source_set_lock_funcs (gavl_packet_source_t *src, gavl_connector_lock_func_t lock_func, gavl_connector_lock_func_t unlock_func, void *priv) |
Set lock functions. More... | |
GAVL_PUBLIC void | gavl_packet_source_set_free_func (gavl_packet_source_t *src, gavl_connector_free_func_t free_func) |
Set free function. More... | |
GAVL_PUBLIC const gavl_compression_info_t * | gavl_packet_source_get_ci (gavl_packet_source_t *s) |
Get the compression info. More... | |
GAVL_PUBLIC const gavl_audio_format_t * | gavl_packet_source_get_audio_format (gavl_packet_source_t *s) |
Get the audio format. More... | |
GAVL_PUBLIC const gavl_video_format_t * | gavl_packet_source_get_video_format (gavl_packet_source_t *s) |
Get the video format. More... | |
GAVL_PUBLIC int | gavl_packet_source_get_timescale (gavl_packet_source_t *s) |
Get the time scale. More... | |
GAVL_PUBLIC gavl_source_status_t | gavl_packet_source_read_packet (void *s, gavl_packet_t **p) |
Read one packet. More... | |
GAVL_PUBLIC void | gavl_packet_source_destroy (gavl_packet_source_t *s) |
Destroy a packet source. More... | |
A/V sources are elements, which can be used to conveniently pass audio or video frames from one program module to another. They do implicit format conversion and optimized buffer handling.
A module, which provides A/V frames, creates a source module and tells the native format in which it provides the frames. If you want to obtain the frames from the source, you tell the desired output format and if you intend to overwrite the frames.
To obtain the frames, you pass the address of the pointer of the frame. If the pointer is NULL, it will be set to an internal buffer.
The return value is of the type gavl_source_status_t, which can have 3 states depending on whether the stream ended (EOF) or a frame is available or if no frame is available right now. The latter can be used to implement parts of the pipeline in pull mode (the default) and others in push mode.
#define GAVL_SOURCE_SRC_ALLOC (1<<0) |
Source provides a pointer to an internal structure.
#define GAVL_SOURCE_SRC_FRAMESIZE_MAX (1<<2) |
Samples per frame is just an upper bound. Frames can have smaller sizes also. The last frame is always allowed to have fewer samples, even if this flag is not set.
#define GAVL_SOURCE_SRC_DISCONTINUOUS (1<<3) |
Stream is discontinuous. Set this for video sources delivering graphical subtitles.
typedef struct gavl_video_source_s gavl_video_source_t |
Forward declaration of the video source.
You don't want to know what's inside
typedef struct gavl_audio_source_s gavl_audio_source_t |
Forward declaration of the audio source.
You don't want to know what's inside
typedef struct gavl_packet_source_s gavl_packet_source_t |
Forward declaration of the packet source.
You don't want to know what's inside
typedef gavl_source_status_t(* gavl_audio_source_func_t) (void *priv, gavl_audio_frame_t **frame) |
Prototype for obtaining one audio frame.
priv | Client data |
frame | Where to store the frame |
If *frame is non-null, the data will be copied there, otherwise the address of an internally allocated frame is returned
typedef gavl_source_status_t(* gavl_video_source_func_t) (void *priv, gavl_video_frame_t **frame) |
Prototype for obtaining one video frame.
priv | Client data |
frame | Where to store the frame |
If *frame is non-null, the data will be copied there, otherwise the address of an internally allocated frame is returned.
typedef gavl_source_status_t(* gavl_packet_source_func_t) (void *priv, gavl_packet_t **p) |
Prototype for obtaining one packet.
priv | Client data |
frame | Where to store the packet |
If *packet is non-null, the data will be copied there, otherwise the address of an internally allocated packet is returned.
enum gavl_source_status_t |
GAVL_PUBLIC gavl_video_source_t* gavl_video_source_create | ( | gavl_video_source_func_t | func, |
void * | priv, | ||
int | src_flags, | ||
const gavl_video_format_t * | src_format | ||
) |
Create a video source.
func | Function to get the frames from |
priv | Client data to pass to func |
src_flags | Flags describing the source |
src_format | Native source format |
GAVL_PUBLIC gavl_video_source_t* gavl_video_source_create_source | ( | gavl_video_source_func_t | func, |
void * | priv, | ||
int | src_flags, | ||
gavl_video_source_t * | src | ||
) |
Create a video source from another source.
func | Function to get the frames from |
priv | Client data to pass to func |
src_flags | Flags describing the source |
src | preceeding source in the pipeline |
This will take the destination format of the preceeding source as the input format
GAVL_PUBLIC void gavl_video_source_set_lock_funcs | ( | gavl_video_source_t * | src, |
gavl_connector_lock_func_t | lock_func, | ||
gavl_connector_lock_func_t | unlock_func, | ||
void * | priv | ||
) |
Set lock functions.
src | A video source |
lock_func | Function called before a frame is read |
unlock_func | Function called after a frame is read |
priv | Client data (e.g. a mutex) to pass to the functions |
GAVL_PUBLIC void gavl_video_source_set_free_func | ( | gavl_video_source_t * | src, |
gavl_connector_free_func_t | free_func | ||
) |
Set free function.
src | A video source |
free_func | Function called with the private data when the source is destroyed |
Use this if you don't want to keep a reference to the private data along wit the source
GAVL_PUBLIC gavl_video_options_t* gavl_video_source_get_options | ( | gavl_video_source_t * | s | ) |
Get coversion options of a video source.
s | A video source |
GAVL_PUBLIC void gavl_video_source_reset | ( | gavl_video_source_t * | s | ) |
Reset a video source.
s | A video source |
Call this after seeking to reset the internal state
GAVL_PUBLIC void gavl_video_source_destroy | ( | gavl_video_source_t * | s | ) |
Destroy a video source.
s | A video source |
Destroy a video source including all video frames ever created by it.
GAVL_PUBLIC void gavl_video_source_support_hw | ( | gavl_video_source_t * | s | ) |
Enable hardware surfaces.
s | A video source |
Call this function if you can handle hardware surfaces on the destination side. If this function is not called, hardware surfaces are copied to RAM before they are passed to the destination.
GAVL_PUBLIC const gavl_video_format_t* gavl_video_source_get_src_format | ( | gavl_video_source_t * | s | ) |
Get the native format.
s | A video source |
GAVL_PUBLIC const gavl_video_format_t* gavl_video_source_get_dst_format | ( | gavl_video_source_t * | s | ) |
Get the output format.
s | A video source |
GAVL_PUBLIC void gavl_video_source_set_dst | ( | gavl_video_source_t * | s, |
int | dst_flags, | ||
const gavl_video_format_t * | dst_format | ||
) |
Set the destination mode.
s | A video source |
dst_flags | Flags |
dst_format | Format in which the frames will be read |
If you accept the source format (as returned by gavl_video_source_get_src_format) you can pass NULL for the dst_format.
If the destination format differs from the source format, the frames will converted. For this, we have a gavl_video_converter_t and also do simple framerate conversion which repeats/drops frames.
GAVL_PUBLIC gavl_source_status_t gavl_video_source_read_frame | ( | void * | s, |
gavl_video_frame_t ** | frame | ||
) |
Read a video frame.
s | A video source |
frame | Address of a frame. |
This reads one frame from the source. If *frame is NULL it will be set to an internal buffer, otherwise the data is copied to the frame you pass.
GAVL_PUBLIC gavl_audio_source_t* gavl_audio_source_create | ( | gavl_audio_source_func_t | func, |
void * | priv, | ||
int | src_flags, | ||
const gavl_audio_format_t * | src_format | ||
) |
Create an audio source.
func | Function to get the frames from |
priv | Client data to pass to func |
src_flags | Flags describing the source |
src_format | Native source format |
GAVL_PUBLIC gavl_audio_source_t* gavl_audio_source_create_source | ( | gavl_audio_source_func_t | func, |
void * | priv, | ||
int | src_flags, | ||
gavl_audio_source_t * | src | ||
) |
Create an audio source from another source.
func | Function to get the frames from |
priv | Client data to pass to func |
src_flags | Flags describing the source |
src | preceeding source in the pipeline |
This will take the destination format of the preceeding source as the input format
GAVL_PUBLIC void gavl_audio_source_set_lock_funcs | ( | gavl_audio_source_t * | src, |
gavl_connector_lock_func_t | lock_func, | ||
gavl_connector_lock_func_t | unlock_func, | ||
void * | priv | ||
) |
Set lock functions.
src | An audio source |
lock_func | Function called before a frame is read |
unlock_func | Function called after a frame is read |
priv | Client data (e.g. a mutex) to pass to the functions |
GAVL_PUBLIC void gavl_audio_source_set_free_func | ( | gavl_audio_source_t * | src, |
gavl_connector_free_func_t | free_func | ||
) |
Set free function.
src | A audio source |
free_func | Function called with the private data when the source is destroyed |
Use this if you don't want to keep a reference to the private data along wit the source
GAVL_PUBLIC const gavl_audio_format_t* gavl_audio_source_get_src_format | ( | gavl_audio_source_t * | s | ) |
Get the native format.
s | An audio source |
GAVL_PUBLIC const gavl_audio_format_t* gavl_audio_source_get_dst_format | ( | gavl_audio_source_t * | s | ) |
Get the output format.
s | An audio source |
GAVL_PUBLIC int gavl_audio_source_get_dst_flags | ( | gavl_audio_source_t * | s | ) |
Get the output flags.
s | An audio source |
GAVL_PUBLIC void gavl_audio_source_set_dst | ( | gavl_audio_source_t * | s, |
int | dst_flags, | ||
const gavl_audio_format_t * | dst_format | ||
) |
Set the destination mode.
s | An audio source |
dst_flags | Flags |
dst_format | Format in which the frames will be read |
If you accept the source format (as returned by gavl_video_source_get_src_format) you can pass NULL for the dst_format.
If the destination format differs from the source format, the frames will converted. For this, we have a gavl_audio_converter_t. In addition, if the samples_per_frame members are different, the frames will be repackaged.
GAVL_PUBLIC gavl_source_status_t gavl_audio_source_read_frame | ( | void * | s, |
gavl_audio_frame_t ** | frame | ||
) |
Read an audio frame.
s | An audio source |
frame | Address of a frame. |
This reads one frame from the source. If *frame is NULL it will be set to an internal buffer, otherwise the data is copied to the frame you pass.
If the return value is GAVL_SOURCE_AGAIN, you might have an imcomplete frame. In this case you must call this function again with exactly the same frame argument.
GAVL_PUBLIC void gavl_audio_source_skip | ( | gavl_audio_source_t * | s, |
int | num_samples | ||
) |
Skip audio samples at the input.
s | An audio source |
num_samples | Number of samples to skip |
This skips a number of input samples. It can be used after seeking if the sample position after a seek is no multiple of the frame size.
GAVL_PUBLIC int gavl_audio_source_read_samples | ( | void * | s, |
gavl_audio_frame_t * | frame, | ||
int | num_samples | ||
) |
Read audio samples.
s | An audio source |
frame | An audio frame |
num_samples | Number of samples to read |
This is for APIs, which pass the number of samples to each read() call and the number is not known in advance.
GAVL_PUBLIC gavl_audio_options_t* gavl_audio_source_get_options | ( | gavl_audio_source_t * | s | ) |
Get coversion options of an audio source.
s | An audio source |
GAVL_PUBLIC void gavl_audio_source_reset | ( | gavl_audio_source_t * | s | ) |
Reset an audio source.
s | An audio source |
This resets the internal state as if no frame was read yet.
GAVL_PUBLIC void gavl_audio_source_destroy | ( | gavl_audio_source_t * | s | ) |
Destroy an audio source.
s | An audio source |
Destroy an audio source including all audio frames ever created by it.
GAVL_PUBLIC gavl_packet_source_t* gavl_packet_source_create | ( | gavl_packet_source_func_t | func, |
void * | priv, | ||
int | src_flags | ||
) |
Create a packet source.
func | Callback for reading one frame |
priv | Client data to be passed to func |
src_flags | Flags |
Typically, you'll use the more specific functions gavl_packet_source_create_audio, gavl_packet_source_create_video, gavl_packet_source_create_text and gavl_packet_source_create_source
GAVL_PUBLIC gavl_packet_source_t* gavl_packet_source_create_audio | ( | gavl_packet_source_func_t | func, |
void * | priv, | ||
int | src_flags, | ||
const gavl_compression_info_t * | ci, | ||
const gavl_audio_format_t * | afmt | ||
) |
Create an audio packet source.
func | Callback for reading one frame |
priv | Client data to be passed to func |
src_flags | Flags |
ci | Compression info |
afmt | Format of the audio stream |
GAVL_PUBLIC gavl_packet_source_t* gavl_packet_source_create_video | ( | gavl_packet_source_func_t | func, |
void * | priv, | ||
int | src_flags, | ||
const gavl_compression_info_t * | ci, | ||
const gavl_video_format_t * | vfmt | ||
) |
Create a video packet source.
func | Callback for reading one frame |
priv | Client data to be passed to func |
src_flags | Flags |
ci | Compression info |
vfmt | Format of the video stream |
GAVL_PUBLIC gavl_packet_source_t* gavl_packet_source_create_text | ( | gavl_packet_source_func_t | func, |
void * | priv, | ||
int | src_flags, | ||
int | timescale | ||
) |
Create a text packet source.
func | Callback for reading one frame |
priv | Client data to be passed to func |
src_flags | Flags |
scale | Timescale of the text packets |
GAVL_PUBLIC gavl_packet_source_t* gavl_packet_source_create_source | ( | gavl_packet_source_func_t | func, |
void * | priv, | ||
int | src_flags, | ||
gavl_packet_source_t * | src | ||
) |
Create a packet source from another packet source.
func | Callback for reading one frame |
priv | Client data to be passed to func |
src_flags | Flags |
src | Source to copy the stream specific data from |
GAVL_PUBLIC void gavl_packet_source_set_lock_funcs | ( | gavl_packet_source_t * | src, |
gavl_connector_lock_func_t | lock_func, | ||
gavl_connector_lock_func_t | unlock_func, | ||
void * | priv | ||
) |
Set lock functions.
src | A packet source |
lock_func | Function called before a packet is read |
unlock_func | Function called after a packet is read |
priv | Client data (e.g. a mutex) to pass to the functions |
GAVL_PUBLIC void gavl_packet_source_set_free_func | ( | gavl_packet_source_t * | src, |
gavl_connector_free_func_t | free_func | ||
) |
Set free function.
src | A packet source |
free_func | Function called with the private data when the source is destroyed |
Use this if you don't want to keep a reference to the private data along wit the source
GAVL_PUBLIC const gavl_compression_info_t* gavl_packet_source_get_ci | ( | gavl_packet_source_t * | s | ) |
Get the compression info.
s | A packet source |
GAVL_PUBLIC const gavl_audio_format_t* gavl_packet_source_get_audio_format | ( | gavl_packet_source_t * | s | ) |
Get the audio format.
s | A packet source |
GAVL_PUBLIC const gavl_video_format_t* gavl_packet_source_get_video_format | ( | gavl_packet_source_t * | s | ) |
Get the video format.
s | A packet source |
GAVL_PUBLIC int gavl_packet_source_get_timescale | ( | gavl_packet_source_t * | s | ) |
Get the time scale.
s | A packet source |
GAVL_PUBLIC gavl_source_status_t gavl_packet_source_read_packet | ( | void * | s, |
gavl_packet_t ** | p | ||
) |
Read one packet.
s | A packet source |
GAVL_PUBLIC void gavl_packet_source_destroy | ( | gavl_packet_source_t * | s | ) |
Destroy a packet source.
s | A packet source |