pub struct OngoingRepacketizer<'a, 'buf> { /* private fields */ }Expand description
Ongoing repacketizer process
Lifetime parameters:
a- Depends on original instance of Repacketizerbuf- 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>
impl<'a, 'buf> OngoingRepacketizer<'a, 'buf>
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Re-initializes this Repacketizer state, resetting ongoing progress, if any.
Sourcepub fn get_nb_frames(&self) -> u32
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
Sourcepub fn add_packet(&mut self, input: &'buf [u8]) -> Result<(), ErrorCode>
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.
Sourcepub fn with_packet<'new_buf>(
self,
input: &'new_buf [u8],
) -> Result<OngoingRepacketizer<'a, 'new_buf>, ErrorCode>where
'buf: 'new_buf,
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
Sourcepub fn create_packet(
&self,
range: (u32, u32),
out: &mut [MaybeUninit<u8>],
) -> Result<usize, ErrorCode>
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 range0..=get_nb_frames()out- Output buffer to store new packet. Max required size can be calculated as1277*(range.1 - range.0). Optimal required size is(range.1 - range.0) + [packet1 length]...
§Return value
Number of bytes written in out buffer
Sourcepub fn create_full_packet(
&self,
out: &mut [MaybeUninit<u8>],
) -> Result<usize, ErrorCode>
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), ...)