Struct Decoder

Source
pub struct Decoder { /* private fields */ }
Expand description

An Opus decoder with associated state.

Implementations§

Source§

impl Decoder

Source

pub fn new(sample_rate: u32, channels: Channels) -> Result<Decoder>

Create and initialize a decoder.

Source

pub fn decode( &mut self, input: &[u8], output: &mut [i16], fec: bool, ) -> Result<usize>

Decode an Opus packet.

Source

pub fn decode_float( &mut self, input: &[u8], output: &mut [f32], fec: bool, ) -> Result<usize>

Decode an Opus packet with floating point output.

Source

pub fn get_nb_samples(&self, packet: &[u8]) -> Result<usize>

Get the number of samples of an Opus packet.

Source

pub fn reset_state(&mut self) -> Result<()>

Reset the codec state to be equivalent to a freshly initialized state.

Source

pub fn get_final_range(&mut self) -> Result<u32>

Get the final range of the codec’s entropy coder.

Source

pub fn get_bandwidth(&mut self) -> Result<Bandwidth>

Get the decoder’s last bandpass.

Source

pub fn get_sample_rate(&mut self) -> Result<u32>

Get the samping rate the decoder was intialized with.

Source

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))

Source

pub fn get_gain(&mut self) -> Result<i32>

Gets the decoder’s configured gain adjustment.

Source

pub fn get_last_packet_duration(&mut self) -> Result<u32>

Gets the duration (in samples) of the last packet successfully decoded or concealed.

Source

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.

Trait Implementations§

Source§

impl Debug for Decoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Decoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Decoder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.