# `MobWebrtc.Native`
[🔗](https://github.com/GenericJam/mob_webrtc/blob/main/lib/mob_webrtc/native.ex#L1)

Gets the static `ex_dtls`, `ex_libsrtp` and `ex_sctp` NIFs loading on a Mob
device.

The first two NIF modules come from Bundlex, whose `on_load` builds the
library path from `:code.priv_dir/1` and falls back to
`Mix.Project.build_path/0` when that fails; `ExSCTP`'s Rustler `on_load`
calls `Application.app_dir/2`, which raises without a lib dir. Mob deploys
every `.beam` to one flat directory, so these apps have no lib dir, Mix
isn't on the device, and `on_load` fails. An empty `lib/<app>/ebin`, added
to the code path, gives each app a lib dir. The path is never opened: the
BEAM finds a static NIF by its module name. The dirs go under
`MOB_DATA_DIR`, not the beams dir, which is the read-only signed bundle in an
iOS release build.

`prepare/0` runs at application start, before anything touches the NIF
modules. Off the device (no `MOB_DATA_DIR`) it does nothing.

# `prepare`

```elixir
@spec prepare() :: :ok
```

# `status`

```elixir
@spec status() :: %{
  ex_dtls: :loaded | {:error, term()},
  ex_libsrtp: :loaded | {:error, term()},
  ex_sctp: :loaded | {:error, term()}
}
```

Whether each NIF module is loaded, loading it if it isn't yet.

---

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