Class AudioStreamAlign
- All Implemented Interfaces:
Proxy
GstAudioStreamAlign
provides a helper object that helps tracking audio
stream alignment and discontinuities, and detects discontinuities if
possible.
See gst_audio_stream_align_new() for a description of its parameters and gst_audio_stream_align_process() for the details of the processing.
-
Constructor Summary
ConstructorDescriptionAudioStreamAlign
(int rate, ClockTime alignmentThreshold, ClockTime discontWait) Allocate a newGstAudioStreamAlign
with the given configuration.AudioStreamAlign
(MemorySegment address) Create a AudioStreamAlign proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Copy a GstAudioStreamAlign structure.void
free()
Free a GstAudioStreamAlign structure previously allocated with gst_audio_stream_align_new() or gst_audio_stream_align_copy().Gets the currently configured alignment threshold.Gets the currently configured discont wait.int
getRate()
Gets the currently configured sample rate.long
Returns the number of samples that were processed since the last discontinuity was detected.Timestamp that was passed when a discontinuity was detected, i.e.static Type
getType()
Get the GType of the AudioStreamAlign classvoid
Marks the next buffer as discontinuous and resets timestamp tracking.boolean
process
(boolean discont, ClockTime timestamp, int nSamples, ClockTime outTimestamp, ClockTime outDuration, Out<Long> outSamplePosition) Processes data withtimestamp
andnSamples
, and returns the output timestamp, duration and sample position together with a boolean to signal whether a discontinuity was detected or not.void
setAlignmentThreshold
(ClockTime alignmentThreshold) SetsalignmentTreshold
as new alignment threshold for the following processing.void
setDiscontWait
(ClockTime discontWait) SetsalignmentTreshold
as new discont wait for the following processing.void
setRate
(int rate) Setsrate
as new sample rate for the following processing.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
AudioStreamAlign
Create a AudioStreamAlign proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
AudioStreamAlign
Allocate a newGstAudioStreamAlign
with the given configuration. All processing happens according to sample raterate
, until gst_audio_stream_align_set_rate() is called with a newrate
. A negative rate can be used for reverse playback.alignmentThreshold
gives the tolerance in nanoseconds after which a timestamp difference is considered a discontinuity. Once detected,discontWait
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 gst_audio_stream_align_set_alignment_threshold() and gst_audio_stream_align_set_discont_wait().- Parameters:
rate
- a sample ratealignmentThreshold
- a alignment threshold in nanosecondsdiscontWait
- discont wait in nanoseconds
-
-
Method Details
-
getType
-
copy
Copy a GstAudioStreamAlign structure.- Returns:
- a new
GstAudioStreamAlign
. free with gst_audio_stream_align_free.
-
free
public void free()Free a GstAudioStreamAlign structure previously allocated with gst_audio_stream_align_new() or gst_audio_stream_align_copy(). -
getAlignmentThreshold
Gets the currently configured alignment threshold.- Returns:
- The currently configured alignment threshold
-
getDiscontWait
Gets the currently configured discont wait.- Returns:
- The currently configured discont wait
-
getRate
public int getRate()Gets the currently configured sample rate.- Returns:
- The currently configured sample rate
-
getSamplesSinceDiscont
public long getSamplesSinceDiscont()Returns the number of samples that were processed since the last discontinuity was detected.- Returns:
- The number of samples processed since the last discontinuity.
-
getTimestampAtDiscont
Timestamp that was passed when a discontinuity was detected, i.e. the first timestamp after the discontinuity.- Returns:
- The last timestamp at when a discontinuity was detected
-
markDiscont
public void markDiscont()Marks the next buffer as discontinuous and resets timestamp tracking. -
process
public boolean process(boolean discont, ClockTime timestamp, int nSamples, ClockTime outTimestamp, ClockTime outDuration, Out<Long> outSamplePosition) Processes data withtimestamp
andnSamples
, 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.
- Parameters:
discont
- if this data is considered to be discontinuoustimestamp
- aGstClockTime
of the start of the datanSamples
- number of samples to processoutTimestamp
- output timestamp of the dataoutDuration
- output duration of the dataoutSamplePosition
- output sample position of the start of the data- Returns:
true
if a discontinuity was detected,false
otherwise.
-
setAlignmentThreshold
SetsalignmentTreshold
as new alignment threshold for the following processing.- Parameters:
alignmentThreshold
- a new alignment threshold
-
setDiscontWait
SetsalignmentTreshold
as new discont wait for the following processing.- Parameters:
discontWait
- a new discont wait
-
setRate
public void setRate(int rate) Setsrate
as new sample rate for the following processing. If the sample rate differs this implicitly marks the next data as discontinuous.- Parameters:
rate
- a new sample rate
-