GStreamer Base Plugins 1.0 Library Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#include <gst/audio/audio.h> enum GstAudioFlags; enum GstAudioFormat; enum GstAudioFormatFlags; struct GstAudioFormatInfo; struct GstAudioInfo; enum GstAudioLayout; enum GstAudioPackFlags; void (*GstAudioFormatPack) (const GstAudioFormatInfo *info
,GstAudioPackFlags flags
,const gpointer src
,gpointer data
,gint length
); void (*GstAudioFormatUnpack) (const GstAudioFormatInfo *info
,GstAudioPackFlags flags
,gpointer dest
,const gpointer data
,gint length
); void gst_audio_info_init (GstAudioInfo *info
); gboolean gst_audio_info_from_caps (GstAudioInfo *info
,const GstCaps *caps
); GstCaps * gst_audio_info_to_caps (const GstAudioInfo *info
); gboolean gst_audio_info_convert (const GstAudioInfo *info
,GstFormat src_fmt
,gint64 src_val
,GstFormat dest_fmt
,gint64 *dest_val
); const GstAudioFormatInfo * gst_audio_format_get_info (GstAudioFormat format
); GstAudioInfo * gst_audio_info_copy (const GstAudioInfo *info
); void gst_audio_info_free (GstAudioInfo *info
); GstAudioInfo * gst_audio_info_new (void
); void gst_audio_info_set_format (GstAudioInfo *info
,GstAudioFormat format
,gint rate
,gint channels
,const GstAudioChannelPosition *position
); GstAudioFormat gst_audio_format_build_integer (gboolean sign
,gint endianness
,gint width
,gint depth
); void gst_audio_format_fill_silence (const GstAudioFormatInfo *info
,gpointer dest
,gsize length
); GstAudioFormat gst_audio_format_from_string (const gchar *format
); const gchar * gst_audio_format_to_string (GstAudioFormat format
); #define GST_AUDIO_FORMAT_INFO_DEPTH (info) #define GST_AUDIO_FORMAT_INFO_ENDIANNESS (info) #define GST_AUDIO_FORMAT_INFO_FLAGS (info) #define GST_AUDIO_FORMAT_INFO_FORMAT (info) #define GST_AUDIO_FORMAT_INFO_IS_FLOAT (info) #define GST_AUDIO_FORMAT_INFO_IS_INTEGER (info) #define GST_AUDIO_FORMAT_INFO_IS_BIG_ENDIAN (info) #define GST_AUDIO_FORMAT_INFO_IS_LITTLE_ENDIAN(info) #define GST_AUDIO_FORMAT_INFO_IS_SIGNED (info) #define GST_AUDIO_FORMAT_INFO_NAME (info) #define GST_AUDIO_FORMAT_INFO_WIDTH (info) #define GST_AUDIO_INFO_BPF (info) #define GST_AUDIO_INFO_BPS (info) #define GST_AUDIO_INFO_CHANNELS (info) #define GST_AUDIO_INFO_DEPTH (i) #define GST_AUDIO_INFO_FLAGS (info) #define GST_AUDIO_INFO_FORMAT (i) #define GST_AUDIO_INFO_NAME (i) #define GST_AUDIO_INFO_POSITION (info, c) #define GST_AUDIO_INFO_RATE (info) #define GST_AUDIO_INFO_WIDTH (i) #define GST_AUDIO_INFO_ENDIANNESS (i) #define GST_AUDIO_INFO_IS_BIG_ENDIAN (i) #define GST_AUDIO_INFO_IS_FLOAT (i) #define GST_AUDIO_INFO_IS_INTEGER (i) #define GST_AUDIO_INFO_IS_LITTLE_ENDIAN (i) #define GST_AUDIO_INFO_IS_SIGNED (i) #define GST_AUDIO_INFO_IS_UNPOSITIONED (info) #define GST_AUDIO_INFO_IS_VALID (i) #define GST_AUDIO_INFO_LAYOUT (info) #define GST_FRAMES_TO_CLOCK_TIME (frames, rate) #define GST_CLOCK_TIME_TO_FRAMES (clocktime, rate) #define GST_AUDIO_DEF_RATE GstBuffer * gst_audio_buffer_clip (GstBuffer *buffer
,GstSegment *segment
,gint rate
,gint bpf
);
typedef enum { GST_AUDIO_FLAG_NONE = 0, GST_AUDIO_FLAG_UNPOSITIONED = (1 << 0) } GstAudioFlags;
Extra audio flags
typedef enum { GST_AUDIO_FORMAT_UNKNOWN, GST_AUDIO_FORMAT_ENCODED, /* 8 bit */ GST_AUDIO_FORMAT_S8, GST_AUDIO_FORMAT_U8, /* 16 bit */ GST_AUDIO_FORMAT_S16LE, GST_AUDIO_FORMAT_S16BE, GST_AUDIO_FORMAT_U16LE, GST_AUDIO_FORMAT_U16BE, /* 24 bit in low 3 bytes of 32 bits*/ GST_AUDIO_FORMAT_S24_32LE, GST_AUDIO_FORMAT_S24_32BE, GST_AUDIO_FORMAT_U24_32LE, GST_AUDIO_FORMAT_U24_32BE, /* 32 bit */ GST_AUDIO_FORMAT_S32LE, GST_AUDIO_FORMAT_S32BE, GST_AUDIO_FORMAT_U32LE, GST_AUDIO_FORMAT_U32BE, /* 24 bit in 3 bytes*/ GST_AUDIO_FORMAT_S24LE, GST_AUDIO_FORMAT_S24BE, GST_AUDIO_FORMAT_U24LE, GST_AUDIO_FORMAT_U24BE, /* 20 bit in 3 bytes*/ GST_AUDIO_FORMAT_S20LE, GST_AUDIO_FORMAT_S20BE, GST_AUDIO_FORMAT_U20LE, GST_AUDIO_FORMAT_U20BE, /* 18 bit in 3 bytes*/ GST_AUDIO_FORMAT_S18LE, GST_AUDIO_FORMAT_S18BE, GST_AUDIO_FORMAT_U18LE, GST_AUDIO_FORMAT_U18BE, /* float */ GST_AUDIO_FORMAT_F32LE, GST_AUDIO_FORMAT_F32BE, GST_AUDIO_FORMAT_F64LE, GST_AUDIO_FORMAT_F64BE, /* native endianness equivalents */ GST_AUDIO_FORMAT_S16 = _GST_AUDIO_FORMAT_NE(S16), GST_AUDIO_FORMAT_U16 = _GST_AUDIO_FORMAT_NE(U16), GST_AUDIO_FORMAT_S24_32 = _GST_AUDIO_FORMAT_NE(S24_32), GST_AUDIO_FORMAT_U24_32 = _GST_AUDIO_FORMAT_NE(U24_32), GST_AUDIO_FORMAT_S32 = _GST_AUDIO_FORMAT_NE(S32), GST_AUDIO_FORMAT_U32 = _GST_AUDIO_FORMAT_NE(U32), GST_AUDIO_FORMAT_S24 = _GST_AUDIO_FORMAT_NE(S24), GST_AUDIO_FORMAT_U24 = _GST_AUDIO_FORMAT_NE(U24), GST_AUDIO_FORMAT_S20 = _GST_AUDIO_FORMAT_NE(S20), GST_AUDIO_FORMAT_U20 = _GST_AUDIO_FORMAT_NE(U20), GST_AUDIO_FORMAT_S18 = _GST_AUDIO_FORMAT_NE(S18), GST_AUDIO_FORMAT_U18 = _GST_AUDIO_FORMAT_NE(U18), GST_AUDIO_FORMAT_F32 = _GST_AUDIO_FORMAT_NE(F32), GST_AUDIO_FORMAT_F64 = _GST_AUDIO_FORMAT_NE(F64) } GstAudioFormat;
Enum value describing the most common audio formats.
unknown or unset audio format | |
encoded audio format | |
8 bits in 8 bits, signed | |
8 bits in 8 bits, unsigned | |
16 bits in 16 bits, signed, little endian | |
16 bits in 16 bits, signed, big endian | |
16 bits in 16 bits, unsigned, little endian | |
16 bits in 16 bits, unsigned, big endian | |
24 bits in 32 bits, signed, little endian | |
24 bits in 32 bits, signed, big endian | |
24 bits in 32 bits, unsigned, little endian | |
24 bits in 32 bits, unsigned, big endian | |
32 bits in 32 bits, signed, little endian | |
32 bits in 32 bits, signed, big endian | |
32 bits in 32 bits, unsigned, little endian | |
32 bits in 32 bits, unsigned, big endian | |
24 bits in 24 bits, signed, little endian | |
24 bits in 24 bits, signed, big endian | |
24 bits in 24 bits, unsigned, little endian | |
24 bits in 24 bits, unsigned, big endian | |
20 bits in 24 bits, signed, little endian | |
20 bits in 24 bits, signed, big endian | |
20 bits in 24 bits, unsigned, little endian | |
20 bits in 24 bits, unsigned, big endian | |
18 bits in 24 bits, signed, little endian | |
18 bits in 24 bits, signed, big endian | |
18 bits in 24 bits, unsigned, little endian | |
18 bits in 24 bits, unsigned, big endian | |
32-bit floating point samples, little endian | |
32-bit floating point samples, big endian | |
64-bit floating point samples, little endian | |
64-bit floating point samples, big endian | |
16 bits in 16 bits, signed, native endianness | |
16 bits in 16 bits, unsigned, native endianness | |
24 bits in 32 bits, signed, native endianness | |
24 bits in 32 bits, unsigned, native endianness | |
32 bits in 32 bits, signed, native endianness | |
32 bits in 32 bits, unsigned, native endianness | |
24 bits in 24 bits, signed, native endianness | |
24 bits in 24 bits, unsigned, native endianness | |
20 bits in 24 bits, signed, native endianness | |
20 bits in 24 bits, unsigned, native endianness | |
18 bits in 24 bits, signed, native endianness | |
18 bits in 24 bits, unsigned, native endianness | |
32-bit floating point samples, native endianness | |
64-bit floating point samples, native endianness |
typedef enum { GST_AUDIO_FORMAT_FLAG_INTEGER = (1 << 0), GST_AUDIO_FORMAT_FLAG_FLOAT = (1 << 1), GST_AUDIO_FORMAT_FLAG_SIGNED = (1 << 2), GST_AUDIO_FORMAT_FLAG_COMPLEX = (1 << 4), GST_AUDIO_FORMAT_FLAG_UNPACK = (1 << 5) } GstAudioFormatFlags;
The different audio flags that a format info can have.
integer samples | |
float samples | |
signed samples | |
complex layout | |
the format can be used in GstAudioFormatUnpack and GstAudioFormatPack functions |
struct GstAudioFormatInfo { GstAudioFormat format; const gchar *name; const gchar *description; GstAudioFormatFlags flags; gint endianness; gint width; gint depth; guint8 silence[8]; GstAudioFormat unpack_format; GstAudioFormatUnpack unpack_func; GstAudioFormatPack pack_func; };
Information for an audio format.
GstAudioFormat |
GstAudioFormat |
const gchar * |
string representation of the format |
const gchar * |
user readable description of the format |
GstAudioFormatFlags |
GstAudioFormatFlags |
gint |
the endianness |
gint |
amount of bits used for one sample |
gint |
amount of valid bits in width
|
width /8 bytes with 1 silent sample |
|
GstAudioFormat |
the format of the unpacked samples |
GstAudioFormatUnpack |
function to unpack samples |
GstAudioFormatPack |
function to pack samples |
struct GstAudioInfo { const GstAudioFormatInfo *finfo; GstAudioFlags flags; GstAudioLayout layout; gint rate; gint channels; gint bpf; GstAudioChannelPosition position[64]; };
Information describing audio properties. This information can be filled
in from GstCaps with gst_audio_info_from_caps()
.
Use the provided macros to access the info in this structure.
const GstAudioFormatInfo * |
the format info of the audio |
GstAudioFlags |
additional audio flags |
GstAudioLayout |
audio layout |
gint |
the audio sample rate |
gint |
the number of channels |
gint |
the number of bytes for one frame, this is the size of one
sample * channels
|
GstAudioChannelPosition |
the positions for each channel |
typedef enum { GST_AUDIO_LAYOUT_INTERLEAVED = 0, GST_AUDIO_LAYOUT_NON_INTERLEAVED } GstAudioLayout;
Layout of the audio samples for the different channels.
typedef enum { GST_AUDIO_PACK_FLAG_NONE = 0 } GstAudioPackFlags;
The different flags that can be used when packing and unpacking.
void (*GstAudioFormatPack) (const GstAudioFormatInfo *info
,GstAudioPackFlags flags
,const gpointer src
,gpointer data
,gint length
);
Packs length
samples from src
to the data array in format info
.
The samples from source have each channel interleaved
and will be packed into data
.
|
a GstAudioFormatInfo |
|
a source array. [array][element-type guint8] |
|
pointer to the destination data. [array][element-type guint8] |
|
the amount of samples to pack. |
void (*GstAudioFormatUnpack) (const GstAudioFormatInfo *info
,GstAudioPackFlags flags
,gpointer dest
,const gpointer data
,gint length
);
Unpacks length
samples from the given data of format info
.
The samples will be unpacked into dest
which each channel
interleaved. dest
should at least be big enough to hold length
*
channels * size(unpack_format) bytes.
|
a GstAudioFormatInfo |
|
a destination array. [array][element-type guint8] |
|
pointer to the audio data. [array][element-type guint8] |
|
the amount of samples to unpack. |
void gst_audio_info_init (GstAudioInfo *info
);
Initialize info
with default values.
|
a GstAudioInfo |
gboolean gst_audio_info_from_caps (GstAudioInfo *info
,const GstCaps *caps
);
Parse caps
and update info
.
|
a GstAudioInfo |
|
a GstCaps |
Returns : |
TRUE if caps could be parsed |
GstCaps * gst_audio_info_to_caps (const GstAudioInfo *info
);
Convert the values of info
into a GstCaps.
|
a GstAudioInfo |
Returns : |
the new GstCaps containing the
info of info . [transfer full]
|
gboolean gst_audio_info_convert (const GstAudioInfo *info
,GstFormat src_fmt
,gint64 src_val
,GstFormat dest_fmt
,gint64 *dest_val
);
Converts among various GstFormat types. This function handles GST_FORMAT_BYTES, GST_FORMAT_TIME, and GST_FORMAT_DEFAULT. For raw audio, GST_FORMAT_DEFAULT corresponds to audio frames. This function can be used to handle pad queries of the type GST_QUERY_CONVERT.
|
a GstAudioInfo |
|
GstFormat of the src_val
|
|
value to convert |
|
GstFormat of the dest_val
|
|
pointer to destination value |
Returns : |
TRUE if the conversion was successful. |
const GstAudioFormatInfo * gst_audio_format_get_info (GstAudioFormat format
);
Get the GstAudioFormatInfo for format
|
a GstAudioFormat |
Returns : |
The GstAudioFormatInfo for format . |
GstAudioInfo * gst_audio_info_copy (const GstAudioInfo *info
);
Copy a GstAudioInfo structure.
|
a GstAudioInfo |
Returns : |
a new GstAudioInfo. free with gst_audio_info_free. |
void gst_audio_info_free (GstAudioInfo *info
);
Free a GstAudioInfo structure previously allocated with gst_audio_info_new()
or gst_audio_info_copy()
.
|
a GstAudioInfo |
GstAudioInfo * gst_audio_info_new (void
);
Allocate a new GstAudioInfo that is also initialized with
gst_audio_info_init()
.
Returns : |
a new GstAudioInfo. free with gst_audio_info_free() . |
void gst_audio_info_set_format (GstAudioInfo *info
,GstAudioFormat format
,gint rate
,gint channels
,const GstAudioChannelPosition *position
);
Set the default info for the audio info of format
and rate
and channels
.
|
a GstAudioInfo |
|
the format |
|
the samplerate |
|
the number of channels |
|
the channel positions |
GstAudioFormat gst_audio_format_build_integer (gboolean sign
,gint endianness
,gint width
,gint depth
);
Construct a GstAudioFormat with given parameters.
|
signed or unsigned format |
|
G_LITTLE_ENDIAN or G_BIG_ENDIAN |
|
amount of bits used per sample |
|
amount of used bits in width
|
Returns : |
a GstAudioFormat or GST_AUDIO_FORMAT_UNKNOWN when no audio format exists with the given parameters. |
void gst_audio_format_fill_silence (const GstAudioFormatInfo *info
,gpointer dest
,gsize length
);
Fill length
bytes in dest
with silence samples for info
.
|
a GstAudioFormatInfo |
|
a destination to fill. [array length=length][element-type guint8] |
|
the length to fill |
GstAudioFormat gst_audio_format_from_string (const gchar *format
);
Convert the format
string to its GstAudioFormat.
|
a format string |
Returns : |
the GstAudioFormat for format or GST_AUDIO_FORMAT_UNKNOWN when the
string is not a known format. |
#define GST_AUDIO_FORMAT_INFO_ENDIANNESS(info) ((info)->endianness)
#define GST_AUDIO_FORMAT_INFO_IS_FLOAT(info) !!((info)->flags & GST_AUDIO_FORMAT_FLAG_FLOAT)
#define GST_AUDIO_FORMAT_INFO_IS_INTEGER(info) !!((info)->flags & GST_AUDIO_FORMAT_FLAG_INTEGER)
#define GST_AUDIO_FORMAT_INFO_IS_BIG_ENDIAN(info) ((info)->endianness == G_BIG_ENDIAN)
#define GST_AUDIO_FORMAT_INFO_IS_LITTLE_ENDIAN(info) ((info)->endianness == G_LITTLE_ENDIAN)
#define GST_AUDIO_FORMAT_INFO_IS_SIGNED(info) !!((info)->flags & GST_AUDIO_FORMAT_FLAG_SIGNED)
#define GST_AUDIO_INFO_ENDIANNESS(i) (GST_AUDIO_FORMAT_INFO_ENDIANNES((i)->finfo))
#define GST_AUDIO_INFO_IS_BIG_ENDIAN(i) (GST_AUDIO_FORMAT_INFO_IS_BIG_ENDIAN((i)->finfo))
#define GST_AUDIO_INFO_IS_FLOAT(i) (GST_AUDIO_FORMAT_INFO_IS_FLOAT((i)->finfo))
#define GST_AUDIO_INFO_IS_INTEGER(i) (GST_AUDIO_FORMAT_INFO_IS_INTEGER((i)->finfo))
#define GST_AUDIO_INFO_IS_LITTLE_ENDIAN(i) (GST_AUDIO_FORMAT_INFO_IS_LITTLE_ENDIAN((i)->finfo))
#define GST_AUDIO_INFO_IS_SIGNED(i) (GST_AUDIO_FORMAT_INFO_IS_SIGNED((i)->finfo))
#define GST_AUDIO_INFO_IS_UNPOSITIONED(info) ((info)->flags & GST_AUDIO_FLAG_UNPOSITIONED)
#define GST_AUDIO_INFO_IS_VALID(i) ((i)->finfo != NULL && (i)->rate > 0 && (i)->channels > 0 && (i)->bpf > 0)
#define GST_FRAMES_TO_CLOCK_TIME(frames, rate)
Calculate clocktime from sample frames
and rate
.
|
sample frames |
|
sampling rate |
#define GST_CLOCK_TIME_TO_FRAMES(clocktime, rate)
Calculate frames from clocktime
and sample rate
.
|
clock time |
|
sampling rate |
GstBuffer * gst_audio_buffer_clip (GstBuffer *buffer
,GstSegment *segment
,gint rate
,gint bpf
);
Clip the buffer to the given GstSegment
.
After calling this function the caller does not own a reference to
buffer
anymore.
|
The buffer to clip. [transfer full] |
|
Segment in GST_FORMAT_TIME or GST_FORMAT_DEFAULT to which
the buffer should be clipped. |
|
sample rate. |
|
size of one audio frame in bytes. This is the size of one sample * channels. |
Returns : |
NULL if the buffer is completely outside the configured segment,
otherwise the clipped buffer is returned.
If the buffer has no timestamp, it is assumed to be inside the segment and
is not clipped. [transfer full]
|