Skip to main content

RtpPacket

Struct RtpPacket 

Source
pub struct RtpPacket<'a> {
    pub marker: bool,
    pub payload_type: u8,
    pub sequence_number: u16,
    pub timestamp: u32,
    pub ssrc: u32,
    pub csrc: Vec<u32>,
    pub extension: Option<HeaderExtension<'a>>,
    pub padding: Option<&'a [u8]>,
    pub payload: &'a [u8],
}
Expand description

A parsed (or to-be-serialized) RTP packet: the §5.1 fixed header, the CSRC list, the optional §5.3.1 header extension, an optional padding region, and the payload.

version is not a stored field: RFC 3550 fixes it at 2, so parse rejects any other value and serialize_into always writes 2 — storing a field that can only ever legally hold one value would just be another way for caller state to disagree with the wire (see RTP_VERSION).

P (padding) and X (extension) are likewise never stored directly: they are derived from padding.is_some() / extension.is_some() on serialize, and CC is derived from csrc.len() — the same “derive from the typed data, never trust an independent flag” discipline used throughout this project (see the module doc’s citation of docs/rtp-header.md).

Fields§

§marker: bool

marker (M) — profile-specific, opaque at this layer (§5.1).

§payload_type: u8

payload type (PT), 7 bits (§5.1).

§sequence_number: u16

sequence number, 16 bits (§5.1).

§timestamp: u32

timestamp, 32 bits (§5.1).

§ssrc: u32

SSRC — synchronization source identifier, 32 bits (§5.1).

§csrc: Vec<u32>

The CSRC identifier list, 0–15 entries (§5.1 CC/CSRC list). CC is always csrc.len() — there is no separate stored count.

§extension: Option<HeaderExtension<'a>>

The §5.3.1 header extension, if X=1.

§padding: Option<&'a [u8]>

The trailing padding region, if P=1: the raw octets as they appear on the wire, whose last byte is the padding count “including itself” (§5.1). Storing the whole slice (rather than just a count) preserves whatever content precedes the count byte byte-exactly on round-trip, since RFC 3550 does not constrain it.

§payload: &'a [u8]

The payload: whatever bytes remain after the fixed header, CSRC list, and extension, with the trailing padding (if any) already excluded.

Implementations§

Source§

impl RtpPacket<'_>

Source

pub fn csrc_count(&self) -> usize

CC — the CSRC count that will be written on serialize: always csrc.len() (§5.1).

Trait Implementations§

Source§

impl<'a> Clone for RtpPacket<'a>

Source§

fn clone(&self) -> RtpPacket<'a>

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<'a> Debug for RtpPacket<'a>

Source§

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

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

impl<'a> Eq for RtpPacket<'a>

Source§

impl<'a> Parse<'a> for RtpPacket<'a>

Source§

type Error = Error

The error type this implementer returns. Typically the enclosing crate’s Error enum.
Source§

fn parse(bytes: &'a [u8]) -> Result<Self>

Parse bytes as Self. Returns Err(Self::Error) on any protocol violation or buffer underrun.
Source§

impl<'a> PartialEq for RtpPacket<'a>

Source§

fn eq(&self, other: &RtpPacket<'a>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<'a> Serialize for RtpPacket<'a>

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Serialize for RtpPacket<'_>

Source§

type Error = Error

The error type this implementer returns (usually the same as the corresponding Parse impl, but need not be).
Source§

fn serialized_len(&self) -> usize

Number of bytes serialize_into will write.
Source§

fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>

Write the serialised form into buf. Returns the number of bytes written (always equal to serialized_len()).
Source§

fn to_bytes(&self) -> Vec<u8>
where Self::Error: Debug,

Convenience: allocate a Vec and serialise into it. Read more
Source§

impl<'a> StructuralPartialEq for RtpPacket<'a>

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> UnsafeUnpin 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> 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> 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 = 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.