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

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 the Router::create_plain_transport options) then connect() must be called with just the remote srtp_parameters.
  • If comedia is disabled, connect() must be eventually called with remote ip, port, optional rtcp_port (if RTCP-mux is not enabled) and optional srtp_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?;

Set maximum incoming bitrate for media streams sent by the remote endpoint over this transport.

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 its local_ip, local_port and protocol.
  • Information about remote_ip and remote_port will be set:
    • after calling connect() method, or
    • via dynamic remote address detection when using comedia mode.

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 its local_ip, local_port and protocol.
  • Information about remote_ip and remote_port will be set:
    • after calling connect() method, or
    • via dynamic remote address detection when using comedia mode.

Current SCTP state. Or None if SCTP is not enabled.

Current SCTP state. Or None if SCTP is not enabled.

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()).

Callback is called after the remote RTP origin has been discovered. Only if comedia mode was set.

Callback is called after the remote RTCP origin has been discovered. Only if comedia mode was set and rtcp_mux was not.

Callback is called when the transport SCTP state changes.

Downgrade PlainTransport to WeakPlainTransport instance.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Transport id.

Router to which transport belongs.

Custom application data.

Whether the transport is closed.

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

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

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

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

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

Callback is called when a new producer is created.

Callback is called when a new consumer is created.

Callback is called when a new data producer is created.

Callback is called when a new data consumer is created.

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

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

👎 Deprecated:

Use router().id() instead

Router id.

Stats data structure specific to each transport.

Returns current RTC statistics of the transport. Each transport class produces a different set of statistics. Read more

Dump Transport.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.