pub struct MSDecoder { /* private fields */ }Expand description
Safe wrapper around OpusMSDecoder.
Implementations§
Source§impl MSDecoder
impl MSDecoder
Sourcepub fn new(sr: SampleRate, mapping: Mapping<'_>) -> Result<Self>
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.
Sourcepub fn decode(
&mut self,
packet: &[u8],
out: &mut [i16],
frame_size_per_ch: usize,
fec: bool,
) -> Result<usize>
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.
Sourcepub fn decode_float(
&mut self,
packet: &[u8],
out: &mut [f32],
frame_size_per_ch: usize,
fec: bool,
) -> Result<usize>
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.
Sourcepub fn final_range(&mut self) -> Result<u32>
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.
Sourcepub fn reset(&mut self) -> Result<()>
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.
Sourcepub fn set_gain(&mut self, q8_db: i32) -> Result<()>
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.
Sourcepub fn gain(&mut self) -> Result<i32>
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.
Sourcepub fn set_phase_inversion_disabled(&mut self, disabled: bool) -> Result<()>
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.
Sourcepub fn phase_inversion_disabled(&mut self) -> Result<bool>
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.
Sourcepub fn get_sample_rate(&mut self) -> Result<i32>
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.
Sourcepub fn get_pitch(&mut self) -> Result<i32>
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.
Sourcepub fn get_last_packet_duration(&mut self) -> Result<i32>
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.
Sourcepub const fn sample_rate(&self) -> SampleRate
pub const fn sample_rate(&self) -> SampleRate
Output sample rate.
Sourcepub fn new_surround(
sr: SampleRate,
channels: u8,
mapping_family: i32,
) -> Result<(Self, Vec<u8>, u8, u8)>
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.
Sourcepub unsafe fn decoder_state_ptr(
&mut self,
stream_index: i32,
) -> Result<*mut OpusDecoder>
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.