Struct RtpPacketBuilder

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

Source

pub fn new() -> Self

Create a new RTP packet builder

Source

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.

Source

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.

Source

pub fn marked(self, flag: bool) -> Self

Set the marker bit in the RTP header

Source

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.

Source

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.

Source

pub fn sequence(self, seq: Seq) -> Self

Set the sequence number

Source

pub fn ssrc(self, ssrc: u32) -> Self

Set the source for this packet

Source

pub fn timestamp(self, timestamp: u32) -> Self

Set the timestamp

Source

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.

Source

pub fn payload(self, payload: &'a [u8]) -> Self

Set the payload of the packet

Source

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.

Source

pub fn build_into_unchecked(&self, target: &mut [u8]) -> usize

Build the packet into the target buffer but ignore all validity checks.

Source

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.

Source

pub fn build(&self) -> Result<Vec<u8>, RtpPacketBuildError>

Build the RTP packet. On success it returns a buffer containing the target packet.

Trait Implementations§

Source§

impl<'a> Clone for RtpPacketBuilder<'a>

Source§

fn clone(&self) -> RtpPacketBuilder<'a>

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

Auto Trait Implementations§

§

impl<'a> Freeze for RtpPacketBuilder<'a>

§

impl<'a> RefUnwindSafe for RtpPacketBuilder<'a>

§

impl<'a> Send for RtpPacketBuilder<'a>

§

impl<'a> Sync for RtpPacketBuilder<'a>

§

impl<'a> Unpin for RtpPacketBuilder<'a>

§

impl<'a> UnwindSafe for RtpPacketBuilder<'a>

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.