[−][src]Struct mediasoup::consumer::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.
Implementations
impl Consumer
[src]
pub fn id(&self) -> ConsumerId
[src]
Consumer id.
pub fn producer_id(&self) -> ProducerId
[src]
Associated Producer id.
pub fn kind(&self) -> MediaKind
[src]
Media kind.
pub fn rtp_parameters(&self) -> &RtpParameters
[src]
Consumer RTP parameters.
Notes on usage
Check the RTP Parameters and Capabilities section for more details (TypeScript-oriented, but concepts apply here as well).
pub fn type(&self) -> ConsumerType
[src]
Consumer type.
pub fn paused(&self) -> bool
[src]
Whether the consumer is paused. It does not take into account whether the associated producer is paused.
pub fn producer_paused(&self) -> bool
[src]
Whether the associate Producer is paused.
pub fn priority(&self) -> u8
[src]
Consumer priority (see Consumer::set_priority
method).
pub fn score(&self) -> ConsumerScore
[src]
The score of the RTP stream being sent, representing its transmission quality.
pub fn preferred_layers(&self) -> Option<ConsumerLayers>
[src]
Preferred spatial and temporal layers (see Consumer::set_preferred_layers
method). For
simulcast and SVC consumers, None
otherwise.
pub fn current_layers(&self) -> Option<ConsumerLayers>
[src]
Currently active spatial and temporal layers (for Simulcast
and SVC
consumers only).
It's None
if no layers are being sent to the consuming endpoint at this time (or if the
consumer is consuming from a Simulcast
or SVC
producer).
pub fn app_data(&self) -> &AppData
[src]
Custom application data.
pub fn closed(&self) -> bool
[src]
Whether the consumer is closed.
pub async fn get_stats(&self) -> Result<ConsumerStats, RequestError>
[src]
Returns current RTC statistics of the consumer.
Check the RTC Statistics section for more details (TypeScript-oriented, but concepts apply here as well).
pub async fn pause(&self) -> Result<(), RequestError>
[src]
Pauses the consumer (no RTP is sent to the consuming endpoint).
pub async fn resume(&self) -> Result<(), RequestError>
[src]
Resumes the consumer (RTP is sent again to the consuming endpoint).
pub async fn set_preferred_layers(
&self,
consumer_layers: ConsumerLayers
) -> Result<(), RequestError>
[src]
&self,
consumer_layers: ConsumerLayers
) -> Result<(), RequestError>
Sets the preferred (highest) spatial and temporal layers to be sent to the consuming
endpoint. Just valid for Simulcast
and SVC
consumers.
pub async fn set_priority(&self, priority: u8) -> Result<(), RequestError>
[src]
Sets the priority for this consumer. It affects how the estimated outgoing bitrate in the transport (obtained via transport-cc or REMB) is distributed among all video consumers, by prioritizing those with higher priority.
pub async fn unset_priority(&self) -> Result<(), RequestError>
[src]
Unsets the priority for this consumer (it sets it to its default value 1
).
pub async fn request_key_frame(&self) -> Result<(), RequestError>
[src]
Request a key frame from associated producer. Just valid for video consumers.
pub async fn enable_trace_event(
&self,
types: Vec<ConsumerTraceEventType>
) -> Result<(), RequestError>
[src]
&self,
types: Vec<ConsumerTraceEventType>
) -> Result<(), RequestError>
Instructs the consumer to emit "trace" events. For monitoring purposes. Use with caution.
pub fn on_rtp<F: Fn(&Bytes) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
Callback is called when the consumer receives through its router a RTP packet from the associated producer.
Notes on usage
Just available in direct transports, this is, those created via
Router::create_direct_transport
.
pub fn on_pause<F: Fn() + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
Callback is called when the consumer or its associated producer is paused and, as result, the consumer becomes paused.
pub fn on_resume<F: Fn() + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
Callback is called when the consumer or its associated producer is resumed and, as result, the consumer is no longer paused.
pub fn on_producer_pause<F: Fn() + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
Callback is called when the associated producer is paused.
pub fn on_producer_resume<F: Fn() + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
Callback is called when the associated producer is resumed.
pub fn on_score<F: Fn(&ConsumerScore) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
Callback is called when the consumer score changes.
pub fn on_layers_change<F: Fn(&Option<ConsumerLayers>) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
Callback is called when the spatial/temporal layers being sent to the endpoint change. Just
for Simulcast
or SVC
consumers.
Notes on usage
This callback is called under various circumstances in SVC
or Simulcast
consumers
(assuming the consumer endpoints supports BWE via REMB or Transport-CC):
- When the consumer (or its associated producer) is paused.
- When all the RTP streams of the associated producer become inactive (no RTP received for a while).
- When the available bitrate of the BWE makes the consumer upgrade or downgrade the spatial and/or temporal layers.
- When there is no available bitrate for this consumer (even for the lowest layers) so the
callback is called with
None
as argument.
The Rust application can detect the latter (consumer deactivated due to not enough
bandwidth) by checking if both consumer.paused()
and consumer.producer_paused()
are
falsy after the consumer has called this callback with None
as argument.
pub fn on_trace<F: Fn(&ConsumerTraceEventData) + Send + Sync + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
See Consumer::enable_trace_event
method.
pub fn on_producer_close<F: FnOnce() + Send + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
Callback is called when the associated producer is closed for whatever reason. The consumer itself is also closed.
pub fn on_transport_close<F: FnOnce() + Send + 'static>(
&self,
callback: F
) -> HandlerId
[src]
&self,
callback: F
) -> HandlerId
Callback is called when the transport this consumer belongs to is closed for whatever reason. The consumer itself is also closed.
pub fn on_close<F: FnOnce() + Send + 'static>(&self, callback: F) -> HandlerId
[src]
Callback is called when the consumer is closed for whatever reason.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Consumer
[src]
impl Send for Consumer
[src]
impl Sync for Consumer
[src]
impl Unpin for Consumer
[src]
impl !UnwindSafe for Consumer
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,