View Source Membrane.WebRTC.SignalingChannel (Membrane WebRTC plugin v0.19.0)

Channel for sending WebRTC signaling messages between Membrane elements and other WebRTC peers.

The flow of using the signaling channel is the following:

Summary

Types

Messages sent and received if message_format is ex_webrtc.

Messages sent and received if message_format is json_data.

Messages sent by the signaling channel to the peer.

Messages that the peer sends with signal/2 and receives in message/0.

t()

Functions

Returns a specification to start this module under a supervisor.

Registers a process as a peer, so that it can send and receive signaling messages.

Sends a signaling message to the channel.

Types

@type ex_webrtc_message() ::
  ExWebRTC.ICECandidate.t() | ExWebRTC.SessionDescription.t()

Messages sent and received if message_format is ex_webrtc.

@type json_data_message() :: %{required(String.t()) => term()}

Messages sent and received if message_format is json_data.

The keys and values are the following

  • %{"type" => "sdp_offer", "data" => data}, where data is the return value of ExWebRTC.SessionDescription.to_json/1 or RTCPeerConnection.create_offer in the JavaScript API
  • %{"type" => "sdp_answer", "data" => data}, where data is the return value of ExWebRTC.SessionDescription.to_json/1 or RTCPeerConnection.create_answer in the JavaScript API
  • %{"type" => "ice_candidate", "data" => data}, where data is the return value of ExWebRTC.ICECandidate.to_json/1 or event.candidate from the RTCPeerConnection.onicecandidate callback in the JavaScript API.
@type message() :: {Membrane.WebRTC.SignalingChannel, pid(), message_content()}

Messages sent by the signaling channel to the peer.

@type message_content() :: ex_webrtc_message() | json_data_message()

Messages that the peer sends with signal/2 and receives in message/0.

If the message_format of the peer is ex_webrtc (default), they should be ex_webrtc_message/0. If the message_format is json_data, they should be json_data_message/0.

The message_format of the peer can be set in register_peer/2.

@type t() :: %Membrane.WebRTC.SignalingChannel{pid: pid()}

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

close(signaling_channel)

View Source
@spec close(t()) :: :ok
@spec new() :: t()
Link to this function

register_peer(signaling_channel, opts \\ [])

View Source
@spec register_peer(t(), message_format: :ex_webrtc | :json_data, pid: pid()) :: :ok

Registers a process as a peer, so that it can send and receive signaling messages.

Options:

  • pid - pid of the peer, self() by default
  • message_format - :ex_webrtc by default, see message_content/0

See the moduledoc for details.

Link to this function

signal(signaling_channel, message)

View Source
@spec signal(t(), message_content()) :: :ok

Sends a signaling message to the channel.

The calling process must be previously registered with register_peer/2. See the moduledoc for details.