pub struct RepacketizerRef<'a> { /* private fields */ }Expand description
Borrowed wrapper around a repacketizer state.
The owning handle cannot be moved out of this borrowed wrapper:
use opus_codec::repacketizer::{Repacketizer, RepacketizerRef};
fn extract<'a>(state: &mut RepacketizerRef<'a>, replacement: Repacketizer) -> Repacketizer {
std::mem::replace(&mut **state, replacement)
}Implementations§
Source§impl<'a> RepacketizerRef<'a>
impl<'a> RepacketizerRef<'a>
Sourcepub unsafe fn from_raw(ptr: *mut OpusRepacketizer) -> Self
pub unsafe fn from_raw(ptr: *mut OpusRepacketizer) -> Self
Wrap an externally-initialized repacketizer without taking ownership.
§Safety
ptrmust point to valid, initialized memory of at leastRepacketizer::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
- If
ptralready contains packet pointers, their backing storage must remain valid while this wrapper is used.
Use Repacketizer::init_in_place to initialize the memory before calling this.
If packets are pushed through this wrapper, dropping it resets the raw
state to avoid leaving dangling pointers to the wrapper’s owned buffers.
§Panics
Panics if ptr is null or not pointer-aligned.
Sourcepub fn init_in(buf: &'a mut AlignedBuffer) -> Result<Self>
pub fn init_in(buf: &'a mut AlignedBuffer) -> Result<Self>
Initialize and wrap an externally allocated buffer.
§Errors
Returns Error::BadArg if the buffer is too small.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn push(&mut self, packet: &[u8]) -> Result<()>
pub fn push(&mut self, packet: &[u8]) -> Result<()>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.
Sourcepub fn push_owned(&mut self, packet: Vec<u8>) -> Result<()>
pub fn push_owned(&mut self, packet: Vec<u8>) -> Result<()>
Calls the corresponding operation on this borrowed libopus state.
§Errors
Returns the same errors as the corresponding owning-handle method.