GstAudio.AudioStreamAlign

Fields

None

Methods

class new (rate, alignment_threshold, discont_wait)
  copy ()
  free ()
  get_alignment_threshold ()
  get_discont_wait ()
  get_rate ()
  get_samples_since_discont ()
  get_timestamp_at_discont ()
  mark_discont ()
  process (discont, timestamp, n_samples)
  set_alignment_threshold (alignment_threshold)
  set_discont_wait (discont_wait)
  set_rate (rate)

Details

class GstAudio.AudioStreamAlign

GstAudio.AudioStreamAlign provides a helper object that helps tracking audio stream alignment and discontinuities, and detects discontinuities if possible.

See GstAudio.AudioStreamAlign.new() for a description of its parameters and GstAudio.AudioStreamAlign.process() for the details of the processing.

New in version 1.14.

classmethod new(rate, alignment_threshold, discont_wait)[source]
Parameters:
  • rate (int) – a sample rate
  • alignment_threshold (int) – a alignment threshold in nanoseconds
  • discont_wait (int) – discont wait in nanoseconds
Returns:

a new GstAudio.AudioStreamAlign. free with GstAudio.AudioStreamAlign.free().

Return type:

GstAudio.AudioStreamAlign

Allocate a new GstAudio.AudioStreamAlign with the given configuration. All processing happens according to sample rate rate, until GstAudio.AudioStreamAlign.set_rate() is called with a new rate. A negative rate can be used for reverse playback.

alignment_threshold gives the tolerance in nanoseconds after which a timestamp difference is considered a discontinuity. Once detected, discont_wait nanoseconds have to pass without going below the threshold again until the output buffer is marked as a discontinuity. These can later be re-configured with GstAudio.AudioStreamAlign.set_alignment_threshold() and GstAudio.AudioStreamAlign.set_discont_wait().

New in version 1.14.

copy()[source]
Returns:a new GstAudio.AudioStreamAlign. free with GstAudio.AudioStreamAlign.free.
Return type:GstAudio.AudioStreamAlign

Copy a GstAudio.AudioStreamAlign structure.

New in version 1.14.

free()[source]

Free a GstAudio.AudioStreamAlign structure previously allocated with GstAudio.AudioStreamAlign.new() or GstAudio.AudioStreamAlign.copy().

New in version 1.14.

get_alignment_threshold()[source]
Returns:The currently configured alignment threshold
Return type:int

Gets the currently configured alignment threshold.

New in version 1.14.

get_discont_wait()[source]
Returns:The currently configured discont wait
Return type:int

Gets the currently configured discont wait.

New in version 1.14.

get_rate()[source]
Returns:The currently configured sample rate
Return type:int

Gets the currently configured sample rate.

New in version 1.14.

get_samples_since_discont()[source]
Returns:The number of samples processed since the last discontinuity.
Return type:int

Returns the number of samples that were processed since the last discontinuity was detected.

New in version 1.14.

get_timestamp_at_discont()[source]
Returns:The last timestamp at when a discontinuity was detected
Return type:int

Timestamp that was passed when a discontinuity was detected, i.e. the first timestamp after the discontinuity.

New in version 1.14.

mark_discont()[source]

Marks the next buffer as discontinuous and resets timestamp tracking.

New in version 1.14.

process(discont, timestamp, n_samples)[source]
Parameters:
  • discont (bool) – if this data is considered to be discontinuous
  • timestamp (int) – a #GstClockTime of the start of the data
  • n_samples (int) – number of samples to process
Returns:

True if a discontinuity was detected, False otherwise.

out_timestamp:output timestamp of the data
out_duration:output duration of the data
out_sample_position:
 output sample position of the start of the data

Return type:

(bool, out_timestamp: int, out_duration: int, out_sample_position: int)

Processes data with timestamp and n_samples, and returns the output timestamp, duration and sample position together with a boolean to signal whether a discontinuity was detected or not. All non-discontinuous data will have perfect timestamps and durations.

A discontinuity is detected once the difference between the actual timestamp and the timestamp calculated from the sample count since the last discontinuity differs by more than the alignment threshold for a duration longer than discont wait.

Note: In reverse playback, every buffer is considered discontinuous in the context of buffer flags because the last sample of the previous buffer is discontinuous with the first sample of the current one. However for this function they are only considered discontinuous in reverse playback if the first sample of the previous buffer is discontinuous with the last sample of the current one.

New in version 1.14.

set_alignment_threshold(alignment_threshold)[source]
Parameters:alignment_threshold (int) – a new alignment threshold

Sets alignment_treshold as new alignment threshold for the following processing.

New in version 1.14.

set_discont_wait(discont_wait)[source]
Parameters:discont_wait (int) – a new discont wait

Sets alignment_treshold as new discont wait for the following processing.

New in version 1.14.

set_rate(rate)[source]
Parameters:rate (int) – a new sample rate

Sets rate as new sample rate for the following processing. If the sample rate differs this implicitely marks the next data as discontinuous.

New in version 1.14.