Skip to main content

RtpHeader

Struct RtpHeader 

Source
pub struct RtpHeader {
    pub payload_type: u8,
    pub marker: bool,
    pub sequence: u16,
    pub timestamp: u32,
    pub ssrc: u32,
}
Expand description

The RFC 3550 fixed header fields a packetizer chooses per packet.

Fields§

§payload_type: u8

7-bit payload type (a static PT like 0 = PCMU, or a dynamic 96..=127).

§marker: bool

Frame/talkspurt boundary marker; payload-format-defined semantics.

§sequence: u16

Per-packet sequence number (the packetizer increments, wrapping).

§timestamp: u32

Media-clock timestamp of the payload’s sampling instant.

§ssrc: u32

Synchronization source identifier.

Implementations§

Source§

impl RtpHeader

Source

pub fn parse(buf: &[u8]) -> Option<RtpParsed>

Parse an RTP datagram received from an arbitrary peer, returning the fixed-header fields and the payload’s byte range. The inverse of to_bytes, but tolerant of the header variations a real sender may set that to_bytes never emits: a CSRC list (CC), a profile extension header (X), and payload padding (P).

Parser discipline (never trust the wire, per the demuxer rule): every offset and length is folded with checked arithmetic and bounds-checked against buf, so a malformed or truncated datagram returns None rather than panicking or reading out of bounds. A non-RTP-v2 packet is rejected. Heap-free (part of the no-alloc subset), so an MCU RTP source uses it directly.

Source

pub fn parse_header(buf: &[u8]) -> Option<RtpParsedHeader>

Parse the authenticated RTP header without reading the payload. This accepts CSRC identifiers and an RTP extension and rejects any header whose declared fields exceed buf.

Source

pub const fn to_bytes(self) -> [u8; 12]

The header as it goes on the wire. Pure and heap-free; a packetizer prepends this to its payload.

Trait Implementations§

Source§

impl Clone for RtpHeader

Source§

fn clone(&self) -> RtpHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RtpHeader

Source§

impl Debug for RtpHeader

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for RtpHeader

Source§

impl PartialEq for RtpHeader

Source§

fn eq(&self, other: &RtpHeader) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RtpHeader

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ElementBound for T
where T: Send,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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.