MedEx.Preview (med_ex v0.1.0)

Copy Markdown View Source

One replaceable, send-only WebRTC peer for an Opus preview. The caller owns the peer and receives its ExWebRTC state changes. Capture has its own lifetime.

Summary

Functions

Answers a receive-only browser audio offer containing the browser's ICE candidates.

Stops the underlying WebRTC peer connection if it is still alive.

Sends one Opus RTP packet with separate per-peer sequence (wrapped mod 65_536) and 48 kHz media clock sample_index (wrapped mod 2^32).

Types

t()

@type t() :: %MedEx.Preview{pid: pid(), track_id: ExWebRTC.MediaStreamTrack.id()}

Functions

answer(offer_sdp, opts \\ [])

@spec answer(String.t(), keyword()) :: {:ok, t(), String.t()} | {:error, term()}

Answers a receive-only browser audio offer containing the browser's ICE candidates.

The calling process owns the resulting ExWebRTC.PeerConnection and receives {:ex_webrtc, peer.pid, {:connection_state_change, state}} messages (such as :connected, :failed, and :closed). Call close/1 on teardown.

Options

  • :ice_servers — list of ICE server maps passed to ExWebRTC.PeerConnection (defaults to [] for direct local candidates).

close(preview)

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

Stops the underlying WebRTC peer connection if it is still alive.

send_opus(preview, payload, sequence, sample_index)

@spec send_opus(t(), binary(), non_neg_integer(), non_neg_integer()) :: :ok

Sends one Opus RTP packet with separate per-peer sequence (wrapped mod 65_536) and 48 kHz media clock sample_index (wrapped mod 2^32).