OngoingRepacketizer

Struct OngoingRepacketizer 

Source
pub struct OngoingRepacketizer<'a, 'buf> { /* private fields */ }
Expand description

Ongoing repacketizer process

Lifetime parameters:

  • a - Depends on original instance of Repacketizer
  • buf - Lifetime of the last buffer added to the state. Note that all previous lifetimes must fit it too

Dropping state will reset Repacketizer

Implementations§

Source§

impl<'a, 'buf> OngoingRepacketizer<'a, 'buf>

Source

pub fn reset(&mut self)

Re-initializes this Repacketizer state, resetting ongoing progress, if any.

Source

pub fn get_nb_frames(&self) -> u32

Return the total number of frames contained in packet data submitted to the repacketizer state since the last time reset has been called

Source

pub fn add_packet(&mut self, input: &'buf [u8]) -> Result<(), ErrorCode>

Add a packet to the current repacketizer state.

This packet must match the configuration of any packets already submitted for repacketization since the last call to reset(). This means that it must have the same coding mode, audio bandwidth, frame size, and channel count. This can be checked in advance by examining the top 6 bits of the first byte of the packet, and ensuring they match the top 6 bits of the first byte of any previously submitted packet. The total duration of audio in the repacketizer state also must not exceed 120 ms, the maximum duration of a single packet, after adding this packet.

In order to add a packet with a different configuration or to add more audio beyond 120 ms, you must clear the repacketizer state by calling reset(). If a packet is too large to add to the current repacketizer state, no part of it is added, even if it contains multiple frames, some of which might fit. If you wish to be able to add parts of such packets, you should first use another repacketizer to split the packet into pieces and add them individually.

Source

pub fn with_packet<'new_buf>( self, input: &'new_buf [u8], ) -> Result<OngoingRepacketizer<'a, 'new_buf>, ErrorCode>
where 'buf: 'new_buf,

Adds packet to the ongoing state, returning Self with modified lifetime

Refers to add_packet for details

Source

pub fn create_packet( &self, range: (u32, u32), out: &mut [MaybeUninit<u8>], ) -> Result<usize, ErrorCode>

Construct a new packet from data previously submitted to the repacketizer state

§Parameters
  • range - Should contain range of frames to encode in range 0..=get_nb_frames()
  • out - Output buffer to store new packet. Max required size can be calculated as 1277*(range.1 - range.0). Optimal required size is (range.1 - range.0) + [packet1 length]...
§Return value

Number of bytes written in out buffer

Source

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

Construct a new packet from data previously submitted to the repacketizer state using all frames available

This is the same as calling create_packet((0, nb_frames), ...)

Trait Implementations§

Source§

impl<'a, 'buf> Drop for OngoingRepacketizer<'a, 'buf>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, 'buf> Freeze for OngoingRepacketizer<'a, 'buf>

§

impl<'a, 'buf> RefUnwindSafe for OngoingRepacketizer<'a, 'buf>

§

impl<'a, 'buf> Send for OngoingRepacketizer<'a, 'buf>

§

impl<'a, 'buf> !Sync for OngoingRepacketizer<'a, 'buf>

§

impl<'a, 'buf> Unpin for OngoingRepacketizer<'a, 'buf>

§

impl<'a, 'buf> !UnwindSafe for OngoingRepacketizer<'a, 'buf>

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