MultistreamDecoder

Struct MultistreamDecoder 

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

Safe wrapper around OpusMSDecoder.

Implementations§

Source§

impl MultistreamDecoder

Source

pub fn size(streams: u8, coupled_streams: u8) -> Result<usize>

Size in bytes of a multistream decoder state for external allocation.

§Errors

Returns Error::BadArg if the stream counts are invalid or libopus reports an impossible size.

Source

pub unsafe fn init_in_place( ptr: *mut OpusMSDecoder, sr: SampleRate, mapping: Mapping<'_>, ) -> Result<()>

Initialize a previously allocated multistream decoder state.

§Safety

The caller must provide a valid pointer to MultistreamDecoder::size() bytes, aligned to at least align_of::<usize>() (malloc-style alignment).

§Errors

Returns Error::BadArg if the mapping is invalid or ptr is null, or a mapped libopus error on failure.

Source

pub fn new(sr: SampleRate, mapping: Mapping<'_>) -> Result<Self>

Create a new multistream decoder.

§Errors

Returns Error::BadArg when the mapping dimensions are inconsistent, or propagates allocation/configuration failures from libopus.

Source

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

Decode into interleaved i16 PCM (frame_size is per-channel).

§Errors

Returns Error::InvalidState if the decoder handle is invalid, Error::BadArg for buffer mismatches, or the mapped libopus error code.

Source

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

Decode into interleaved f32 PCM (frame_size is per-channel).

§Errors

Returns Error::InvalidState if the decoder handle is invalid, Error::BadArg for buffer mismatches, or the mapped libopus error code.

Source

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

Final RNG state from the last decode.

§Errors

Returns Error::InvalidState when the decoder handle is null or propagates the libopus error.

Source

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

Reset the decoder to its initial state.

§Errors

Returns Error::InvalidState if the decoder handle is null or propagates any error reported by libopus.

Source

pub fn set_gain(&mut self, q8_db: i32) -> Result<()>

Set post-decode gain in Q8 dB units.

§Errors

Returns Error::InvalidState if the decoder handle is null or propagates any error reported by libopus.

Source

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

Query post-decode gain in Q8 dB units.

§Errors

Returns Error::InvalidState if the decoder handle is null or propagates any error reported by libopus.

Source

pub fn set_phase_inversion_disabled(&mut self, disabled: bool) -> Result<()>

Disable or enable phase inversion (CELT stereo decorrelation).

§Errors

Returns Error::InvalidState if the decoder handle is null or propagates any error reported by libopus.

Source

pub fn phase_inversion_disabled(&mut self) -> Result<bool>

Query the phase inversion disabled flag.

§Errors

Returns Error::InvalidState if the decoder handle is null or propagates any error reported by libopus.

Source

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

Query decoder output sample rate.

§Errors

Returns Error::InvalidState if the decoder handle is null or propagates any error reported by libopus.

Source

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

Query the pitch (fundamental period) of the last decoded frame.

§Errors

Returns Error::InvalidState if the decoder handle is null or propagates any error reported by libopus.

Source

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

Query the duration (per channel) of the last decoded packet.

§Errors

Returns Error::InvalidState if the decoder handle is null or propagates any error reported by libopus.

Source

pub const fn channels(&self) -> u8

Output channels (interleaved).

Source

pub const fn sample_rate(&self) -> SampleRate

Output sample rate.

Source

pub fn new_surround( sr: SampleRate, channels: u8, mapping_family: i32, ) -> Result<(Self, Vec<u8>, u8, u8)>

Create a multistream decoder using libopus surround mapping helpers.

§Errors

Returns Error::BadArg for invalid channel counts or the mapped libopus error when decoder initialisation fails.

Source

pub unsafe fn decoder_state_ptr( &mut self, stream_index: i32, ) -> Result<*mut OpusDecoder>

Borrow a pointer to an individual underlying decoder state for CTLs.

§Safety

Caller must not outlive the multistream decoder and must ensure the returned pointer is only used for immediate FFI calls.

§Errors

Returns Error::InvalidState if the decoder handle is invalid or propagates the libopus error when retrieving the per-stream state fails.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.