pub trait RtpPacketWriter {
    type Output;
    type Payload: PayloadLength;
    type Extension: PayloadLength;

    // Required methods
    fn push(&mut self, data: &[u8]);
    fn push_extension(&mut self, extension_data: &Self::Extension);
    fn push_payload(&mut self, payload: &Self::Payload);
    fn padding(&mut self, size: u8);
    fn finish(&mut self) -> Self::Output;

    // Provided methods
    fn reserve(&mut self, _size: usize) { ... }
    fn max_size(&self) -> Option<usize> { ... }
}
Expand description

Trait to write an RTP packet into and/or from custom data types

Required Associated Types§

Required Methods§

source

fn push(&mut self, data: &[u8])

Provides data to append to the output. May be called multiple times per packet.

source

fn push_extension(&mut self, extension_data: &Self::Extension)

Provides the extension data to add to the output. The extension should be written as-is without any transformations.

source

fn push_payload(&mut self, payload: &Self::Payload)

Provides the payload data to add to the output. The payload should be written as-is without any transformations

source

fn padding(&mut self, size: u8)

Provides any padding value the builder was constructed with. The padding value specifies the number of bytes of zeroes of padding at the end to write. The last byte of padding must be set to the padding count. e.g.

[..., 0, 0, 0, 4]

source

fn finish(&mut self) -> Self::Output

Finishes and returns the built RTP packet. The implementation should reset internal state so that a new packet can be created after finish is called.

Provided Methods§

source

fn reserve(&mut self, _size: usize)

Reserve a number of bytes in the output. Multiple calls are possible and provide the entire size to reserve

source

fn max_size(&self) -> Option<usize>

Return the maximum size of the output. If the output data is not bound to a fixed size, None should be returned.

Implementors§

source§

impl<'a> RtpPacketWriter for RtpPacketWriterMutSlice<'a>

§

type Output = usize

§

type Payload = &'a [u8]

§

type Extension = &'a [u8]

source§

impl<'a> RtpPacketWriter for RtpPacketWriterMutVec<'a>

§

type Output = ()

§

type Payload = &'a [u8]

§

type Extension = &'a [u8]

source§

impl<'a> RtpPacketWriter for RtpPacketWriterVec<'a>

§

type Output = Vec<u8>

§

type Payload = &'a [u8]

§

type Extension = &'a [u8]