audiopus::coder

Struct Decoder

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

Decoder to decode.

Implementations§

Source§

impl Decoder

Source

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

Creates a new Opus decoder.

Source

pub fn decode<'a, TP, TS>( &mut self, input: Option<TP>, output: TS, fec: bool, ) -> Result<usize>
where TP: TryInto<Packet<'a>>, TS: TryInto<MutSignals<'a, i16>>,

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.

Source

pub fn decode_float<'a, TP, TS>( &mut self, input: Option<TP>, output: TS, fec: bool, ) -> Result<usize>
where TP: TryInto<Packet<'a>>, TS: TryInto<MutSignals<'a, f32>>,

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.

Source

pub fn last_packet_duration(&self) -> Result<u32>

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

Source

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.

Source

pub fn gain(&self) -> Result<i32>

Gets the decoder’s configured amount to scale PCM signal by in Q8 dB units.

Source

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.

Source

pub fn size(&self) -> usize

Gets size of self’s underlying Opus-decoder in bytes.

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)

We have to ensure that the resource our wrapping Opus-struct is pointing to is deallocated properly.

Source§

impl GenericCtl for Decoder

Source§

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.

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.