View Source Membrane.WebRTC.Signaling (Membrane WebRTC plugin v0.25.0)
Signaling 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 to
Membrane.WebRTC.Source
orMembrane.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 signaling channel sendsmessage/0
to 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 signaling 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/1
orRTCPeerConnection.create_offer
in the JavaScript API%{"type" => "sdp_answer", "data" => data}
, where data is the return value ofExWebRTC.SessionDescription.to_json/1
orRTCPeerConnection.create_answer
in the JavaScript API%{"type" => "ice_candidate", "data" => data}
, where data is the return value ofExWebRTC.ICECandidate.to_json/1
orevent.candidate
from theRTCPeerConnection.onicecandidate
callback in the JavaScript API.
@type message() :: {:membrane_webrtc_signaling, 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.Signaling{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_webrtc
by default, seemessage_content/0
See the moduledoc for details.
@spec signal(t(), message_content(), metadata :: map()) :: :ok
Sends a signaling message to the signaling channel.
The calling process must be previously registered with register_peer/2
.
See the moduledoc for details.