RtpPacket

Struct RtpPacket 

Source
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>

Source

pub const MIN_RTP_PACKET_LEN: usize = 12usize

The minimum number of bytes a RTP packet must be to be parsed correctly.

Source

pub const MAX_N_CSRCS: usize = 15usize

The maximum number of CSRCs a RTP packet can contain.

Source

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.

Source

pub fn version(&self) -> u8

The RTP version in this packet. Only version 2 is supported.

Source

pub fn padding_bit(&self) -> bool

Returns whether the padding bit is set for this packet.

Source

pub fn padding(&self) -> Option<u8>

Returns the number of bytes of padding used by this packet or None.

Source

pub fn extension_bit(&self) -> bool

Returns whether the extension bit is set for this packet.

Source

pub fn n_csrcs(&self) -> u8

Returns the number of Contribution Sources for this packet. May not be used by this packet.

Source

pub fn marker(&self) -> bool

👎Deprecated: Use marker_bit() instead

Returns whether the marker bit is set for this packet. The meaning of the marker bit is payload-specific.

Source

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.

Source

pub fn payload_type(&self) -> u8

Returns the payload type for this packet.

Source

pub fn sequence_number(&self) -> u16

Returns the sequence number for this packet.

Source

pub fn timestamp(&self) -> u32

Returns the RTP timestamp for this packet

Source

pub fn ssrc(&self) -> u32

Returns the Sychronisation Source for this packet.

Source

pub fn csrc(&self) -> impl Iterator<Item = u32> + '_

Returns a (potentially empty) iterator over the Contribution Sources for this packet.

Source

pub fn extension_len(&self) -> usize

Returns the length of the extension data in this packet.

Source

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.

Source

pub fn payload_offset(&self) -> usize

Returns the offset of the payload in this packet relative to the beginning of the packet.

Source

pub fn payload_len(&self) -> usize

Returns the length of the payload in this packet without padding.

Source

pub fn payload(&self) -> &[u8]

Returns the payload data.

Source

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.

Trait Implementations§

Source§

impl<'a> Debug for RtpPacket<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RtpPacket<'a>

§

impl<'a> RefUnwindSafe for RtpPacket<'a>

§

impl<'a> Send for RtpPacket<'a>

§

impl<'a> Sync for RtpPacket<'a>

§

impl<'a> Unpin for RtpPacket<'a>

§

impl<'a> UnwindSafe for RtpPacket<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.