Struct mediasoup::plain_transport::PlainTransport
source · [−]pub struct PlainTransport { /* private fields */ }
Expand description
A plain transport represents a network path through which RTP, RTCP (optionally secured with SRTP) and SCTP (DataChannel) is transmitted.
Implementations
sourceimpl PlainTransport
impl PlainTransport
sourcepub async fn connect(
&self,
remote_parameters: PlainTransportRemoteParameters
) -> Result<(), RequestError>
pub async fn connect(
&self,
remote_parameters: PlainTransportRemoteParameters
) -> Result<(), RequestError>
Provide the PlainTransport
with remote parameters.
Notes on usage
- If
comedia
is enabled in this plain transport and SRTP is not,connect()
must not be called. - If
comedia
is enabled and SRTP is also enabled (enable_srtp
was set in theRouter::create_plain_transport
options) thenconnect()
must be called with just the remotesrtp_parameters
. - If
comedia
is disabled,connect()
must be eventually called with remoteip
,port
, optionalrtcp_port
(if RTCP-mux is not enabled) and optionalsrtp_parameters
(if SRTP is enabled).
Examples
use mediasoup::plain_transport::PlainTransportRemoteParameters;
// Calling connect() on a PlainTransport created with comedia and rtcp_mux set.
plain_transport
.connect(PlainTransportRemoteParameters {
ip: Some("1.2.3.4".parse().unwrap()),
port: Some(9998),
rtcp_port: None,
srtp_parameters: None,
})
.await?;
use mediasoup::plain_transport::PlainTransportRemoteParameters;
// Calling connect() on a PlainTransport created with comedia unset and rtcp_mux
// also unset.
plain_transport
.connect(PlainTransportRemoteParameters {
ip: Some("1.2.3.4".parse().unwrap()),
port: Some(9998),
rtcp_port: Some(9999),
srtp_parameters: None,
})
.await?;
use mediasoup::plain_transport::PlainTransportRemoteParameters;
use mediasoup::srtp_parameters::{SrtpParameters, SrtpCryptoSuite};
// Calling connect() on a PlainTransport created with comedia set and
// enable_srtp enabled.
plain_transport
.connect(PlainTransportRemoteParameters {
ip: None,
port: None,
rtcp_port: None,
srtp_parameters: Some(SrtpParameters {
crypto_suite: SrtpCryptoSuite::AesCm128HmacSha180,
key_base64: "ZnQ3eWJraDg0d3ZoYzM5cXN1Y2pnaHU5NWxrZTVv".to_string(),
}),
})
.await?;
use mediasoup::plain_transport::PlainTransportRemoteParameters;
use mediasoup::srtp_parameters::{SrtpParameters, SrtpCryptoSuite};
// Calling connect() on a PlainTransport created with comedia unset, rtcpMux
// set and enableSrtp enabled.
plain_transport
.connect(PlainTransportRemoteParameters {
ip: Some("1.2.3.4".parse().unwrap()),
port: Some(9998),
rtcp_port: None,
srtp_parameters: Some(SrtpParameters {
crypto_suite: SrtpCryptoSuite::AesCm128HmacSha180,
key_base64: "ZnQ3eWJraDg0d3ZoYzM5cXN1Y2pnaHU5NWxrZTVv".to_string(),
}),
})
.await?;
sourcepub async fn set_max_incoming_bitrate(
&self,
bitrate: u32
) -> Result<(), RequestError>
pub async fn set_max_incoming_bitrate(
&self,
bitrate: u32
) -> Result<(), RequestError>
Set maximum incoming bitrate for media streams sent by the remote endpoint over this transport.
sourcepub fn tuple(&self) -> TransportTuple
pub fn tuple(&self) -> TransportTuple
The transport tuple. If RTCP-mux is enabled (rtcp_mux
is set), this tuple refers to both
RTP and RTCP.
Notes on usage
- Once the plain transport is created,
transport.tuple()
will contain information about itslocal_ip
,local_port
andprotocol
. - Information about
remote_ip
andremote_port
will be set:- after calling
connect()
method, or - via dynamic remote address detection when using
comedia
mode.
- after calling
sourcepub fn rtcp_tuple(&self) -> Option<TransportTuple>
pub fn rtcp_tuple(&self) -> Option<TransportTuple>
The transport tuple for RTCP. If RTCP-mux is enabled (rtcp_mux
is set), its value is
None
.
Notes on usage
- Once the plain transport is created (with RTCP-mux disabled),
transport.rtcp_tuple()
will contain information about itslocal_ip
,local_port
andprotocol
. - Information about
remote_ip
andremote_port
will be set:- after calling
connect()
method, or - via dynamic remote address detection when using
comedia
mode.
- after calling
sourcepub fn sctp_parameters(&self) -> Option<SctpParameters>
pub fn sctp_parameters(&self) -> Option<SctpParameters>
Current SCTP state. Or None
if SCTP is not enabled.
sourcepub fn sctp_state(&self) -> Option<SctpState>
pub fn sctp_state(&self) -> Option<SctpState>
Current SCTP state. Or None
if SCTP is not enabled.
sourcepub fn srtp_parameters(&self) -> Option<SrtpParameters>
pub fn srtp_parameters(&self) -> Option<SrtpParameters>
Local SRTP parameters representing the crypto suite and key material used to encrypt sending
RTP and SRTP. Note that, if comedia
mode is set, these local SRTP parameters may change
after calling connect()
with the remote SRTP parameters (to override the local SRTP crypto
suite with the one given in connect()
).
sourcepub fn on_tuple<F: Fn(&TransportTuple) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
pub fn on_tuple<F: Fn(&TransportTuple) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
Callback is called after the remote RTP origin has been discovered. Only if comedia
mode
was set.
sourcepub fn on_rtcp_tuple<F: Fn(&TransportTuple) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
pub fn on_rtcp_tuple<F: Fn(&TransportTuple) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
Callback is called after the remote RTCP origin has been discovered. Only if comedia
mode
was set and rtcp_mux
was not.
sourcepub fn on_sctp_state_change<F: Fn(SctpState) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
pub fn on_sctp_state_change<F: Fn(SctpState) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
Callback is called when the transport SCTP state changes.
sourcepub fn downgrade(&self) -> WeakPlainTransport
pub fn downgrade(&self) -> WeakPlainTransport
Downgrade PlainTransport
to WeakPlainTransport
instance.
Trait Implementations
sourceimpl Clone for PlainTransport
impl Clone for PlainTransport
sourcefn clone(&self) -> PlainTransport
fn clone(&self) -> PlainTransport
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 PlainTransport
impl Debug for PlainTransport
sourceimpl Transport for PlainTransport
impl Transport for PlainTransport
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 PlainTransport
impl TransportGeneric for PlainTransport
type Stat = PlainTransportStat
type Stat = PlainTransportStat
Stats data structure specific to each transport.
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. Each transport class produces a different set of statistics. Read more
Auto Trait Implementations
impl !RefUnwindSafe for PlainTransport
impl Send for PlainTransport
impl Sync for PlainTransport
impl Unpin for PlainTransport
impl !UnwindSafe for PlainTransport
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