Skip to main content

OpusMultistreamDecoder

Struct OpusMultistreamDecoder 

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

Opus multistream decoder.

Holds one OpusDecoder per stream. Coupled streams use stereo decoders and remaining streams use mono decoders.

Implementations§

Source§

impl OpusMultistreamDecoder

Source

pub fn new( sample_rate: u32, nb_channels: usize, nb_streams: usize, nb_coupled_streams: usize, mapping: &[u8], ) -> Result<Self, OpusError>

Create a new multistream decoder.

Parameters: sample_rate, total output nb_channels, nb_streams, nb_coupled_streams, and per-output-channel mapping. Returns: initialized multistream decoder on success.

§Examples
use opus_decoder::OpusMultistreamDecoder;

let decoder = OpusMultistreamDecoder::new(48_000, 2, 2, 0, &[0, 1])?;
Source

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

Decode a multistream packet into interleaved i16 PCM.

Parameters: multistream packet, writable interleaved pcm, and fec.

  • fec: reserved for future in-band FEC support. Currently treated as packet loss concealment (PLC) when true. Pass false for normal decode.

Returns: decoded samples per output channel.

§Examples
use opus_decoder::OpusMultistreamDecoder;

let mut decoder = OpusMultistreamDecoder::new(48_000, 2, 2, 0, &[0, 1])?;
let packet = std::fs::read("multistream-frame.opus")?;
let mut pcm = vec![0i16; 960 * 2];
let samples = decoder.decode(&packet, &mut pcm, false)?;
Source

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

Decode a multistream packet into interleaved f32 PCM.

Parameters: multistream packet, writable interleaved pcm, and fec.

  • fec: reserved for future in-band FEC support. Currently treated as packet loss concealment (PLC) when true. Pass false for normal decode.

Returns: decoded samples per output channel.

§Examples
use opus_decoder::OpusMultistreamDecoder;

let mut decoder = OpusMultistreamDecoder::new(48_000, 2, 2, 0, &[0, 1])?;
let packet = std::fs::read("multistream-frame.opus")?;
let mut pcm = vec![0.0f32; 960 * 2];
let samples = decoder.decode_float(&packet, &mut pcm, false)?;
Source

pub fn reset(&mut self)

Reset all internal decoders.

Parameters: none. Returns: nothing.

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.