pub struct InterleavedFrame {
pub channel: u8,
pub payload: Vec<u8>,
}Expand description
One interleaved binary data block (RFC 2326 §10.12): a channel id and a payload (exactly one upper-layer PDU, e.g. one RTP packet).
Fields§
§channel: u8Channel identifier, as negotiated by interleaved= in the Transport
header. By convention even = RTP, odd = RTCP.
payload: Vec<u8>The framed payload bytes.
Implementations§
Source§impl InterleavedFrame
impl InterleavedFrame
Sourcepub fn new(channel: u8, payload: impl Into<Vec<u8>>) -> Self
pub fn new(channel: u8, payload: impl Into<Vec<u8>>) -> Self
Creates a frame for channel carrying payload.
Sourcepub fn serialized_len(&self) -> usize
pub fn serialized_len(&self) -> usize
The serialized length of this frame (4 + payload.len()).
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>>
pub fn to_bytes(&self) -> Result<Vec<u8>>
Serializes the frame to a fresh Vec<u8> ($, channel, u16-be length,
payload).
Returns an error if the payload exceeds the 16-bit length field.
Sourcepub fn serialize_into(&self, out: &mut Vec<u8>) -> Result<()>
pub fn serialize_into(&self, out: &mut Vec<u8>) -> Result<()>
Appends the serialized frame to out.
Returns an error if the payload exceeds the 16-bit length field.
Sourcepub fn parse(buf: &[u8]) -> Result<Option<(InterleavedFrame, usize)>>
pub fn parse(buf: &[u8]) -> Result<Option<(InterleavedFrame, usize)>>
Parses a single frame from the front of buf.
On success returns the frame and the number of bytes consumed
(4 + payload len). Returns Ok(None) if buf does not yet contain a
complete frame (need more bytes). Returns an error if the leading byte is
not the $ magic.
Trait Implementations§
Source§impl Clone for InterleavedFrame
impl Clone for InterleavedFrame
Source§fn clone(&self) -> InterleavedFrame
fn clone(&self) -> InterleavedFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more