Summary

Functions

Returns a specification to start this module under a supervisor.

Closes the consumer.

Tells whether the given consumer is closed on the local node.

Currently active spatial and temporal layers (for simulcast and SVC consumers only). It's nil 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). https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-currentLayers

Dump internal stat for Consumer.

Consumer identifier.

The media kind

Pauses the consumer (no RTP is sent to the consuming endpoint). https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-pause

Whether the consumer is paused. It does not take into account whether the associated producer is paused. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-paused

Preferred spatial and temporal layers (see set_preferred_layers/2 method). For simulcast and SVC consumers, nil otherwise. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-preferredLayers

The associated producer identifier.

Request a key frame to the associated producer. Just valid for video consumers. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-requestKeyFrame

Resumes the consumer (RTP is sent again to the consuming endpoint). https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-resume

Consumer RTP parameters.

The score of the RTP stream being sent, representing its tranmission quality.

Sets the preferred (highest) spatial and temporal layers to be sent to the consuming endpoint. Just valid for simulcast and SVC consumers. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-setPreferredLayers

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 priorizing those with higher priority. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-setPriority

Unsets the priority for this consumer (it sets it to its default value 1). https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-unsetPriority

Types

@type consumer_layers() :: map()

https://mediasoup.org/documentation/v3/mediasoup/api/#ConsumerLayers

@type consumer_score() :: map()

https://mediasoup.org/documentation/v3/mediasoup/api/#ConsumerScore

@type event_type() ::
  :on_close
  | :on_pause
  | :on_resume
  | :on_producer_resume
  | :on_producer_pause
  | :on_producer_close
  | :on_transport_close
  | :on_score
  | :on_layers_change
@type kind() :: String.t()

MediaKind("audio" or "video")

@type rtpParameters() :: map()

https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/#RtpReceiveParameters

@type t() :: %Mediasoup.Consumer{
  id: String.t(),
  kind: kind(),
  pid: pid(),
  producer_id: String.t(),
  rtp_parameters: rtpParameters(),
  type: type()
}
@type type() :: String.t()

https://mediasoup.org/documentation/v3/mediasoup/api/#ConsumerType

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec close(t()) :: :ok

Closes the consumer.

@spec closed?(t()) :: boolean()

Tells whether the given consumer is closed on the local node.

Link to this function

current_layers(consumer)

View Source
@spec current_layers(t()) :: consumer_layers() | nil

Currently active spatial and temporal layers (for simulcast and SVC consumers only). It's nil 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). https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-currentLayers

@spec dump(t()) :: map() | {:error}

Dump internal stat for Consumer.

Link to this function

event(consumer, listener, event_types \\ [:on_close, :on_pause, :on_resume, :on_producer_resume, :on_producer_pause, :on_producer_close, :on_transport_close, :on_score, :on_layers_change])

View Source
@spec event(t(), pid(), event_types :: [event_type()]) ::
  {:ok} | {:error, :terminated}

Starts observing event.

@spec get_stats(t()) :: list() | {:error, reason :: term()}

Returns current RTC statistics of the consumer. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-getStats

@spec id(t()) :: String.t()

Consumer identifier.

@spec kind(t()) :: kind()

The media kind

@spec pause(t()) :: {:ok} | {:error}

Pauses the consumer (no RTP is sent to the consuming endpoint). https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-pause

@spec paused?(t()) :: boolean()

Whether the consumer is paused. It does not take into account whether the associated producer is paused. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-paused

Link to this function

preferred_layers(consumer)

View Source
@spec preferred_layers(t()) :: consumer_layers() | nil

Preferred spatial and temporal layers (see set_preferred_layers/2 method). For simulcast and SVC consumers, nil otherwise. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-preferredLayers

@spec priority(t()) :: number()

Consumer priority (see set_priority/2). https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-priority

@spec producer_id(t()) :: String.t()

The associated producer identifier.

Link to this function

producer_paused?(consumer)

View Source
@spec producer_paused?(t()) :: boolean()

Whether the associated producer is paused. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-producerPaused

Link to this function

request_key_frame(consumer)

View Source
@spec request_key_frame(t()) :: {:ok} | {:error}

Request a key frame to the associated producer. Just valid for video consumers. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-requestKeyFrame

@spec resume(t()) :: {:ok} | {:error}

Resumes the consumer (RTP is sent again to the consuming endpoint). https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-resume

@spec rtp_parameters(t()) :: rtpParameters()

Consumer RTP parameters.

@spec score(t()) :: consumer_score()

The score of the RTP stream being sent, representing its tranmission quality.

Link to this function

set_preferred_layers(consumer, layer)

View Source
@spec set_preferred_layers(t(), map()) :: {:ok} | {:error}

Sets the preferred (highest) spatial and temporal layers to be sent to the consuming endpoint. Just valid for simulcast and SVC consumers. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-setPreferredLayers

Link to this function

set_priority(consumer, priority)

View Source
@spec set_priority(t(), integer()) :: {:ok} | {:error}

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 priorizing those with higher priority. https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-setPriority

@spec struct_from_pid(pid()) :: t()
Link to this function

struct_from_pid_and_ref(pid, reference)

View Source
@spec type(t()) :: type()

Consumer type. https://mediasoup.org/documentation/v3/mediasoup/api/#ConsumerType

Link to this function

unset_priority(consumer)

View Source
@spec unset_priority(t()) :: {:ok} | {:error}

Unsets the priority for this consumer (it sets it to its default value 1). https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-unsetPriority