Struct rtp_types::RtpPacketBuilder
source · pub struct RtpPacketBuilder<P: PayloadLength, E: PayloadLength> { /* private fields */ }Expand description
Struct for building a new RTP packet
Implementations§
source§impl<P: PayloadLength, E: PayloadLength> RtpPacketBuilder<P, E>
impl<P: PayloadLength, E: PayloadLength> RtpPacketBuilder<P, E>
sourcepub fn new() -> RtpPacketBuilder<P, E>
pub fn new() -> RtpPacketBuilder<P, E>
Construct a new packet builder
sourcepub fn padding(self, padding: u8) -> Self
pub fn padding(self, padding: u8) -> Self
Set the number of padding bytes to use for this packet
sourcepub fn maybe_padding(self, padding: Option<u8>) -> Self
pub fn maybe_padding(self, padding: Option<u8>) -> Self
Set 1. whether padding is used and 2. the number of padding bytes to use for this packet
sourcepub fn clear_csrcs(self) -> Self
pub fn clear_csrcs(self) -> Self
Clear any CSRCs configured for this packet
sourcepub fn payload_type(self, pt: u8) -> Self
pub fn payload_type(self, pt: u8) -> Self
Set the payload type for this packet
sourcepub fn sequence_number(self, sequence: u16) -> Self
pub fn sequence_number(self, sequence: u16) -> Self
Set the sequence number for this packet
sourcepub fn extension(self, extension_id: u16, extension_data: E) -> Self
pub fn extension(self, extension_id: u16, extension_data: E) -> Self
Set the extension header for this packet
sourcepub fn clear_extension(self) -> Self
pub fn clear_extension(self) -> Self
Clear any extension data configured for this packet
sourcepub fn payload(self, payload: P) -> Self
pub fn payload(self, payload: P) -> Self
Add a chunk of payload data for this packet.
Can be called multiple times, in which case the payload data chunks will be concatenated when the final packet is created.
sourcepub fn clear_payloads(self) -> Self
pub fn clear_payloads(self) -> Self
Clear any payloads currently configured
sourcepub fn calculate_size(&self) -> Result<usize, RtpWriteError>
pub fn calculate_size(&self) -> Result<usize, RtpWriteError>
Calculate the size required for writing the packet.
sourcepub fn write_unchecked<O>(
&self,
writer: &mut impl RtpPacketWriter<Payload = P, Extension = E, Output = O>
) -> O
pub fn write_unchecked<O>( &self, writer: &mut impl RtpPacketWriter<Payload = P, Extension = E, Output = O> ) -> O
Write this packet using writer without any validity checks
sourcepub fn write<O>(
&self,
writer: &mut impl RtpPacketWriter<Payload = P, Extension = E, Output = O>
) -> Result<O, RtpWriteError>
pub fn write<O>( &self, writer: &mut impl RtpPacketWriter<Payload = P, Extension = E, Output = O> ) -> Result<O, RtpWriteError>
Write the packet using writer.
source§impl<'a> RtpPacketBuilder<&'a [u8], &'a [u8]>
impl<'a> RtpPacketBuilder<&'a [u8], &'a [u8]>
sourcepub fn write_into_unchecked<'b: 'a>(&self, buf: &'b mut [u8]) -> usize
pub fn write_into_unchecked<'b: 'a>(&self, buf: &'b mut [u8]) -> usize
Write this packet into buf without any validity checks. Returns the number of bytes
written.
sourcepub fn write_into<'b: 'a>(
&self,
buf: &'b mut [u8]
) -> Result<usize, RtpWriteError>
pub fn write_into<'b: 'a>( &self, buf: &'b mut [u8] ) -> Result<usize, RtpWriteError>
Write this packet into buf. On success returns the number of bytes written or an
RtpWriteError on failure.
sourcepub fn write_into_vec_unchecked(&self, buf: &'a mut Vec<u8>)
pub fn write_into_vec_unchecked(&self, buf: &'a mut Vec<u8>)
Write this packet into buf without any validity checks. The data will be appended to the
end of the provide Vec.
sourcepub fn write_into_vec(&self, buf: &'a mut Vec<u8>) -> Result<(), RtpWriteError>
pub fn write_into_vec(&self, buf: &'a mut Vec<u8>) -> Result<(), RtpWriteError>
Write this packet into buf. The data will be appended to the end of the provide Vec.
sourcepub fn write_vec_unchecked(&self) -> Vec<u8> ⓘ
pub fn write_vec_unchecked(&self) -> Vec<u8> ⓘ
Write this packet into a newly generated Vec<u8> without any validity checks.