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
impl OpusMultistreamDecoder
Sourcepub fn new(
sample_rate: u32,
nb_channels: usize,
nb_streams: usize,
nb_coupled_streams: usize,
mapping: &[u8],
) -> Result<Self, OpusError>
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])?;Sourcepub fn decode(
&mut self,
packet: &[u8],
pcm: &mut [i16],
fec: bool,
) -> Result<usize, OpusError>
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) whentrue. Passfalsefor 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)?;Sourcepub fn decode_float(
&mut self,
packet: &[u8],
pcm: &mut [f32],
fec: bool,
) -> Result<usize, OpusError>
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) whentrue. Passfalsefor 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)?;Auto Trait Implementations§
impl Freeze for OpusMultistreamDecoder
impl RefUnwindSafe for OpusMultistreamDecoder
impl Send for OpusMultistreamDecoder
impl Sync for OpusMultistreamDecoder
impl Unpin for OpusMultistreamDecoder
impl UnsafeUnpin for OpusMultistreamDecoder
impl UnwindSafe for OpusMultistreamDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more