GstAudio.AudioConverter¶
Fields¶
None
Methods¶
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class GstAudio.AudioConverter¶
This object is used to convert audio samples from one format to another. The object can perform conversion of:
audio format with optional dithering and noise shaping
audio samplerate
audio channels and channel layout
New in version 1.8.
- classmethod new(flags, in_info, out_info, config)[source]¶
- Parameters:
flags (
GstAudio.AudioConverterFlags
) – extraGstAudio.AudioConverterFlags
in_info (
GstAudio.AudioInfo
) – a sourceGstAudio.AudioInfo
out_info (
GstAudio.AudioInfo
) – a destinationGstAudio.AudioInfo
config (
Gst.Structure
orNone
) – aGst.Structure
with configuration options
- Returns:
a
GstAudio.AudioConverter
orNone
if conversion is not possible.- Return type:
Create a new
GstAudio.AudioConverter
that is able to convert between in and out audio formats.config contains extra configuration options, see
GST_AUDIO_CONVERTER_OPT_*
parameters for details about the options and values.
- convert(flags, in_)[source]¶
- Parameters:
flags (
GstAudio.AudioConverterFlags
) – extraGstAudio.AudioConverterFlags
in (
bytes
) – input data
- Returns:
True
is the conversion could be performed.- out:
a pointer where the output data will be written
- Return type:
Convenience wrapper around
GstAudio.AudioConverter.samples
(), which will perform allocation of the output buffer based on the result fromGstAudio.AudioConverter.get_out_frames
().New in version 1.14.
- get_config()[source]¶
- Returns:
a
Gst.Structure
that remains valid for as long as self is valid or untilGstAudio.AudioConverter.update_config
() is called.- in_rate:
result input rate
- out_rate:
result output rate
- Return type:
(
Gst.Structure
, in_rate:int
, out_rate:int
)
Get the current configuration of self.
- get_in_frames(out_frames)[source]¶
- Parameters:
out_frames (
int
) – number of output frames- Returns:
the number of input frames
- Return type:
Calculate how many input frames are currently needed by self to produce out_frames of output frames.
- get_max_latency()[source]¶
- Returns:
the latency of self as expressed in the number of frames.
- Return type:
Get the maximum number of input frames that the converter would need before producing output.
- get_out_frames(in_frames)[source]¶
- Parameters:
in_frames (
int
) – number of input frames- Returns:
the number of output frames
- Return type:
Calculate how many output frames can be produced when in_frames input frames are given to self.
- is_passthrough()[source]¶
-
Returns whether the audio converter will operate in passthrough mode. The return value would be typically input to
GstBase.BaseTransform.set_passthrough
()New in version 1.16.
- reset()[source]¶
Reset self to the state it was when it was first created, clearing any history it might currently have.
- samples(flags, in_, in_frames, out, out_frames)[source]¶
- Parameters:
flags (
GstAudio.AudioConverterFlags
) – extraGstAudio.AudioConverterFlags
in_frames (
int
) – number of input framesout_frames (
int
) – number of output frames
- Returns:
True
is the conversion could be performed.- Return type:
Perform the conversion with in_frames in in to out_frames in out using self.
In case the samples are interleaved, in and out must point to an array with a single element pointing to a block of interleaved samples.
If non-interleaved samples are used, in and out must point to an array with pointers to memory blocks, one for each channel.
in may be
None
, in which case in_frames of silence samples are processed by the converter.This function always produces out_frames of output and consumes in_frames of input. Use
GstAudio.AudioConverter.get_out_frames
() andGstAudio.AudioConverter.get_in_frames
() to make sure in_frames and out_frames are matching and in and out point to enough memory.
- supports_inplace()[source]¶
-
Returns whether the audio converter can perform the conversion in-place. The return value would be typically input to
GstBase.BaseTransform.set_in_place
()New in version 1.12.
- update_config(in_rate, out_rate, config)[source]¶
- Parameters:
in_rate (
int
) – input rateout_rate (
int
) – output rateconfig (
Gst.Structure
orNone
) – aGst.Structure
orNone
- Returns:
True
when the new parameters could be set- Return type:
Set in_rate, out_rate and config as extra configuration for self.
in_rate and out_rate specify the new sample rates of input and output formats. A value of 0 leaves the sample rate unchanged.
config can be
None
, in which case, the current configuration is not changed.If the parameters in config can not be set exactly, this function returns
False
and will try to update as much state as possible. The new state can then be retrieved and refined withGstAudio.AudioConverter.get_config
().Look at the
GST_AUDIO_CONVERTER_OPT_*
fields to check valid configuration option and values.