#[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
Regular(RegularProducer)
Producer created on transport other than
DirectTransport
.
Direct(DirectProducer)
Producer created on DirectTransport
.
Implementations§
source§impl Producer
impl Producer
sourcepub fn id(&self) -> ProducerId
pub fn id(&self) -> ProducerId
Producer identifier.
sourcepub fn rtp_parameters(&self) -> &RtpParameters
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).
sourcepub fn type(&self) -> ProducerType
pub fn type(&self) -> ProducerType
Producer type.
sourcepub fn score(&self) -> Vec<ProducerScore>
pub fn score(&self) -> Vec<ProducerScore>
The score of each RTP stream being received, representing their transmission quality.
sourcepub async fn get_stats(&self) -> Result<Vec<ProducerStat>, RequestError>
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).
sourcepub async fn pause(&self) -> Result<(), RequestError>
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.
sourcepub async fn resume(&self) -> Result<(), RequestError>
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.
sourcepub async fn enable_trace_event(
&self,
types: Vec<ProducerTraceEventType>
) -> Result<(), RequestError>
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.
sourcepub fn on_score<F: Fn(&[ProducerScore]) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
pub fn on_score<F: Fn(&[ProducerScore]) + Send + Sync + 'static>( &self, callback: F ) -> HandlerId
Callback is called when the producer score changes.
sourcepub fn on_video_orientation_change<F: Fn(ProducerVideoOrientation) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
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.
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 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 producer is resumed.
sourcepub fn on_trace<F: Fn(&ProducerTraceEventData) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
pub fn on_trace<F: Fn(&ProducerTraceEventData) + Send + Sync + 'static>( &self, callback: F ) -> HandlerId
See Producer::enable_trace_event
method.
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 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.
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 producer is already closed.
sourcepub fn downgrade(&self) -> WeakProducer
pub fn downgrade(&self) -> WeakProducer
Downgrade Producer
to WeakProducer
instance.