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

A direct transport represents a direct connection between the mediasoup Rust process and a Router instance in a mediasoup-worker thread.

A direct transport can be used to directly send and receive data messages from/to Rust by means of DataProducers and DataConsumers of type Direct created on a direct transport. Direct messages sent by a DataProducer in a direct transport can be consumed by endpoints connected through a SCTP capable transport (WebRtcTransport, PlainTransport, PipeTransport and also by the Rust application by means of a DataConsumer created on a DirectTransport (and vice-versa: messages sent over SCTP/DataChannel can be consumed by the Rust application by means of a DataConsumer created on a DirectTransport).

A direct transport can also be used to inject and directly consume RTP and RTCP packets in Rust by using the DirectProducer::send and Consumer::on_rtp API (plus DirectTransport::send_rtcp and DirectTransport::on_rtcp API).

Implementations§

source§

impl DirectTransport

source

pub fn send_rtcp(&self, rtcp_packet: Vec<u8>) -> Result<(), NotificationError>

Send a RTCP packet from the Rust process.

  • rtcp_packet - Bytes containing a valid RTCP packet (can be a compound packet).
source

pub fn on_rtcp<F: Fn(&[u8]) + Send + Sync + 'static>( &self, callback: F ) -> HandlerId

Callback is called when the direct transport receives a RTCP packet from its router.

source

pub fn downgrade(&self) -> WeakDirectTransport

Downgrade DirectTransport to WeakDirectTransport instance.

Trait Implementations§

source§

impl Clone for DirectTransport

source§

fn clone(&self) -> DirectTransport

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DirectTransport

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Transport for DirectTransport

source§

fn id(&self) -> TransportId

Transport id.
source§

fn router(&self) -> &Router

Router to which transport belongs.
source§

fn app_data(&self) -> &AppData

Custom application data.
source§

fn closed(&self) -> bool

Whether the transport is closed.
source§

fn produce<'life0, 'async_trait>( &'life0 self, producer_options: ProducerOptions ) -> Pin<Box<dyn Future<Output = Result<Producer, ProduceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Instructs the router to receive audio or video RTP (or SRTP depending on the transport). This is the way to inject media into mediasoup. Read more
source§

fn consume<'life0, 'async_trait>( &'life0 self, consumer_options: ConsumerOptions ) -> Pin<Box<dyn Future<Output = Result<Consumer, ConsumeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Instructs the router to send audio or video RTP (or SRTP depending on the transport). This is the way to extract media from mediasoup. Read more
source§

fn produce_data<'life0, 'async_trait>( &'life0 self, data_producer_options: DataProducerOptions ) -> Pin<Box<dyn Future<Output = Result<DataProducer, ProduceDataError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Instructs the router to receive data messages. Those messages can be delivered by an endpoint via SCTP protocol (AKA DataChannel in WebRTC) or can be directly sent from the Rust application if the transport is a DirectTransport. Read more
source§

fn consume_data<'life0, 'async_trait>( &'life0 self, data_consumer_options: DataConsumerOptions ) -> Pin<Box<dyn Future<Output = Result<DataConsumer, ConsumeDataError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Instructs the router to send data messages to the endpoint via SCTP protocol (AKA DataChannel in WebRTC) or directly to the Rust process if the transport is a DirectTransport. Read more
source§

fn enable_trace_event<'life0, 'async_trait>( &'life0 self, types: Vec<TransportTraceEventType> ) -> Pin<Box<dyn Future<Output = Result<(), RequestError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Instructs the transport to emit “trace” events. For monitoring purposes. Use with caution.
source§

fn on_new_producer( &self, callback: Arc<dyn Fn(&Producer) + Send + Sync + 'static> ) -> HandlerId

Callback is called when a new producer is created.
source§

fn on_new_consumer( &self, callback: Arc<dyn Fn(&Consumer) + Send + Sync + 'static> ) -> HandlerId

Callback is called when a new consumer is created.
source§

fn on_new_data_producer( &self, callback: Arc<dyn Fn(&DataProducer) + Send + Sync + 'static> ) -> HandlerId

Callback is called when a new data producer is created.
source§

fn on_new_data_consumer( &self, callback: Arc<dyn Fn(&DataConsumer) + Send + Sync + 'static> ) -> HandlerId

Callback is called when a new data consumer is created.
source§

fn on_trace( &self, callback: Arc<dyn Fn(&TransportTraceEventData) + Send + Sync + 'static> ) -> HandlerId

source§

fn on_router_close( &self, callback: Box<dyn FnOnce() + Send + 'static> ) -> HandlerId

Callback is called when the router this transport belongs to is closed for whatever reason. The transport itself is also closed. on_transport_close callbacks are also called on all its producers and consumers.
source§

fn on_close(&self, callback: Box<dyn FnOnce() + Send + 'static>) -> HandlerId

Callback is called when the router is closed for whatever reason. Read more
source§

impl TransportGeneric for DirectTransport

source§

fn get_stats<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Stat>, RequestError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns current RTC statistics of the transport.

Check the RTC Statistics section for more details (TypeScript-oriented, but concepts apply here as well).

§

type Stat = DirectTransportStat

Stats data structure specific to each transport.
source§

fn dump<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Self::Dump, RequestError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Dump Transport.

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> ToOwned for T
where T: Clone,

§

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

§

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.