Skip to main content

RepacketizerRef

Struct RepacketizerRef 

Source
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>

Source

pub unsafe fn from_raw(ptr: *mut OpusRepacketizer) -> Self

Wrap an externally-initialized repacketizer without taking ownership.

§Safety
  • ptr must point to valid, initialized memory of at least Repacketizer::size() bytes
  • ptr must be aligned to at least align_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 ptr already 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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn emit_range( &mut self, begin: i32, end: i32, out: &mut [u8], ) -> Result<usize>

Calls the corresponding operation on this borrowed libopus state.

§Errors

Returns the same errors as the corresponding owning-handle method.

Source

pub fn emit(&mut self, out: &mut [u8]) -> Result<usize>

Calls the corresponding operation on this borrowed libopus state.

§Errors

Returns the same errors as the corresponding owning-handle method.

Methods from Deref<Target = Repacketizer>§

Source

pub fn frame_count(&self) -> i32

Number of frames currently queued.

Source

pub fn len(&self) -> usize

Number of frames currently queued as a usize.

Source

pub fn is_empty(&self) -> bool

Returns true when there are no queued frames.

Trait Implementations§

Source§

impl Deref for RepacketizerRef<'_>

Source§

type Target = Repacketizer

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Drop for RepacketizerRef<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for RepacketizerRef<'_>

Auto Trait Implementations§

§

impl<'a> !Sync for RepacketizerRef<'a>

§

impl<'a> !UnwindSafe for RepacketizerRef<'a>

§

impl<'a> Freeze for RepacketizerRef<'a>

§

impl<'a> RefUnwindSafe for RepacketizerRef<'a>

§

impl<'a> Unpin for RepacketizerRef<'a>

§

impl<'a> UnsafeUnpin for RepacketizerRef<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.