RTCPeerConnection object

[Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.]

The RTCPeerConnection object is used to represent a connection between a local device and a remote peer.

Syntax

 var peerConnection = new RTCPeerConnection(configuration); 

Members

The RTCPeerConnection object has these types of members:

  • Events
  • Methods
  • Properties

Events

The RTCPeerConnection object has these events.

Event Description
onaddstream

This event fires when a new MediaStream object is added to the RTCPeerConnection.

onicecandidate

This event fires when a new RTCIceCandidate object is made available.

oniceconnectionstatechange

This event fires when the iceConnectionState of the RTCPeerConnection has changed.

onicegatheringstatechange

This event fires when the iceGatheringState of the RTCPeerConnection has changed.

onnegotiationneeded

This event fires any time the browser wants to inform the application that session negotiation needs to be done.

onremovestream

This event fires when a MediaStream object is removed from the RTCPeerConnection.

onsignalingstatechange

This event fires when the signaling state has changed.

 

Methods

The RTCPeerConnection object has these methods.

Method Description
addIceCandidate

The addIceCandidate method adds an ice candidate to an ICE agent.

addStream

The addStream method takes a MediaStream and adds it as a local source to an RTCPeerConnection object.

close

The close method closes the current peer connection.

createAnswer

The createAnswer method creates an answer once an offer from a remote peer has been received.

createOffer

The createOffer method creates an SDP offer.

getConfiguration

The getConfiguration method returns an RTCConfiguration object that has the current configuration values of the RTCPeerConnection object.

getLocalStreams

The getLocalStreams method returns a sequenced array of MediaStreams that are associated with the local end of the connection.

getRemoteStreams

The getRemoteStreams method returns a sequenced array of MediaStreams that are associated with the remote end of the connection.

getStats

The getStats method gathers stats of the RTCPeerConnection and reports the result asynchronously.

getStreamById

The getStreamById method takes an ID and returns the MediaStream with that ID associated with the local or remote end of the connection.

removeStream

The removeStream method takes a MediaStream and removes it as a local source from an RTCPeerConnection object.

setLocalDescription

The setLocalDescription method updates the local description of the connection.

setRemoteDescription

The setRemoteDescription method updates the remote description of the connection.

 

Properties

The RTCPeerConnection object has these properties.

Property Access type Description

canTrickleIceCandidates

Read-only

The canTrickleIceCandidates property indicates whether the remote peer can accept trickled ICE candidates.

iceConnectionState

Read-only

The iceConnectionState property indicates whether the remote peer can accept trickled ICE candidates.

iceGatheringState

Read-only

The iceGatheringState property describes the connections gathering state.

localDescription

Read-only

The localDescription property represents the description of the local end of the connection.

remoteDescription

Read-only

The remoteDescription property represents the description of the remote end of the connection.

signalingState

Read-only

The signalingState property describes the state of the signaling process for the local end of the connection.

 

Remarks

The RTCPeerConnection constructor includes the following parameters:

Parameter Type Description
configuration RTCConfiguration Provides changes to be made to the connection configuration.