API Reference xgw v#0.1.0

Copy Markdown View Source

Modules

XGW

XGW is a media gateway: it sits between a browser (or other WebRTC client) and your application so you do not have to implement ICE, DTLS, and SRTP yourself.

OTP application entry for XGW.

Creates and fingerprints the TLS certificate used for DTLS.

Starts and completes the DTLS handshake that unlocks encrypted media keys.

Patches Erlang/OTP's DTLS packet demux so XGW can share one UDP socket.

Turns a finished DTLS handshake into the keys SRTP needs for media.

Adapts OTP :ssl DTLS to XGW's shared Listener socket.

Separates mixed UDP packets that share one socket into STUN, DTLS, and media.

Turns negotiated Session Description Protocol (SDP) text into a transport config map that XGW.Peer can use.

Shared Interactive Connectivity Establishment (ICE) types and pure helpers.

Builds and validates STUN Binding messages used as ICE connectivity checks.

Forms, sorts, and advances ICE candidate pairs through check states.

Keeps an already-selected ICE path "alive" (consent freshness, RFC 7675).

Full ICE agent: gather candidates, run the checklist, nominate a pair.

Discovers ICE candidates: host, server-reflexive (srflx), and TURN relay.

ICE-lite agent: answer inbound STUN checks in the controlled role.

Shared UDP (and optional TCP) socket that receives all WebRTC traffic for many peers and routes each packet to the right XGW.Peer.

Accepts ICE-TCP connections and delivers framed STUN to XGW.Listener.

One remote WebRTC client: runs ICE, DTLS, and SRTP, then gives your app plaintext media and data-channel events.

Per-Peer process that owns SCTP and DTLS application-data for data channels.

Post-SDP local candidate checks and background srflx/relay gather for a Peer.

Starts and drives the SCTP association used for WebRTC data channels.

Hot-path outbound RTP without GenServer hops on Peer or Listener.

Peer-side TURN lifecycle: allocate, refresh, unwrap, and encode relay traffic.

Encrypts and decrypts media packets for one Peer after DTLS succeeds.

Plug router for the browser spike: static index, SDP offer/answer, trickle ICE.

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

Browser spike GenServer: one Listener + Peer, SDP answer, trickle ICE, status.

Frames STUN messages for transport over TCP (RFC 8489).

Client for TURN: allocate a relay address and send/receive through it.

Static-key SRTP for inter-edge trunk pipes.

Multiplex header for inter-edge trunk UDP payloads.

Bidirectional UDP + SRTP trunk between media edges.

Mix Tasks

Lab Mix task: run a browser-facing DTLS-SRTP spike against a local XGW stack.