pub struct Decoder { /* private fields */ }
Expand description
An Opus decoder with associated state.
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn new(sample_rate: u32, channels: Channels) -> Result<Decoder>
pub fn new(sample_rate: u32, channels: Channels) -> Result<Decoder>
Create and initialize a decoder.
Sourcepub fn decode(
&mut self,
input: &[u8],
output: &mut [i16],
fec: bool,
) -> Result<usize>
pub fn decode( &mut self, input: &[u8], output: &mut [i16], fec: bool, ) -> Result<usize>
Decode an Opus packet.
Sourcepub fn decode_float(
&mut self,
input: &[u8],
output: &mut [f32],
fec: bool,
) -> Result<usize>
pub fn decode_float( &mut self, input: &[u8], output: &mut [f32], fec: bool, ) -> Result<usize>
Decode an Opus packet with floating point output.
Sourcepub fn get_nb_samples(&self, packet: &[u8]) -> Result<usize>
pub fn get_nb_samples(&self, packet: &[u8]) -> Result<usize>
Get the number of samples of an Opus packet.
Sourcepub fn reset_state(&mut self) -> Result<()>
pub fn reset_state(&mut self) -> Result<()>
Reset the codec state to be equivalent to a freshly initialized state.
Sourcepub fn get_final_range(&mut self) -> Result<u32>
pub fn get_final_range(&mut self) -> Result<u32>
Get the final range of the codec’s entropy coder.
Sourcepub fn get_bandwidth(&mut self) -> Result<Bandwidth>
pub fn get_bandwidth(&mut self) -> Result<Bandwidth>
Get the decoder’s last bandpass.
Sourcepub fn get_sample_rate(&mut self) -> Result<u32>
pub fn get_sample_rate(&mut self) -> Result<u32>
Get the samping rate the decoder was intialized with.
Sourcepub fn set_gain(&mut self, gain: i32) -> Result<()>
pub fn set_gain(&mut self, gain: i32) -> Result<()>
Configures decoder gain adjustment.
Scales the decoded output by a factor specified in Q8 dB units. This has
a maximum range of -32768 to 32768 inclusive, and returns BadArg
otherwise. The default is zero indicating no adjustment. This setting
survives decoder reset.
gain = pow(10, x / (20.0 * 256))
Sourcepub fn get_last_packet_duration(&mut self) -> Result<u32>
pub fn get_last_packet_duration(&mut self) -> Result<u32>
Gets the duration (in samples) of the last packet successfully decoded or concealed.
Sourcepub fn get_pitch(&mut self) -> Result<i32>
pub fn get_pitch(&mut self) -> Result<i32>
Gets the pitch 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.