RTCPeerConnection

open class RTCPeerConnection(configuration: RTCConfiguration = definedExternally) : EventTarget(source)

The RTCPeerConnection interface represents a WebRTC connection between the local computer and a remote peer.

MDN Reference

Constructors

Link copied to clipboard
constructor(configuration: RTCConfiguration = definedExternally)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The canTrickleIceCandidates read-only property of the RTCPeerConnection interface returns a boolean value which indicates whether or not the remote peer can accept trickled ICE candidates.

Link copied to clipboard

The connectionState read-only property of the RTCPeerConnection interface indicates the current state of the peer connection by returning one of the following string values: new, connecting, connected, disconnected, failed, or closed.

Link copied to clipboard

The currentLocalDescription read-only property of the RTCPeerConnection interface returns an RTCSessionDescription object describing the local end of the connection as it was most recently successfully negotiated since the last time the RTCPeerConnection finished negotiating and connecting to a remote peer.

Link copied to clipboard

The currentRemoteDescription read-only property of the RTCPeerConnection interface returns an Also included is a list of any ICE candidates that may already have been generated by the ICE agent since the offer or answer represented by the description was first instantiated.

Link copied to clipboard

The iceConnectionState read-only property of the RTCPeerConnection interface returns a string which state of the ICE agent associated with the RTCPeerConnection: new, checking, connected, completed, failed, disconnected, and closed.

Link copied to clipboard

The iceGatheringState read-only property of the RTCPeerConnection interface returns a string that describes the overall ICE gathering state for this connection.

Link copied to clipboard

The localDescription read-only property of the RTCPeerConnection interface returns an RTCSessionDescription describing the session for the local end of the connection.

Link copied to clipboard

The pendingLocalDescription read-only property of the RTCPeerConnection interface returns an RTCSessionDescription object describing a pending configuration change for the local end of the connection.

Link copied to clipboard

The pendingRemoteDescription read-only property of the RTCPeerConnection interface returns an RTCSessionDescription object describing a pending configuration change for the remote end of the connection.

Link copied to clipboard

The remoteDescription read-only property of the RTCPeerConnection interface returns a RTCSessionDescription describing the session (which includes configuration and media information) for the remote end of the connection.

Link copied to clipboard

The sctp read-only property of the RTCPeerConnection interface returns an RTCSctpTransport describing the SCTP transport over which SCTP data is being sent and received.

Link copied to clipboard

The signalingState read-only property of the RTCPeerConnection interface returns a string value describing the state of the signaling process on the local end of the connection while connecting or reconnecting to another peer.

Functions

Link copied to clipboard
suspend fun addIceCandidate(candidate: RTCIceCandidateInit? = definedExternally)

The addIceCandidate() method of the RTCPeerConnection interface adds a new remote candidate to the connection's remote description, which describes the state of the remote end of the connection.

Link copied to clipboard
fun addIceCandidateAsync(candidate: RTCIceCandidateInit? = definedExternally): Promise<Void>
Link copied to clipboard
fun addTrack(track: MediaStreamTrack, vararg streams: MediaStream): RTCRtpSender

The addTrack() method of the RTCPeerConnection interface adds a new media track to the set of tracks which will be transmitted to the other peer.

Link copied to clipboard
fun addTransceiver(trackOrKind: String, init: RTCRtpTransceiverInit = definedExternally): RTCRtpTransceiver

fun addTransceiver(trackOrKind: MediaStreamTrack, init: RTCRtpTransceiverInit = definedExternally): RTCRtpTransceiver

The addTransceiver() method of the RTCPeerConnection interface creates a new RTCRtpTransceiver and adds it to the set of transceivers associated with the RTCPeerConnection.

Link copied to clipboard
fun close()

The close() method of the RTCPeerConnection interface closes the current peer connection.

Link copied to clipboard
suspend fun createAnswer(options: RTCAnswerOptions = definedExternally): RTCSessionDescriptionInit

The createAnswer() method of the RTCPeerConnection interface creates an SDP answer to an offer received from a remote peer during the offer/answer negotiation of a WebRTC connection.

Link copied to clipboard
Link copied to clipboard
fun createDataChannel(label: String, dataChannelDict: RTCDataChannelInit = definedExternally): RTCDataChannel

The createDataChannel() method of the RTCPeerConnection interface creates a new channel linked with the remote peer, over which any kind of data may be transmitted.

Link copied to clipboard
suspend fun createOffer(options: RTCOfferOptions = definedExternally): RTCSessionDescriptionInit

The createOffer() method of the RTCPeerConnection interface initiates the creation of an SDP offer for the purpose of starting a new WebRTC connection to a remote peer.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The getConfiguration() method of the RTCPeerConnection interface returns an object which indicates the current configuration of the RTCPeerConnection on which the method is called.

Link copied to clipboard

The getReceivers() method of the RTCPeerConnection interface returns an array of RTCRtpReceiver objects, each of which represents one RTP receiver.

Link copied to clipboard

The getSenders() method of the RTCPeerConnection interface returns an array of RTCRtpSender objects, each of which represents the RTP sender responsible for transmitting one track's data.

Link copied to clipboard
suspend fun getStats(selector: MediaStreamTrack? = definedExternally): RTCStatsReport

The getStats() method of the RTCPeerConnection interface returns a promise which resolves with data providing statistics about either the overall connection or about the specified MediaStreamTrack.

Link copied to clipboard
fun getStatsAsync(selector: MediaStreamTrack? = definedExternally): Promise<RTCStatsReport>
Link copied to clipboard

The getTransceivers() method of the RTCPeerConnection interface returns a list of the RTCRtpTransceiver objects being used to send and receive data on the connection.

Link copied to clipboard

The removeTrack() method of the RTCPeerConnection interface tells the local end of the connection to stop sending media from the specified track, without actually removing the corresponding RTCRtpSender from the list of senders as reported by RTCPeerConnection.getSenders().

Link copied to clipboard

The restartIce() method of the RTCPeerConnection interface allows a web application to request that ICE candidate gathering be redone on both ends of the connection.

Link copied to clipboard
fun setConfiguration(configuration: RTCConfiguration = definedExternally)

The setConfiguration() method of the RTCPeerConnection interface sets the current configuration of the connection based on the values included in the specified object.

Link copied to clipboard
suspend fun setLocalDescription(description: RTCLocalSessionDescriptionInit = definedExternally)

The setLocalDescription() method of the RTCPeerConnection interface changes the local description associated with the connection.

Link copied to clipboard
Link copied to clipboard

The setRemoteDescription() method of the RTCPeerConnection interface sets the specified session description as the remote peer's current offer or answer.

Link copied to clipboard