Class AudioConverter
- All Implemented Interfaces:
Proxy
- audio format with optional dithering and noise shaping
- audio samplerate
- audio channels and channel layout
-
Constructor Summary
ConstructorDescriptionAudioConverter
(MemorySegment address) Create a AudioConverter proxy instance for the provided memory address.AudioConverter
(Set<AudioConverterFlags> flags, AudioInfo inInfo, AudioInfo outInfo, @Nullable Structure config) Create a newGstAudioConverter
that is able to convert betweenin
andout
audio formats.AudioConverter
(AudioConverterFlags flags, AudioInfo inInfo, AudioInfo outInfo, @Nullable Structure config) Create a newGstAudioConverter
that is able to convert betweenin
andout
audio formats. -
Method Summary
Modifier and TypeMethodDescriptionboolean
convert
(Set<AudioConverterFlags> flags, byte[] in, Out<byte[]> out) Convenience wrapper around gst_audio_converter_samples(), which will perform allocation of the output buffer based on the result from gst_audio_converter_get_out_frames().boolean
convert
(AudioConverterFlags flags, byte[] in, Out<byte[]> out) Convenience wrapper around gst_audio_converter_samples(), which will perform allocation of the output buffer based on the result from gst_audio_converter_get_out_frames().void
free()
Free a previously allocated this AudioConverter instance.Get the current configuration of this AudioConverter.long
getInFrames
(long outFrames) Calculate how many input frames are currently needed by this AudioConverter to produceoutFrames
of output frames.long
Get the maximum number of input frames that the converter would need before producing output.long
getOutFrames
(long inFrames) Calculate how many output frames can be produced wheninFrames
input frames are given to this AudioConverter.static Type
getType()
Get the GType of the AudioConverter classboolean
Returns whether the audio converter will operate in passthrough mode.void
reset()
Reset this AudioConverter to the state it was when it was first created, clearing any history it might currently have.boolean
samples
(Set<AudioConverterFlags> flags, @Nullable MemorySegment in, long inFrames, @Nullable MemorySegment out, long outFrames) Perform the conversion withinFrames
inin
tooutFrames
inout
using this AudioConverter.boolean
samples
(AudioConverterFlags flags, @Nullable MemorySegment in, long inFrames, @Nullable MemorySegment out, long outFrames) Perform the conversion withinFrames
inin
tooutFrames
inout
using this AudioConverter.boolean
Returns whether the audio converter can perform the conversion in-place.boolean
updateConfig
(int inRate, int outRate, @Nullable Structure config) SetinRate
,outRate
andconfig
as extra configuration for this AudioConverter.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
AudioConverter
Create a AudioConverter proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
AudioConverter
public AudioConverter(Set<AudioConverterFlags> flags, AudioInfo inInfo, AudioInfo outInfo, @Nullable @Nullable Structure config) Create a newGstAudioConverter
that is able to convert betweenin
andout
audio formats.config
contains extra configuration options, seeGST_AUDIO_CONVERTER_OPT_*
parameters for details about the options and values.- Parameters:
flags
- extraGstAudioConverterFlags
inInfo
- a sourceGstAudioInfo
outInfo
- a destinationGstAudioInfo
config
- aGstStructure
with configuration options
-
AudioConverter
public AudioConverter(AudioConverterFlags flags, AudioInfo inInfo, AudioInfo outInfo, @Nullable @Nullable Structure config) Create a newGstAudioConverter
that is able to convert betweenin
andout
audio formats.config
contains extra configuration options, seeGST_AUDIO_CONVERTER_OPT_*
parameters for details about the options and values.- Parameters:
flags
- extraGstAudioConverterFlags
inInfo
- a sourceGstAudioInfo
outInfo
- a destinationGstAudioInfo
config
- aGstStructure
with configuration options
-
-
Method Details
-
getType
-
convert
Convenience wrapper around gst_audio_converter_samples(), which will perform allocation of the output buffer based on the result from gst_audio_converter_get_out_frames().- Parameters:
flags
- extraGstAudioConverterFlags
in
- input dataout
- a pointer where the output data will be written- Returns:
true
is the conversion could be performed.
-
convert
Convenience wrapper around gst_audio_converter_samples(), which will perform allocation of the output buffer based on the result from gst_audio_converter_get_out_frames().- Parameters:
flags
- extraGstAudioConverterFlags
in
- input dataout
- a pointer where the output data will be written- Returns:
true
is the conversion could be performed.
-
free
public void free()Free a previously allocated this AudioConverter instance. -
getConfig
public Structure getConfig(@Nullable @Nullable Out<Integer> inRate, @Nullable @Nullable Out<Integer> outRate) Get the current configuration of this AudioConverter.- Parameters:
inRate
- result input rateoutRate
- result output rate- Returns:
- a
GstStructure
that remains valid for as long as this AudioConverter is valid or until gst_audio_converter_update_config() is called.
-
getInFrames
public long getInFrames(long outFrames) Calculate how many input frames are currently needed by this AudioConverter to produceoutFrames
of output frames.- Parameters:
outFrames
- number of output frames- Returns:
- the number of input frames
-
getMaxLatency
public long getMaxLatency()Get the maximum number of input frames that the converter would need before producing output.- Returns:
- the latency of this AudioConverter as expressed in the number of frames.
-
getOutFrames
public long getOutFrames(long inFrames) Calculate how many output frames can be produced wheninFrames
input frames are given to this AudioConverter.- Parameters:
inFrames
- number of input frames- Returns:
- the number of output frames
-
isPassthrough
public boolean isPassthrough()Returns whether the audio converter will operate in passthrough mode. The return value would be typically input to gst_base_transform_set_passthrough()- Returns:
true
when no conversion will actually occur.
-
reset
public void reset()Reset this AudioConverter to the state it was when it was first created, clearing any history it might currently have. -
samples
public boolean samples(Set<AudioConverterFlags> flags, @Nullable @Nullable MemorySegment in, long inFrames, @Nullable @Nullable MemorySegment out, long outFrames) Perform the conversion withinFrames
inin
tooutFrames
inout
using this AudioConverter.In case the samples are interleaved,
in
andout
must point to an array with a single element pointing to a block of interleaved samples.If non-interleaved samples are used,
in
andout
must point to an array with pointers to memory blocks, one for each channel.in
may benull
, in which caseinFrames
of silence samples are processed by the converter.This function always produces
outFrames
of output and consumesinFrames
of input. Use gst_audio_converter_get_out_frames() and gst_audio_converter_get_in_frames() to make sureinFrames
andoutFrames
are matching andin
andout
point to enough memory.- Parameters:
flags
- extraGstAudioConverterFlags
in
- input framesinFrames
- number of input framesout
- output framesoutFrames
- number of output frames- Returns:
true
is the conversion could be performed.
-
samples
public boolean samples(AudioConverterFlags flags, @Nullable @Nullable MemorySegment in, long inFrames, @Nullable @Nullable MemorySegment out, long outFrames) Perform the conversion withinFrames
inin
tooutFrames
inout
using this AudioConverter.In case the samples are interleaved,
in
andout
must point to an array with a single element pointing to a block of interleaved samples.If non-interleaved samples are used,
in
andout
must point to an array with pointers to memory blocks, one for each channel.in
may benull
, in which caseinFrames
of silence samples are processed by the converter.This function always produces
outFrames
of output and consumesinFrames
of input. Use gst_audio_converter_get_out_frames() and gst_audio_converter_get_in_frames() to make sureinFrames
andoutFrames
are matching andin
andout
point to enough memory.- Parameters:
flags
- extraGstAudioConverterFlags
in
- input framesinFrames
- number of input framesout
- output framesoutFrames
- number of output frames- Returns:
true
is the conversion could be performed.
-
supportsInplace
public boolean supportsInplace()Returns whether the audio converter can perform the conversion in-place. The return value would be typically input to gst_base_transform_set_in_place()- Returns:
true
when the conversion can be done in place.
-
updateConfig
SetinRate
,outRate
andconfig
as extra configuration for this AudioConverter.inRate
andoutRate
specify the new sample rates of input and output formats. A value of 0 leaves the sample rate unchanged.config
can benull
, in which case, the current configuration is not changed.If the parameters in
config
can not be set exactly, this function returnsfalse
and will try to update as much state as possible. The new state can then be retrieved and refined with gst_audio_converter_get_config().Look at the
GST_AUDIO_CONVERTER_OPT_*
fields to check valid configuration option and values.- Parameters:
inRate
- input rateoutRate
- output rateconfig
- aGstStructure
ornull
- Returns:
true
when the new parameters could be set
-