# Crate Documentation **Version:** 0.20.0 **Format Version:** 55 # Module `mediasoup` Rust port of [mediasoup](https://github.com/versatica/mediasoup) TypeScript library! For general information go to readme in repository. # For TypeScript users If you were using mediasoup in TypeScript before, most of the API should be familiar to you. However, this is not one-to-one port, API was adjusted to more idiomatic Rust style leveraging powerful type system and ownership system to make API more robust and more misuse-resistant. So you will find specific types in most places where plain strings were used, instead of `close()` you will see `Drop` implementation for major entities that will close everything gracefully when it goes out of scope. # Before you start This is very low-level **library**. Which means it doesn't come with a ready to use signaling mechanism or easy to customize app scaffold (see [design goals](https://github.com/versatica/mediasoup/tree/v3/rust/readme.md#design-goals)). It is recommended to visit mediasoup website and read [design overview](https://mediasoup.org/documentation/v3/mediasoup/design/) first. There are some requirements for building underlying C++ `mediasoup-worker`, please find them in [installation instructions](https://mediasoup.org/documentation/v3/mediasoup/installation/) # Examples There are some examples in `examples` and `examples-frontend` directories (for server- and client-side respectively), you may want to look at those to get a general idea of what API looks like and what needs to be done in what order (check WebSocket messages in browser DevTools for better understanding of what is happening under the hood). # How to start With that in mind, you want start with creating [`WorkerManager`](worker_manager::WorkerManager) instance and then 1 or more workers. Workers a responsible for low-level job of sending media and data back and forth. Each worker is backed by single-core C++ worker thread. On each worker you create one or more routers that enable injection, selection and forwarding of media and data through [`transport`] instances. There are a few different transports available, but most likely you'll want to use [`WebRtcTransport`](webrtc_transport::WebRtcTransport) most often. With transport created you can start creating [`Producer`](producer::Producer)s to send data to [`Router`](router::Router) and [`Consumer`](consumer::Consumer) instances to extract data from [`Router`](router::Router). Some of the more advanced cases involve multiple routers and even workers that can user more than one core on the machine or even scale beyond single host. Check [scalability page](https://mediasoup.org/documentation/v3/scalability/) of the official documentation. Please check integration and unit tests for usage examples, they cover all major functionality and are a good place to start until we have demo apps built in Rust). ## Modules ## Module `prelude` mediasoup prelude. Re-exports commonly used traits and structs from this crate. # Examples Import the prelude with: ``` # #[allow(unused_imports)] use mediasoup::prelude::*; ``` ```rust pub mod prelude { /* ... */ } ``` ### Re-exports #### Re-export `WorkerManager` ```rust pub use crate::worker_manager::WorkerManager; ``` #### Re-export `Worker` ```rust pub use crate::worker::Worker; ``` #### Re-export `WorkerSettings` ```rust pub use crate::worker::WorkerSettings; ``` #### Re-export `PipeDataProducerToRouterError` ```rust pub use crate::router::PipeDataProducerToRouterError; ``` #### Re-export `PipeDataProducerToRouterPair` ```rust pub use crate::router::PipeDataProducerToRouterPair; ``` #### Re-export `PipeProducerToRouterError` ```rust pub use crate::router::PipeProducerToRouterError; ``` #### Re-export `PipeProducerToRouterPair` ```rust pub use crate::router::PipeProducerToRouterPair; ``` #### Re-export `PipeToRouterOptions` ```rust pub use crate::router::PipeToRouterOptions; ``` #### Re-export `Router` ```rust pub use crate::router::Router; ``` #### Re-export `RouterOptions` ```rust pub use crate::router::RouterOptions; ``` #### Re-export `WebRtcServer` ```rust pub use crate::webrtc_server::WebRtcServer; ``` #### Re-export `WebRtcServerId` ```rust pub use crate::webrtc_server::WebRtcServerId; ``` #### Re-export `WebRtcServerListenInfos` ```rust pub use crate::webrtc_server::WebRtcServerListenInfos; ``` #### Re-export `WebRtcServerOptions` ```rust pub use crate::webrtc_server::WebRtcServerOptions; ``` #### Re-export `DirectTransport` ```rust pub use crate::direct_transport::DirectTransport; ``` #### Re-export `DirectTransportOptions` ```rust pub use crate::direct_transport::DirectTransportOptions; ``` #### Re-export `WeakDirectTransport` ```rust pub use crate::direct_transport::WeakDirectTransport; ``` #### Re-export `PipeTransport` ```rust pub use crate::pipe_transport::PipeTransport; ``` #### Re-export `PipeTransportOptions` ```rust pub use crate::pipe_transport::PipeTransportOptions; ``` #### Re-export `PipeTransportRemoteParameters` ```rust pub use crate::pipe_transport::PipeTransportRemoteParameters; ``` #### Re-export `WeakPipeTransport` ```rust pub use crate::pipe_transport::WeakPipeTransport; ``` #### Re-export `PlainTransport` ```rust pub use crate::plain_transport::PlainTransport; ``` #### Re-export `PlainTransportOptions` ```rust pub use crate::plain_transport::PlainTransportOptions; ``` #### Re-export `PlainTransportRemoteParameters` ```rust pub use crate::plain_transport::PlainTransportRemoteParameters; ``` #### Re-export `WeakPlainTransport` ```rust pub use crate::plain_transport::WeakPlainTransport; ``` #### Re-export `ConsumeDataError` ```rust pub use crate::transport::ConsumeDataError; ``` #### Re-export `ConsumeError` ```rust pub use crate::transport::ConsumeError; ``` #### Re-export `ProduceDataError` ```rust pub use crate::transport::ProduceDataError; ``` #### Re-export `ProduceError` ```rust pub use crate::transport::ProduceError; ``` #### Re-export `Transport` ```rust pub use crate::transport::Transport; ``` #### Re-export `TransportGeneric` ```rust pub use crate::transport::TransportGeneric; ``` #### Re-export `TransportId` ```rust pub use crate::transport::TransportId; ``` #### Re-export `WebRtcTransport` ```rust pub use crate::webrtc_transport::WebRtcTransport; ``` #### Re-export `WebRtcTransportListenInfos` ```rust pub use crate::webrtc_transport::WebRtcTransportListenInfos; ``` #### Re-export `WebRtcTransportOptions` ```rust pub use crate::webrtc_transport::WebRtcTransportOptions; ``` #### Re-export `WebRtcTransportRemoteParameters` ```rust pub use crate::webrtc_transport::WebRtcTransportRemoteParameters; ``` #### Re-export `ActiveSpeakerObserver` ```rust pub use crate::active_speaker_observer::ActiveSpeakerObserver; ``` #### Re-export `ActiveSpeakerObserverDominantSpeaker` ```rust pub use crate::active_speaker_observer::ActiveSpeakerObserverDominantSpeaker; ``` #### Re-export `ActiveSpeakerObserverOptions` ```rust pub use crate::active_speaker_observer::ActiveSpeakerObserverOptions; ``` #### Re-export `WeakActiveSpeakerObserver` ```rust pub use crate::active_speaker_observer::WeakActiveSpeakerObserver; ``` #### Re-export `AudioLevelObserver` ```rust pub use crate::audio_level_observer::AudioLevelObserver; ``` #### Re-export `AudioLevelObserverOptions` ```rust pub use crate::audio_level_observer::AudioLevelObserverOptions; ``` #### Re-export `AudioLevelObserverVolume` ```rust pub use crate::audio_level_observer::AudioLevelObserverVolume; ``` #### Re-export `WeakAudioLevelObserver` ```rust pub use crate::audio_level_observer::WeakAudioLevelObserver; ``` #### Re-export `RtpObserver` ```rust pub use crate::rtp_observer::RtpObserver; ``` #### Re-export `RtpObserverAddProducerOptions` ```rust pub use crate::rtp_observer::RtpObserverAddProducerOptions; ``` #### Re-export `RtpObserverId` ```rust pub use crate::rtp_observer::RtpObserverId; ``` #### Re-export `Consumer` ```rust pub use crate::consumer::Consumer; ``` #### Re-export `ConsumerId` ```rust pub use crate::consumer::ConsumerId; ``` #### Re-export `ConsumerLayers` ```rust pub use crate::consumer::ConsumerLayers; ``` #### Re-export `ConsumerOptions` ```rust pub use crate::consumer::ConsumerOptions; ``` #### Re-export `WeakConsumer` ```rust pub use crate::consumer::WeakConsumer; ``` #### Re-export `DataConsumer` ```rust pub use crate::data_consumer::DataConsumer; ``` #### Re-export `DataConsumerId` ```rust pub use crate::data_consumer::DataConsumerId; ``` #### Re-export `DataConsumerOptions` ```rust pub use crate::data_consumer::DataConsumerOptions; ``` #### Re-export `DirectDataConsumer` ```rust pub use crate::data_consumer::DirectDataConsumer; ``` #### Re-export `RegularDataConsumer` ```rust pub use crate::data_consumer::RegularDataConsumer; ``` #### Re-export `WeakDataConsumer` ```rust pub use crate::data_consumer::WeakDataConsumer; ``` #### Re-export `DataProducer` ```rust pub use crate::data_producer::DataProducer; ``` #### Re-export `DataProducerId` ```rust pub use crate::data_producer::DataProducerId; ``` #### Re-export `DataProducerOptions` ```rust pub use crate::data_producer::DataProducerOptions; ``` #### Re-export `DirectDataProducer` ```rust pub use crate::data_producer::DirectDataProducer; ``` #### Re-export `NonClosingDataProducer` ```rust pub use crate::data_producer::NonClosingDataProducer; ``` #### Re-export `RegularDataProducer` ```rust pub use crate::data_producer::RegularDataProducer; ``` #### Re-export `WeakDataProducer` ```rust pub use crate::data_producer::WeakDataProducer; ``` #### Re-export `Producer` ```rust pub use crate::producer::Producer; ``` #### Re-export `ProducerId` ```rust pub use crate::producer::ProducerId; ``` #### Re-export `ProducerOptions` ```rust pub use crate::producer::ProducerOptions; ``` #### Re-export `WeakProducer` ```rust pub use crate::producer::WeakProducer; ``` #### Re-export `AppData` ```rust pub use mediasoup_types::data_structures::AppData; ``` #### Re-export `DtlsParameters` ```rust pub use mediasoup_types::data_structures::DtlsParameters; ``` #### Re-export `IceCandidate` ```rust pub use mediasoup_types::data_structures::IceCandidate; ``` #### Re-export `IceParameters` ```rust pub use mediasoup_types::data_structures::IceParameters; ``` #### Re-export `ListenInfo` ```rust pub use mediasoup_types::data_structures::ListenInfo; ``` #### Re-export `Protocol` ```rust pub use mediasoup_types::data_structures::Protocol; ``` #### Re-export `WebRtcMessage` ```rust pub use mediasoup_types::data_structures::WebRtcMessage; ``` #### Re-export `MediaKind` ```rust pub use mediasoup_types::rtp_parameters::MediaKind; ``` #### Re-export `MimeTypeAudio` ```rust pub use mediasoup_types::rtp_parameters::MimeTypeAudio; ``` #### Re-export `MimeTypeVideo` ```rust pub use mediasoup_types::rtp_parameters::MimeTypeVideo; ``` #### Re-export `RtcpFeedback` ```rust pub use mediasoup_types::rtp_parameters::RtcpFeedback; ``` #### Re-export `RtcpParameters` ```rust pub use mediasoup_types::rtp_parameters::RtcpParameters; ``` #### Re-export `RtpCapabilities` ```rust pub use mediasoup_types::rtp_parameters::RtpCapabilities; ``` #### Re-export `RtpCapabilitiesFinalized` ```rust pub use mediasoup_types::rtp_parameters::RtpCapabilitiesFinalized; ``` #### Re-export `RtpCodecCapability` ```rust pub use mediasoup_types::rtp_parameters::RtpCodecCapability; ``` #### Re-export `RtpCodecParameters` ```rust pub use mediasoup_types::rtp_parameters::RtpCodecParameters; ``` #### Re-export `RtpCodecParametersParameters` ```rust pub use mediasoup_types::rtp_parameters::RtpCodecParametersParameters; ``` #### Re-export `RtpEncodingParameters` ```rust pub use mediasoup_types::rtp_parameters::RtpEncodingParameters; ``` #### Re-export `RtpEncodingParametersRtx` ```rust pub use mediasoup_types::rtp_parameters::RtpEncodingParametersRtx; ``` #### Re-export `RtpHeaderExtensionParameters` ```rust pub use mediasoup_types::rtp_parameters::RtpHeaderExtensionParameters; ``` #### Re-export `RtpHeaderExtensionUri` ```rust pub use mediasoup_types::rtp_parameters::RtpHeaderExtensionUri; ``` #### Re-export `RtpParameters` ```rust pub use mediasoup_types::rtp_parameters::RtpParameters; ``` #### Re-export `SctpStreamParameters` ```rust pub use mediasoup_types::sctp_parameters::SctpStreamParameters; ``` #### Re-export `SrtpCryptoSuite` ```rust pub use mediasoup_types::srtp_parameters::SrtpCryptoSuite; ``` ## Module `router` A router enables injection, selection and forwarding of media streams through [`Transport`] instances created on it. Developers may think of a mediasoup router as if it were a "multi-party conference room", although mediasoup is much more low level than that and doesn't constrain itself to specific high level use cases (for instance, a "multi-party conference room" could involve various mediasoup routers, even in different physicals hosts). ```rust pub mod router { /* ... */ } ``` ### Types #### Struct `RouterId` [`Router`] identifier. ```rust pub struct RouterId(/* private field */); ``` ##### Fields | Index | Type | Documentation | |-------|------|---------------| | 0 | `private` | *Private field* | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> RouterId { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Copy** - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Deserialize** - ```rust fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result::Error> where __D: _serde::Deserializer<''de> { /* ... */ } ``` - **DeserializeOwned** - **Display** - ```rust fn fmt(self: &Self, f: &mut std::fmt::Formatter<''_>) -> std::fmt::Result { /* ... */ } ``` - **Eq** - **Equivalent** - ```rust fn equivalent(self: &Self, key: &K) -> bool { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - ```rust fn from(id: RouterId) -> Self { /* ... */ } ``` - **FromStr** - ```rust fn from_str(s: &str) -> Result::Err> { /* ... */ } ``` - **Hash** - ```rust fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ } ``` - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **Ord** - ```rust fn cmp(self: &Self, other: &RouterId) -> $crate::cmp::Ordering { /* ... */ } ``` - **PartialEq** - ```rust fn eq(self: &Self, other: &RouterId) -> bool { /* ... */ } ``` - **PartialOrd** - ```rust fn partial_cmp(self: &Self, other: &RouterId) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ } ``` - **RefUnwindSafe** - **Send** - **Serialize** - ```rust fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error> where __S: _serde::Serializer { /* ... */ } ``` - **StructuralPartialEq** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `RouterOptions` **Attributes:** - `NonExhaustive` [`Router`] options. # Notes on usage * Feature codecs such as `RTX` MUST NOT be placed into the mediaCodecs list. * If `preferred_payload_type` is given in a [`RtpCodecCapability`] (although it's unnecessary) it's extremely recommended to use a value in the 96-127 range. ```rust pub struct RouterOptions { pub media_codecs: Vec, pub app_data: mediasoup_types::data_structures::AppData, } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | `media_codecs` | `Vec` | Router media codecs. | | `app_data` | `mediasoup_types::data_structures::AppData` | Custom application data. | ##### Implementations ###### Methods - ```rust pub fn new(media_codecs: Vec) -> Self { /* ... */ } ``` Create router options with given list of declared media codecs. ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Default** - ```rust fn default() -> Self { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `PipeToRouterOptions` Options used for piping media or data producer to into another router on the same host. # Notes on usage * SCTP arguments will only apply the first time the underlying transports are created. ```rust pub struct PipeToRouterOptions { pub router: Router, pub enable_sctp: bool, pub num_sctp_streams: mediasoup_types::sctp_parameters::NumSctpStreams, pub enable_rtx: bool, pub enable_srtp: bool, // Some fields omitted } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | `router` | `Router` | Target Router instance. | | `enable_sctp` | `bool` | Create a SCTP association.

