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

consumer_layers()

@type consumer_layers() :: map()

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

consumer_score()

@type consumer_score() :: map()

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

event_type()

@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

kind()

@type kind() :: String.t()

MediaKind("audio" or "video")

rtpParameters()

@type rtpParameters() :: map()

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

t()

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

type()

@type type() :: String.t()

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

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(consumer)

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

Closes the consumer.

closed?(consumer)

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

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

current_layers(consumer)

@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

dump(consumer)

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

Dump internal stat for Consumer.

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])

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

Starts observing event.

get_stats(consumer)

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

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

id(map)

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

Consumer identifier.

kind(map)

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

The media kind

pause(consumer)

@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

paused?(consumer)

@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

preferred_layers(consumer)

@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

priority(consumer)

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

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

producer_id(map)

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

The associated producer identifier.

producer_paused?(consumer)

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

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

request_key_frame(consumer)

@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

resume(consumer)

@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

rtp_parameters(map)

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

Consumer RTP parameters.

score(consumer)

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

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

set_preferred_layers(consumer, layer)

@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

set_priority(consumer, priority)

@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

start_link(opt)

struct_from_pid(pid)

@spec struct_from_pid(pid()) :: t()

struct_from_pid_and_ref(pid, reference)

type(map)

@spec type(t()) :: type()

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

unset_priority(consumer)

@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