What a WebRTC implementation provides to MobWebrtc.Peer.
An engine owns one peer connection per start_link/1 and reports to the
process that called it with messages of its own shape; event/1 turns each
into the engine-neutral events MobWebrtc documents, so a screen never sees
which engine is underneath. Descriptions and ICE candidates are JSON-shaped
maps with string keys (RTCSessionDescriptionInit, RTCIceCandidateInit),
ready to send over signaling as they are.
Engines:
MobWebrtc.Engine.ExWebRTC:ex_webrtcover the static NIFs.MobWebrtc.Engine.Fake: no network or native code, for host tests and for driving a screen without a remote peer.
Summary
Callbacks
Opens a data channel. Options: :ordered (boolean, default true),
:max_retransmits or :max_packet_life_time (ms; neither means reliable),
:protocol.
Turns a message the engine sent its caller into MobWebrtc events, or :ignore.
The local description with every local candidate gathered so far in it
(RTCPeerConnection.localDescription), or nil before one is set.
Asks the remote sender of track_id (a receive track) for a keyframe (RTCP PLI).
Sends one message on an open data channel.
Types
Callbacks
@callback close(pc()) :: :ok
@callback create_answer(pc()) :: {:ok, description()} | {:error, term()}
@callback create_data_channel(pc(), label :: String.t(), opts :: keyword()) :: {:ok, channel_ref()} | {:error, term()}
Opens a data channel. Options: :ordered (boolean, default true),
:max_retransmits or :max_packet_life_time (ms; neither means reliable),
:protocol.
@callback create_offer(pc()) :: {:ok, description()} | {:error, term()}
@callback event(message :: term()) :: {:ok, [MobWebrtc.event()]} | :ignore
Turns a message the engine sent its caller into MobWebrtc events, or :ignore.
@callback local_description(pc()) :: description() | nil
The local description with every local candidate gathered so far in it
(RTCPeerConnection.localDescription), or nil before one is set.
Asks the remote sender of track_id (a receive track) for a keyframe (RTCP PLI).
@callback send_data(pc(), channel_ref(), binary(), data_type()) :: :ok
Sends one message on an open data channel.
@callback send_rtp(pc(), track_id(), ExRTP.Packet.t()) :: :ok
@callback set_local_description(pc(), description()) :: :ok | {:error, term()}
@callback set_remote_description(pc(), description()) :: :ok | {:error, term()}