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 marker(self, marker: bool) -> Self
👎Deprecated: Use marker_bit()
instead
pub fn marker(self, marker: bool) -> Self
marker_bit()
insteadSet the marker bit for this packet.
Sourcepub fn marker_bit(self, marker_bit: bool) -> Self
pub fn marker_bit(self, marker_bit: bool) -> Self
Set the marker bit 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, 'b> RtpPacketBuilder<&'a [u8], &'b [u8]>
impl<'a, 'b> RtpPacketBuilder<&'a [u8], &'b [u8]>
Sourcepub fn write_into_unchecked(&self, buf: &mut [u8]) -> usize
pub fn write_into_unchecked(&self, buf: &mut [u8]) -> usize
Write this packet into buf
without any validity checks. Returns the number of bytes
written.
Sourcepub fn write_into(&self, buf: &mut [u8]) -> Result<usize, RtpWriteError>
pub fn write_into(&self, buf: &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: &mut Vec<u8>)
pub fn write_into_vec_unchecked(&self, buf: &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: &mut Vec<u8>) -> Result<(), RtpWriteError>
pub fn write_into_vec(&self, buf: &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.