Global Index
HTML5 JS API Index > WebRTC Tutorials & Specs

RTCPeerConnection

Extends EventTarget.

Properties
RTCIceConnectionState
iceConnectionState
The iceConnectionState attribute MUST return the state of the RTCPeerConnection ICE Agent ICE state.
RTCIceGatheringState
iceGatheringState
The iceGatheringState attribute MUST return the gathering state of the RTCPeerConnection ICE Agent connection state.
RTCSessionDescription?
localDescription
The localDescription attribute MUST return the RTCSessionDescription that was most recently passed to setLocalDescription(), plus any local candidates that have been generated by the ICE Agent since then.
EventHandler
onaddstream
This event handler, of event handler event type addstream, MUST be fired by all objects implementing the RTCPeerConnection interface. It is called any time a MediaStream is added by the remote peer. This will be fired only as a result of setRemoteDescription.
EventHandler
ondatachannel
This event handler, of type datachannel, MUST be supported by all objects implementing the RTCPeerConnection interface.
EventHandler
onicecandidate
This event handler, of event handler event type icecandidate, MUST be supported by all objects implementing the RTCPeerConnection interface.
EventHandler
oniceconnectionstatechange
This event handler, of event handler event type iceconnectionstatechange, MUST be fired by all objects implementing the RTCPeerConnection interface. It is called any time the iceConnectionState changes.
EventHandler
onidentityresult
This event handler, of event handler event type identityresult, MUST be fired by all objects implementing the RTCPeerConnection interface. It is called any time an identity verification succeeds or fails.
EventHandler
onnegotiationneeded
This event handler, of event handler event type negotiationneeded , MUST be supported by all objects implementing the RTCPeerConnection interface.
EventHandler
onremovestream
This event handler, of event handler event type removestream, MUST be fired by all objects implementing the RTCPeerConnection interface. It is called any time a MediaStream is removed by the remote peer. This will be fired only as a result of setRemoteDescription.
EventHandler
onsignalingstatechange
This event handler, of event handler event type signalingstatechange, MUST be supported by all objects implementing the RTCPeerConnection interface. It is called any time the readyState changes, i.e., from a call to setLocalDescription, a call to setRemoteDescription, or code.
RTCIdentityAssertion?
peerIdentity
Contains the peer identity assertion information if an identity assertion was provided and verified.
RTCSessionDescription?
remoteDescription
The remoteDescription attribute MUST return the RTCSessionDescription that was most recently passed to setRemoteDescription(), plus any remote candidates that have been supplied via addIceCandidate() since then.
RTCSignalingState
signalingState
The signalingState attribute MUST return the RTCPeerConnection object's RTCPeerConnection signaling state.
Constructor
RTCPeerConnection(RTCConfiguration configuration)
Operations
void
addIceCandidate(RTCIceCandidate candidate, VoidFunction successCallback, RTCPeerConnectionErrorCallback failureCallback)
The addIceCandidate() method provides a remote candidate to the ICE Agent. In addition to being added to the remote description, connectivity checks will be sent to the new candidates as long as the ICE Transports setting is not set to none.
void
addStream(MediaStream stream)
Adds a new stream to the RTCPeerConnection.
voidclose()
void
createAnswer(RTCSessionDescriptionCallback successCallback, RTCPeerConnectionErrorCallback failureCallback, optional RTCOfferAnswerOptions options)
The createAnswer method generates an [SDP] answer with the supported configuration for the session that is compatible with the parameters in the remote configuration. Like createOffer, the returned blob contains descriptions of the local MediaStreams attached to this RTCPeerConnection, the codec/RTP/RTCP options negotiated for this session, and any candidates that have been gathered by the ICE Agent.
RTCDataChannel
createDataChannel(DOMString label, optional RTCDataChannelInit dataChannelDict)
Creates a new RTCDataChannel object with the given label. The RTCDataChannelInit dictionary can be used to configure properties of the underlying channel such as data reliability.
RTCDTMFSender
createDTMFSender(MediaStreamTrack track)
The createDTMFSender() method creates an RTCDTMFSender that references the given MediaStreamTrack. The MediaStreamTrack MUST be an element of a MediaStream that's currently in the RTCPeerConnection object's local streams set; if not, throw an InvalidParameter exception and abort these steps.
void
createOffer(RTCSessionDescriptionCallback successCallback, RTCPeerConnectionErrorCallback failureCallback, optional RTCOfferOptions options)
The createOffer method generates a blob of SDP that contains an RFC 3264 offer with the supported configurations for the session, including descriptions of the local MediaStreams attached to this RTCPeerConnection, the codec/RTP/RTCP options supported by this implementation, and any candidates that have been gathered by the ICE Agent.
RTCConfiguration
getConfiguration()
Returns a RTCConfiguration object representing the current configuration of this RTCPeerConnection object.
void
getIdentityAssertion()
Initiates the process of obtaining an identity assertion. Applications need not make this call. It is merely intended to allow them to start the process of obtaining identity assertions before a call is initiated. If an identity is needed, either because the browser has been configured with a default identity provider or because the setIdentityProvider() method was called, then an identity will be automatically requested when an offer or answer is created.
sequence<MediaStream>
getLocalStreams()
Returns a sequence of MediaStream objects representing the streams that are currently sent with this RTCPeerConnection object.
sequence<MediaStream>
getRemoteStreams()
Returns a sequence of MediaStream objects representing the streams that are currently received with this RTCPeerConnection object.
void
getStats(MediaStreamTrack? selector, RTCStatsCallback successCallback, RTCPeerConnectionErrorCallback failureCallback)
Gathers stats for the given selector and reports the result asynchronously.
MediaStream?
getStreamById(DOMString streamId)
If a MediaStream object, with an id equal to streamId, exists in this RTCPeerConnection object’s stream sets (local streams set or remote streams set), then the getStreamById() method MUST return that MediaStream object.
void
removeStream(MediaStream stream)
Removes the given stream from the RTCPeerConnection.
void
setIdentityProvider(DOMString provider, optional DOMString protocol, optional DOMString username)
Sets the identity provider to be used for a given RTCPeerConnection object. Applications need not make this call; if the browser is already configured for an IdP, then that configured IdP will be used to get an assertion.
void
setLocalDescription(RTCSessionDescription description, VoidFunction successCallback, RTCPeerConnectionErrorCallback failureCallback)
The setLocalDescription() method instructs the RTCPeerConnection to apply the supplied RTCSessionDescription as the local description.
void
setRemoteDescription(RTCSessionDescription description, VoidFunction successCallback, RTCPeerConnectionErrorCallback failureCallback)
The setRemoteDescription() method instructs the RTCPeerConnection to apply the supplied RTCSessionDescription as the remote offer or answer. This API changes the local media state.
void
updateIce(RTCConfiguration configuration)
The updateIce method updates the ICE Agent process of gathering local candidates and pinging remote candidates.