View Source ExWebRTC.PeerConnection (ex_webrtc v0.1.0)

Implementation of the RTCPeerConnection.

Summary

Types

Possible PeerConnection states.

Messages sent by the ExWebRTC.

Possible PeerConnection signaling states.

Types

@type answer_options() :: []
@type connection_state() ::
  :closed | :failed | :disconnected | :new | :connecting | :connected

Possible PeerConnection states.

For the exact meaning, refer to the WebRTC W3C, section 4.3.3

@type offer_options() :: [{:ice_restart, boolean()}]
@type peer_connection() :: GenServer.server()
@type signal() ::
  {:ex_webrtc, pid(),
   :negotiation_needed
   | {:ice_candidate, ExWebRTC.ICECandidate.t()}
   | {:signaling_state_change, signaling_state()}
   | {:connection_state_change, connection_state()}
   | {:track, ExWebRTC.MediaStreamTrack.t()}
   | {:track_muted, ExWebRTC.MediaStreamTrack.id()}
   | {:track_ended, ExWebRTC.MediaStreamTrack.id()}
   | {:rtp, ExWebRTC.MediaStreamTrack.id(), ExRTP.Packet.t()}}

Messages sent by the ExWebRTC.

@type signaling_state() :: :stable | :have_local_offer | :have_remote_offer

Possible PeerConnection signaling states.

For the exact meaning, refer to the WebRTC W3C, section 4.3.1

@type transceiver_options() :: [{:direction, ExWebRTC.RTPTransceiver.direction()}]

Functions

Link to this function

add_ice_candidate(peer_connection, candidate)

View Source
@spec add_ice_candidate(peer_connection(), ExWebRTC.ICECandidate.t()) ::
  :ok | {:error, :no_remote_description}
Link to this function

add_track(peer_connection, track)

View Source
Link to this function

add_transceiver(peer_connection, kind_or_track, options \\ [])

View Source

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec close(peer_connection()) :: :ok
Link to this function

create_answer(peer_connection, options \\ [])

View Source
@spec create_answer(peer_connection(), answer_options()) ::
  {:ok, ExWebRTC.SessionDescription.t()} | {:error, :invalid_state}
Link to this function

create_offer(peer_connection, options \\ [])

View Source
@spec create_offer(peer_connection(), offer_options()) ::
  {:ok, ExWebRTC.SessionDescription.t()} | {:error, :invalid_state}
@spec get_all_running() :: [pid()]

Returns a list of all running peer connections.

Link to this function

get_current_local_description(peer_connection)

View Source
@spec get_current_local_description(peer_connection()) ::
  ExWebRTC.SessionDescription.t() | nil
Link to this function

get_current_remote_description(peer_connection)

View Source
@spec get_current_remote_description(peer_connection()) ::
  ExWebRTC.SessionDescription.t() | nil
Link to this function

get_stats(peer_connection)

View Source
@spec get_stats(peer_connection()) :: %{required(atom() | integer()) => map()}

Returns peer connection's statistics.

See RTCStatsReport for the output structure.

Link to this function

get_transceivers(peer_connection)

View Source
@spec get_transceivers(peer_connection()) :: [ExWebRTC.RTPTransceiver.t()]
Link to this function

remove_track(peer_connection, sender_id)

View Source
@spec remove_track(peer_connection(), ExWebRTC.RTPSender.id()) ::
  :ok | {:error, :invalid_sender_id}
Link to this function

replace_track(peer_connection, sender_id, track)

View Source
@spec replace_track(
  peer_connection(),
  ExWebRTC.RTPSender.id(),
  ExWebRTC.MediaStreamTrack.t()
) ::
  :ok | {:error, :invalid_sender_id | :invalid_track_type}
Link to this function

send_rtp(peer_connection, track_id, packet)

View Source
@spec send_rtp(peer_connection(), String.t(), ExRTP.Packet.t()) :: :ok
Link to this function

set_local_description(peer_connection, description)

View Source
@spec set_local_description(peer_connection(), ExWebRTC.SessionDescription.t()) ::
  :ok | {:error, atom()}
Link to this function

set_remote_description(peer_connection, description)

View Source
@spec set_remote_description(peer_connection(), ExWebRTC.SessionDescription.t()) ::
  :ok | {:error, atom()}
Link to this function

set_transceiver_direction(peer_connection, transceiver_id, direction)

View Source
@spec set_transceiver_direction(
  peer_connection(),
  ExWebRTC.RTPTransceiver.id(),
  ExWebRTC.RTPTransceiver.direction()
) :: :ok | {:error, :invalid_transceiver_id}
Link to this function

start_link(options \\ [])

View Source
Link to this function

stop_transceiver(peer_connection, transceiver_id)

View Source
@spec stop_transceiver(peer_connection(), ExWebRTC.RTPTransceiver.id()) ::
  :ok | {:error, :invalid_transceiver_id}