pub struct MockStream { /* private fields */ }
Expand description

MockStream is a helper struct for testing interceptors.

Implementations§

source§

impl MockStream

source

pub async fn new( info: &StreamInfo, interceptor: Arc<dyn Interceptor + Send + Sync> ) -> Arc<Self>

new creates a new MockStream

source

pub async fn write_rtcp( &self, pkt: &[Box<dyn Packet + Send + Sync>] ) -> Result<usize, Error>

write_rtcp writes a batch of rtcp packet to the stream, using the interceptor

source

pub async fn write_rtp(&self, pkt: &Packet) -> Result<usize, Error>

write_rtp writes an rtp packet to the stream, using the interceptor

source

pub async fn receive_rtcp(&self, pkts: Vec<Box<dyn Packet + Send + Sync>>)

receive_rtcp schedules a new rtcp batch, so it can be read be the stream

source

pub async fn receive_rtp(&self, pkt: Packet)

receive_rtp schedules a rtp packet, so it can be read be the stream

source

pub async fn written_rtcp(&self) -> Option<Vec<Box<dyn Packet + Send + Sync>>>

written_rtcp returns a channel containing the rtcp batches written, modified by the interceptor

source

pub async fn last_written_rtcp( &self ) -> Option<Vec<Box<dyn Packet + Send + Sync>>>

Returns the last rtcp packet bacth that was written, modified by the interceptor.

NB: This method discards all other previously recoreded packet batches.

source

pub async fn written_rtp(&self) -> Option<Packet>

written_rtp returns a channel containing rtp packets written, modified by the interceptor

source

pub async fn read_rtcp( &self ) -> Option<Result<Vec<Box<dyn Packet + Send + Sync>>, Error>>

read_rtcp returns a channel containing the rtcp batched read, modified by the interceptor

source

pub async fn read_rtp(&self) -> Option<Result<Packet, Error>>

read_rtp returns a channel containing the rtp packets read, modified by the interceptor

source

pub async fn close(&self) -> Result<(), Error>

close closes the stream and the underlying interceptor

Trait Implementations§

source§

impl RTCPReader for MockStream

source§

fn read<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, buf: &'life1 mut [u8], a: &'life2 Attributes ) -> Pin<Box<dyn Future<Output = Result<(Vec<Box<dyn Packet + Send + Sync>>, Attributes), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

read a batch of rtcp packets
source§

impl RTCPWriter for MockStream

source§

fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, pkts: &'life1 [Box<dyn Packet + Send + Sync>], _attributes: &'life2 Attributes ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

write a batch of rtcp packets
source§

impl RTPReader for MockStream

source§

fn read<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, buf: &'life1 mut [u8], a: &'life2 Attributes ) -> Pin<Box<dyn Future<Output = Result<(Packet, Attributes), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

read a rtp packet
source§

impl RTPWriter for MockStream

source§

fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, pkt: &'life1 Packet, _a: &'life2 Attributes ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

write a rtp packet

Auto Trait Implementations§

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> 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V