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

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

# `connect_option`

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

# `create_option`

```elixir
@type create_option() :: map() | Mediasoup.WebRtcTransport.Options.t()
```

# `event_type`

```elixir
@type event_type() ::
  :on_close
  | :on_sctp_state_change
  | :on_ice_state_change
  | :on_dtls_state_change
  | :on_ice_selected_tuple_change
```

# `ice_parameter`

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

# `t`

```elixir
@type t() :: %Mediasoup.WebRtcTransport{id: String.t(), pid: pid()}
```

# `transport_stat`

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

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

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

  Closes the WebRtcTransport.

# `closed?`

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

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

# `connect`

```elixir
@spec connect(t(), connect_option()) :: {:ok} | {:error, String.t() | :terminated}
```

Provides the WebRTC transport with the endpoint parameters.
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-connect

# `consume`

```elixir
@spec consume(t(), Mediasoup.Consumer.Options.t() | map()) ::
  {:ok, Mediasoup.Consumer.t()} | {:error, String.t() | :terminated}
```

Instructs the router to send audio or video RTP (or SRTP depending on the transport class). This is the way to extract media from mediasoup.
https://mediasoup.org/documentation/v3/mediasoup/api/#transport-consume

# `consume_data`

```elixir
@spec consume_data(t(), Mediasoup.DataConsumer.Options.t() | map()) ::
  {:ok, Mediasoup.DataConsumer.t()} | {:error, String.t() | :terminated}
```

Instructs the router to send data messages to the endpoint via SCTP protocol or directly to the Node.js process if the transport is a DirectTransport.
https://mediasoup.org/documentation/v3/mediasoup/api/#transport-consumedata

# `dtls_parameters`

```elixir
@spec dtls_parameters(t()) :: map() | {:error, :terminated}
```

Local DTLS parameters.
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-dtlsParameters

# `dtls_state`

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

Current DTLS state.
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-dtlsState

# `dump`

```elixir
@spec dump(t()) :: any() | {:error, :terminated}
```

Dump internal stat for WebRtcTransport.

# `event`

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

Starts observing event.

# `get_stats`

```elixir
@spec get_stats(t()) :: [transport_stat()] | {:error, reason :: term()}
```

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

# `ice_candidates`

```elixir
@spec ice_candidates(t()) :: [any()]
```

Local ICE candidates.
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-iceCandidates

# `ice_parameters`

```elixir
@spec ice_parameters(t()) :: ice_parameter() | {:error, :terminated}
```

Local ICE parameters.
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-iceParameters

# `ice_role`

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

Local ICE role. Due to the mediasoup ICE Lite design, this is always "controlled".
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-iceRole

# `ice_selected_tuple`

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

The selected transport tuple if ICE is in "connected" or "completed" state. It is undefined if ICE is not established (no working candidate pair was found).
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-iceSelectedTuple

# `ice_state`

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

Current ICE state.
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-iceState

# `id`

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

WebRtcTransport identifier.

# `produce`

```elixir
@spec produce(t(), Mediasoup.Producer.Options.t() | map()) ::
  {:ok, Mediasoup.Producer.t()} | {:error, String.t() | :terminated}
```

Instructs the router to receive audio or video RTP (or SRTP depending on the transport class). This is the way to inject media into mediasoup.
https://mediasoup.org/documentation/v3/mediasoup/api/#transport-produce

# `produce_data`

```elixir
@spec produce_data(t(), Mediasoup.DataProducer.Options.t() | map()) ::
  {:ok, Mediasoup.DataProducer.t()} | {:error, String.t() | :terminated}
```

Instructs the router to receive data messages. Those messages can be delivered by an endpoint via SCTP protocol or can be directly sent from the Node.js application if the transport is a DirectTransport.
https://mediasoup.org/documentation/v3/mediasoup/api/#transport-producedata

# `restart_ice`

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

Current ICE state.
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-iceState

# `sctp_parameters`

```elixir
@spec sctp_parameters(t()) :: map() | {:error, :terminated}
```

Local SCTP parameters. Or undefined if SCTP is not enabled.
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-sctpParameters

# `sctp_state`

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

Current SCTP state. Or undefined if SCTP is not enabled.
https://mediasoup.org/documentation/v3/mediasoup/api/#webRtcTransport-sctpState

# `set_max_incoming_bitrate`

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

# `set_max_outgoing_bitrate`

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

# `start_link`

# `struct_from_pid`

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

# `struct_from_pid_and_ref`

---

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