pub struct MultistreamDecoderRef<'a> { /* private fields */ }Expand description
Borrowed wrapper around a multistream decoder.
Implementations§
Source§impl<'a> MultistreamDecoderRef<'a>
impl<'a> MultistreamDecoderRef<'a>
Sourcepub unsafe fn from_raw(
ptr: *mut OpusMSDecoder,
sr: SampleRate,
mapping: Mapping<'_>,
) -> Self
pub unsafe fn from_raw( ptr: *mut OpusMSDecoder, sr: SampleRate, mapping: Mapping<'_>, ) -> Self
Wrap an externally-initialized multistream decoder without taking ownership.
§Safety
ptrmust point to valid, initialized memory of at leastMultistreamDecoder::size()bytesptrmust be aligned to at leastalign_of::<usize>()(malloc-style alignment)- The memory must remain valid for the lifetime
'a - Caller is responsible for freeing the memory after this wrapper is dropped
Use MultistreamDecoder::init_in_place to initialize the memory before calling this.
Sourcepub fn init_in(
buf: &'a mut AlignedBuffer,
sr: SampleRate,
mapping: Mapping<'_>,
) -> Result<Self>
pub fn init_in( buf: &'a mut AlignedBuffer, sr: SampleRate, mapping: Mapping<'_>, ) -> Result<Self>
Initialize and wrap an externally allocated buffer.
§Errors
Returns Error::BadArg if the buffer is too small, or a mapped libopus error.
Methods from Deref<Target = MultistreamDecoder>§
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 fn sample_rate(&self) -> SampleRate
pub fn sample_rate(&self) -> SampleRate
Output sample rate.
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.