89 KiB
Crate Documentation
Version: 0.20.0
Format Version: 55
Module mediasoup
Rust port of 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).
It is recommended to visit mediasoup website and read design overview first.
There are some requirements for building underlying C++ mediasoup-worker, please find them in
installation instructions
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
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 most often. With
transport created you can start creating Producers to send data to
Router and Consumer instances to extract data from
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 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::*;
pub mod prelude { /* ... */ }
Re-exports
Re-export WorkerManager
pub use crate::worker_manager::WorkerManager;
Re-export Worker
pub use crate::worker::Worker;
Re-export WorkerSettings
pub use crate::worker::WorkerSettings;
Re-export PipeDataProducerToRouterError
pub use crate::router::PipeDataProducerToRouterError;
Re-export PipeDataProducerToRouterPair
pub use crate::router::PipeDataProducerToRouterPair;
Re-export PipeProducerToRouterError
pub use crate::router::PipeProducerToRouterError;
Re-export PipeProducerToRouterPair
pub use crate::router::PipeProducerToRouterPair;
Re-export PipeToRouterOptions
pub use crate::router::PipeToRouterOptions;
Re-export Router
pub use crate::router::Router;
Re-export RouterOptions
pub use crate::router::RouterOptions;
Re-export WebRtcServer
pub use crate::webrtc_server::WebRtcServer;
Re-export WebRtcServerId
pub use crate::webrtc_server::WebRtcServerId;
Re-export WebRtcServerListenInfos
pub use crate::webrtc_server::WebRtcServerListenInfos;
Re-export WebRtcServerOptions
pub use crate::webrtc_server::WebRtcServerOptions;
Re-export DirectTransport
pub use crate::direct_transport::DirectTransport;
Re-export DirectTransportOptions
pub use crate::direct_transport::DirectTransportOptions;
Re-export WeakDirectTransport
pub use crate::direct_transport::WeakDirectTransport;
Re-export PipeTransport
pub use crate::pipe_transport::PipeTransport;
Re-export PipeTransportOptions
pub use crate::pipe_transport::PipeTransportOptions;
Re-export PipeTransportRemoteParameters
pub use crate::pipe_transport::PipeTransportRemoteParameters;
Re-export WeakPipeTransport
pub use crate::pipe_transport::WeakPipeTransport;
Re-export PlainTransport
pub use crate::plain_transport::PlainTransport;
Re-export PlainTransportOptions
pub use crate::plain_transport::PlainTransportOptions;
Re-export PlainTransportRemoteParameters
pub use crate::plain_transport::PlainTransportRemoteParameters;
Re-export WeakPlainTransport
pub use crate::plain_transport::WeakPlainTransport;
Re-export ConsumeDataError
pub use crate::transport::ConsumeDataError;
Re-export ConsumeError
pub use crate::transport::ConsumeError;
Re-export ProduceDataError
pub use crate::transport::ProduceDataError;
Re-export ProduceError
pub use crate::transport::ProduceError;
Re-export Transport
pub use crate::transport::Transport;
Re-export TransportGeneric
pub use crate::transport::TransportGeneric;
Re-export TransportId
pub use crate::transport::TransportId;
Re-export WebRtcTransport
pub use crate::webrtc_transport::WebRtcTransport;
Re-export WebRtcTransportListenInfos
pub use crate::webrtc_transport::WebRtcTransportListenInfos;
Re-export WebRtcTransportOptions
pub use crate::webrtc_transport::WebRtcTransportOptions;
Re-export WebRtcTransportRemoteParameters
pub use crate::webrtc_transport::WebRtcTransportRemoteParameters;
Re-export ActiveSpeakerObserver
pub use crate::active_speaker_observer::ActiveSpeakerObserver;
Re-export ActiveSpeakerObserverDominantSpeaker
pub use crate::active_speaker_observer::ActiveSpeakerObserverDominantSpeaker;
Re-export ActiveSpeakerObserverOptions
pub use crate::active_speaker_observer::ActiveSpeakerObserverOptions;
Re-export WeakActiveSpeakerObserver
pub use crate::active_speaker_observer::WeakActiveSpeakerObserver;
Re-export AudioLevelObserver
pub use crate::audio_level_observer::AudioLevelObserver;
Re-export AudioLevelObserverOptions
pub use crate::audio_level_observer::AudioLevelObserverOptions;
Re-export AudioLevelObserverVolume
pub use crate::audio_level_observer::AudioLevelObserverVolume;
Re-export WeakAudioLevelObserver
pub use crate::audio_level_observer::WeakAudioLevelObserver;
Re-export RtpObserver
pub use crate::rtp_observer::RtpObserver;
Re-export RtpObserverAddProducerOptions
pub use crate::rtp_observer::RtpObserverAddProducerOptions;
Re-export RtpObserverId
pub use crate::rtp_observer::RtpObserverId;
Re-export Consumer
pub use crate::consumer::Consumer;
Re-export ConsumerId
pub use crate::consumer::ConsumerId;
Re-export ConsumerLayers
pub use crate::consumer::ConsumerLayers;
Re-export ConsumerOptions
pub use crate::consumer::ConsumerOptions;
Re-export WeakConsumer
pub use crate::consumer::WeakConsumer;
Re-export DataConsumer
pub use crate::data_consumer::DataConsumer;
Re-export DataConsumerId
pub use crate::data_consumer::DataConsumerId;
Re-export DataConsumerOptions
pub use crate::data_consumer::DataConsumerOptions;
Re-export DirectDataConsumer
pub use crate::data_consumer::DirectDataConsumer;
Re-export RegularDataConsumer
pub use crate::data_consumer::RegularDataConsumer;
Re-export WeakDataConsumer
pub use crate::data_consumer::WeakDataConsumer;
Re-export DataProducer
pub use crate::data_producer::DataProducer;
Re-export DataProducerId
pub use crate::data_producer::DataProducerId;
Re-export DataProducerOptions
pub use crate::data_producer::DataProducerOptions;
Re-export DirectDataProducer
pub use crate::data_producer::DirectDataProducer;
Re-export NonClosingDataProducer
pub use crate::data_producer::NonClosingDataProducer;
Re-export RegularDataProducer
pub use crate::data_producer::RegularDataProducer;
Re-export WeakDataProducer
pub use crate::data_producer::WeakDataProducer;
Re-export Producer
pub use crate::producer::Producer;
Re-export ProducerId
pub use crate::producer::ProducerId;
Re-export ProducerOptions
pub use crate::producer::ProducerOptions;
Re-export WeakProducer
pub use crate::producer::WeakProducer;
Re-export AppData
pub use mediasoup_types::data_structures::AppData;
Re-export DtlsParameters
pub use mediasoup_types::data_structures::DtlsParameters;
Re-export IceCandidate
pub use mediasoup_types::data_structures::IceCandidate;
Re-export IceParameters
pub use mediasoup_types::data_structures::IceParameters;
Re-export ListenInfo
pub use mediasoup_types::data_structures::ListenInfo;
Re-export Protocol
pub use mediasoup_types::data_structures::Protocol;
Re-export WebRtcMessage
pub use mediasoup_types::data_structures::WebRtcMessage;
Re-export MediaKind
pub use mediasoup_types::rtp_parameters::MediaKind;
Re-export MimeTypeAudio
pub use mediasoup_types::rtp_parameters::MimeTypeAudio;
Re-export MimeTypeVideo
pub use mediasoup_types::rtp_parameters::MimeTypeVideo;
Re-export RtcpFeedback
pub use mediasoup_types::rtp_parameters::RtcpFeedback;
Re-export RtcpParameters
pub use mediasoup_types::rtp_parameters::RtcpParameters;
Re-export RtpCapabilities
pub use mediasoup_types::rtp_parameters::RtpCapabilities;
Re-export RtpCapabilitiesFinalized
pub use mediasoup_types::rtp_parameters::RtpCapabilitiesFinalized;
Re-export RtpCodecCapability
pub use mediasoup_types::rtp_parameters::RtpCodecCapability;
Re-export RtpCodecParameters
pub use mediasoup_types::rtp_parameters::RtpCodecParameters;
Re-export RtpCodecParametersParameters
pub use mediasoup_types::rtp_parameters::RtpCodecParametersParameters;
Re-export RtpEncodingParameters
pub use mediasoup_types::rtp_parameters::RtpEncodingParameters;
Re-export RtpEncodingParametersRtx
pub use mediasoup_types::rtp_parameters::RtpEncodingParametersRtx;
Re-export RtpHeaderExtensionParameters
pub use mediasoup_types::rtp_parameters::RtpHeaderExtensionParameters;
Re-export RtpHeaderExtensionUri
pub use mediasoup_types::rtp_parameters::RtpHeaderExtensionUri;
Re-export RtpParameters
pub use mediasoup_types::rtp_parameters::RtpParameters;
Re-export SctpStreamParameters
pub use mediasoup_types::sctp_parameters::SctpStreamParameters;
Re-export SrtpCryptoSuite
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).
pub mod router { /* ... */ }
Types
Struct RouterId
[Router] identifier.
pub struct RouterId(/* private field */);
Fields
| Index | Type | Documentation |
|---|---|---|
| 0 | private |
Private field |
Implementations
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> RouterId { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Copy
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Deserialize
-
fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result<Self, <__D as >::Error>
-
where __D: _serde::Deserializer<''de> { /* ... */ } ```
-
DeserializeOwned
-
Display
-
fn fmt(self: &Self, f: &mut std::fmt::Formatter<''_>) -> std::fmt::Result { /* ... */ }
-
-
Eq
-
Equivalent
-
fn equivalent(self: &Self, key: &K) -> bool { /* ... */ }
-
-
Freeze
-
From
-
fn from(t: T) -> T { /* ... */ }Returns the argument unchanged.
-
fn from(id: RouterId) -> Self { /* ... */ }
-
-
FromStr
-
fn from_str(s: &str) -> Result<Self, <Self as >::Err> { /* ... */ }
-
-
Hash
-
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
Ord
-
fn cmp(self: &Self, other: &RouterId) -> $crate::cmp::Ordering { /* ... */ }
-
-
PartialEq
-
fn eq(self: &Self, other: &RouterId) -> bool { /* ... */ }
-
-
PartialOrd
-
fn partial_cmp(self: &Self, other: &RouterId) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ }
-
-
RefUnwindSafe
-
Send
-
Serialize
-
fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error>
-
where __S: _serde::Serializer { /* ... */ } ```
-
StructuralPartialEq
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Struct RouterOptions
Attributes:
NonExhaustive
[Router] options.
Notes on usage
- Feature codecs such as
RTXMUST NOT be placed into the mediaCodecs list. - If
preferred_payload_typeis given in a [RtpCodecCapability] (although it's unnecessary) it's extremely recommended to use a value in the 96-127 range.
pub struct RouterOptions {
pub media_codecs: Vec<mediasoup_types::rtp_parameters::RtpCodecCapability>,
pub app_data: mediasoup_types::data_structures::AppData,
}
Fields
| Name | Type | Documentation |
|---|---|---|
media_codecs |
Vec<mediasoup_types::rtp_parameters::RtpCodecCapability> |
Router media codecs. |
app_data |
mediasoup_types::data_structures::AppData |
Custom application data. |
Implementations
Methods
-
Create router options with given list of declared media codecs.
pub fn new(media_codecs: Vec<RtpCodecCapability>) -> Self { /* ... */ }
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Default
-
fn default() -> Self { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::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.
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
-
Crate pipe options for piping into given local router.
pub fn new(router: Router) -> Self { /* ... */ }
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::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.
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Enum PipeProducerToRouterError
Error that caused [Router::pipe_producer_to_router()] to fail.
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Display
-
fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ }
-
-
Error
-
Freeze
-
From
-
fn from(t: T) -> T { /* ... */ }Returns the argument unchanged.
-
fn from(error: RequestError) -> Self { /* ... */ } -
fn from(error: ConsumeError) -> Self { /* ... */ } -
fn from(error: ProduceError) -> Self { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::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.
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Enum PipeDataProducerToRouterError
Error that caused [Router::pipe_data_producer_to_router()] to fail.
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Display
-
fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ }
-
-
Error
-
Freeze
-
From
-
fn from(t: T) -> T { /* ... */ }Returns the argument unchanged.
-
fn from(error: RequestError) -> Self { /* ... */ } -
fn from(error: ConsumeDataError) -> Self { /* ... */ } -
fn from(error: ProduceDataError) -> Self { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Enum UpdateMediaCodecsError
Error that caused [Router::update_media_codecs] to fail.
pub enum UpdateMediaCodecsError {
FailedRtpCapabilitiesGeneration(ortc::RtpCapabilitiesError),
}
Variants
FailedRtpCapabilitiesGeneration
RTP capabilities generation error
Fields:
| Index | Type | Documentation |
|---|---|---|
| 0 | ortc::RtpCapabilitiesError |
Implementations
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Display
-
fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ }
-
-
Error
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Enum NewTransport
New transport that was just created.
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Deref
-
fn deref(self: &Self) -> &<Self as >::Target { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
Receiver
-
RefUnwindSafe
-
Send
-
Sync
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Enum NewRtpObserver
New RTP observer that was just created.
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Deref
-
fn deref(self: &Self) -> &<Self as >::Target { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
Receiver
-
RefUnwindSafe
-
Send
-
Sync
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::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).
pub struct Router {
// Some fields omitted
}
Fields
| Name | Type | Documentation |
|---|---|---|
| private fields | ... | Some fields have been omitted |
Implementations
Methods
-
pub fn id(self: &Self) -> RouterId { /* ... */ }Router id.
-
pub fn worker(self: &Self) -> &Worker { /* ... */ }Worker to which router belongs.
-
pub fn app_data(self: &Self) -> &AppData { /* ... */ }Custom application data.
-
pub fn closed(self: &Self) -> bool { /* ... */ }Whether router is closed.
-
pub fn rtp_capabilities(self: &Self) -> RtpCapabilitiesFinalized { /* ... */ }RTP capabilities of the router. These capabilities are typically needed by mediasoup clients
-
pub async fn create_direct_transport(self: &Self, direct_transport_options: DirectTransportOptions) -> Result<DirectTransport, RequestError> { /* ... */ }Create a [
DirectTransport]. -
pub async fn create_webrtc_transport(self: &Self, webrtc_transport_options: WebRtcTransportOptions) -> Result<WebRtcTransport, RequestError> { /* ... */ }Create a [
WebRtcTransport]. -
pub async fn create_pipe_transport(self: &Self, pipe_transport_options: PipeTransportOptions) -> Result<PipeTransport, RequestError> { /* ... */ }Create a [
PipeTransport]. -
pub async fn create_plain_transport(self: &Self, plain_transport_options: PlainTransportOptions) -> Result<PlainTransport, RequestError> { /* ... */ }Create a [
PlainTransport]. -
pub async fn create_audio_level_observer(self: &Self, audio_level_observer_options: AudioLevelObserverOptions) -> Result<AudioLevelObserver, RequestError> { /* ... */ }Create an [
AudioLevelObserver]. -
pub async fn create_active_speaker_observer(self: &Self, active_speaker_observer_options: ActiveSpeakerObserverOptions) -> Result<ActiveSpeakerObserver, RequestError> { /* ... */ }Create an [
ActiveSpeakerObserver]. -
pub async fn pipe_producer_to_router(self: &Self, producer_id: ProducerId, pipe_to_router_options: PipeToRouterOptions) -> Result<PipeProducerToRouterPair, PipeProducerToRouterError> { /* ... */ }Pipes [
Producer] with the givenproducer_idinto another [Router] on same host. -
pub async fn pipe_data_producer_to_router(self: &Self, data_producer_id: DataProducerId, pipe_to_router_options: PipeToRouterOptions) -> Result<PipeDataProducerToRouterPair, PipeDataProducerToRouterError> { /* ... */ }Pipes [
DataProducer] with the givendata_producer_idinto another [Router] on same -
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.
-
pub fn update_media_codecs(self: &mut Self, media_codecs: Vec<RtpCodecCapability>) -> Result<(), UpdateMediaCodecsError> { /* ... */ }Update the Router media codecs. Once called, the return value of
-
pub fn on_new_transport<F: Fn(NewTransport<''_>) + Send + Sync + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when a new transport is created.
-
pub fn on_new_rtp_observer<F: Fn(NewRtpObserver<''_>) + Send + Sync + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when a new RTP observer is created.
-
pub fn on_worker_close<F: FnOnce() + Send + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when the worker this router belongs to is closed for whatever reason.
-
pub fn on_close<F: FnOnce() + Send + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when the router is closed for whatever reason.
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> Router { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Module supported_rtp_capabilities
RTP capabilities supported by mediasoup.
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() and
libmediasoupclient's
device.Load()
methods. There you must use
Router::rtp_capabilities getter instead.
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
WebRtcTransports.
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, meaning that it does not initiate
ICE connections but expects ICE Binding Requests from endpoints.
pub mod webrtc_server { /* ... */ }
Types
Struct WebRtcServerId
[WebRtcServer] identifier.
pub struct WebRtcServerId(/* private field */);
Fields
| Index | Type | Documentation |
|---|---|---|
| 0 | private |
Private field |
Implementations
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WebRtcServerId { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Copy
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Deserialize
-
fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result<Self, <__D as >::Error>
-
where __D: _serde::Deserializer<''de> { /* ... */ } ```
-
DeserializeOwned
-
Display
-
fn fmt(self: &Self, f: &mut std::fmt::Formatter<''_>) -> std::fmt::Result { /* ... */ }
-
-
Eq
-
Equivalent
-
fn equivalent(self: &Self, key: &K) -> bool { /* ... */ }
-
-
Freeze
-
From
-
fn from(t: T) -> T { /* ... */ }Returns the argument unchanged.
-
fn from(id: WebRtcServerId) -> Self { /* ... */ }
-
-
FromStr
-
fn from_str(s: &str) -> Result<Self, <Self as >::Err> { /* ... */ }
-
-
Hash
-
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
Ord
-
fn cmp(self: &Self, other: &WebRtcServerId) -> $crate::cmp::Ordering { /* ... */ }
-
-
PartialEq
-
fn eq(self: &Self, other: &WebRtcServerId) -> bool { /* ... */ }
-
-
PartialOrd
-
fn partial_cmp(self: &Self, other: &WebRtcServerId) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ }
-
-
RefUnwindSafe
-
Send
-
Serialize
-
fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error>
-
where __S: _serde::Serializer { /* ... */ } ```
-
StructuralPartialEq
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Struct WebRtcServerListenInfos
Struct that protects an invariant of having non-empty list of listen infos.
pub struct WebRtcServerListenInfos(/* private field */);
Fields
| Index | Type | Documentation |
|---|---|---|
| 0 | private |
Private field |
Implementations
Methods
-
pub fn new(listen_info: ListenInfo) -> Self { /* ... */ }Create WebRTC server listen infos with given info populated initially.
-
pub fn insert(self: Self, listen_info: ListenInfo) -> Self { /* ... */ }Insert another listen info.
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WebRtcServerListenInfos { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Deref
-
fn deref(self: &Self) -> &<Self as >::Target { /* ... */ }
-
-
Eq
-
Equivalent
-
fn equivalent(self: &Self, key: &K) -> bool { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
PartialEq
-
fn eq(self: &Self, other: &WebRtcServerListenInfos) -> bool { /* ... */ }
-
-
Receiver
-
RefUnwindSafe
-
Send
-
Serialize
-
fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error>
-
where __S: _serde::Serializer { /* ... */ } ```
-
StructuralPartialEq
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ } -
fn try_from(listen_infos: Vec<ListenInfo>) -> Result<Self, <Self as >::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::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.
pub struct EmptyListError;
Implementations
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Display
-
fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ }
-
-
Eq
-
Equivalent
-
fn equivalent(self: &Self, key: &K) -> bool { /* ... */ }
-
-
Error
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
PartialEq
-
fn eq(self: &Self, other: &EmptyListError) -> bool { /* ... */ }
-
-
RefUnwindSafe
-
Send
-
StructuralPartialEq
-
Sync
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Struct WebRtcServerOptions
Attributes:
NonExhaustive
[WebRtcServer] options.
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
-
Create [
pub fn new(listen_infos: WebRtcServerListenInfos) -> Self { /* ... */ }WebRtcServer] options with given listen infos.
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Struct WebRtcServer
A WebRTC server brings the ability to listen on a single UDP/TCP port for multiple
WebRtcTransports.
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, meaning that it does not initiate
ICE connections but expects ICE Binding Requests from endpoints.
pub struct WebRtcServer {
// Some fields omitted
}
Fields
| Name | Type | Documentation |
|---|---|---|
| private fields | ... | Some fields have been omitted |
Implementations
Methods
-
pub fn id(self: &Self) -> WebRtcServerId { /* ... */ }Router id.
-
pub fn worker(self: &Self) -> &Worker { /* ... */ }Worker to which WebRTC server belongs.
-
pub fn app_data(self: &Self) -> &AppData { /* ... */ }Custom application data.
-
pub fn closed(self: &Self) -> bool { /* ... */ }Whether WebRTC server is closed.
-
pub fn on_worker_close<F: FnOnce() + Send + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when the worker this WebRTC server belongs to is closed for whatever
-
pub fn on_new_webrtc_transport<F>(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<F: FnOnce() + Send + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }
Callback is called when the WebRTC server is closed for whatever reason.
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WebRtcServer { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Module worker
A worker represents a mediasoup C++ thread that runs on a single CPU core and handles
[Router] instances.
pub mod worker { /* ... */ }
Types
Struct WorkerId
Worker identifier.
pub struct WorkerId(/* private field */);
Fields
| Index | Type | Documentation |
|---|---|---|
| 0 | private |
Private field |
Implementations
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WorkerId { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Copy
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Deserialize
-
fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result<Self, <__D as >::Error>
-
where __D: _serde::Deserializer<''de> { /* ... */ } ```
-
DeserializeOwned
-
Display
-
fn fmt(self: &Self, f: &mut std::fmt::Formatter<''_>) -> std::fmt::Result { /* ... */ }
-
-
Eq
-
Equivalent
-
fn equivalent(self: &Self, key: &K) -> bool { /* ... */ }
-
-
Freeze
-
From
-
fn from(t: T) -> T { /* ... */ }Returns the argument unchanged.
-
fn from(id: WorkerId) -> Self { /* ... */ }
-
-
FromStr
-
fn from_str(s: &str) -> Result<Self, <Self as >::Err> { /* ... */ }
-
-
Hash
-
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
Ord
-
fn cmp(self: &Self, other: &WorkerId) -> $crate::cmp::Ordering { /* ... */ }
-
-
PartialEq
-
fn eq(self: &Self, other: &WorkerId) -> bool { /* ... */ }
-
-
PartialOrd
-
fn partial_cmp(self: &Self, other: &WorkerId) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ }
-
-
RefUnwindSafe
-
Send
-
Serialize
-
fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error>
-
where __S: _serde::Serializer { /* ... */ } ```
-
StructuralPartialEq
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Enum RequestError
Error that caused request to mediasoup-worker request to fail.
pub enum RequestError {
ChannelClosed,
TimedOut,
Response {
reason: String,
},
FailedToParse {
error: String,
},
NoData,
ResponseConversion(Box<dyn Error + Send + Sync>),
}
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<dyn Error + Send + Sync> |
Implementations
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Display
-
fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ }
-
-
Error
-
Freeze
-
From
-
fn from(t: T) -> T { /* ... */ }Returns the argument unchanged.
-
fn from(error: RequestError) -> Self { /* ... */ } -
fn from(error: RequestError) -> Self { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Enum WorkerLogLevel
Attributes:
Other("#[serde(rename_all = \"lowercase\")]")
Logging level for logs generated by the media worker thread (check the Debugging documentation on TypeScript implementation and generic Rust-specific docs).
Default [WorkerLogLevel::Error].
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WorkerLogLevel { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Copy
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Default
-
fn default() -> Self { /* ... */ }
-
-
Eq
-
Equivalent
-
fn equivalent(self: &Self, key: &K) -> bool { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Hash
-
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
Ord
-
fn cmp(self: &Self, other: &WorkerLogLevel) -> $crate::cmp::Ordering { /* ... */ }
-
-
PartialEq
-
fn eq(self: &Self, other: &WorkerLogLevel) -> bool { /* ... */ }
-
-
PartialOrd
-
fn partial_cmp(self: &Self, other: &WorkerLogLevel) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ }
-
-
RefUnwindSafe
-
Send
-
Serialize
-
fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error>
-
where __S: _serde::Serializer { /* ... */ } ```
-
StructuralPartialEq
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::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 documentation.
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WorkerLogTag { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Copy
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Eq
-
Equivalent
-
fn equivalent(self: &Self, key: &K) -> bool { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Hash
-
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H) { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
Ord
-
fn cmp(self: &Self, other: &WorkerLogTag) -> $crate::cmp::Ordering { /* ... */ }
-
-
PartialEq
-
fn eq(self: &Self, other: &WorkerLogTag) -> bool { /* ... */ }
-
-
PartialOrd
-
fn partial_cmp(self: &Self, other: &WorkerLogTag) -> $crate::option::Option<$crate::cmp::Ordering> { /* ... */ }
-
-
RefUnwindSafe
-
Send
-
Serialize
-
fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error>
-
where __S: _serde::Serializer { /* ... */ } ```
-
StructuralPartialEq
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Struct WorkerDtlsFiles
DTLS certificate and private key.
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WorkerDtlsFiles { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Struct WorkerSettings
Attributes:
NonExhaustive
Settings for worker to be created with.
pub struct WorkerSettings {
pub log_level: WorkerLogLevel,
pub log_tags: Vec<WorkerLogTag>,
pub rtc_port_range: std::ops::RangeInclusive<u16>,
pub dtls_files: Option<WorkerDtlsFiles>,
pub enable_liburing: bool,
pub thread_initializer: Option<std::sync::Arc<dyn Fn() + Send + Sync>>,
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<WorkerLogTag> |
Log tags for debugging. Check the meaning of each available tag in the Debugging documentation. |
rtc_port_range |
std::ops::RangeInclusive<u16> |
RTC port range for ICE, DTLS, RTP, etc. Default 10000..=59999. |
dtls_files |
Option<WorkerDtlsFiles> |
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<std::sync::Arc<dyn Fn() + Send + Sync>> |
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WorkerSettings { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ }
-
-
Default
-
fn default() -> Self { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Struct WorkerUpdateSettings
Attributes:
Other("#[serde(rename_all = \"camelCase\")]")NonExhaustive
Worker settings that can be updated in runtime.
pub struct WorkerUpdateSettings {
pub log_level: Option<WorkerLogLevel>,
pub log_tags: Option<Vec<WorkerLogTag>>,
}
Fields
| Name | Type | Documentation |
|---|---|---|
log_level |
Option<WorkerLogLevel> |
Logging level for logs generated by the media worker thread. If None, logging level will not be updated. |
log_tags |
Option<Vec<WorkerLogTag>> |
Log tags for debugging. Check the meaning of each available tag in the Debugging documentation. If None, log tags will not be updated. |
Implementations
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WorkerUpdateSettings { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Default
-
fn default() -> WorkerUpdateSettings { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Serialize
-
fn serialize<__S>(self: &Self, __serializer: __S) -> _serde::__private::Result<<__S as >::Ok, <__S as >::Error>
-
where __S: _serde::Serializer { /* ... */ } ```
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Enum CreateWebRtcServerError
Error that caused [Worker::create_webrtc_server] to fail.
pub enum CreateWebRtcServerError {
Request(RequestError),
}
Variants
Request
Request to worker failed
Fields:
| Index | Type | Documentation |
|---|---|---|
| 0 | RequestError |
Implementations
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Display
-
fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ }
-
-
Error
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Enum CreateRouterError
Error that caused [Worker::create_router] to fail.
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
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<''_>) -> $crate::fmt::Result { /* ... */ }
-
-
Display
-
fn fmt(self: &Self, __formatter: &mut ::core::fmt::Formatter<''_>) -> ::core::fmt::Result { /* ... */ }
-
-
Error
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToString
-
fn to_string(self: &Self) -> String { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::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.
pub struct Worker {
// Some fields omitted
}
Fields
| Name | Type | Documentation |
|---|---|---|
| private fields | ... | Some fields have been omitted |
Implementations
Methods
-
pub fn id(self: &Self) -> WorkerId { /* ... */ }Worker id.
-
pub fn worker_manager(self: &Self) -> &WorkerManager { /* ... */ }Worker manager to which worker belongs.
-
pub fn app_data(self: &Self) -> &AppData { /* ... */ }Custom application data.
-
pub fn closed(self: &Self) -> bool { /* ... */ }Whether the worker is closed.
-
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.
-
pub async fn create_webrtc_server(self: &Self, webrtc_server_options: WebRtcServerOptions) -> Result<WebRtcServer, CreateWebRtcServerError> { /* ... */ }Create a WebRtcServer.
-
pub async fn create_router(self: &Self, router_options: RouterOptions) -> Result<Router, CreateRouterError> { /* ... */ }Create a Router.
-
pub fn on_new_webrtc_server<F: Fn(&WebRtcServer) + Send + Sync + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when a new WebRTC server is created.
-
pub fn on_new_router<F: Fn(&Router) + Send + Sync + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when a new router is created.
-
pub fn on_dead<F: FnOnce(Result<(), ExitError>) + Send + Sync + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when the worker thread unexpectedly dies.
-
pub fn on_close<F: FnOnce() + Send + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when the worker is closed for whatever reason.
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> Worker { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Re-exports
Re-export RtpCapabilitiesError
pub use crate::ortc::RtpCapabilitiesError;
Re-export ExitError
pub use crate::worker::utils::ExitError;
Module worker_manager
Container that creates [Worker] instances.
pub mod worker_manager { /* ... */ }
Types
Struct WorkerManager
Attributes:
MustUse { reason: None }
Container that creates [Worker] instances.
Examples
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.
pub struct WorkerManager {
// Some fields omitted
}
Fields
| Name | Type | Documentation |
|---|---|---|
| private fields | ... | Some fields have been omitted |
Implementations
Methods
-
pub fn new() -> Self { /* ... */ }Create new worker manager, internally a new single-threaded executor will be created.
-
pub fn with_executor(executor: Arc<Executor<''static>>) -> Self { /* ... */ }Create new worker manager, uses externally provided executor.
-
pub async fn create_worker(self: &Self, worker_settings: WorkerSettings) -> io::Result<Worker> { /* ... */ }Creates a new worker with the given settings.
-
pub fn on_new_worker<F: Fn(&Worker) + Send + Sync + ''static>(self: &Self, callback: F) -> HandlerId { /* ... */ }Callback is called when a new worker is created.
Trait Implementations
-
Any
-
fn type_id(self: &Self) -> TypeId { /* ... */ }
-
-
Borrow
-
fn borrow(self: &Self) -> &T { /* ... */ }
-
-
BorrowMut
-
fn borrow_mut(self: &mut Self) -> &mut T { /* ... */ }
-
-
Clone
-
fn clone(self: &Self) -> WorkerManager { /* ... */ }
-
-
CloneToUninit
-
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8) { /* ... */ }
-
-
Debug
-
fn fmt(self: &Self, f: &mut fmt::Formatter<''_>) -> fmt::Result { /* ... */ }
-
-
Default
-
fn default() -> Self { /* ... */ }
-
-
Freeze
-
From
-
Returns the argument unchanged.
fn from(t: T) -> T { /* ... */ }
-
-
Into
-
Calls
fn into(self: Self) -> U { /* ... */ }U::from(self).
-
-
RefUnwindSafe
-
Send
-
Sync
-
ToOwned
-
fn to_owned(self: &Self) -> T { /* ... */ } -
fn clone_into(self: &Self, target: &mut T) { /* ... */ }
-
-
TryFrom
-
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> { /* ... */ }
-
-
TryInto
-
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error> { /* ... */ }
-
-
Unpin
-
UnwindSafe
Module audio_level_observer
An audio level observer monitors the volume of the selected audio producers.
pub mod audio_level_observer { /* ... */ }
Re-exports
Re-export crate::router::audio_level_observer::*
pub use crate::router::audio_level_observer::*;
Module active_speaker_observer
An active speaker observer monitors the speaking activity of the selected audio producers.
pub mod active_speaker_observer { /* ... */ }
Re-exports
Re-export crate::router::active_speaker_observer::*
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.
pub mod consumer { /* ... */ }
Re-exports
Re-export crate::router::consumer::*
pub use crate::router::consumer::*;
Module data_consumer
A data consumer represents an endpoint capable of receiving data messages from a mediasoup
Router.
A data consumer can use SCTP (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.
pub mod data_consumer { /* ... */ }
Re-exports
Re-export crate::router::data_consumer::*
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.
pub mod producer { /* ... */ }
Re-exports
Re-export crate::router::producer::*
pub use crate::router::producer::*;
Module data_producer
A data producer represents an endpoint capable of injecting data messages into a mediasoup
Router.
A data producer can use SCTP (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.
pub mod data_producer { /* ... */ }
Re-exports
Re-export crate::router::data_producer::*
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,
Consumer, DataProducer and
DataConsumer instances created on it.
mediasoup implements the following transports:
WebRtcTransportPlainTransportPipeTransportDirectTransport
pub mod transport { /* ... */ }
Re-exports
Re-export crate::router::transport::*
pub use crate::router::transport::*;
Module direct_transport
A direct transport represents a direct connection between the mediasoup Rust process and a
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 DataProducers and
DataConsumers of type Direct created on a direct
transport.
Direct messages sent by a DataProducer in a direct
transport can be consumed by endpoints connected through a SCTP capable transport
(WebRtcTransport,
PlainTransport,
PipeTransport and also by the Rust application by means
of a 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 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 and
Consumer::on_rtp API (plus [DirectTransport::send_rtcp]
and [DirectTransport::on_rtcp] API).
pub mod direct_transport { /* ... */ }
Re-exports
Re-export crate::router::direct_transport::*
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 instances collocated on the same host or on
separate hosts.
Notes on usage
When calling PipeTransport::consume, all RTP streams of
the Producer are transmitted verbatim (in contrast to what happens
in WebRtcTransport and
PlainTransport in which a single and continuous RTP
stream is sent to the consuming endpoint).
pub mod pipe_transport { /* ... */ }
Re-exports
Re-export crate::router::pipe_transport::*
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.
pub mod plain_transport { /* ... */ }
Re-exports
Re-export crate::router::plain_transport::*
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
pub mod rtp_observer { /* ... */ }
Re-exports
Re-export crate::router::rtp_observer::*
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, meaning that it does not initiate ICE connections but expects ICE Binding Requests from endpoints.
pub mod webrtc_transport { /* ... */ }
Re-exports
Re-export crate::router::webrtc_transport::*
pub use crate::router::webrtc_transport::*;
Re-exports
Re-export mediasoup_types
pub use mediasoup_types as types;