pub struct Header {Show 13 fields
pub version: u8,
pub padding: bool,
pub extension: bool,
pub marker: bool,
pub payload_type: u8,
pub sequence_number: u16,
pub timestamp: u32,
pub ssrc: u32,
pub csrc: Vec<u32>,
pub extension_profile: u16,
pub extensions: Vec<Extension>,
pub extensions_padding: usize,
pub padding_size: u8,
}Expand description
Header represents an RTP packet header NOTE: PayloadOffset is populated by Marshal/Unmarshal and should not be modified
Fields§
§version: u8The RTP version, always 2. Header::default sets it; marshal and unmarshal refuse any
other value (RFC 3550 section 5.1).
padding: boolWhether the payload is followed by padding octets, the last giving the padding length.
extension: boolWhether a header-extension block follows the fixed header.
marker: boolThe marker bit: the last packet of a video frame, or the start of a talk spurt for audio.
payload_type: u8The payload type, which identifies the codec as negotiated in SDP.
sequence_number: u16Increments by one per packet sent; used to detect loss and restore order.
timestamp: u32The sampling instant of the first octet, in the codec’s clock rate.
ssrc: u32The synchronization source — the identifier of the stream this packet belongs to.
csrc: Vec<u32>The contributing sources, listed when a mixer combined several streams.
extension_profile: u16Which header-extension form is in use: EXTENSION_PROFILE_ONE_BYTE or
EXTENSION_PROFILE_TWO_BYTE.
extensions: Vec<Extension>The header extensions present on this packet.
extensions_padding: usizePadding bytes appended to the extension block so it ends on a 32-bit boundary.
padding_size: u8How many padding octets follow the payload when padding is set, the count octet
included (RFC 3550 5.1). Filled in by Packet unmarshal so a
packet re-marshals with the padding it arrived with; 0 lets marshal pad to the next
32-bit boundary, as it always did.
Implementations§
Source§impl Header
impl Header
Sourcepub fn get_extension_payload_len(&self) -> usize
pub fn get_extension_payload_len(&self) -> usize
The total encoded length of the extension payloads, padding excluded.
Sourcepub fn extension_form(&self) -> Option<ExtensionForm>
pub fn extension_form(&self) -> Option<ExtensionForm>
The form of this header’s extension block, or None when it has none.
Sourcepub fn set_extension(&mut self, id: u8, payload: Bytes) -> Result<()>
pub fn set_extension(&mut self, id: u8, payload: Bytes) -> Result<()>
Sets an RTP header extension, keeping the form the header already has.
A header that has no extension yet takes the one-byte form when the element fits it (id 1 to 14, 1 to 16 bytes) and the two-byte form otherwise (RFC 8285 section 4.2: an id above 14 is never sent in the one-byte form; section 4.1.2: the two-byte form is not used when everything fits the one-byte form).
A header that already has extensions keeps its form, because a stream carries one form
only unless a=extmap-allow-mixed was negotiated (RFC 8285 sections 4.1.2 and 6). Use
Header::set_extension_upgrading when mixing is allowed, or
Header::upgrade_to_two_byte on every packet of a stream that is two-byte throughout.
§Errors
Fails when the id or the length does not fit the header’s form, or no RFC 8285 form at all (id 0 on a header without extensions, more than 255 bytes).
Sourcepub fn set_extension_upgrading(&mut self, id: u8, payload: Bytes) -> Result<()>
pub fn set_extension_upgrading(&mut self, id: u8, payload: Bytes) -> Result<()>
Sets an RTP header extension, converting a one-byte header to the two-byte form when the element needs it (an id above 14, an empty element or one over 16 bytes).
The conversion changes the form of this packet only. RFC 8285 section 4.1.2 lets a
stream mix the forms only when a=extmap-allow-mixed was negotiated (section 6), so
call this when it was, or when the element is set on every packet of the stream (the
stream is then two-byte throughout).
§Errors
Fails when the element fits neither form (id 0, more than 255 bytes), or the header carries an RFC 3550 extension that is not RFC 8285.
Sourcepub fn upgrade_to_two_byte(&mut self) -> Result<()>
pub fn upgrade_to_two_byte(&mut self) -> Result<()>
Converts a one-byte extension block to the two-byte form, with appbits 0. Every
one-byte element is valid in the two-byte form (RFC 8285 section 4.3: one id space).
A header without extensions, or already two-byte, is left as it is.
§Errors
Fails for a header whose extension is not RFC 8285.
Sourcepub fn get_extension_ids(&self) -> Vec<u8> ⓘ
pub fn get_extension_ids(&self) -> Vec<u8> ⓘ
returns an extension id array
Sourcepub fn get_extension(&self, id: u8) -> Option<Bytes>
pub fn get_extension(&self, id: u8) -> Option<Bytes>
returns an RTP header extension
Sourcepub fn del_extension(&mut self, id: u8) -> Result<()>
pub fn del_extension(&mut self, id: u8) -> Result<()>
Removes an RTP Header extension.
Removing the last element removes the extension block too: the X bit is cleared, since the block is present only when the packet carries at least one element (RFC 8285 section 4.1.1).
Trait Implementations§
impl Eq for Header
Source§impl MarshalSize for Header
impl MarshalSize for Header
Source§fn marshal_size(&self) -> usize
fn marshal_size(&self) -> usize
MarshalSize returns the size of the packet once marshaled.