View Source Membrane.WebRTC.SignalingChannel (Membrane WebRTC plugin v0.23.1)
Channel for sending WebRTC signaling messages between Membrane elements and other WebRTC peers.
The flow of using the signaling channel is the following:
- Create it with
new/0. - Register the peer process (the one to send and receive signaling messages)
with
register_peer/2. - Pass the signaling channel to
Membrane.WebRTC.SourceorMembrane.WebRTC.Sink(this can also be done before the call toregister_peer/2). - Send and receive signaling messages. Messages can be sent by calling
signal/2. The channel sendsmessage/0to the peer.
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.
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.
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 ofExWebRTC.SessionDescription.to_json/1orRTCPeerConnection.create_offerin the JavaScript API%{"type" => "sdp_answer", "data" => data}, where data is the return value ofExWebRTC.SessionDescription.to_json/1orRTCPeerConnection.create_answerin the JavaScript API%{"type" => "ice_candidate", "data" => data}, where data is the return value ofExWebRTC.ICECandidate.to_json/1orevent.candidatefrom theRTCPeerConnection.onicecandidatecallback in the JavaScript API.
@type message() :: {Membrane.WebRTC.SignalingChannel, pid(), message_content(), metadata :: map()}
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.
@spec close(t()) :: :ok
@spec new() :: t()
Registers a process as a peer, so that it can send and receive signaling messages.
Options:
pid- pid of the peer,self()by defaultmessage_format-:ex_webrtcby default, seemessage_content/0
See the moduledoc for details.
@spec signal(t(), message_content(), metadata :: map()) :: :ok
Sends a signaling message to the channel.
The calling process must be previously registered with register_peer/2.
See the moduledoc for details.