#[non_exhaustive]pub enum DataProducer {
Regular(RegularDataProducer),
Direct(DirectDataProducer),
}
Expand description
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
.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Regular(RegularDataProducer)
Data producer created on transport other than
DirectTransport
.
Direct(DirectDataProducer)
Data producer created on DirectTransport
.
Implementations§
Source§impl DataProducer
impl DataProducer
Sourcepub fn id(&self) -> DataProducerId
pub fn id(&self) -> DataProducerId
Data producer identifier.
Sourcepub fn type(&self) -> DataProducerType
pub fn type(&self) -> DataProducerType
The type of the data producer.
Sourcepub fn sctp_stream_parameters(&self) -> Option<SctpStreamParameters>
pub fn sctp_stream_parameters(&self) -> Option<SctpStreamParameters>
The SCTP stream parameters (just if the data producer type is Sctp
).
Sourcepub async fn get_stats(&self) -> Result<Vec<DataProducerStat>, RequestError>
pub async fn get_stats(&self) -> Result<Vec<DataProducerStat>, RequestError>
Returns current statistics of the data producer.
Check the RTC Statistics section for more details (TypeScript-oriented, but concepts apply here as well).
Sourcepub async fn pause(&self) -> Result<(), RequestError>
pub async fn pause(&self) -> Result<(), RequestError>
Pauses the data producer (no message is sent to its associated data consumers).
Calls DataConsumer::on_data_producer_pause
callback on all its associated data consumers.
Sourcepub async fn resume(&self) -> Result<(), RequestError>
pub async fn resume(&self) -> Result<(), RequestError>
Resumes the data producer (messages are sent to its associated data consumers).
Calls DataConsumer::on_data_producer_resume
callback on all its associated data consumers.
Sourcepub fn on_transport_close<F: FnOnce() + Send + 'static>(
&self,
callback: F,
) -> HandlerId
pub fn on_transport_close<F: FnOnce() + Send + 'static>( &self, callback: F, ) -> HandlerId
Callback is called when the transport this data producer belongs to is closed for whatever
reason. The producer itself is also closed. A on_data_producer_close
callback is called on
all its associated consumers.
Sourcepub fn on_pause<F: Fn() + Send + Sync + 'static>(
&self,
callback: F,
) -> HandlerId
pub fn on_pause<F: Fn() + Send + Sync + 'static>( &self, callback: F, ) -> HandlerId
Callback is called when the data producer is paused.
Sourcepub fn on_resume<F: Fn() + Send + Sync + 'static>(
&self,
callback: F,
) -> HandlerId
pub fn on_resume<F: Fn() + Send + Sync + 'static>( &self, callback: F, ) -> HandlerId
Callback is called when the data producer is resumed.
Sourcepub fn on_close<F: FnOnce() + Send + 'static>(&self, callback: F) -> HandlerId
pub fn on_close<F: FnOnce() + Send + 'static>(&self, callback: F) -> HandlerId
Callback is called when the producer is closed for whatever reason.
NOTE: Callback will be called in place if data producer is already closed.
Sourcepub fn downgrade(&self) -> WeakDataProducer
pub fn downgrade(&self) -> WeakDataProducer
Downgrade DataProducer
to WeakDataProducer
instance.
Trait Implementations§
Source§impl Clone for DataProducer
impl Clone for DataProducer
Source§fn clone(&self) -> DataProducer
fn clone(&self) -> DataProducer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more