# `XGW.Spike.SDP`
[🔗](https://github.com/Lazarus404/xgw/blob/main/spike/sdp.ex#L1)

Minimal SDP answer builder and helpers for the browser spike (`mix xgw.spike`).

# `answer`

```elixir
@spec answer(
  binary(),
  keyword()
) :: binary()
```

Builds a minimal WebRTC answer from an offer and local ICE/DTLS parameters.

Opts may include `:codec` as `:opus | :pcmu | :pcma | :g722` (default `:opus`).
The answer lists only that codec so the browser is forced onto it.

When the offer includes an SCTP application m-line, the answer BUNDLEs a matching
`m=application` with `a=sctp-port` / `a=max-message-size`.

# `detect_advert_ips`

```elixir
@spec detect_advert_ips() :: [:inet.ip_address()]
```

Host candidate IPs for the spike answer: loopback plus non-loopback IPv4 locals.

# `normalize_codec`

```elixir
@spec normalize_codec(term()) :: :opus | :pcmu | :pcma | :g722
```

Coerces a codec atom or header string to `:opus | :pcmu | :pcma | :g722`.

# `parse_ice`

```elixir
@spec parse_ice(binary()) :: {String.t() | nil, String.t() | nil}
```

Parses the browser's ICE ufrag and pwd from an offer SDP.

Uses the last match so media-level credentials win over session-level duplicates.

---

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