pub struct MultistreamDecoderRef<'a> { /* private fields */ }Expand description
Borrowed wrapper around a multistream decoder.
The owning handle cannot be moved out of this borrowed wrapper:
use opus_codec::multistream::{MultistreamDecoder, MultistreamDecoderRef};
fn extract<'a>(
state: &mut MultistreamDecoderRef<'a>,
replacement: MultistreamDecoder,
) -> MultistreamDecoder {
std::mem::replace(&mut **state, replacement)
}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)srandmappingmust exactly match the decoder state already stored atptr- The memory must remain valid for the lifetime
'a - Caller is responsible for freeing the memory after this wrapper is dropped
Passing mismatched metadata is undefined behavior: later safe methods may validate buffer sizes with the wrong layout and then call libopus with out-of-bounds buffers.
§Panics
Panics if ptr is null, not pointer-aligned, or mapping is invalid.
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.
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>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
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>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn final_range(&mut self) -> Result<u32>
pub fn final_range(&mut self) -> Result<u32>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn reset(&mut self) -> Result<()>
pub fn reset(&mut self) -> Result<()>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn set_gain(&mut self, q8_db: i32) -> Result<()>
pub fn set_gain(&mut self, q8_db: i32) -> Result<()>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn gain(&mut self) -> Result<i32>
pub fn gain(&mut self) -> Result<i32>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn set_phase_inversion_disabled(&mut self, disabled: bool) -> Result<()>
pub fn set_phase_inversion_disabled(&mut self, disabled: bool) -> Result<()>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn phase_inversion_disabled(&mut self) -> Result<bool>
pub fn phase_inversion_disabled(&mut self) -> Result<bool>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn get_sample_rate(&mut self) -> Result<i32>
pub fn get_sample_rate(&mut self) -> Result<i32>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn get_pitch(&mut self) -> Result<i32>
pub fn get_pitch(&mut self) -> Result<i32>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn get_last_packet_duration(&mut self) -> Result<i32>
pub fn get_last_packet_duration(&mut self) -> Result<i32>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
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>
Methods from Deref<Target = MultistreamDecoder>§
Sourcepub fn sample_rate(&self) -> SampleRate
pub fn sample_rate(&self) -> SampleRate
Output sample rate.