Skip to main content

Decoder

Enum Decoder 

Source
pub enum Decoder {
    G711(G711Codec),
    Opus(OpusDecoder),
}
Expand description

The decode half of a negotiated call codec.

The loss-recovery calls are uniform so a receive loop can drive them without codec branches: for G.711 they are no-ops (append nothing, return 0) because G.711 carries no redundancy and its historical loss behavior — silence by absence — is the correct one to keep.

Variants§

§

G711(G711Codec)

PCMU or PCMA.

§

Opus(OpusDecoder)

Opus, with in-band FEC recovery and PLC.

Implementations§

Source§

impl Decoder

Source

pub fn pcm_sample_rate(&self) -> u32

The PCM rate decoded frames come out at: 8 kHz for G.711, 16 kHz for Opus.

Source

pub fn decode( &mut self, payload: &[u8], out: &mut Vec<i16>, ) -> Result<usize, CoreError>

Decode one received payload, appending PCM to out and returning the sample count. Use the returned length — Opus peers choose their own frame size.

Source

pub fn recover_lost( &mut self, next_payload: &[u8], out: &mut Vec<i16>, ) -> Result<usize, CoreError>

Recover a single lost frame from the packet that followed it (drive this on a one-packet RTP sequence gap). Opus decodes the next packet’s in-band FEC; G.711 has nothing to recover and appends nothing.

Source

pub fn conceal(&mut self, out: &mut Vec<i16>) -> Result<usize, CoreError>

Produce one concealment frame for a packet that is not coming back (multi-packet gap). Opus extrapolates via PLC; G.711 appends nothing — absence already sounds like silence.

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.