#[non_exhaustive]
pub enum Producer { Regular(RegularProducer), Direct(DirectProducer), }
Expand description

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.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Regular(RegularProducer)

Producer created on transport other than DirectTransport.

§

Direct(DirectProducer)

Producer created on DirectTransport.

Implementations§

source§

impl Producer

source

pub fn id(&self) -> ProducerId

Producer identifier.

source

pub fn transport(&self) -> &Arc<dyn Transport>

Transport to which producer belongs.

source

pub fn kind(&self) -> MediaKind

Media kind.

source

pub fn rtp_parameters(&self) -> &RtpParameters

Producer RTP parameters.

§Notes on usage

Check the RTP Parameters and Capabilities section for more details (TypeScript-oriented, but concepts apply here as well).

source

pub fn type(&self) -> ProducerType

Producer type.

source

pub fn paused(&self) -> bool

Whether the Producer is paused.

source

pub fn score(&self) -> Vec<ProducerScore>

The score of each RTP stream being received, representing their transmission quality.

source

pub fn app_data(&self) -> &AppData

Custom application data.

source

pub fn closed(&self) -> bool

Whether the producer is closed.

source

pub async fn get_stats(&self) -> Result<Vec<ProducerStat>, RequestError>

Returns current RTC statistics of the producer.

Check the RTC Statistics section for more details (TypeScript-oriented, but concepts apply here as well).

source

pub async fn pause(&self) -> Result<(), RequestError>

Pauses the producer (no RTP is sent to its associated consumers). Calls Consumer::on_producer_pause callback on all its associated consumers.

source

pub async fn resume(&self) -> Result<(), RequestError>

Resumes the producer (RTP is sent to its associated consumers). Calls Consumer::on_producer_resume callback on all its associated consumers.

source

pub async fn enable_trace_event( &self, types: Vec<ProducerTraceEventType> ) -> Result<(), RequestError>

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

source

pub fn on_score<F: Fn(&[ProducerScore]) + Send + Sync + 'static>( &self, callback: F ) -> HandlerId

Callback is called when the producer score changes.

source

pub fn on_video_orientation_change<F: Fn(ProducerVideoOrientation) + Send + Sync + 'static>( &self, callback: F ) -> HandlerId

Callback is called when the video orientation changes. This is just possible if the urn:3gpp:video-orientation RTP extension has been negotiated in the producer RTP parameters.

source

pub fn on_pause<F: Fn() + Send + Sync + 'static>( &self, callback: F ) -> HandlerId

Callback is called when the producer is paused.

source

pub fn on_resume<F: Fn() + Send + Sync + 'static>( &self, callback: F ) -> HandlerId

Callback is called when the producer is resumed.

source

pub fn on_trace<F: Fn(&ProducerTraceEventData) + Send + Sync + 'static>( &self, callback: F ) -> HandlerId

source

pub fn on_transport_close<F: FnOnce() + Send + 'static>( &self, callback: F ) -> HandlerId

Callback is called when the transport this producer belongs to is closed for whatever reason. The producer itself is also closed. A on_producer_close callback is called on all its associated consumers.

source

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 producer is already closed.

source

pub fn downgrade(&self) -> WeakProducer

Downgrade Producer to WeakProducer instance.

Trait Implementations§

source§

impl Clone for Producer

source§

fn clone(&self) -> Producer

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Producer

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<DirectProducer> for Producer

source§

fn from(producer: DirectProducer) -> Self

Converts to this type from the input type.
source§

impl From<RegularProducer> for Producer

source§

fn from(producer: RegularProducer) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.