pub struct Decoder { /* private fields */ }
Expand description
Decoder
to decode.
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn new(sample_rate: SampleRate, channels: Channels) -> Result<Decoder>
pub fn new(sample_rate: SampleRate, channels: Channels) -> Result<Decoder>
Creates a new Opus decoder.
Sourcepub fn decode<'a, TP, TS>(
&mut self,
input: Option<TP>,
output: TS,
fec: bool,
) -> Result<usize>
pub fn decode<'a, TP, TS>( &mut self, input: Option<TP>, output: TS, fec: bool, ) -> Result<usize>
Decodes an Opus packet as input
and writes decoded data into output
.
Passing None
as input
indicates a packet loss.
Errors:
If passed input
’s length exceeds std::i32::MAX
, PacketTooLarge
will be returned.
If passed output
’s length exceeds std::i32::MAX
, SignalsTooLarge
will be returned.
Sourcepub fn decode_float<'a, TP, TS>(
&mut self,
input: Option<TP>,
output: TS,
fec: bool,
) -> Result<usize>
pub fn decode_float<'a, TP, TS>( &mut self, input: Option<TP>, output: TS, fec: bool, ) -> Result<usize>
Decodes an Opus frame from floating point input.
The input
signal (interleaved if 2 channels) will be encoded into the
output
payload and on success, returns the length of the
encoded packet.
Sourcepub fn last_packet_duration(&self) -> Result<u32>
pub fn last_packet_duration(&self) -> Result<u32>
Gets the duration (in samples) of the last packet successfully decoded or concealed.
Sourcepub fn pitch(&self) -> Result<i32>
pub fn pitch(&self) -> Result<i32>
Gets the pitch period at 48 kHz of the last decoded frame, if available.
This can be used for any post-processing algorithm requiring the use of pitch, e.g. time stretching/shortening. If the last frame was not voiced, or if the pitch was not coded in the frame, then zero is returned.
Sourcepub fn gain(&self) -> Result<i32>
pub fn gain(&self) -> Result<i32>
Gets the decoder’s configured amount to scale PCM signal by in Q8 dB units.
Sourcepub fn set_gain(&self, gain: i32) -> Result<()>
pub fn set_gain(&self, gain: i32) -> Result<()>
Configures decoder gain adjustment.
Scales the decoded output by a factor of gain
specified in
Q8 dB units.
Warning:
This has a maximum range of -32768 to 32767 inclusive, and returns
BadArgument
otherwise.
The default is 0 indicating no adjustment.
Info: This setting survives decoder reset.
Trait Implementations§
Source§impl GenericCtl for Decoder
impl GenericCtl for Decoder
fn final_range(&self) -> Result<u32>
fn phase_inversion_disabled(&self) -> Result<bool>
fn set_phase_inversion_disabled(&mut self, disabled: bool) -> Result<()>
fn sample_rate(&self) -> Result<SampleRate>
fn reset_state(&mut self) -> Result<()>
impl Send for Decoder
The Opus decoder can be sent between threads unless the Opus library
has been compiled with NONTHREADSAFE_PSEUDOSTACK
to disallow decoding in
parallel.