gstaudio

gstaudio — Support library for audio elements

Functions

Types and Values

Includes

#include <gst/audio/audio.h>

Description

This library contains some helper functions for audio elements.

Functions

gst_audio_info_init ()

void
gst_audio_info_init (GstAudioInfo *info);

gst_audio_info_clear ()

void
gst_audio_info_clear (GstAudioInfo *info);

gst_audio_info_copy ()

GstAudioInfo *
gst_audio_info_copy (GstAudioInfo *info);

gst_audio_info_free ()

void
gst_audio_info_free (GstAudioInfo *info);

gst_audio_info_from_caps ()

gboolean
gst_audio_info_from_caps (GstAudioInfo *info,
                          const GstCaps *caps);

Parse caps and update info .

Parameters

info

a GstAudioInfo

 

caps

a GstCaps

 

Returns

TRUE if caps could be parsed

Since 0.10.36


gst_audio_info_to_caps ()

GstCaps *
gst_audio_info_to_caps (GstAudioInfo *info);

Convert the values of info into a GstCaps.

Parameters

info

a GstAudioInfo

 

Returns

the new GstCaps containing the info of info .

[transfer full]

Since 0.10.36


gst_audio_info_convert ()

gboolean
gst_audio_info_convert (GstAudioInfo *info,
                        GstFormat src_fmt,
                        gint64 src_val,
                        GstFormat dest_fmt,
                        gint64 *dest_val);

gst_audio_format_get_info ()

const GstAudioFormatInfo *
gst_audio_format_get_info (GstAudioFormat format);

GST_AUDIO_FORMAT_INFO_DEPTH()

#define GST_AUDIO_FORMAT_INFO_DEPTH(info)            ((info)->depth)

GST_AUDIO_FORMAT_INFO_ENDIANNESS()

#define GST_AUDIO_FORMAT_INFO_ENDIANNESS(info)       ((info)->endianness)

GST_AUDIO_FORMAT_INFO_FLAGS()

#define GST_AUDIO_FORMAT_INFO_FLAGS(info)            ((info)->flags)

GST_AUDIO_FORMAT_INFO_FORMAT()

#define GST_AUDIO_FORMAT_INFO_FORMAT(info)           ((info)->format)

GST_AUDIO_FORMAT_INFO_IS_FLOAT()

#define GST_AUDIO_FORMAT_INFO_IS_FLOAT(info)         !!((info)->flags & GST_AUDIO_FORMAT_FLAG_FLOAT)

GST_AUDIO_FORMAT_INFO_IS_INTEGER()

#define GST_AUDIO_FORMAT_INFO_IS_INTEGER(info)       !!((info)->flags & GST_AUDIO_FORMAT_FLAG_INTEGER)

GST_AUDIO_FORMAT_INFO_IS_BIG_ENDIAN()

#define GST_AUDIO_FORMAT_INFO_IS_BIG_ENDIAN(info)    ((info)->endianness == G_BIG_ENDIAN)

GST_AUDIO_FORMAT_INFO_IS_LITTLE_ENDIAN()

#define GST_AUDIO_FORMAT_INFO_IS_LITTLE_ENDIAN(info) ((info)->endianness == G_LITTLE_ENDIAN)

GST_AUDIO_FORMAT_INFO_IS_SIGNED()

#define GST_AUDIO_FORMAT_INFO_IS_SIGNED(info)        !!((info)->flags & GST_AUDIO_FORMAT_FLAG_SIGNED)

GST_AUDIO_FORMAT_INFO_NAME()

#define GST_AUDIO_FORMAT_INFO_NAME(info)             ((info)->name)

GST_AUDIO_FORMAT_INFO_WIDTH()

#define GST_AUDIO_FORMAT_INFO_WIDTH(info)            ((info)->width)

GST_AUDIO_INFO_BPF()

#define GST_AUDIO_INFO_BPF(info)             ((info)->bpf)

GST_AUDIO_INFO_BPS()

#define GST_AUDIO_INFO_BPS(info)             (GST_AUDIO_INFO_DEPTH(info) >> 3)

GST_AUDIO_INFO_CHANNELS()

