pub struct RtpPacketBuilder<'a> { /* private fields */ }
Expand description
A new packet build which collects the data which should be written as RTP packet
Implementations§
Source§impl<'a> RtpPacketBuilder<'a>
impl<'a> RtpPacketBuilder<'a>
Sourcepub fn payload_type(self, payload_type: u8) -> Self
pub fn payload_type(self, payload_type: u8) -> Self
Set the payload type.
The type must be in range of [0; 127],
else RtpPacketBuilder::build_info
will fail.
Sourcepub fn padded(self, pad: Pad) -> Self
pub fn padded(self, pad: Pad) -> Self
Control if and how bytes are appended to the packet if the headers and payload together do not have an appropriate length (for instance if the length of the resulting RTP data must be a multiple of 4 bytes).
The default is Pad::none()
- no padding bytes will be added and the padding flag will not
be set in the RTP header.
Sourcepub fn add_csrc(self, csrc: u32) -> Self
pub fn add_csrc(self, csrc: u32) -> Self
Add a contributing source (csrc). If added more than 15 contributing sources the rest will be discarded.
Sourcepub fn set_csrc(self, csrcs: &[u32]) -> Self
pub fn set_csrc(self, csrcs: &[u32]) -> Self
Set the contributing sources (csrc). If added more than 15 contributing sources the rest will be discarded.
Sourcepub fn extension(self, id: u16, payload: &'a [u8]) -> Self
pub fn extension(self, id: u16, payload: &'a [u8]) -> Self
Add a custom extension payload.
The bytes should be aligned to a a four byte boundary,
else RtpPacketBuilder::build_info
will fail.
Sourcepub fn target_length(&self) -> usize
pub fn target_length(&self) -> usize
Calculate the target length of the packet.
This can be used to allocate a buffer for the build_into
method.
Sourcepub fn build_into_unchecked(&self, target: &mut [u8]) -> usize
pub fn build_into_unchecked(&self, target: &mut [u8]) -> usize
Build the packet into the target buffer but ignore all validity checks.
Sourcepub fn build_into(
&self,
target: &mut [u8],
) -> Result<usize, RtpPacketBuildError>
pub fn build_into( &self, target: &mut [u8], ) -> Result<usize, RtpPacketBuildError>
Build the RTP packet on the target buffer. The length of the final packet will be returned on success.
Trait Implementations§
Source§impl<'a> Clone for RtpPacketBuilder<'a>
impl<'a> Clone for RtpPacketBuilder<'a>
Source§fn clone(&self) -> RtpPacketBuilder<'a>
fn clone(&self) -> RtpPacketBuilder<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more