pub struct RtcpPacket { /* private fields */ }Expand description
RTCP packet.
Implementations§
Source§impl RtcpPacket
impl RtcpPacket
Sourcepub const fn new(packet_type: RtcpPacketType) -> Self
pub const fn new(packet_type: RtcpPacketType) -> Self
Create a new packet.
Sourcepub fn from_parts(
header: RtcpHeader,
payload: Bytes,
) -> Result<Self, InvalidInput>
pub fn from_parts( header: RtcpHeader, payload: Bytes, ) -> Result<Self, InvalidInput>
Create a new RTCP packet from given parts.
Sourcepub fn deconstruct(self) -> (RtcpHeader, Bytes)
pub fn deconstruct(self) -> (RtcpHeader, Bytes)
Deconstruct the packet into its header and payload.
Sourcepub fn decode(data: &mut Bytes) -> Result<Self, InvalidInput>
pub fn decode(data: &mut Bytes) -> Result<Self, InvalidInput>
Decode an RTCP packet.
Sourcepub fn header(&self) -> &RtcpHeader
pub fn header(&self) -> &RtcpHeader
Get the packet header.
Sourcepub fn packet_type(&self) -> RtcpPacketType
pub fn packet_type(&self) -> RtcpPacketType
Get the packet type.
Sourcepub fn with_packet_type(self, packet_type: RtcpPacketType) -> Self
pub fn with_packet_type(self, packet_type: RtcpPacketType) -> Self
Set the packet type.
Sourcepub fn item_count(&self) -> u8
pub fn item_count(&self) -> u8
Get number of items in the packet body.
Note: Only the lower 5 bits are actually used.
Sourcepub fn with_item_count(self, count: u8) -> Self
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.
Sourcepub fn padding(&self) -> u8
pub fn padding(&self) -> u8
Get length of the optional padding.
Zero means that the padding is not used at all.
Sourcepub fn stripped_payload(&self) -> Bytes
pub fn stripped_payload(&self) -> Bytes
Get the packet payload without any padding.
Sourcepub fn with_payload(self, payload: Bytes, padding: u8) -> Self
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.
Sourcepub fn with_padded_payload(self, payload: Bytes) -> Self
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.
Trait Implementations§
Source§impl Clone for RtcpPacket
impl Clone for RtcpPacket
Source§fn clone(&self) -> RtcpPacket
fn clone(&self) -> RtcpPacket
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more