pub struct RtpPacket<'a> { /* private fields */ }
Expand description
A parsed RTP packet. A wrapper around a byte slice. Each field is only accessed when needed.
Implementations§
Source§impl<'a> RtpPacket<'a>
impl<'a> RtpPacket<'a>
Sourcepub const MIN_RTP_PACKET_LEN: usize = 12usize
pub const MIN_RTP_PACKET_LEN: usize = 12usize
The minimum number of bytes a RTP packet must be to be parsed correctly.
Sourcepub const MAX_N_CSRCS: usize = 15usize
pub const MAX_N_CSRCS: usize = 15usize
The maximum number of CSRCs a RTP packet can contain.
Sourcepub fn parse(data: &'a [u8]) -> Result<RtpPacket<'a>, RtpParseError>
pub fn parse(data: &'a [u8]) -> Result<RtpPacket<'a>, RtpParseError>
Parse a byte slice into a RtpPacket
. This implementation prefers to fail fast and will
return errors when the size of passed in data is not sufficient for values described in the
data.
Sourcepub fn padding_bit(&self) -> bool
pub fn padding_bit(&self) -> bool
Returns whether the padding bit is set for this packet.
Sourcepub fn padding(&self) -> Option<u8>
pub fn padding(&self) -> Option<u8>
Returns the number of bytes of padding used by this packet or None
.
Sourcepub fn extension_bit(&self) -> bool
pub fn extension_bit(&self) -> bool
Returns whether the extension bit is set for this packet.
Sourcepub fn n_csrcs(&self) -> u8
pub fn n_csrcs(&self) -> u8
Returns the number of Contribution Sources for this packet. May not be used by this packet.
Sourcepub fn marker(&self) -> bool
👎Deprecated: Use marker_bit()
instead
pub fn marker(&self) -> bool
marker_bit()
insteadReturns whether the marker bit is set for this packet. The meaning of the marker bit is payload-specific.
Sourcepub fn marker_bit(&self) -> bool
pub fn marker_bit(&self) -> bool
Returns whether the marker bit is set for this packet. The meaning of the marker bit is payload-specific.
Sourcepub fn payload_type(&self) -> u8
pub fn payload_type(&self) -> u8
Returns the payload type for this packet.
Sourcepub fn sequence_number(&self) -> u16
pub fn sequence_number(&self) -> u16
Returns the sequence number for this packet.
Sourcepub fn csrc(&self) -> impl Iterator<Item = u32> + '_
pub fn csrc(&self) -> impl Iterator<Item = u32> + '_
Returns a (potentially empty) iterator over the Contribution Sources for this packet.
Sourcepub fn extension_len(&self) -> usize
pub fn extension_len(&self) -> usize
Returns the length of the extension data in this packet.
Sourcepub fn extension(&self) -> Option<(u16, &[u8])>
pub fn extension(&self) -> Option<(u16, &[u8])>
Returns the extension data for this packet. The first value is an identifier and is ‘defined by the RTP profile’. The second value is the extension data.
Sourcepub fn payload_offset(&self) -> usize
pub fn payload_offset(&self) -> usize
Returns the offset of the payload in this packet relative to the beginning of the packet.
Sourcepub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
Returns the length of the payload in this packet without padding.
Sourcepub fn as_builder(&'a self) -> RtpPacketBuilder<&'a [u8], &'a [u8]>
pub fn as_builder(&'a self) -> RtpPacketBuilder<&'a [u8], &'a [u8]>
Creates a builder that will be able to reconstruct this packet byte for byte (excluding any padding bytes). Any aspect of the returned builder can be modified.