Struct mediasoup::prelude::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
sourceimpl 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
sourceimpl Clone for DirectTransport
impl Clone for DirectTransport
sourcefn clone(&self) -> DirectTransport
fn clone(&self) -> DirectTransport
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for DirectTransport
impl Debug for DirectTransport
sourceimpl Transport for DirectTransport
impl Transport for DirectTransport
sourcefn id(&self) -> TransportId
fn id(&self) -> TransportId
Transport id.
sourcefn produce<'life0, 'async_trait>(
&'life0 self,
producer_options: ProducerOptions
) -> Pin<Box<dyn Future<Output = Result<Producer, ProduceError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn produce<'life0, 'async_trait>(
&'life0 self,
producer_options: ProducerOptions
) -> Pin<Box<dyn Future<Output = Result<Producer, ProduceError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: '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
sourcefn consume<'life0, 'async_trait>(
&'life0 self,
consumer_options: ConsumerOptions
) -> Pin<Box<dyn Future<Output = Result<Consumer, ConsumeError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn consume<'life0, 'async_trait>(
&'life0 self,
consumer_options: ConsumerOptions
) -> Pin<Box<dyn Future<Output = Result<Consumer, ConsumeError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: '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
sourcefn produce_data<'life0, 'async_trait>(
&'life0 self,
data_producer_options: DataProducerOptions
) -> Pin<Box<dyn Future<Output = Result<DataProducer, ProduceDataError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: '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
sourcefn consume_data<'life0, 'async_trait>(
&'life0 self,
data_consumer_options: DataConsumerOptions
) -> Pin<Box<dyn Future<Output = Result<DataConsumer, ConsumeDataError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: '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
sourcefn enable_trace_event<'life0, 'async_trait>(
&'life0 self,
types: Vec<TransportTraceEventType>
) -> Pin<Box<dyn Future<Output = Result<(), RequestError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: 'async_trait,
Instructs the transport to emit “trace” events. For monitoring purposes. Use with caution.
sourcefn 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
Callback is called when a new producer is created.
sourcefn 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
Callback is called when a new consumer is created.
sourcefn 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
Callback is called when a new data producer is created.
sourcefn 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
Callback is called when a new data consumer is created.
sourcefn 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
sourcefn on_router_close(
&self,
callback: Box<dyn FnOnce() + Send + 'static>
) -> HandlerId
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. Read more
sourceimpl TransportGeneric for DirectTransport
impl TransportGeneric for DirectTransport
sourcefn get_stats<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Stat>, RequestError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn get_stats<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Stat>, RequestError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: '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
type Stat = DirectTransportStat
Stats data structure specific to each transport.
Auto Trait Implementations
impl !RefUnwindSafe for DirectTransport
impl Send for DirectTransport
impl Sync for DirectTransport
impl Unpin for DirectTransport
impl !UnwindSafe for DirectTransport
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more