Struct mediasoup::direct_transport::DirectTransport
source · 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 DataProducer
s and DataConsumer
s 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
impl DirectTransport
sourcepub fn send_rtcp(&self, rtcp_packet: Vec<u8>) -> Result<(), NotificationError>
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).
sourcepub fn on_rtcp<F: Fn(&[u8]) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
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.
sourcepub fn downgrade(&self) -> WeakDirectTransport
pub fn downgrade(&self) -> WeakDirectTransport
Downgrade DirectTransport
to WeakDirectTransport
instance.
Trait Implementations§
source§impl Clone for DirectTransport
impl Clone for DirectTransport
source§fn clone(&self) -> DirectTransport
fn clone(&self) -> DirectTransport
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DirectTransport
impl Debug for DirectTransport
source§impl Transport for DirectTransport
impl Transport for DirectTransport
source§fn id(&self) -> TransportId
fn id(&self) -> TransportId
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,
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,
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,
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,
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,
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,
DataChannel
in WebRTC) or can be directly sent from the Rust application if the transport is a
DirectTransport
. Read moresource§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,
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,
DataChannel
in WebRTC)
or directly to the Rust process if the transport is a
DirectTransport
. Read moresource§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,
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,
source§fn on_new_producer(
&self,
callback: Arc<dyn Fn(&Producer) + Send + Sync + 'static>
) -> HandlerId
fn on_new_producer( &self, callback: Arc<dyn Fn(&Producer) + Send + Sync + 'static> ) -> HandlerId
source§fn on_new_consumer(
&self,
callback: Arc<dyn Fn(&Consumer) + Send + Sync + 'static>
) -> HandlerId
fn on_new_consumer( &self, callback: Arc<dyn Fn(&Consumer) + Send + Sync + 'static> ) -> HandlerId
source§fn on_new_data_producer(
&self,
callback: Arc<dyn Fn(&DataProducer) + Send + Sync + 'static>
) -> HandlerId
fn on_new_data_producer( &self, callback: Arc<dyn Fn(&DataProducer) + Send + Sync + 'static> ) -> HandlerId
source§fn on_new_data_consumer(
&self,
callback: Arc<dyn Fn(&DataConsumer) + Send + Sync + 'static>
) -> HandlerId
fn on_new_data_consumer( &self, callback: Arc<dyn Fn(&DataConsumer) + Send + Sync + 'static> ) -> HandlerId
source§fn on_trace(
&self,
callback: Arc<dyn Fn(&TransportTraceEventData) + Send + Sync + 'static>
) -> HandlerId
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
fn on_router_close( &self, callback: Box<dyn FnOnce() + Send + 'static> ) -> HandlerId
on_transport_close
callbacks are also called on all
its producers and consumers.source§impl TransportGeneric for DirectTransport
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,
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).