#define GST_AUDIO_INFO_CHANNELS(info)        ((info)->channels)

GST_AUDIO_INFO_DEPTH()

#define GST_AUDIO_INFO_DEPTH(i)              (GST_AUDIO_FORMAT_INFO_DEPTH((i)->finfo))

GST_AUDIO_INFO_FLAGS()

#define GST_AUDIO_INFO_FLAGS(info)           ((info)->flags)

GST_AUDIO_INFO_FORMAT()

#define GST_AUDIO_INFO_FORMAT(i)             (GST_AUDIO_FORMAT_INFO_FORMAT((i)->finfo))

GST_AUDIO_INFO_HAS_DEFAULT_POSITIONS()

#define GST_AUDIO_INFO_HAS_DEFAULT_POSITIONS(info) ((info)->flags & GST_AUDIO_FLAG_DEFAULT_POSITIONS)

GST_AUDIO_INFO_NAME()

#define GST_AUDIO_INFO_NAME(i)               (GST_AUDIO_FORMAT_INFO_NAME((i)->finfo))

GST_AUDIO_INFO_POSITION()

#define GST_AUDIO_INFO_POSITION(info,c)      ((info)->position[c])

GST_AUDIO_INFO_RATE()

#define GST_AUDIO_INFO_RATE(info)            ((info)->rate)

GST_AUDIO_INFO_WIDTH()

#define GST_AUDIO_INFO_WIDTH(i)              (GST_AUDIO_FORMAT_INFO_WIDTH((i)->finfo))

GST_FRAMES_TO_CLOCK_TIME()

#define             GST_FRAMES_TO_CLOCK_TIME(frames, rate)

Calculate clocktime from sample frames and rate .

Parameters

frames

sample frames

 

rate

sampling rate

 

GST_CLOCK_TIME_TO_FRAMES()

#define             GST_CLOCK_TIME_TO_FRAMES(clocktime, rate)

Calculate frames from clocktime and sample rate .

Parameters

clocktime

clock time

 

rate

sampling rate

 

gst_audio_frame_byte_size ()

int
gst_audio_frame_byte_size (GstPad *pad);

Calculate byte size of an audio frame.

Parameters

pad

the GstPad to get the caps from

 

Returns

the byte size, or 0 if there was an error


gst_audio_frame_length ()

long
gst_audio_frame_length (GstPad *pad,
                        GstBuffer *buf);

Calculate length of buffer in frames.

Parameters

pad

the GstPad to get the caps from

 

buf

the GstBuffer

 

Returns

0 if there's an error, or the number of frames if everything's ok


gst_audio_duration_from_pad_buffer ()

GstClockTime
gst_audio_duration_from_pad_buffer (GstPad *pad,
                                    GstBuffer *buf);

Calculate length in nanoseconds of audio buffer buf based on capabilities of pad .

Parameters

pad

the GstPad to get the caps from

 

buf

the GstBuffer

 

Returns

the length.


gst_audio_is_buffer_framed ()

gboolean
gst_audio_is_buffer_framed (GstPad *pad,
                            GstBuffer *buf);

Check if the buffer size is a whole multiple of the frame size.

Parameters

pad

the GstPad to get the caps from

 

buf

the GstBuffer

 

Returns

TRUE if buffer size is multiple.


gst_audio_structure_set_int ()

void
gst_audio_structure_set_int (GstStructure *structure,
                             GstAudioFieldFlag flag);

gst_audio_structure_set_int is deprecated and should not be used in newly-written code.

use gst_structure_set()

Do not use anymore.

Parameters

structure

a GstStructure

 

flag

a set of GstAudioFieldFlag

 

gst_audio_buffer_clip ()

GstBuffer *
gst_audio_buffer_clip (GstBuffer *buffer,
                       GstSegment *segment,
                       gint rate,
                       gint frame_size);

gst_audio_buffer_clip is deprecated and should not be used in newly-written code.

Clip the buffer to the given GstSegment.

After calling this function the caller does not own a reference to buffer anymore.

Parameters

buffer

The buffer to clip.

 

segment

