GstAudioAdapter

GstAudioAdapter — GstAdapter-like class that understands audio stream formats.

Synopsis

#include <gstlal/gstaudioadapter.h>

#define             GST_AUDIODAPATER_GET_CLASS          (obj)
struct              GstAudioAdapter;
struct              GstAudioAdapterClass;
gboolean            gst_audioadapter_is_empty           (GstAudioAdapter *adapter);
GstClockTime        gst_audioadapter_expected_timestamp (GstAudioAdapter *adapter);
guint64             gst_audioadapter_expected_offset    (GstAudioAdapter *adapter);
void                gst_audioadapter_clear              (GstAudioAdapter *adapter);
void                gst_audioadapter_push               (GstAudioAdapter *adapter,
                                                         GstBuffer *buf);
gboolean            gst_audioadapter_is_gap             (GstAudioAdapter *adapter);
guint               gst_audioadapter_head_gap_length    (GstAudioAdapter *adapter);
guint               gst_audioadapter_tail_gap_length    (GstAudioAdapter *adapter);
guint               gst_audioadapter_head_nongap_length (GstAudioAdapter *adapter);
guint               gst_audioadapter_tail_nongap_length (GstAudioAdapter *adapter);
void                gst_audioadapter_copy_samples       (GstAudioAdapter *adapter,
                                                         void *dst,
                                                         guint samples,
                                                         gboolean *copied_gap,
                                                         gboolean *copied_nongap);
GList *             gst_audioadapter_get_list_samples   (GstAudioAdapter *adapter,
                                                         guint samples);
void                gst_audioadapter_flush_samples      (GstAudioAdapter *adapter,
                                                         guint samples);

Object Hierarchy

  GObject
   +----GstAudioAdapter

Properties

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

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().

Details

GST_AUDIODAPATER_GET_CLASS()

#define             GST_AUDIODAPATER_GET_CLASS(obj)


struct GstAudioAdapter

struct GstAudioAdapter;

The opaque GstAudioAdapter instance structure.


struct GstAudioAdapterClass

struct GstAudioAdapterClass {
	GObjectClass parent_class;
};

gst_audioadapter_is_empty ()

gboolean            gst_audioadapter_is_empty           (GstAudioAdapter *adapter);

TRUE if the GstAudioAdapter is empty, FALSE otherwise.

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()

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()

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.

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.

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.

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.

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.

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.

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.

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.

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

All metadata from the original GstBuffer objects is preserved, including GstCaps, the GstBufferFlags, etc..

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.

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

adapter :

a GstAudioAdapter

samples :

the number of samples to flush

Property Details

The "size" property

  "size"                     guint                 : Read

The number of frames in the adapter.

Default value: 0


The "unit-size" property

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

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

Allowed values: >= 1

Default value: 1