pub struct Repacketizer { /* private fields */ }Expand description
opus_repacketizer: accumulate frames from one or more same-config packets, then emit them as a single re-framed packet.
Frame payloads are held back to back in one buffer. Repacketizer::reset
keeps its capacity, so a reused repacketizer that writes with
Repacketizer::out_into performs no allocation once warmed up.
Implementations§
Source§impl Repacketizer
impl Repacketizer
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Drop all held frames, keeping allocated capacity (opus_repacketizer_init).
Sourcepub fn cat(&mut self, data: &[u8]) -> Result<(), Error>
pub fn cat(&mut self, data: &[u8]) -> Result<(), Error>
Append the frames of data (opus_repacketizer_cat). Errors if the TOC
config differs from frames already held, or the 120 ms cap is exceeded.
§Errors
Error::InvalidPacket if data is malformed, its TOC configuration
differs from the packets already added, or the total would exceed 120 ms.
Sourcepub fn out_range(&self, begin: usize, end: usize) -> Result<Vec<u8>, Error>
pub fn out_range(&self, begin: usize, end: usize) -> Result<Vec<u8>, Error>
Emit frames [begin, end) as one packet (opus_repacketizer_out_range).
§Errors
Error::BadArg if begin..end is empty or outside the stored frames.
Sourcepub fn out_into(&self, out: &mut [u8]) -> Result<usize, Error>
pub fn out_into(&self, out: &mut [u8]) -> Result<usize, Error>
Emit all held frames into out, returning the packet length
(opus_repacketizer_out with a caller buffer). Allocation-free.
§Errors
Error::BadArg if no frames have been added;
Error::BufferTooSmall if the packet does not fit in out.
Sourcepub fn out_range_into(
&self,
begin: usize,
end: usize,
out: &mut [u8],
) -> Result<usize, Error>
pub fn out_range_into( &self, begin: usize, end: usize, out: &mut [u8], ) -> Result<usize, Error>
Emit frames [begin, end) into out, returning the packet length.
Allocation-free.
§Errors
Error::BadArg if begin..end is empty or outside the stored frames;
Error::BufferTooSmall if the packet does not fit in out.
Sourcepub fn out_self_delimited(&self) -> Result<Vec<u8>, Error>
pub fn out_self_delimited(&self) -> Result<Vec<u8>, Error>
Emit all frames with the self-delimited framing multistream uses (the last frame’s length is coded so the packet’s total size is derivable).
§Errors
Error::BadArg if no frames have been added.