GstAudioAdapter

GstAudioAdapter — GstAdapter like class that understands audio stream formats.

Functions

Properties

guint size Read
guint unit-size Read / Write / Construct

Types and Values

Object Hierarchy

    GObject
    ╰── GstAudioAdapter

Includes

#include <gstlal/gstaudioadapter.h>

Description

GstAudioAdapter provides a queue to accumulate time series data and facilitate its ingestion by code that requires or prefers to process data in blocks of some size. GStreamer provides GstAdapter, which is a similar class but is not specifically tailored to time series data.

After a GstAudioAdapter is created, and one or more GstBuffer objects inserted into it with gst_audioadapter_push(), its size (in samples) can be checked by checking the “size” property, buffers retrieved with gst_audioadapter_get_list_samples(), and then data flushed from it with gst_audioadapter_flush_samples().

Functions

GST_AUDIODAPATER_GET_CLASS()

#define             GST_AUDIODAPATER_GET_CLASS(obj)

gst_audioadapter_is_empty ()

gboolean
gst_audioadapter_is_empty (GstAudioAdapter *adapter);

TRUE if the GstAudioAdapter is empty, FALSE otherwise.

Parameters

adapter

a GstAudioAdapter

 

Returns

gboolean


gst_audioadapter_expected_timestamp ()

GstClockTime
gst_audioadapter_expected_timestamp (GstAudioAdapter *adapter);

If the GstAudioAdapter is not empty, returns the GstClockTime of the next buffer that should be pushed into the adapter if the next buffer is to be contiguous with the data in the GstAudioAdapter. Returns GST_CLOCK_TIME_NONE if the GstAudioAdapter is empty.

See also: gst_audioadapter_expected_offset()

Parameters

adapter

a GstAudioAdapter

 

Returns

GstClockTime


gst_audioadapter_expected_offset ()

guint64
gst_audioadapter_expected_offset (GstAudioAdapter *adapter);

If the GstAudioAdapter is not empty, returns the offset of the next GstBuffer that should be pushed into the adapter if the next GstBuffer is to be contiguous with the data in the GstAudioAdapter. Returns GST_BUFFER_OFFSET_NONE if the GstAudioAdapter is empty.

See also: gst_audioadapter_expected_timestamp()

Parameters

adapter

a GstAudioAdapter

 

Returns

guint64


gst_audioadapter_clear ()

void
gst_audioadapter_clear (GstAudioAdapter *adapter);

Empty the GstAudioAdapter. All buffers are unref'ed and the “size” is set to 0.

Parameters

adapter

a GstAudioAdapter

 

gst_audioadapter_push ()

void
gst_audioadapter_push (GstAudioAdapter *adapter,
                       GstBuffer *buf);

The GstBuffer is pushed into the GstAudioAdapter's tail and the “size” is updated. The GstAudioAdapter takes ownership of the GstBuffer. If the calling code wishes to continue to access the GstBuffer's contents it must gst_buffer_ref() it before calling this function. The GstBuffer's timestamp, duration, offset and offset end must all be valid.

Gap buffers need not have any data in them, but the size of all others must no smaller than (offset end - offset) * unit size. If larger, the additional data will be ignored.

Parameters

adapter

a GstAudioAdapter

 

buf

the GstBuffer to push into (append to) the GstAudioAdapter

 

gst_audioadapter_is_gap ()

gboolean
gst_audioadapter_is_gap (GstAudioAdapter *adapter);

TRUE if all GstBuffers in the adapter are gaps or are zero length. FALSE if the GstAudioAdapter contains a non-zero length of non-gap GstBuffers.

Parameters

adapter

a GstAudioAdapter

 

Returns

gboolean


gst_audioadapter_head_gap_length ()

guint
gst_audioadapter_head_gap_length (GstAudioAdapter *adapter);

Return the number of contiguous gap samples at the head (samples to be pulled out first) of the GstAudioAdapter.

Parameters

adapter

a GstAudioAdapter

 

Returns

guint


gst_audioadapter_tail_gap_length ()

guint
gst_audioadapter_tail_gap_length (GstAudioAdapter *adapter);

Return the number of contiguous gap samples at the tail (samples to be pulled out last) of the GstAudioAdapter.

Parameters

adapter

a GstAudioAdapter

 

Returns

guint


gst_audioadapter_head_nongap_length ()

guint
gst_audioadapter_head_nongap_length (GstAudioAdapter *adapter);

Return the number of contiguous non-gap samples at the head (samples to be pulled out first) of the GstAudioAdapter.

Parameters

adapter

a GstAudioAdapter

 

Returns

guint


gst_audioadapter_tail_nongap_length ()

guint
gst_audioadapter_tail_nongap_length (GstAudioAdapter *adapter);

Return the number of contiguous non-gap samples at the tail (samples to be pulled out last) of the GstAudioAdapter.

Parameters

adapter

a GstAudioAdapter

 

Returns

guint


gst_audioadapter_copy_samples ()

void
gst_audioadapter_copy_samples (GstAudioAdapter *adapter,
                               void *dst,
                               guint samples,
                               gboolean *copied_gap,
                               gboolean *copied_nongap);

Copies samples from the GstAudioAdapter's head to a contiguous region of memory. Samples taken from GstBuffers that have their GST_BUFFER_FLAG_GAP set to TRUE are set to 0 in the target buffer.

Parameters

adapter

a GstAudioAdapter

 

dst

start of the memory region to which to copy the samples, it must be large enough to accomodate them

 

samples

the number of samples to copy

 

copied_gap

if not NULL, the address of a gboolean that will be set to TRUE if any gap samples were among the samples copied or FALSE if all samples were not gap samples.

 

copied_nongap

if not NULL, the address of a gboolean that will be set to TRUE if any non-gap samples were among the samples copied or FALSE if all samples were gaps.

 

gst_audioadapter_get_list_samples ()

GList *
gst_audioadapter_get_list_samples (GstAudioAdapter *adapter,
                                   guint samples);

Construct and return a GList of GstBuffer objects containing the first samples from GstAudioAdapter's head. The list contains references to the GstBuffer objects in the GstAudioAdapter (or sub-buffers thereof depending on how the number of samples requested aligns with GstBuffer boundaries).

The GstBufferFlags on each buffer are preserved, and the offsets are set and/or adjusted appropriated, but the timestamps and durations are undefined.

Parameters

adapter

a GstAudioAdapter

 

samples

the number of samples to copy

 

Returns

GList of GstBuffers. Calling code owns a reference to each GstBuffer in the list --- call gst_buffer_unref() on each when done --- but they are not necessarily writable, the references might be shared.


gst_audioadapter_flush_samples ()

void
gst_audioadapter_flush_samples (GstAudioAdapter *adapter,
                                guint samples);

Flush samples from the head of the GstAudioAdapter, and update the “size”.

Parameters

adapter

a GstAudioAdapter

 

samples

the number of samples to flush

 

Types and Values

struct GstAudioAdapter

struct GstAudioAdapter;

The opaque GstAudioAdapter instance structure.


struct GstAudioAdapterClass

struct GstAudioAdapterClass {
	GObjectClass parent_class;
};

Members

GObjectClass parent_class;

the parent class

 

Property Details

The “size” property

  “size”                     guint

The number of frames in the adapter.

Flags: Read

Default value: 0


The “unit-size” property

  “unit-size”                guint

The size, in bytes, of one "frame" (one sample from all channels).

Flags: Read / Write / Construct

Allowed values: >= 1

Default value: 1