pub struct WebRtcTransport { /* private fields */ }
Expand description
A WebRtcTransport
represents a network path negotiated by both, a WebRTC endpoint and
mediasoup, via ICE and DTLS procedures. A WebRtcTransport
may be used to receive media, to
send media or to both receive and send. There is no limitation in mediasoup. However, due to
their design, mediasoup-client and libmediasoupclient require separate WebRtcTransport
s for
sending and receiving.
§Notes on usage
The WebRtcTransport
implementation of mediasoup is
ICE Lite, meaning that it does not initiate
ICE connections but expects ICE Binding Requests from endpoints.
Implementations§
Source§impl WebRtcTransport
impl WebRtcTransport
Sourcepub async fn connect(
&self,
remote_parameters: WebRtcTransportRemoteParameters,
) -> Result<(), RequestError>
pub async fn connect( &self, remote_parameters: WebRtcTransportRemoteParameters, ) -> Result<(), RequestError>
Provide the WebRtcTransport
with remote parameters.
§Example
use mediasoup::data_structures::{DtlsParameters, DtlsRole, DtlsFingerprint};
use mediasoup::webrtc_transport::WebRtcTransportRemoteParameters;
// Calling connect() on a PlainTransport created with comedia and rtcp_mux set.
webrtc_transport
.connect(WebRtcTransportRemoteParameters {
dtls_parameters: DtlsParameters {
role: DtlsRole::Server,
fingerprints: vec![
DtlsFingerprint::Sha256 {
value: [
0xE5, 0xF5, 0xCA, 0xA7, 0x2D, 0x93, 0xE6, 0x16, 0xAC, 0x21, 0x09,
0x9F, 0x23, 0x51, 0x62, 0x8C, 0xD0, 0x66, 0xE9, 0x0C, 0x22, 0x54,
0x2B, 0x82, 0x0C, 0xDF, 0xE0, 0xC5, 0x2C, 0x7E, 0xCD, 0x53,
],
},
],
},
})
.await?;
Sourcepub fn webrtc_server(&self) -> &Option<WebRtcServer>
pub fn webrtc_server(&self) -> &Option<WebRtcServer>
WebRTC server used during creation of this transport.
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 async fn set_max_outgoing_bitrate(
&self,
bitrate: u32,
) -> Result<(), RequestError>
pub async fn set_max_outgoing_bitrate( &self, bitrate: u32, ) -> Result<(), RequestError>
Set maximum outgoing bitrate for media streams sent by the remote endpoint over this transport.
Sourcepub async fn set_min_outgoing_bitrate(
&self,
bitrate: u32,
) -> Result<(), RequestError>
pub async fn set_min_outgoing_bitrate( &self, bitrate: u32, ) -> Result<(), RequestError>
Set minimum outgoing bitrate for media streams sent by the remote endpoint over this transport.
Sourcepub fn ice_role(&self) -> IceRole
pub fn ice_role(&self) -> IceRole
Local ICE role. Due to the mediasoup ICE Lite design, this is always Controlled
.
Sourcepub fn ice_parameters(&self) -> &IceParameters
pub fn ice_parameters(&self) -> &IceParameters
Local ICE parameters.
Sourcepub fn ice_candidates(&self) -> &Vec<IceCandidate>
pub fn ice_candidates(&self) -> &Vec<IceCandidate>
Local ICE candidates.
Sourcepub fn ice_selected_tuple(&self) -> Option<TransportTuple>
pub fn ice_selected_tuple(&self) -> Option<TransportTuple>
The selected transport tuple if ICE is in Connected
or Completed
state. It is None
if
ICE is not established (no working candidate pair was found).
Sourcepub fn dtls_parameters(&self) -> DtlsParameters
pub fn dtls_parameters(&self) -> DtlsParameters
Local DTLS parameters.
Sourcepub fn dtls_state(&self) -> DtlsState
pub fn dtls_state(&self) -> DtlsState
Current DTLS state.
Sourcepub fn dtls_remote_cert(&self) -> Option<String>
pub fn dtls_remote_cert(&self) -> Option<String>
The remote certificate in PEM format. It is Some
once the DTLS state becomes Connected
.
§Notes on usage
The application may want to inspect the remote certificate for authorization purposes by using some certificates utility.
Sourcepub fn sctp_parameters(&self) -> Option<SctpParameters>
pub fn sctp_parameters(&self) -> Option<SctpParameters>
Local SCTP parameters. 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 async fn restart_ice(&self) -> Result<IceParameters, RequestError>
pub async fn restart_ice(&self) -> Result<IceParameters, RequestError>
Restarts the ICE layer by generating new local ICE parameters that must be signaled to the remote endpoint.
Sourcepub fn on_webrtc_server_close(
&self,
callback: Box<dyn FnOnce() + Send + 'static>,
) -> HandlerId
pub fn on_webrtc_server_close( &self, callback: Box<dyn FnOnce() + Send + 'static>, ) -> HandlerId
Callback is called when the WebRTC server used during creation of this transport is closed
for whatever reason.
The transport itself is also closed. on_transport_close
callbacks are also called on all
its producers and consumers.
Sourcepub fn on_ice_state_change<F: Fn(IceState) + Send + Sync + 'static>(
&self,
callback: F,
) -> HandlerId
pub fn on_ice_state_change<F: Fn(IceState) + Send + Sync + 'static>( &self, callback: F, ) -> HandlerId
Callback is called when the transport ICE state changes.
Sourcepub fn on_ice_selected_tuple_change<F: Fn(&TransportTuple) + Send + Sync + 'static>(
&self,
callback: F,
) -> HandlerId
pub fn on_ice_selected_tuple_change<F: Fn(&TransportTuple) + Send + Sync + 'static>( &self, callback: F, ) -> HandlerId
Callback is called after ICE state becomes Completed
and when the ICE selected tuple
changes.
Sourcepub fn on_dtls_state_change<F: Fn(DtlsState) + Send + Sync + 'static>(
&self,
callback: F,
) -> HandlerId
pub fn on_dtls_state_change<F: Fn(DtlsState) + Send + Sync + 'static>( &self, callback: F, ) -> HandlerId
Callback is called when the transport DTLS state changes.
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) -> WeakWebRtcTransport
pub fn downgrade(&self) -> WeakWebRtcTransport
Downgrade WebRtcTransport
to WeakWebRtcTransport
instance.
Trait Implementations§
Source§impl Clone for WebRtcTransport
impl Clone for WebRtcTransport
Source§fn clone(&self) -> WebRtcTransport
fn clone(&self) -> WebRtcTransport
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for WebRtcTransport
impl Debug for WebRtcTransport
Source§impl Transport for WebRtcTransport
impl Transport for WebRtcTransport
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.