Trait mediasoup::transport::Transport[][src]

pub trait Transport: Debug + Send + Sync + CloneTransport {
    fn id(&self) -> TransportId;
fn router_id(&self) -> RouterId;
fn app_data(&self) -> &AppData;
fn closed(&self) -> bool;
#[must_use] fn produce<'life0, 'async_trait>(
        &'life0 self,
        producer_options: ProducerOptions
    ) -> Pin<Box<dyn Future<Output = Result<Producer, ProduceError>> + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn consume<'life0, 'async_trait>(
        &'life0 self,
        consumer_options: ConsumerOptions
    ) -> Pin<Box<dyn Future<Output = Result<Consumer, ConsumeError>> + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn produce_data<'life0, 'async_trait>(
        &'life0 self,
        data_producer_options: DataProducerOptions
    ) -> Pin<Box<dyn Future<Output = Result<DataProducer, ProduceDataError>> + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn consume_data<'life0, 'async_trait>(
        &'life0 self,
        data_consumer_options: DataConsumerOptions
    ) -> Pin<Box<dyn Future<Output = Result<DataConsumer, ConsumeDataError>> + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn enable_trace_event<'life0, 'async_trait>(
        &'life0 self,
        types: Vec<TransportTraceEventType>
    ) -> Pin<Box<dyn Future<Output = Result<(), RequestError>> + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn on_new_producer(
        &self,
        callback: Box<dyn Fn(&Producer) + Send + Sync + 'static>
    ) -> HandlerId;
fn on_new_consumer(
        &self,
        callback: Box<dyn Fn(&Consumer) + Send + Sync + 'static>
    ) -> HandlerId;
fn on_new_data_producer(
        &self,
        callback: Box<dyn Fn(&DataProducer) + Send + Sync + 'static>
    ) -> HandlerId;
fn on_new_data_consumer(
        &self,
        callback: Box<dyn Fn(&DataConsumer) + Send + Sync + 'static>
    ) -> HandlerId;
fn on_trace(
        &self,
        callback: Box<dyn Fn(&TransportTraceEventData) + Send + Sync + 'static>
    ) -> HandlerId;
fn on_router_close(
        &self,
        callback: Box<dyn FnOnce() + Send + 'static>
    ) -> HandlerId;
fn on_close(
        &self,
        callback: Box<dyn FnOnce() + Send + 'static>
    ) -> HandlerId; }

A transport connects an endpoint with a mediasoup router and enables transmission of media in both directions by means of Producer, Consumer, DataProducer and DataConsumer instances created on it.

mediasoup implements the following transports:

For additional methods see TransportGeneric.

Required methods

fn id(&self) -> TransportId[src]

Transport id.

fn router_id(&self) -> RouterId[src]

Router id.

fn app_data(&self) -> &AppData[src]

Custom application data.

fn closed(&self) -> bool[src]

Whether the transport is closed.

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

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

Transport will be kept alive as long as at least one producer instance is alive.

Notes on usage

Check the RTP Parameters and Capabilities section for more details (TypeScript-oriented, but concepts apply here as well).

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

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

Transport will be kept alive as long as at least one consumer instance is alive.

Notes on usage

Check the RTP Parameters and Capabilities section for more details (TypeScript-oriented, but concepts apply here as well).

When creating a consumer it’s recommended to set ConsumerOptions::paused to true, then transmit the consumer parameters to the consuming endpoint and, once the consuming endpoint has created its local side consumer, unpause the server side consumer using the Consumer::resume() method.

Reasons for create the server side consumer in paused mode:

  • If the remote endpoint is a WebRTC browser or application and it receives a RTP packet of the new consumer before the remote RTCPeerConnection is ready to process it (this is, before the remote consumer is created in the remote endpoint) it may happen that the RTCPeerConnection will wrongly associate the SSRC of the received packet to an already existing SDP m= section, so the imminent creation of the new consumer and its associated m= section will fail.
  • Also, when creating a video consumer, this is an optimization to make it possible for the consuming endpoint to render the video as far as possible. If the server side consumer was created with paused: false, mediasoup will immediately request a key frame to the producer and that key frame may reach the consuming endpoint even before it’s ready to consume it, generating “black” video until the device requests a keyframe by itself.

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

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.

Transport will be kept alive as long as at least one data producer instance is alive.

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

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.

Transport will be kept alive as long as at least one data consumer instance is alive.

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

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

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

Callback is called when a new producer is created.

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

Callback is called when a new consumer is created.

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

Callback is called when a new data producer is created.

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

Callback is called when a new data consumer is created.

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

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

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.

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

Callback is called when the router is closed for whatever reason.

NOTE: Callback will be called in place if transport is already closed.

Loading content...

Implementors

impl Transport for DirectTransport[src]

fn id(&self) -> TransportId[src]

Transport id.

fn app_data(&self) -> &AppData[src]

Custom application data.

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

Create a Producer.

Transport will be kept alive as long as at least one producer instance is alive.

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

Create a Consumer.

Transport will be kept alive as long as at least one consumer instance is alive.

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

Create a DataProducer.

Transport will be kept alive as long as at least one data producer instance is alive.

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

Create a DataConsumer.

Transport will be kept alive as long as at least one data consumer instance is alive.

impl Transport for PipeTransport[src]

impl Transport for PlainTransport[src]

impl Transport for WebRtcTransport[src]

Loading content...