Default `true`. | | `num_sctp_streams` | `mediasoup_types::sctp_parameters::NumSctpStreams` | SCTP streams number. | | `enable_rtx` | `bool` | Enable RTX and NACK for RTP retransmission.

Default `false`. | | `enable_srtp` | `bool` | Enable SRTP.

Default `false`. | | *private fields* | ... | *Some fields have been omitted* | ##### Implementations ###### Methods - ```rust pub fn new(router: Router) -> Self { /* ... */ } ``` Crate pipe options for piping into given local router. ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `PipeProducerToRouterPair` Container for pipe consumer and pipe producer pair. # Notes on usage Pipe consumer and Pipe producer will not be closed on drop, to control this manually get pipe producer out of non-closing variant with [`PipedProducer::into_inner()`] call, otherwise pipe consumer and pipe producer lifetime will be tied to source producer lifetime. Pipe consumer is always tied to the lifetime of pipe producer. ```rust pub struct PipeProducerToRouterPair { pub pipe_consumer: crate::consumer::Consumer, pub pipe_producer: crate::producer::PipedProducer, } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | `pipe_consumer` | `crate::consumer::Consumer` | The Consumer created in the current Router. | | `pipe_producer` | `crate::producer::PipedProducer` | The Producer created in the target Router, get regular instance with
[`PipedProducer::into_inner()`] call. | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `PipeProducerToRouterError` Error that caused [`Router::pipe_producer_to_router()`] to fail. ```rust pub enum PipeProducerToRouterError { SameRouter, ProducerNotFound(crate::producer::ProducerId), TransportFailed(crate::worker::RequestError), ConsumeFailed(crate::transport::ConsumeError), ProduceFailed(crate::transport::ProduceError), } ``` ##### Variants ###### `SameRouter` Destination router must be different ###### `ProducerNotFound` Producer with specified id not found Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `crate::producer::ProducerId` | | ###### `TransportFailed` Failed to create or connect Pipe transport Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `crate::worker::RequestError` | | ###### `ConsumeFailed` Failed to consume Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `crate::transport::ConsumeError` | | ###### `ProduceFailed` Failed to produce Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `crate::transport::ProduceError` | | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Display** - ```rust fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ } ``` - **Error** - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - ```rust fn from(error: RequestError) -> Self { /* ... */ } ``` - ```rust fn from(error: ConsumeError) -> Self { /* ... */ } ``` - ```rust fn from(error: ProduceError) -> Self { /* ... */ } ``` - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `PipeDataProducerToRouterPair` Container for pipe data consumer and pipe data producer pair. # Notes on usage Pipe data consumer and pipe data producer will not be closed on drop, to control this manually get pipe data producer out of non-closing variant with [`NonClosingDataProducer::into_inner()`] call, otherwise pipe data consumer and pipe data producer lifetime will be tied to source data producer lifetime. Pipe data consumer is always tied to the lifetime of pipe data producer. ```rust pub struct PipeDataProducerToRouterPair { pub pipe_data_consumer: crate::data_consumer::DataConsumer, pub pipe_data_producer: crate::data_producer::NonClosingDataProducer, } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | `pipe_data_consumer` | `crate::data_consumer::DataConsumer` | The DataConsumer created in the current Router. | | `pipe_data_producer` | `crate::data_producer::NonClosingDataProducer` | The DataProducer created in the target Router, get regular instance with
[`NonClosingDataProducer::into_inner()`] call. | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `PipeDataProducerToRouterError` Error that caused [`Router::pipe_data_producer_to_router()`] to fail. ```rust pub enum PipeDataProducerToRouterError { SameRouter, DataProducerNotFound(crate::data_producer::DataProducerId), TransportFailed(crate::worker::RequestError), ConsumeFailed(crate::transport::ConsumeDataError), ProduceFailed(crate::transport::ProduceDataError), } ``` ##### Variants ###### `SameRouter` Destination router must be different ###### `DataProducerNotFound` Data producer with specified id not found Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `crate::data_producer::DataProducerId` | | ###### `TransportFailed` Failed to create or connect Pipe transport Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `crate::worker::RequestError` | | ###### `ConsumeFailed` Failed to consume Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `crate::transport::ConsumeDataError` | | ###### `ProduceFailed` Failed to produce Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `crate::transport::ProduceDataError` | | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Display** - ```rust fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ } ``` - **Error** - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - ```rust fn from(error: RequestError) -> Self { /* ... */ } ``` - ```rust fn from(error: ConsumeDataError) -> Self { /* ... */ } ``` - ```rust fn from(error: ProduceDataError) -> Self { /* ... */ } ``` - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `UpdateMediaCodecsError` Error that caused [`Router::update_media_codecs`] to fail. ```rust pub enum UpdateMediaCodecsError { FailedRtpCapabilitiesGeneration(ortc::RtpCapabilitiesError), } ``` ##### Variants ###### `FailedRtpCapabilitiesGeneration` RTP capabilities generation error Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `ortc::RtpCapabilitiesError` | | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Display** - ```rust fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ } ``` - **Error** - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `NewTransport` New transport that was just created. ```rust pub enum NewTransport<''a> { Direct(&''a crate::direct_transport::DirectTransport), Pipe(&''a crate::pipe_transport::PipeTransport), Plain(&''a crate::plain_transport::PlainTransport), WebRtc(&''a crate::webrtc_transport::WebRtcTransport), } ``` ##### Variants ###### `Direct` Direct transport Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `&''a crate::direct_transport::DirectTransport` | | ###### `Pipe` Pipe transport Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `&''a crate::pipe_transport::PipeTransport` | | ###### `Plain` Plain transport Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `&''a crate::plain_transport::PlainTransport` | | ###### `WebRtc` WebRtc transport Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `&''a crate::webrtc_transport::WebRtcTransport` | | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Deref** - ```rust fn deref(self: &Self) -> &::Target { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **Receiver** - **RefUnwindSafe** - **Send** - **Sync** - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `NewRtpObserver` New RTP observer that was just created. ```rust pub enum NewRtpObserver<''a> { AudioLevel(&''a crate::audio_level_observer::AudioLevelObserver), ActiveSpeaker(&''a crate::active_speaker_observer::ActiveSpeakerObserver), } ``` ##### Variants ###### `AudioLevel` Audio level observer Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `&''a crate::audio_level_observer::AudioLevelObserver` | | ###### `ActiveSpeaker` Active speaker observer Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `&''a crate::active_speaker_observer::ActiveSpeakerObserver` | | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Deref** - ```rust fn deref(self: &Self) -> &::Target { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **Receiver** - **RefUnwindSafe** - **Send** - **Sync** - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `Router` **Attributes:** - `MustUse { reason: Some("Router will be closed on drop, make sure to keep it around for as long as needed") }` A router enables injection, selection and forwarding of media streams through [`Transport`] instances created on it. Developers may think of a mediasoup router as if it were a "multi-party conference room", although mediasoup is much more low level than that and doesn't constrain itself to specific high level use cases (for instance, a "multi-party conference room" could involve various mediasoup routers, even in different physicals hosts). ```rust pub struct Router { // Some fields omitted } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | *private fields* | ... | *Some fields have been omitted* | ##### Implementations ###### Methods - ```rust pub fn id(self: &Self) -> RouterId { /* ... */ } ``` Router id. - ```rust pub fn worker(self: &Self) -> &Worker { /* ... */ } ``` Worker to which router belongs. - ```rust pub fn app_data(self: &Self) -> &AppData { /* ... */ } ``` Custom application data. - ```rust pub fn closed(self: &Self) -> bool { /* ... */ } ``` Whether router is closed. - ```rust pub fn rtp_capabilities(self: &Self) -> RtpCapabilitiesFinalized { /* ... */ } ``` RTP capabilities of the router. These capabilities are typically needed by mediasoup clients - ```rust pub async fn create_direct_transport(self: &Self, direct_transport_options: DirectTransportOptions) -> Result { /* ... */ } ``` Create a [`DirectTransport`]. - ```rust pub async fn create_webrtc_transport(self: &Self, webrtc_transport_options: WebRtcTransportOptions) -> Result { /* ... */ } ``` Create a [`WebRtcTransport`]. - ```rust pub async fn create_pipe_transport(self: &Self, pipe_transport_options: PipeTransportOptions) -> Result { /* ... */ } ``` Create a [`PipeTransport`]. - ```rust pub async fn create_plain_transport(self: &Self, plain_transport_options: PlainTransportOptions) -> Result { /* ... */ } ``` Create a [`PlainTransport`]. - ```rust pub async fn create_audio_level_observer(self: &Self, audio_level_observer_options: AudioLevelObserverOptions) -> Result { /* ... */ } ``` Create an [`AudioLevelObserver`]. - ```rust pub async fn create_active_speaker_observer(self: &Self, active_speaker_observer_options: ActiveSpeakerObserverOptions) -> Result { /* ... */ } ``` Create an [`ActiveSpeakerObserver`]. - ```rust pub async fn pipe_producer_to_router(self: &Self, producer_id: ProducerId, pipe_to_router_options: PipeToRouterOptions) -> Result { /* ... */ } ``` Pipes [`Producer`] with the given `producer_id` into another [`Router`] on same host. - ```rust pub async fn pipe_data_producer_to_router(self: &Self, data_producer_id: DataProducerId, pipe_to_router_options: PipeToRouterOptions) -> Result { /* ... */ } ``` Pipes [`DataProducer`] with the given `data_producer_id` into another [`Router`] on same - ```rust pub fn can_consume(self: &Self, producer_id: &ProducerId, rtp_capabilities: &RtpCapabilities) -> bool { /* ... */ } ``` Check whether the given RTP capabilities are valid to consume the given producer. - ```rust pub fn update_media_codecs(self: &mut Self, media_codecs: Vec) -> Result<(), UpdateMediaCodecsError> { /* ... */ } ``` Update the Router media codecs. Once called, the return value of - ```rust pub fn on_new_transport) + Send + Sync + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when a new transport is created. - ```rust pub fn on_new_rtp_observer) + Send + Sync + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when a new RTP observer is created. - ```rust pub fn on_worker_close(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when the worker this router belongs to is closed for whatever reason. - ```rust pub fn on_close(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when the router is closed for whatever reason. ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> Router { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** ## Module `supported_rtp_capabilities` RTP capabilities supported by mediasoup. ```rust pub mod supported_rtp_capabilities { /* ... */ } ``` ### Functions #### Function `get_supported_rtp_capabilities` **Attributes:** - `MustUse { reason: None }` Get a mediasoup supported RTP capabilities. # Notes on usage Those are NOT the RTP capabilities needed by mediasoup-client's [device.load()](https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load) and libmediasoupclient's [device.Load()](https://mediasoup.org/documentation/v3/libmediasoupclient/api/#device-Load) methods. There you must use [`Router::rtp_capabilities`](crate::router::Router::rtp_capabilities) getter instead. ```rust pub fn get_supported_rtp_capabilities() -> mediasoup_types::rtp_parameters::RtpCapabilities { /* ... */ } ``` ## Module `webrtc_server` A WebRTC server brings the ability to listen on a single UDP/TCP port for multiple `WebRtcTransport`s. A WebRTC server exists within the context of a [`Worker`], meaning that if your app launches N workers it also needs to create N WebRTC servers listening on different ports (to not collide). The WebRTC transport implementation of mediasoup is [ICE Lite](https://tools.ietf.org/html/rfc5245#section-2.7), meaning that it does not initiate ICE connections but expects ICE Binding Requests from endpoints. ```rust pub mod webrtc_server { /* ... */ } ``` ### Types #### Struct `WebRtcServerId` [`WebRtcServer`] identifier. ```rust pub struct WebRtcServerId(/* private field */); ``` ##### Fields | Index | Type | Documentation | |-------|------|---------------| | 0 | `private` | *Private field* | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WebRtcServerId { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Copy** - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Deserialize** - ```rust fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result::Error> where __D: _serde::Deserializer<''de> { /* ... */ } ``` - **DeserializeOwned** - **Display** - ```rust fn fmt(self: &Self, f: &mut std::fmt::Formatter<''_>) -> std::fmt::Result { /* ... */ } ``` - **Eq** - **Equivalent** - ```rust fn equivalent(self: &Self, key: &K) -> bool { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - ```rust fn from(id: WebRtcServerId) -> Self { /* ... */ } ``` - **FromStr** - ```rust fn from_str(s: &str) -> Result::Err> { /* ... */ } ``` - **Hash** - ```rust fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ } ``` - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **Ord** - ```rust fn cmp(self: &Self, other: &WebRtcServerId) -> $crate::cmp::Ordering { /* ... */ } ``` - **PartialEq** - ```rust fn eq(self: &Self, other: &WebRtcServerId) -> bool { /* ... */ } ``` - **PartialOrd** - ```rust fn partial_cmp(self: &Self, other: &WebRtcServerId) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ } ``` - **RefUnwindSafe** - **Send** - **Serialize** - ```rust fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error> where __S: _serde::Serializer { /* ... */ } ``` - **StructuralPartialEq** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `WebRtcServerListenInfos` Struct that protects an invariant of having non-empty list of listen infos. ```rust pub struct WebRtcServerListenInfos(/* private field */); ``` ##### Fields | Index | Type | Documentation | |-------|------|---------------| | 0 | `private` | *Private field* | ##### Implementations ###### Methods - ```rust pub fn new(listen_info: ListenInfo) -> Self { /* ... */ } ``` Create WebRTC server listen infos with given info populated initially. - ```rust pub fn insert(self: Self, listen_info: ListenInfo) -> Self { /* ... */ } ``` Insert another listen info. ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WebRtcServerListenInfos { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Deref** - ```rust fn deref(self: &Self) -> &::Target { /* ... */ } ``` - **Eq** - **Equivalent** - ```rust fn equivalent(self: &Self, key: &K) -> bool { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **PartialEq** - ```rust fn eq(self: &Self, other: &WebRtcServerListenInfos) -> bool { /* ... */ } ``` - **Receiver** - **RefUnwindSafe** - **Send** - **Serialize** - ```rust fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error> where __S: _serde::Serializer { /* ... */ } ``` - **StructuralPartialEq** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - ```rust fn try_from(listen_infos: Vec) -> Result::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `EmptyListError` **Attributes:** - `Other("#[error(\"Empty list of listen infos provided, should have at least one element\")]")` Empty list of listen infos provided, should have at least one element. ```rust pub struct EmptyListError; ``` ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Display** - ```rust fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ } ``` - **Eq** - **Equivalent** - ```rust fn equivalent(self: &Self, key: &K) -> bool { /* ... */ } ``` - **Error** - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **PartialEq** - ```rust fn eq(self: &Self, other: &EmptyListError) -> bool { /* ... */ } ``` - **RefUnwindSafe** - **Send** - **StructuralPartialEq** - **Sync** - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `WebRtcServerOptions` **Attributes:** - `NonExhaustive` [`WebRtcServer`] options. ```rust pub struct WebRtcServerOptions { pub listen_infos: WebRtcServerListenInfos, pub app_data: mediasoup_types::data_structures::AppData, } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | `listen_infos` | `WebRtcServerListenInfos` | Listening infos in order of preference (first one is the preferred one). | | `app_data` | `mediasoup_types::data_structures::AppData` | Custom application data. | ##### Implementations ###### Methods - ```rust pub fn new(listen_infos: WebRtcServerListenInfos) -> Self { /* ... */ } ``` Create [`WebRtcServer`] options with given listen infos. ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `WebRtcServer` A WebRTC server brings the ability to listen on a single UDP/TCP port for multiple `WebRtcTransport`s. A WebRTC server exists within the context of a [`Worker`], meaning that if your app launches N workers it also needs to create N WebRTC servers listening on different ports (to not collide). The WebRTC transport implementation of mediasoup is [ICE Lite](https://tools.ietf.org/html/rfc5245#section-2.7), meaning that it does not initiate ICE connections but expects ICE Binding Requests from endpoints. ```rust pub struct WebRtcServer { // Some fields omitted } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | *private fields* | ... | *Some fields have been omitted* | ##### Implementations ###### Methods - ```rust pub fn id(self: &Self) -> WebRtcServerId { /* ... */ } ``` Router id. - ```rust pub fn worker(self: &Self) -> &Worker { /* ... */ } ``` Worker to which WebRTC server belongs. - ```rust pub fn app_data(self: &Self) -> &AppData { /* ... */ } ``` Custom application data. - ```rust pub fn closed(self: &Self) -> bool { /* ... */ } ``` Whether WebRTC server is closed. - ```rust pub fn on_worker_close(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when the worker this WebRTC server belongs to is closed for whatever - ```rust pub fn on_new_webrtc_transport(self: &Self, callback: F) -> HandlerId where F: Fn(&WebRtcTransport) + Send + ''static { /* ... */ } ``` Callback is called when new [`WebRtcTransport`] is added that uses this WebRTC server. - ```rust pub fn on_close(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when the WebRTC server is closed for whatever reason. ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WebRtcServer { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** ## Module `worker` A worker represents a mediasoup C++ thread that runs on a single CPU core and handles [`Router`] instances. ```rust pub mod worker { /* ... */ } ``` ### Types #### Struct `WorkerId` Worker identifier. ```rust pub struct WorkerId(/* private field */); ``` ##### Fields | Index | Type | Documentation | |-------|------|---------------| | 0 | `private` | *Private field* | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WorkerId { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Copy** - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Deserialize** - ```rust fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result::Error> where __D: _serde::Deserializer<''de> { /* ... */ } ``` - **DeserializeOwned** - **Display** - ```rust fn fmt(self: &Self, f: &mut std::fmt::Formatter<''_>) -> std::fmt::Result { /* ... */ } ``` - **Eq** - **Equivalent** - ```rust fn equivalent(self: &Self, key: &K) -> bool { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - ```rust fn from(id: WorkerId) -> Self { /* ... */ } ``` - **FromStr** - ```rust fn from_str(s: &str) -> Result::Err> { /* ... */ } ``` - **Hash** - ```rust fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ } ``` - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **Ord** - ```rust fn cmp(self: &Self, other: &WorkerId) -> $crate::cmp::Ordering { /* ... */ } ``` - **PartialEq** - ```rust fn eq(self: &Self, other: &WorkerId) -> bool { /* ... */ } ``` - **PartialOrd** - ```rust fn partial_cmp(self: &Self, other: &WorkerId) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ } ``` - **RefUnwindSafe** - **Send** - **Serialize** - ```rust fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error> where __S: _serde::Serializer { /* ... */ } ``` - **StructuralPartialEq** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `RequestError` Error that caused request to mediasoup-worker request to fail. ```rust pub enum RequestError { ChannelClosed, TimedOut, Response { reason: String, }, FailedToParse { error: String, }, NoData, ResponseConversion(Box), } ``` ##### Variants ###### `ChannelClosed` Channel already closed. ###### `TimedOut` Request timed out. ###### `Response` Received response error. Fields: | Name | Type | Documentation | |------|------|---------------| | `reason` | `String` | Error reason. | ###### `FailedToParse` Failed to parse response from worker. Fields: | Name | Type | Documentation | |------|------|---------------| | `error` | `String` | Error reason. | ###### `NoData` Worker did not return any data in response. ###### `ResponseConversion` Response conversion error. Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `Box` | | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Display** - ```rust fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ } ``` - **Error** - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - ```rust fn from(error: RequestError) -> Self { /* ... */ } ``` - ```rust fn from(error: RequestError) -> Self { /* ... */ } ``` - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `WorkerLogLevel` **Attributes:** - `Other("#[serde(rename_all = \"lowercase\")]")` Logging level for logs generated by the media worker thread (check the [Debugging](https://mediasoup.org/documentation/v3/mediasoup/debugging/) documentation on TypeScript implementation and generic [Rust-specific](https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/log.html) [docs](https://docs.rs/env_logger)). Default [`WorkerLogLevel::Error`]. ```rust pub enum WorkerLogLevel { Debug, Warn, Error, None, } ``` ##### Variants ###### `Debug` Log all severities. ###### `Warn` Log "warn" and "error" severities. ###### `Error` Log "error" severity. ###### `None` Do not log anything. ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WorkerLogLevel { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Copy** - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Default** - ```rust fn default() -> Self { /* ... */ } ``` - **Eq** - **Equivalent** - ```rust fn equivalent(self: &Self, key: &K) -> bool { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Hash** - ```rust fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ } ``` - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **Ord** - ```rust fn cmp(self: &Self, other: &WorkerLogLevel) -> $crate::cmp::Ordering { /* ... */ } ``` - **PartialEq** - ```rust fn eq(self: &Self, other: &WorkerLogLevel) -> bool { /* ... */ } ``` - **PartialOrd** - ```rust fn partial_cmp(self: &Self, other: &WorkerLogLevel) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ } ``` - **RefUnwindSafe** - **Send** - **Serialize** - ```rust fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error> where __S: _serde::Serializer { /* ... */ } ``` - **StructuralPartialEq** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `WorkerLogTag` **Attributes:** - `Other("#[serde(rename_all = \"lowercase\")]")` Log tags for debugging. Check the meaning of each available tag in the [Debugging](https://mediasoup.org/documentation/v3/mediasoup/debugging/) documentation. ```rust pub enum WorkerLogTag { Info, Ice, Dtls, Rtp, Srtp, Rtcp, Rtx, Bwe, Score, Simulcast, Svc, Sctp, Message, } ``` ##### Variants ###### `Info` Logs about software/library versions, configuration and process information. ###### `Ice` Logs about ICE. ###### `Dtls` Logs about DTLS. ###### `Rtp` Logs about RTP. ###### `Srtp` Logs about SRTP encryption/decryption. ###### `Rtcp` Logs about RTCP. ###### `Rtx` Logs about RTP retransmission, including NACK/PLI/FIR. ###### `Bwe` Logs about transport bandwidth estimation. ###### `Score` Logs related to the scores of Producers and Consumers. ###### `Simulcast` Logs about video simulcast. ###### `Svc` Logs about video SVC. ###### `Sctp` Logs about SCTP (DataChannel). ###### `Message` Logs about messages (can be SCTP messages or direct messages). ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WorkerLogTag { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Copy** - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Eq** - **Equivalent** - ```rust fn equivalent(self: &Self, key: &K) -> bool { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Hash** - ```rust fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ } ``` - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **Ord** - ```rust fn cmp(self: &Self, other: &WorkerLogTag) -> $crate::cmp::Ordering { /* ... */ } ``` - **PartialEq** - ```rust fn eq(self: &Self, other: &WorkerLogTag) -> bool { /* ... */ } ``` - **PartialOrd** - ```rust fn partial_cmp(self: &Self, other: &WorkerLogTag) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ } ``` - **RefUnwindSafe** - **Send** - **Serialize** - ```rust fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error> where __S: _serde::Serializer { /* ... */ } ``` - **StructuralPartialEq** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `WorkerDtlsFiles` DTLS certificate and private key. ```rust pub struct WorkerDtlsFiles { pub certificate: std::path::PathBuf, pub private_key: std::path::PathBuf, } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | `certificate` | `std::path::PathBuf` | Path to the DTLS public certificate file in PEM format. | | `private_key` | `std::path::PathBuf` | Path to the DTLS certificate private key file in PEM format. | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WorkerDtlsFiles { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `WorkerSettings` **Attributes:** - `NonExhaustive` Settings for worker to be created with. ```rust pub struct WorkerSettings { pub log_level: WorkerLogLevel, pub log_tags: Vec, pub rtc_port_range: std::ops::RangeInclusive, pub dtls_files: Option, pub enable_liburing: bool, pub thread_initializer: Option>, pub app_data: mediasoup_types::data_structures::AppData, // Some fields omitted } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | `log_level` | `WorkerLogLevel` | Logging level for logs generated by the media worker thread.

