# `Mediasoup.Consumer`
[🔗](https://github.com/oviceinc/mediasoup-elixir/blob/main/lib/consumer.ex#L1)

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

# `consumer_layers`

```elixir
@type consumer_layers() :: map()
```

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

# `consumer_score`

```elixir
@type consumer_score() :: map()
```

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

# `event_type`

```elixir
@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`

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

  MediaKind("audio" or "video")

# `rtpParameters`

```elixir
@type rtpParameters() :: map()
```

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

# `t`

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

# `type`

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

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

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

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

Closes the consumer.

# `closed?`

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

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

# `current_layers`

```elixir
@spec current_layers(t()) :: consumer_layers() | nil | {:error, :terminated}
```

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`

```elixir
@spec dump(t()) :: map() | {:error, :terminated} | {:error, String.t()}
```

Dump internal stat for Consumer.

# `event`

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

Starts observing event.

# `get_stats`

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

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

# `id`

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

Consumer identifier.

# `kind`

```elixir
@spec kind(t()) :: kind()
```

The media kind

# `link_pipe_producer`

# `pause`

```elixir
@spec pause(t()) :: {:ok} | {:error, :terminated} | {:error}
```

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

# `paused?`

```elixir
@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`

```elixir
@spec preferred_layers(t()) :: consumer_layers() | nil | {:error, :terminated}
```

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`

```elixir
@spec priority(t()) :: number() | {:error, :terminated}
```

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

# `producer_id`

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

The associated producer identifier.

# `producer_paused?`

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

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

# `request_key_frame`

```elixir
@spec request_key_frame(t()) :: {:ok} | {:error, :terminated} | {:error}
```

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

# `resume`

```elixir
@spec resume(t()) :: {:ok} | {:error, :terminated} | {:error}
```

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

# `rtp_parameters`

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

Consumer RTP parameters.

# `score`

```elixir
@spec score(t()) :: consumer_score() | {:error, :terminated}
```

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

# `set_preferred_layers`

```elixir
@spec set_preferred_layers(t(), map()) :: {:ok} | {:error, :terminated} | {: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`

```elixir
@spec set_priority(t(), integer()) :: {:ok} | {:error, :terminated} | {: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`

# `struct_from_pid`

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

# `struct_from_pid_and_ref`

# `type`

```elixir
@spec type(t()) :: type()
```

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

# `unset_priority`

```elixir
@spec unset_priority(t()) :: {:ok} | {:error, :terminated} | {:error}
```

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
