Struct rtp_rs::RtpReader[][src]

pub struct RtpReader<'a> { /* fields omitted */ }
Expand description

Wrapper around a byte-slice of RTP data, providing accessor methods for the RTP header fields.

Implementations

impl<'a> RtpReader<'a>[src]

pub const MIN_HEADER_LEN: usize[src]

An RTP packet header is no fewer than 12 bytes long

pub fn new(b: &'a [u8]) -> Result<RtpReader<'_>, RtpReaderError>[src]

Tries to construct a new RtpHeader instance, or an RtpReaderError if the RTP data is malformed.

In particular, if there is too little data in the given buffer, such that some later attempt to access an RTP header field would need to access bytes that are not available, then this method will fail up front, rather than allowing attempts to access any header field to fail later on.

pub fn version(&self) -> u8[src]

Version field value (currently only version 2 is supported, so other values will not be seen from this release of rtp-rs.

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

Returns the size of the padding at the end of this packet, or None if the padding flag is not set in the packet header

pub fn csrc_count(&self) -> u8[src]

A count of the number of CSRC fields present in the RTP headers - may be 0.

See csrc().

pub fn mark(&self) -> bool[src]

A ‘marker’, which may have some definition in the specific RTP profile in use

pub fn payload_type(&self) -> u8[src]

Indicates the type of content carried in this RTP packet.

A few types-values are defined in the standard, but in many applications of RTP the value of this field needs to be agreed between sender and receiver by some mechanism outside of RTP itself.

pub fn sequence_number(&self) -> Seq[src]

The sequence number of this particular packet.

Sequence numbers are 16 bits, and will wrap back to 0 after reaching the maximum 16-bit value of 65535.

Receivers can identify packet losses or reordering by inspecting the value of this field across a sequence of received packets. The Seq wrapper type helps calling code reason about sequence number problems in the face of any wraparound that might have legitimately happened.

pub fn timestamp(&self) -> u32[src]

The timestamp of this packet, given in a timebase that relates to the particular payload_type in use.

It is perfectly possible for successive packets in a sequence to have the same value, or to have values that differ by arbitrarily large amounts.

Timestamps are 32 bits, and will wrap back to 0 after reaching the maximum 32 bit value of 4294967295.

pub fn ssrc(&self) -> u32[src]

The synchronisation source for this packet. Many applications of RTP do not use this field.

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

A potentially empty list of contributing sources for this packet. Many applications of RTP do not use this field.

pub fn payload_offset(&self) -> usize[src]

Returns the offset of the payload for the packet

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

Returns the payload data of this RTP packet, excluding the packet’s headers and any optional trailing padding.

pub fn extension(&self) -> Option<(u16, &'a [u8])>[src]

Returns details of the optional RTP header extension field. If there is an extension, the first component of the resulting tuple is the extension id, and the second is a byte-slice for the extension data value, to be interpreted by the application.

pub fn create_builder(&self) -> RtpPacketBuilder<'a>[src]

Create a RtpPacketBuilder from this packet. Note that padding from the original packet will not be used by default, and must be defined on the resulting RtpPacketBuilder if required.

The padding is not copied from the original since, while we do know how many padding bytes were present, we don’t know if the intent was to round to 2 bytes, 4 bytes, etc. Blindly copying the padding could result in an incorrect result if the payload is subsequently changed for one with a different length.

If you know your output packets don’t need padding, there is nothing more to do, since that is the default for the resulting RtpPacketBulder.

If you know you output packets need padding to 4 bytes, then you must explicitly specify this using builder.padded(Pad::round_to(4)) even if the source packet was already padded to a 4 byte boundary.

Trait Implementations

impl<'a> Debug for RtpReader<'a>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a> RefUnwindSafe for RtpReader<'a>

impl<'a> Send for RtpReader<'a>

impl<'a> Sync for RtpReader<'a>

impl<'a> Unpin for RtpReader<'a>

impl<'a> UnwindSafe for RtpReader<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.