Default [`WorkerLogLevel::Error`]. | | `log_tags` | `Vec` | Log tags for debugging. Check the meaning of each available tag in the
[Debugging](https://mediasoup.org/documentation/v3/mediasoup/debugging/) documentation. | | `rtc_port_range` | `std::ops::RangeInclusive` | RTC port range for ICE, DTLS, RTP, etc. Default 10000..=59999. | | `dtls_files` | `Option` | DTLS certificate and private key.

If `None`, a certificate is dynamically created. | | `enable_liburing` | `bool` | Enable liburing This option is ignored if io_uring is not supported by
current host.

Default `true`. | | `thread_initializer` | `Option>` | Function that will be called under worker thread before worker starts, can be used for
pinning worker threads to CPU cores. | | `app_data` | `mediasoup_types::data_structures::AppData` | Custom application data. | | *private fields* | ... | *Some fields have been omitted* | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WorkerSettings { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ } ``` - **Default** - ```rust fn default() -> Self { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `WorkerUpdateSettings` **Attributes:** - `Other("#[serde(rename_all = \"camelCase\")]")` - `NonExhaustive` Worker settings that can be updated in runtime. ```rust pub struct WorkerUpdateSettings { pub log_level: Option, pub log_tags: Option>, } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | `log_level` | `Option` | Logging level for logs generated by the media worker thread.

If `None`, logging level will not be updated. | | `log_tags` | `Option>` | Log tags for debugging. Check the meaning of each available tag in the
[Debugging](https://mediasoup.org/documentation/v3/mediasoup/debugging/) documentation.

If `None`, log tags will not be updated. | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WorkerUpdateSettings { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Default** - ```rust fn default() -> WorkerUpdateSettings { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Serialize** - ```rust fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error> where __S: _serde::Serializer { /* ... */ } ``` - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `CreateWebRtcServerError` Error that caused [`Worker::create_webrtc_server`] to fail. ```rust pub enum CreateWebRtcServerError { Request(RequestError), } ``` ##### Variants ###### `Request` Request to worker failed Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `RequestError` | | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Display** - ```rust fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ } ``` - **Error** - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Enum `CreateRouterError` Error that caused [`Worker::create_router`] to fail. ```rust pub enum CreateRouterError { FailedRtpCapabilitiesGeneration(RtpCapabilitiesError), Request(RequestError), } ``` ##### Variants ###### `FailedRtpCapabilitiesGeneration` RTP capabilities generation error Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `RtpCapabilitiesError` | | ###### `Request` Request to worker failed Fields: | Index | Type | Documentation | |-------|------|---------------| | 0 | `RequestError` | | ##### Implementations ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ } ``` - **Display** - ```rust fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ } ``` - **Error** - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToString** - ```rust fn to_string(self: &Self) -> String { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** #### Struct `Worker` **Attributes:** - `MustUse { reason: Some("Worker will be destroyed on drop, make sure to keep it around for as long as needed") }` A worker represents a mediasoup C++ thread that runs on a single CPU core and handles [`Router`] instances. ```rust pub struct Worker { // Some fields omitted } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | *private fields* | ... | *Some fields have been omitted* | ##### Implementations ###### Methods - ```rust pub fn id(self: &Self) -> WorkerId { /* ... */ } ``` Worker id. - ```rust pub fn worker_manager(self: &Self) -> &WorkerManager { /* ... */ } ``` Worker manager to which worker belongs. - ```rust pub fn app_data(self: &Self) -> &AppData { /* ... */ } ``` Custom application data. - ```rust pub fn closed(self: &Self) -> bool { /* ... */ } ``` Whether the worker is closed. - ```rust pub async fn update_settings(self: &Self, data: WorkerUpdateSettings) -> Result<(), RequestError> { /* ... */ } ``` Updates the worker settings in runtime. Just a subset of the worker settings can be updated. - ```rust pub async fn create_webrtc_server(self: &Self, webrtc_server_options: WebRtcServerOptions) -> Result { /* ... */ } ``` Create a WebRtcServer. - ```rust pub async fn create_router(self: &Self, router_options: RouterOptions) -> Result { /* ... */ } ``` Create a Router. - ```rust pub fn on_new_webrtc_server(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when a new WebRTC server is created. - ```rust pub fn on_new_router(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when a new router is created. - ```rust pub fn on_dead) + Send + Sync + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when the worker thread unexpectedly dies. - ```rust pub fn on_close(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when the worker is closed for whatever reason. ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> Worker { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** ### Re-exports #### Re-export `RtpCapabilitiesError` ```rust pub use crate::ortc::RtpCapabilitiesError; ``` #### Re-export `ExitError` ```rust pub use crate::worker::utils::ExitError; ``` ## Module `worker_manager` Container that creates [`Worker`] instances. ```rust pub mod worker_manager { /* ... */ } ``` ### Types #### Struct `WorkerManager` **Attributes:** - `MustUse { reason: None }` Container that creates [`Worker`] instances. # Examples ```no_run use futures_lite::future; use mediasoup::worker::WorkerSettings; use mediasoup::worker_manager::WorkerManager; // Create a manager that will use specified binary for spawning new worker thread let worker_manager = WorkerManager::new(); future::block_on(async move { // Create a new worker with default settings let worker = worker_manager .create_worker(WorkerSettings::default()) .await .unwrap(); }) ``` If you already happen to have [`async_executor::Executor`] instance available or need a multi-threaded executor, [`WorkerManager::with_executor()`] can be used to create an instance instead. ```rust pub struct WorkerManager { // Some fields omitted } ``` ##### Fields | Name | Type | Documentation | |------|------|---------------| | *private fields* | ... | *Some fields have been omitted* | ##### Implementations ###### Methods - ```rust pub fn new() -> Self { /* ... */ } ``` Create new worker manager, internally a new single-threaded executor will be created. - ```rust pub fn with_executor(executor: Arc>) -> Self { /* ... */ } ``` Create new worker manager, uses externally provided executor. - ```rust pub async fn create_worker(self: &Self, worker_settings: WorkerSettings) -> io::Result { /* ... */ } ``` Creates a new worker with the given settings. - ```rust pub fn on_new_worker(self: &Self, callback: F) -> HandlerId { /* ... */ } ``` Callback is called when a new worker is created. ###### Trait Implementations - **Any** - ```rust fn type_id(self: &Self) -> TypeId { /* ... */ } ``` - **Borrow** - ```rust fn borrow(self: &Self) -> &T { /* ... */ } ``` - **BorrowMut** - ```rust fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ } ``` - **Clone** - ```rust fn clone(self: &Self) -> WorkerManager { /* ... */ } ``` - **CloneToUninit** - ```rust unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ } ``` - **Debug** - ```rust fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ } ``` - **Default** - ```rust fn default() -> Self { /* ... */ } ``` - **Freeze** - **From** - ```rust fn from(t: T) -> T { /* ... */ } ``` Returns the argument unchanged. - **Into** - ```rust fn into(self: Self) -> U { /* ... */ } ``` Calls `U::from(self)`. - **RefUnwindSafe** - **Send** - **Sync** - **ToOwned** - ```rust fn to_owned(self: &Self) -> T { /* ... */ } ``` - ```rust fn clone_into(self: &Self, target: &mut T) { /* ... */ } ``` - **TryFrom** - ```rust fn try_from(value: U) -> Result>::Error> { /* ... */ } ``` - **TryInto** - ```rust fn try_into(self: Self) -> Result>::Error> { /* ... */ } ``` - **Unpin** - **UnwindSafe** ## Module `audio_level_observer` An audio level observer monitors the volume of the selected audio producers. ```rust pub mod audio_level_observer { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::audio_level_observer::*` ```rust pub use crate::router::audio_level_observer::*; ``` ## Module `active_speaker_observer` An active speaker observer monitors the speaking activity of the selected audio producers. ```rust pub mod active_speaker_observer { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::active_speaker_observer::*` ```rust pub use crate::router::active_speaker_observer::*; ``` ## Module `consumer` A consumer represents an audio or video source being forwarded from a mediasoup router to an endpoint. It's created on top of a transport that defines how the media packets are carried. ```rust pub mod consumer { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::consumer::*` ```rust pub use crate::router::consumer::*; ``` ## Module `data_consumer` A data consumer represents an endpoint capable of receiving data messages from a mediasoup [`Router`](router::Router). A data consumer can use [SCTP](https://tools.ietf.org/html/rfc4960) (AKA DataChannel) to receive those messages, or can directly receive them in the Rust application if the data consumer was created on top of a [`DirectTransport`](direct_transport::DirectTransport). ```rust pub mod data_consumer { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::data_consumer::*` ```rust pub use crate::router::data_consumer::*; ``` ## Module `producer` A producer represents an audio or video source being injected into a mediasoup router. It's created on top of a transport that defines how the media packets are carried. ```rust pub mod producer { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::producer::*` ```rust pub use crate::router::producer::*; ``` ## Module `data_producer` A data producer represents an endpoint capable of injecting data messages into a mediasoup [`Router`](router::Router). A data producer can use [SCTP](https://tools.ietf.org/html/rfc4960) (AKA DataChannel) to deliver those messages, or can directly send them from the Rust application if the data producer was created on top of a [`DirectTransport`](direct_transport::DirectTransport). ```rust pub mod data_producer { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::data_producer::*` ```rust pub use crate::router::data_producer::*; ``` ## Module `transport` A transport connects an endpoint with a mediasoup router and enables transmission of media in both directions by means of [`Producer`](producer::Producer), [`Consumer`](consumer::Consumer), [`DataProducer`](data_producer::DataProducer) and [`DataConsumer`](data_consumer::DataConsumer) instances created on it. mediasoup implements the following transports: * [`WebRtcTransport`](webrtc_transport::WebRtcTransport) * [`PlainTransport`](plain_transport::PlainTransport) * [`PipeTransport`](pipe_transport::PipeTransport) * [`DirectTransport`](direct_transport::DirectTransport) ```rust pub mod transport { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::transport::*` ```rust pub use crate::router::transport::*; ``` ## Module `direct_transport` A direct transport represents a direct connection between the mediasoup Rust process and a [`Router`](router::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`](data_producer::DataProducer)s and [`DataConsumer`](data_consumer::DataConsumer)s of type `Direct` created on a direct transport. Direct messages sent by a [`DataProducer`](data_producer::DataProducer) in a direct transport can be consumed by endpoints connected through a SCTP capable transport ([`WebRtcTransport`](webrtc_transport::WebRtcTransport), [`PlainTransport`](plain_transport::PlainTransport), [`PipeTransport`](pipe_transport::PipeTransport) and also by the Rust application by means of a [`DataConsumer`](data_consumer::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`](data_consumer::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`](producer::DirectProducer::send) and [`Consumer::on_rtp`](consumer::Consumer::on_rtp) API (plus [`DirectTransport::send_rtcp`] and [`DirectTransport::on_rtcp`] API). ```rust pub mod direct_transport { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::direct_transport::*` ```rust pub use crate::router::direct_transport::*; ``` ## Module `pipe_transport` A pipe transport represents a network path through which RTP, RTCP (optionally secured with SRTP) and SCTP (DataChannel) is transmitted. Pipe transports are intended to intercommunicate two [`Router`](router::Router) instances collocated on the same host or on separate hosts. # Notes on usage When calling [`PipeTransport::consume`](transport::Transport::consume), all RTP streams of the [`Producer`](producer::Producer) are transmitted verbatim (in contrast to what happens in [`WebRtcTransport`](webrtc_transport::WebRtcTransport) and [`PlainTransport`](plain_transport::PlainTransport) in which a single and continuous RTP stream is sent to the consuming endpoint). ```rust pub mod pipe_transport { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::pipe_transport::*` ```rust pub use crate::router::pipe_transport::*; ``` ## Module `plain_transport` A plain transport represents a network path through which RTP, RTCP (optionally secured with SRTP) and SCTP (DataChannel) is transmitted. ```rust pub mod plain_transport { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::plain_transport::*` ```rust pub use crate::router::plain_transport::*; ``` ## Module `rtp_observer` An RTP observer inspects the media received by a set of selected producers. mediasoup implements the following RTP observers: * [`AudioLevelObserver`](audio_level_observer::AudioLevelObserver) ```rust pub mod rtp_observer { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::rtp_observer::*` ```rust pub use crate::router::rtp_observer::*; ``` ## Module `webrtc_transport` A WebRTC transport represents a network path negotiated by both, a WebRTC endpoint and mediasoup, via ICE and DTLS procedures. A WebRTC transport 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 WebRTC transports for sending and receiving. # Notes on usage The WebRTC transport implementation of mediasoup is [ICE Lite](https://tools.ietf.org/html/rfc5245#section-2.7), meaning that it does not initiate ICE connections but expects ICE Binding Requests from endpoints. ```rust pub mod webrtc_transport { /* ... */ } ``` ### Re-exports #### Re-export `crate::router::webrtc_transport::*` ```rust pub use crate::router::webrtc_transport::*; ``` ## Re-exports ### Re-export `mediasoup_types` ```rust pub use mediasoup_types as types; ```