Struct rtp_types::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(&self) -> Option<u8>

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

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

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(&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(&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> 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>,

§

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

§

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.