Segment in GST_FORMAT_TIME or GST_FORMAT_DEFAULT to which the buffer should be clipped.

 

rate

sample rate.

 

frame_size

size of one audio frame in bytes.

 

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

Since 0.10.14

Types and Values

enum GstAudioFlags

Extra audio flags

Members

GST_AUDIO_FLAG_NONE

no valid flag

 

GST_AUDIO_FLAG_DEFAULT_POSITIONS

unpositioned audio layout, position array contains the default layout (meaning that the channel layout was not explicitly specified in the caps)

 

Since 0.10.36


enum GstAudioFormat

Enum value describing the most common audio formats.

Members

GST_AUDIO_FORMAT_UNKNOWN

unknown audio format

 

GST_AUDIO_FORMAT_S8

8 bits in 8 bits, signed

 

GST_AUDIO_FORMAT_U8

8 bits in 8 bits, unsigned

 

GST_AUDIO_FORMAT_S16LE

16 bits in 16 bits, signed, little endian

 

GST_AUDIO_FORMAT_S16BE

16 bits in 16 bits, signed, big endian

 

GST_AUDIO_FORMAT_U16LE

16 bits in 16 bits, unsigned, little endian

 

GST_AUDIO_FORMAT_U16BE

16 bits in 16 bits, unsigned, big endian

 

GST_AUDIO_FORMAT_S24_32LE

24 bits in 32 bits, signed, little endian

 

GST_AUDIO_FORMAT_S24_32BE

24 bits in 32 bits, signed, big endian

 

GST_AUDIO_FORMAT_U24_32LE

24 bits in 32 bits, unsigned, little endian

 

GST_AUDIO_FORMAT_U24_32BE

24 bits in 32 bits, unsigned, big endian

 

GST_AUDIO_FORMAT_S32LE

32 bits in 32 bits, signed, little endian

 

GST_AUDIO_FORMAT_S32BE

32 bits in 32 bits, signed, big endian

 

GST_AUDIO_FORMAT_U32LE

32 bits in 32 bits, unsigned, little endian

 

GST_AUDIO_FORMAT_U32BE

32 bits in 32 bits, unsigned, big endian

 

GST_AUDIO_FORMAT_S24LE

24 bits in 24 bits, signed, little endian

 

GST_AUDIO_FORMAT_S24BE

24 bits in 24 bits, signed, big endian

 

GST_AUDIO_FORMAT_U24LE

24 bits in 24 bits, unsigned, little endian

 

GST_AUDIO_FORMAT_U24BE

24 bits in 24 bits, unsigned, big endian

 

GST_AUDIO_FORMAT_S20LE

20 bits in 24 bits, signed, little endian

 

GST_AUDIO_FORMAT_S20BE

20 bits in 24 bits, signed, big endian

 

GST_AUDIO_FORMAT_U20LE

20 bits in 24 bits, unsigned, little endian

 

GST_AUDIO_FORMAT_U20BE

20 bits in 24 bits, unsigned, big endian

 

GST_AUDIO_FORMAT_S18LE

18 bits in 24 bits, signed, little endian

 

GST_AUDIO_FORMAT_S18BE

18 bits in 24 bits, signed, big endian

 

GST_AUDIO_FORMAT_U18LE

18 bits in 24 bits, unsigned, little endian

 

GST_AUDIO_FORMAT_U18BE

18 bits in 24 bits, unsigned, big endian

 

GST_AUDIO_FORMAT_F32LE

32-bit floating point samples, little endian

 

GST_AUDIO_FORMAT_F32BE

32-bit floating point samples, big endian

 

GST_AUDIO_FORMAT_F64LE

64-bit floating point samples, little endian

 

GST_AUDIO_FORMAT_F64BE

64-bit floating point samples, big endian

 

GST_AUDIO_FORMAT_S16

16 bits in 16 bits, signed, native endianness

 

GST_AUDIO_FORMAT_U16

16 bits in 16 bits, unsigned, native endianness

 

GST_AUDIO_FORMAT_S24_32

24 bits in 32 bits, signed, native endianness

 

GST_AUDIO_FORMAT_U24_32

