WebRtcPeerConnection

Abstract class representing a peer-to-peer connection.

See also

Inheritors

Constructors

Link copied to clipboard
constructor(coroutineContext: CoroutineContext, config: WebRtcConnectionConfig)

Properties

Link copied to clipboard
open override val dataChannelEvents: SharedFlow<DataChannelEvent>

Flow of newly added connection dataChannels, as a result of the remote peer calling WebRtcPeerConnection.createDataChannel.

Link copied to clipboard
open override val iceCandidates: SharedFlow<WebRtc.IceCandidate>

Flow of ICE candidates generated by this peer connection.

Link copied to clipboard
open override val iceConnectionState: StateFlow<WebRtc.IceConnectionState>

Flow of ICE connection state changes.

Link copied to clipboard
open override val iceGatheringState: StateFlow<WebRtc.IceGatheringState>

Flow of ICE gathering state changes.

Link copied to clipboard

The local session description for this connection.

Link copied to clipboard
open override val negotiationNeeded: SharedFlow<Unit>

Sets a callback to be invoked when negotiation (offer-answer exchange, etc.) is needed for this connection.

Link copied to clipboard

The remote session description for this connection.

Link copied to clipboard
open override val signalingState: StateFlow<WebRtc.SignalingState>

Flow of signaling state changes.

Link copied to clipboard
open override val state: StateFlow<WebRtc.ConnectionState>

Flow of connection state changes.

Link copied to clipboard
open override val stats: StateFlow<List<WebRtc.Stats>>

Flow of connection statistics.

Link copied to clipboard
open override val trackEvents: SharedFlow<TrackEvent>

Flow of events on a media track (e.g., add, remove).

Functions

Link copied to clipboard
abstract suspend fun addIceCandidate(candidate: WebRtc.IceCandidate)

Adds a remote ICE candidate to this connection.

Link copied to clipboard
abstract suspend fun addTrack(track: WebRtcMedia.Track): WebRtc.RtpSender

Adds a media track to this connection.

Link copied to clipboard
Link copied to clipboard
open override fun close()
Link copied to clipboard
abstract suspend fun createAnswer(): WebRtc.SessionDescription

Creates an SDP answer in response to a received offer.

Link copied to clipboard
abstract suspend fun createDataChannel(label: String, options: WebRtcDataChannelOptions.() -> Unit = {}): WebRtcDataChannel
Link copied to clipboard
abstract suspend fun createOffer(): WebRtc.SessionDescription

Creates an SDP offer for establishing a connection.

Link copied to clipboard
fun WebRtcPeerConnection.getNative(): RTCPeerConnection

Returns implementation of the peer connection that is used under the hood. Use it with caution.

Link copied to clipboard
abstract suspend fun getStatistics(): List<WebRtc.Stats>

Returns data providing statistics about the overall connection.

Link copied to clipboard
abstract suspend fun removeTrack(sender: WebRtc.RtpSender)

Removes a track from this connection using its RTP sender.

abstract suspend fun removeTrack(track: WebRtcMedia.Track)

Removes a track from this connection.

Link copied to clipboard
abstract fun restartIce()

Restarts ICE negotiation for this connection. Should emit negotiationNeeded event. The next offer will be created with iceRestart option.

Link copied to clipboard
abstract suspend fun setLocalDescription(description: WebRtc.SessionDescription)

Sets the local session description.

Link copied to clipboard
abstract suspend fun setRemoteDescription(description: WebRtc.SessionDescription)

Sets the remote session description.