RtcpPacket

Struct RtcpPacket 

Source
pub struct RtcpPacket { /* private fields */ }
Expand description

RTCP packet.

Implementations§

Source§

impl RtcpPacket

Source

pub const fn new(packet_type: RtcpPacketType) -> Self

Create a new packet.

Source

pub fn from_parts( header: RtcpHeader, payload: Bytes, ) -> Result<Self, InvalidInput>

Create a new RTCP packet from given parts.

Source

pub fn deconstruct(self) -> (RtcpHeader, Bytes)

Deconstruct the packet into its header and payload.

Source

pub fn decode(data: &mut Bytes) -> Result<Self, InvalidInput>

Decode an RTCP packet.

Source

pub fn encode(&self, buf: &mut BytesMut)

Encode the packet.

Source

pub fn header(&self) -> &RtcpHeader

Get the packet header.

Source

pub fn packet_type(&self) -> RtcpPacketType

Get the packet type.

Source

pub fn with_packet_type(self, packet_type: RtcpPacketType) -> Self

Set the packet type.

Source

pub fn item_count(&self) -> u8

Get number of items in the packet body.

Note: Only the lower 5 bits are actually used.

Source

pub fn with_item_count(self, count: u8) -> Self

Set the number of items in the packet body.

§Panics

The method panics if the number of items is greater than 31.

Source

pub fn length(&self) -> usize

Get packet length in bytes.

Source

pub fn padding(&self) -> u8

Get length of the optional padding.

Zero means that the padding is not used at all.

Source

pub fn payload(&self) -> &Bytes

Get the packet payload including the optional padding.

Source

pub fn stripped_payload(&self) -> Bytes

Get the packet payload without any padding.

Source

pub fn with_payload(self, payload: Bytes, padding: u8) -> Self

Set the payload and add padding of a given length.

If the padding is zero, no padding will be added and the padding bit in the RTP header will be set to zero.

§Panics

The method panics if the payload length including padding is not a multiple of four or if the payload length including padding is greater than 262_140.

Source

pub fn with_padded_payload(self, payload: Bytes) -> Self

Set the payload that already includes padding.

§Panics

The method panics if the following conditions are not met:

  • The payload must not be empty.
  • The last byte of the payload (i.e. the length of the padding) must not be zero.
  • The length of the padding must not be greater than the length of the payload itself.
  • The payload length including padding must be a multiple of four.
  • The payload length including padding must not be greater than 262_140.
Source

pub fn raw_size(&self) -> usize

Get encoded size of the packet.

Trait Implementations§

Source§

impl Clone for RtcpPacket

Source§

fn clone(&self) -> RtcpPacket

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl From<RtcpPacket> for CompoundRtcpPacket

Source§

fn from(packet: RtcpPacket) -> Self

Converts to this type from the input type.
Source§

impl<P> From<RtcpPacket> for PacketMux<P>

Source§

fn from(packet: RtcpPacket) -> Self

Converts to this type from the input type.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V