24 bits in 32 bits, unsigned, native endianness

 

GST_AUDIO_FORMAT_S32

32 bits in 32 bits, signed, native endianness

 

GST_AUDIO_FORMAT_U32

32 bits in 32 bits, unsigned, native endianness

 

GST_AUDIO_FORMAT_S24

24 bits in 24 bits, signed, native endianness

 

GST_AUDIO_FORMAT_U24

24 bits in 24 bits, unsigned, native endianness

 

GST_AUDIO_FORMAT_S20

20 bits in 24 bits, signed, native endianness

 

GST_AUDIO_FORMAT_U20

20 bits in 24 bits, unsigned, native endianness

 

GST_AUDIO_FORMAT_S18

18 bits in 24 bits, signed, native endianness

 

GST_AUDIO_FORMAT_U18

18 bits in 24 bits, unsigned, native endianness

 

GST_AUDIO_FORMAT_F32

32-bit floating point samples, native endianness

 

GST_AUDIO_FORMAT_F64

64-bit floating point samples, native endianness

 

Since 0.10.36


enum GstAudioFormatFlags

The different audio flags that a format info can have.

Members

GST_AUDIO_FORMAT_FLAG_INTEGER

integer samples

 

GST_AUDIO_FORMAT_FLAG_FLOAT

float samples

 

GST_AUDIO_FORMAT_FLAG_SIGNED

signed samples

 

GST_AUDIO_FORMAT_FLAG_COMPLEX

complex layout

 

Since 0.10.36


struct GstAudioFormatInfo

struct GstAudioFormatInfo {
  GstAudioFormat      format;
  const gchar *       name;
  GstAudioFormatFlags flags;
  gint                endianness;
  gint                width;
  gint                depth;
  guint8              silence[8];
};

Information for an audio format.

Members

GstAudioFormat format;

GstAudioFormat

 

const gchar *name;

string representation of the format

 

GstAudioFormatFlags flags;

GstAudioFormatFlags

 

gint endianness;

the endianness

 

gint width;

amount of bits used for one sample

 

gint depth;

amount of valid bits in width

 

guint8 silence[8];

width /8 bytes with 1 silent sample

 

Since 0.10.36


struct GstAudioInfo

struct GstAudioInfo {
  const GstAudioFormatInfo *finfo;
  GstAudioFlags             flags;
  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.

Members

const GstAudioFormatInfo *finfo;

the format info of the audio

 

GstAudioFlags flags;

additional audio flags

 

gint rate;

the audio sample rate

 

gint channels;

the number of channels

 

gint bpf;

the number of bytes for one frame, this is the size of one sample * channels

 

GstAudioChannelPosition position[64];

the position for each channel (assume all NONE for >64 channels)

 

Since 0.10.36


enum GstAudioFieldFlag

GstAudioFieldFlag is deprecated and should not be used in newly-written code.

use gst_structure_set() directly

Do not use anymore.

Members

GST_AUDIO_FIELD_RATE

add rate field to caps

 

GST_AUDIO_FIELD_CHANNELS

add channels field to caps

 

GST_AUDIO_FIELD_ENDIANNESS

add endianness field to caps

 

GST_AUDIO_FIELD_WIDTH

add width field to caps

 

GST_AUDIO_FIELD_DEPTH

add depth field to caps

 

GST_AUDIO_FIELD_SIGNED

add signed field to caps

 

GST_AUDIO_DEF_RATE

#define GST_AUDIO_DEF_RATE 44100

Standard sampling rate used in consumer audio.


GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS

#define             GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS

Template caps for float audio. Can be used when defining a GstStaticPadTemplate


GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS

#define             GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS

Template caps for 32bit float mono audio in native byte-order. Can be used when defining a GstStaticPadTemplate


GST_AUDIO_INT_PAD_TEMPLATE_CAPS

#define             GST_AUDIO_INT_PAD_TEMPLATE_CAPS

Template caps for integer audio. Can be used when defining a GstStaticPadTemplate


GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS

#define             GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS

Template caps for 16bit integer stereo audio in native byte-order. Can be used when defining a GstStaticPadTemplate