Abstract
This document defines a set of ECMAScript APIs in WebIDL to allow media and generic application data to be sent to and received from another browser or device implementing the appropriate set of real-time protocols. This specification is being developed in conjunction with a protocol specification developed by the IETF RTCWEB group and an API specification to get access to local media devices.
Status of This Document
This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.
This document includes Candidate Amendments.
Its associated test suite has been used to build an implementation report of the API at the time of its initial publication as a Recommendation. That test suite has been updated to integrate proposed and candidates amendments identified since then, and an updated implementation report focused on the implementation status of these amendments has been used to select features with double implementation as proposed amendments, now fully incorporated in this version of the Recommendation.
This document was published by the Web Real-Time Communications Working Group as a Recommendation using the Recommendation track. It includes candidate amendments, introducing substantive changes and new features since the previous Recommendation.
W3C recommends the wide deployment of this specification as a standard for the Web.
A W3C Recommendation is a specification that, after extensive consensus-building, is endorsed by W3C and its Members, and has commitments from Working Group members to royalty-free licensing for implementations. Future updates to this Recommendation may incorporate new features.
Candidate additions are marked in the document.
Candidate corrections are marked in the document.
This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This document is governed by the 03 November 2023 W3C Process Document.
Table of Contents
- Abstract
- Status of This Document
- 1. Introduction
- 2. Conformance
- 3. Terminology
- 4.
Peer-to-peer connections
- 4.1 Introduction
- 4.2 Configuration
- 4.3 State Definitions
- 4.4 RTCPeerConnection Interface
- 4.5 Error Handling
- 4.6 Session Description Model
- 4.7 Session Negotiation Model
- 4.8 Interfaces for Interactive Connectivity Establishment
- 4.9 Certificate Management
- 5.
RTP Media API
- 5.1 RTCPeerConnection Interface Extensions
- 5.2
RTCRtpSenderInterface- 5.2.1
RTCRtpParametersDictionary - 5.2.2
RTCRtpSendParametersDictionary - 5.2.3
RTCRtpReceiveParametersDictionary - 5.2.4
RTCRtpCodingParametersDictionary - 5.2.5
RTCRtpEncodingParametersDictionary - 5.2.6
RTCRtcpParametersDictionary - 5.2.7
RTCRtpHeaderExtensionParametersDictionary - 5.2.8
RTCRtpCodecDictionary - 5.2.9
RTCRtpCodecParametersDictionary - 5.2.10
RTCRtpCapabilitiesDictionary - 5.2.11
RTCRtpHeaderExtensionCapabilityDictionary - 5.2.12
RTCSetParameterOptionsDictionary
- 5.2.1
- 5.3
RTCRtpReceiverInterface - 5.4
RTCRtpTransceiverInterface - 5.5
RTCDtlsTransportInterface - 5.6
RTCIceTransportInterface - 5.7
RTCTrackEvent
- 6. Peer-to-peer Data API
- 7. Peer-to-peer DTMF
- 8. Statistics Model
- 9. Media Stream API Extensions for Network Use
- 10. Examples and Call Flows
- 11. Error Handling
- 12. Event summary
- 13. Privacy and Security Considerations
- 14. Accessibility Considerations
- A. Candidate Amendments
- B. Acknowledgements
- C. References
This section is non-normative.
There are a number of facets to peer-to-peer communications and video-conferencing in HTML covered by this specification:
- Connecting to remote peers using NAT-traversal technologies such as ICE, STUN, and TURN.
- Sending the locally-produced tracks to remote peers and receiving tracks from remote peers.
- Sending arbitrary data directly to remote peers.
This document defines the APIs used for these features. This specification is being developed in conjunction with a protocol specification developed by the IETF RTCWEB group and an API specification to get access to local media devices [GETUSERMEDIA] developed by the WebRTC Working Group. An overview of the system can be found in [RFC8825] and [RFC8826].
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words MAY, MUST, MUST NOT, and SHOULD in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.
Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.)
Implementations that use ECMAScript to implement the APIs defined in this specification MUST implement them in a manner consistent with the ECMAScript Bindings defined in the Web IDL specification [WEBIDL], as this specification uses that specification and terminology.
The EventHandler interface, representing a callback used for event
handlers, is defined in [HTML].
The concepts queue a task and networking task source are defined in [HTML].
The concept fire an event is defined in [DOM].
The terms event, event handlers and event handler event types are defined in [HTML].
Performance.timeOrigin and Performance.now() are defined in
[hr-time].
The terms serializable objects , serialization steps, and deserialization steps are defined in [HTML].
The terms MediaStream, MediaStreamTrack, and
MediaStreamConstraints are defined in [GETUSERMEDIA]. Note that
MediaStream is extended in 9.2
MediaStream
in this document while MediaStreamTrack is extended in 9.3
MediaStreamTrack in this document.
The term Blob is defined in [FILEAPI].
The term media description is defined in [RFC4566].
The term media transport is defined in [RFC7656].
The term generation is defined in [RFC8838] Section 2.
The terms stats object and monitored object are defined in [WEBRTC-STATS].
When referring to exceptions, the terms throw and created are defined in [WEBIDL].
The callback VoidFunction is defined in [WEBIDL].
The term "throw" is used as specified in [INFRA]: it terminates the current processing steps.
The terms fulfilled , rejected , resolved , and settled used in the context of Promises are defined in [ECMASCRIPT-6.0].
The AlgorithmIdentifier is defined in [WebCryptoAPI].
Note
The general principles for Javascript APIs apply, including the
principle of run-to-completion
and no-data-races as defined in [API-DESIGN-PRINCIPLES]. That is,
while a task is running, external events do not influence what's
visible to the Javascript application. For example, the amount of data
buffered on a data channel will increase due to "send" calls while
Javascript is executing, and the decrease due to packets being sent
will be visible after a task checkpoint.
It is the responsibility of the user agent to make sure the set of
values presented to the application is consistent - for instance that
getContributingSources() (which is synchronous) returns values for all
sources measured at the same time.
This section is non-normative.
An RTCPeerConnection instance allows an application to establish
peer-to-peer communications with another RTCPeerConnection
instance in another browser, or to another endpoint implementing the
required protocols. Communications are coordinated by the exchange of
control messages (called a signaling protocol) over a signaling
channel which is provided by unspecified means, but generally by a
script in the page via the server, e.g. using WebSocket or
XMLHttpRequest.
The RTCConfiguration defines a set of parameters to configure
how the peer-to-peer communication established via
RTCPeerConnection is established or re-established.
dictionary RTCConfiguration {
sequence<RTCIceServer> iceServers = [];
RTCIceTransportPolicy iceTransportPolicy = "all";
RTCBundlePolicy bundlePolicy = "balanced";
RTCRtcpMuxPolicy rtcpMuxPolicy = "require";
sequence<RTCCertificate> certificates = [];
[EnforceRange] octet iceCandidatePoolSize = 0;
};
-
iceServersof type sequence<RTCIceServer>, defaulting to[]. -
An array of objects describing servers available to be used by ICE, such as STUN and TURN servers. If the number of ICE servers exceeds an implementation-defined limit, ignore the ICE servers above the threshold. This implementation defined limit MUST be at least 32.
-
iceTransportPolicyof typeRTCIceTransportPolicy, defaulting to"all". -
Indicates which candidates the ICE Agent is allowed to use.
-
bundlePolicyof typeRTCBundlePolicy, defaulting to"balanced". -
Indicates which media-bundling policy to use when gathering ICE candidates.
-
rtcpMuxPolicyof typeRTCRtcpMuxPolicy, defaulting to"require". -
Indicates which rtcp-mux policy to use when gathering ICE candidates.
-
certificatesof type sequence<RTCCertificate>, defaulting to[]. -
A set of certificates that the
RTCPeerConnectionuses to authenticate.Valid values for this parameter are created through calls to the
generateCertificate()function.Although any given DTLS connection will use only one certificate, this attribute allows the caller to provide multiple certificates that support different algorithms. The final certificate will be selected based on the DTLS handshake, which establishes which certificates are allowed. The
RTCPeerConnectionimplementation selects which of the certificates is used for a given connection; how certificates are selected is outside the scope of this specification.Note
Existing implementations only utilize the first certificate provided; the others are ignored.
If this value is absent, then a default set of certificates is generated for each
RTCPeerConnectioninstance.This option allows applications to establish key continuity. An
RTCCertificatecan be persisted in [INDEXEDDB] and reused. Persistence and reuse also avoids the cost of key generation.The value for this configuration option cannot change after its value is initially selected.
-
iceCandidatePoolSizeof type octet, defaulting to0 -
Size of the prefetched ICE pool as defined in [RFC9429] (section 3.5.4. and section 4.1.1.).
The RTCIceServer dictionary is used to describe the STUN and
TURN servers that can be used by the ICE Agent to establish a
connection with a peer.
dictionary RTCIceServer {
required (DOMString or sequence<DOMString>) urls;
DOMString username;
DOMString credential;
};
-
urlsof type (DOMString or sequence<DOMString>), required -
STUN or TURN URI(s) as defined in [RFC7064] and [RFC7065] or other URI types.
-
usernameof type DOMString -
If this
RTCIceServerobject represents a TURN server, then this attribute specifies the username to use with that TURN server. -
credentialof typeDOMString -
If this
RTCIceServerobject represents a TURN server, then this attribute specifies the credential to use with that TURN server.credentialrepresents a long-term authentication password, as described in [RFC5389], Section 10.2.
An example array of RTCIceServer objects is:
[
{urls: 'stun:stun1.example.net'},
{urls: ['turns:turn.example.org', 'turn:turn.example.net'],
username: 'user',
credential: 'myPassword',
];
As described in [RFC9429] (section 4.1.1.), if
the iceTransportPolicy member of the
RTCConfiguration is specified, it defines the ICE candidate policy [RFC9429] (section 3.5.3.) the
browser uses to surface the permitted candidates to the
application; only these candidates will be used for connectivity
checks.
enum RTCIceTransportPolicy {
"relay",
"all"
};
| Enum value | Description |
|---|---|
relay
|
The ICE Agent uses only media relay candidates such as candidates passing through a TURN server. Note This can be used to prevent the remote endpoint from learning the user's IP addresses, which may be desired in certain use cases. For example, in a "call"-based application, the application may want to prevent an unknown caller from learning the callee's IP addresses until the callee has consented in some way. |
all
|
The ICE Agent can use any type of candidate when this value is specified. Note
The implementation can still use its own candidate
filtering policy in order to limit the IP addresses
exposed to the application, as noted in the description
of |
As described in [RFC9429] (section 4.1.1.), bundle policy affects which media tracks are negotiated if the remote endpoint is not bundle-aware, and what ICE candidates are gathered. If the remote endpoint is bundle-aware, all media tracks and data channels are bundled onto the same transport.
enum RTCBundlePolicy {
"balanced",
"max-compat",
"max-bundle"
};
| Enum value | Description |
|---|---|
balanced
|
Gather ICE candidates for each media type in use (audio, video, and data). If the remote endpoint is not bundle-aware, negotiate only one audio and video track on separate transports. |
max-compat
|
Gather ICE candidates for each track. If the remote endpoint is not bundle-aware, negotiate all media tracks on separate transports. |
max-bundle
|
Gather ICE candidates for only one track. If the remote endpoint is not bundle-aware, negotiate only one media track. |
As described in [RFC9429] (section 4.1.1.), the
RTCRtcpMuxPolicy affects what ICE candidates are gathered to
support non-multiplexed RTCP. The only value defined in this spec
is "require".
enum RTCRtcpMuxPolicy {
"require"
};
| Enum value | Description |
|---|---|
require
|
Gather ICE candidates only for RTP and multiplex RTCP on the RTP candidates. If the remote endpoint is not capable of rtcp-mux, session negotiation will fail. |
These dictionaries describe the options that can be used to control the offer/answer creation process.
dictionary RTCOfferAnswerOptions {};
dictionary RTCOfferOptions : RTCOfferAnswerOptions {
boolean iceRestart = false;
};
-
iceRestartof type boolean, defaulting tofalse -
When the value of this dictionary member is
true, or the relevantRTCPeerConnectionobject's[[LocalIceCredentialsToReplace]]slot is not empty, then the generated description will have ICE credentials that are different from the current credentials (as visible in thecurrentLocalDescriptionattribute's SDP). Applying the generated description will restart ICE, as described in section 9.1.1.1 of [RFC5245].When the value of this dictionary member is
false, and the relevantRTCPeerConnectionobject's[[LocalIceCredentialsToReplace]]slot is empty, and thecurrentLocalDescriptionattribute has valid ICE credentials, then the generated description will have the same ICE credentials as the current value from thecurrentLocalDescriptionattribute.Note
Performing an ICE restart is recommended when
iceConnectionStatetransitions to "failed". An application may additionally choose to listen for theiceConnectionStatetransition to "disconnected" and then use other sources of information (such as usinggetStatsto measure if the number of bytes sent or received over the next couple of seconds increases) to determine whether an ICE restart is advisable.
The RTCAnswerOptions dictionary describe options
specific to session description of type "answer"
(none in this version of the specification).
dictionary RTCAnswerOptions : RTCOfferAnswerOptions {};
enum RTCSignalingState {
"stable",
"have-local-offer",
"have-remote-offer",
"have-local-pranswer",
"have-remote-pranswer",
"closed"
};
| Enum value | Description |
|---|---|
stable
|
There is no offer/answer exchange in progress. This is also the initial state, in which case the local and remote descriptions are empty. |
have-local-offer
|
A local description, of type "offer", has
been successfully applied.
|
have-remote-offer
|
A remote description, of type "offer", has
been successfully applied.
|
have-local-pranswer
|
A remote description of type "offer" has
been successfully applied and a local description of type
"pranswer" has been successfully applied.
|
have-remote-pranswer
|
A local description of type "offer" has been
successfully applied and a remote description of type
"pranswer" has been successfully applied.
|
closed
|
The RTCPeerConnection has been closed; its
[[IsClosed]] slot is true.
|
An example set of transitions might be:
- Caller transition:
-
- new RTCPeerConnection(): "
stable" - setLocalDescription(offer):
"
have-local-offer" - setRemoteDescription(pranswer):
"
have-remote-pranswer" - setRemoteDescription(answer):
"
stable"
- new RTCPeerConnection(): "
- Callee transition:
-
- new RTCPeerConnection(): "
stable" - setRemoteDescription(offer):
"
have-remote-offer" - setLocalDescription(pranswer):
"
have-local-pranswer" - setLocalDescription(answer): "
stable"
- new RTCPeerConnection(): "
enum RTCIceGatheringState {
"new",
"gathering",
"complete"
};
| Enum value | Description |
|---|---|
new
|
Any of the RTCIceTransports are in the
"new" gathering state and none of
the transports are in the
"gathering" state, or there are no
transports.
|
gathering
|
Any of the RTCIceTransports are in the
"gathering" state.
|
complete
|
At least one RTCIceTransport exists, and all
RTCIceTransports are in the
"complete" gathering state.
|
The set of transports considered is the one
presently referenced by the RTCPeerConnection's
set of transceivers and the RTCPeerConnection's
[[SctpTransport]]
internal slot if not null.
enum RTCPeerConnectionState {
"closed",
"failed",
"disconnected",
"new",
"connecting",
"connected"
};
| Enum value | Description |
|---|---|
closed
|
[[IceConnectionState]] is
"closed".
|
failed
|
The previous state doesn't apply, and either
[[IceConnectionState]] is
"failed" or any
RTCDtlsTransports are in the
"failed" state.
|
disconnected
|
None of the previous states apply, and
[[IceConnectionState]] is
"disconnected".
|
new
|
None of the previous states apply, and either
[[IceConnectionState]] is
"new", and all
RTCDtlsTransports are in the
"new" or
"closed" state, or there are no
transports.
|
connected
|
None of the previous states apply,
[[IceConnectionState]] is
"connected", and all
RTCDtlsTransports are in the
"connected" or
"closed" state.
|
connecting
|
None of the previous states apply. |
Note
In the "connecting" state, one or more
RTCIceTransports are in the "new"
or "checking" state, or one or more
RTCDtlsTransports are in the "new"
or "connecting" state.
The set of transports considered is the one
presently referenced by the RTCPeerConnection's
set of transceivers and the RTCPeerConnection's
[[SctpTransport]]
internal slot if not null.
enum RTCIceConnectionState {
"closed",
"failed",
"disconnected",
"new",
"checking",
"completed",
"connected"
};
| Enum value | Description |
|---|---|
closed
|
The RTCPeerConnection object's [[IsClosed]]
slot is true.
|
failed
|
The previous state doesn't apply and any
RTCIceTransports are in the
"failed" state.
|
disconnected
|
None of the previous states apply and any
RTCIceTransports are in the
"disconnected" state.
|
new
|
None of the previous states apply and all
RTCIceTransports are in the
"new" or
"closed" state, or there are no
transports.
|
checking
|
None of the previous states apply and any
RTCIceTransports are in the
"new" or
"checking" state.
|
completed
|
None of the previous states apply and all
RTCIceTransports are in the
"completed" or
"closed" state.
|
connected
|
None of the previous states apply and all
RTCIceTransports are in the
"connected",
"completed" or
"closed" state.
|
The set of transports considered is the one
presently referenced by the RTCPeerConnection's
set of transceivers and the RTCPeerConnection's
[[SctpTransport]]
internal slot if not null.
Note that if an RTCIceTransport is discarded as a result of
signaling (e.g. RTCP mux or bundling), or created as a result of
signaling (e.g. adding a new media description), the state
may advance directly from one state to another.
The [RFC9429] specification, as a whole, describes the details of how
the RTCPeerConnection operates. References to specific
subsections of [RFC9429] are provided as appropriate.
Calling new
creates an
RTCPeerConnection(configuration)RTCPeerConnection object.
configuration.iceServers contains
information used to find and access the servers used by ICE. The
application can supply multiple servers of each type, and any TURN
server MAY also be used as a STUN server for the purposes of
gathering server reflexive candidates.
An RTCPeerConnection object has a
[[SignalingState]], and the aggregated states
[[ConnectionState]],
[[IceGatheringState]], and
[[IceConnectionState]].
These are initialized when the object is created.
The ICE protocol implementation of an RTCPeerConnection is
represented by an ICE agent [RFC5245]. Certain
RTCPeerConnection methods involve interactions with the ICE Agent, namely addIceCandidate, setConfiguration,
setLocalDescription, setRemoteDescription and close.
These interactions are described in the relevant sections in this
document and in [RFC9429]. The ICE Agent also provides
indications to the user agent when the state of its internal
representation of an RTCIceTransport changes, as described in
5.6
RTCIceTransport Interface.
The task source for the tasks listed in this section is the networking task source.
Note
The state of the SDP negotiation is represented by the internal variables
[[SignalingState]],
[[CurrentLocalDescription]],
[[CurrentRemoteDescription]],
[[PendingLocalDescription]] and
[[PendingRemoteDescription]]. These are only set inside the
setLocalDescription and setRemoteDescription operations,
and modified by the addIceCandidate operation and the surface a candidate procedure. In each case, all the
modifications to all the five variables are completed before the
procedures fire any events or invoke any callbacks, so the
modifications are made visible at a single point in time.
As one of the unloading document cleanup steps, run the following steps:
-
Let window be document's relevant global object.
-
For each
RTCPeerConnectionobject connection whose relevant global object is window, close the connection with connection and the valuetrue.
When the RTCPeerConnection.constructor() is
invoked, the user agent MUST run the following steps:
-
If any of the steps enumerated below fails for a reason not specified here, throw an
UnknownErrorwith themessageattribute set to an appropriate description. -
Let connection be a newly created
RTCPeerConnectionobject. -
Let connection have a [[DocumentOrigin]] internal slot, initialized to the relevant settings object's origin.
- Let configuration be the method's first argument.
-
If the
certificatesvalue in configuration is non-empty, run the following steps for each certificate in certificates:-
If the value of certificate.
expiresis less than the current time, throw anInvalidAccessError. -
If certificate.
[[Origin]]is not same origin with connection.[[DocumentOrigin]], throw anInvalidAccessError. -
Store certificate.
-
-
Else, generate one or more new
RTCCertificateinstances with thisRTCPeerConnectioninstance and store them. This MAY happen asynchronously and the value ofcertificatesremainsundefinedfor the subsequent steps. As noted in Section 4.3.2.3 of [RFC8826], WebRTC utilizes self-signed rather than Public Key Infrastructure (PKI) certificates, so that the expiration check is to ensure that keys are not used indefinitely and additional certificate checks are unnecessary. -
Initialize connection's ICE Agent.
-
Let connection have a [[Configuration]] internal slot, initialized to
null. Set the configuration specified by configuration. -
Let connection have an [[IsClosed]] internal slot, initialized to
false. -
Let connection have a [[NegotiationNeeded]] internal slot, initialized to
false. -
Let connection have an [[SctpTransport]] internal slot, initialized to
null. -
Let connection have a [[DataChannels]] internal slot, initialized to an empty ordered set.
-
Let connection have an [[Operations]] internal slot, representing an operations chain, initialized to an empty list.
-
Let connection have a [[UpdateNegotiationNeededFlagOnEmptyChain]] internal slot, initialized to
false. -
Let connection have an [[LastCreatedOffer]] internal slot, initialized to
"". -
Let connection have an [[LastCreatedAnswer]] internal slot, initialized to
"". -
Let connection have an [[EarlyCandidates]] internal slot, initialized to an empty list.
-
Let connection have an [[SignalingState]] internal slot, initialized to "
stable". -
Let connection have an [[IceConnectionState]] internal slot, initialized to "
new". -
Let connection have an [[IceGatheringState]] internal slot, initialized to "
new". -
Let connection have an [[ConnectionState]] internal slot, initialized to "
new". -
Let connection have a [[PendingLocalDescription]] internal slot, initialized to
null. -
Let connection have a [[CurrentLocalDescription]] internal slot, initialized to
null. -
Let connection have a [[PendingRemoteDescription]] internal slot, initialized to
null. -
Let connection have a [[CurrentRemoteDescription]] internal slot, initialized to
null. -
Let connection have a [[LocalIceCredentialsToReplace]] internal slot, initialized to an empty set.
-
Return connection.
An RTCPeerConnection object has an operations
chain , [[Operations]], which ensures that only one
asynchronous operation in the chain executes concurrently. If
subsequent calls are made while the returned promise of a
previous call is still not settled, they are added to the
chain and executed when all the previous calls have finished
executing and their promises have settled.
To chain an operation to an
RTCPeerConnection object's operations chain, run the
following steps:
-
Let connection be the
RTCPeerConnectionobject. -
If connection.
[[IsClosed]]istrue, return a promise rejected with a newly createdInvalidStateError. -
Let operation be the operation to be chained.
-
Let p be a new promise.
-
Append operation to
[[Operations]]. -
If the length of
[[Operations]]is exactly 1, execute operation. -
Upon fulfillment or rejection of the promise returned by the operation, run the following steps:
-
If connection.
[[IsClosed]]istrue, abort these steps. -
If the promise returned by operation was fulfilled with a value, fulfill p with that value.
-
If the promise returned by operation was rejected with a value, reject p with that value.
-
Upon fulfillment or rejection of p, execute the following steps:
-
If connection.
[[IsClosed]]istrue, abort these steps. -
Remove the first element of
[[Operations]]. -
If
[[Operations]]is non-empty, execute the operation represented by the first element of[[Operations]], and abort these steps. -
If connection.
[[UpdateNegotiationNeededFlagOnEmptyChain]]isfalse, abort these steps. -
Set connection.
[[UpdateNegotiationNeededFlagOnEmptyChain]]tofalse. -
Update the negotiation-needed flag for connection.
-
-
-
Return p.
An RTCPeerConnection object has an aggregated
[[ConnectionState]].
Whenever the state of an RTCDtlsTransport changes,
the user agent MUST queue a task that runs the following steps:
-
Let connection be this
RTCPeerConnectionobject associated with theRTCDtlsTransportobject whose state changed. -
If connection.
[[IsClosed]]istrue, abort these steps. -
Let newState be the value of deriving a new state value as described by the
RTCPeerConnectionStateenum. -
If connection.
[[ConnectionState]]is equal to newState, abort these steps. -
Set connection.
[[ConnectionState]]to newState. -
Fire an event named
connectionstatechangeat connection.
To
set a local session description description on
an RTCPeerConnection object connection, set the session description
description on connection with the additional
value false.
To
set a remote session description description
on an RTCPeerConnection object connection, set the session description
description on connection with the additional
value true.
To set
a session description description on an
RTCPeerConnection object connection, given a
remote boolean, run the following steps:
-
Let p be a new promise.
-
If description.
typeis "rollback" and connection.[[SignalingState]]is either "stable", "have-local-pranswer", or "have-remote-pranswer", then reject p with a newly createdInvalidStateErrorand abort these steps. -
Let jsepSetOfTransceivers be a shallow copy of connection's set of transceivers.
-
In parallel, start the process to apply description as described in [RFC9429] (section 5.5. and section 5.6.), with these additional restrictions:
-
Use jsepSetOfTransceivers as the source of truth with regard to what "RtpTransceivers" exist, and their
[[JsepMid]]internal slot as their "mid property". Candidate Correction 5:Forbid ICE gathering and connectivity checks on administrative prohibited candidates (PR #2708)
If remote is
falseand this triggers the ICE candidate gathering process in [RFC9429] (section 5.9.), the ICE Agent MUST NOT gather candidates that would be administratively prohibited.Candidate Correction 5:Forbid ICE gathering and connectivity checks on administrative prohibited candidates (PR #2708)
If remote is
trueand this triggers ICE connectivity checks in [RFC9429] (section 5.10.), the ICE Agent MUST NOT attempt to connect to candidates that are administratively prohibited.-
If remote is
true, validate back-to-back offers as if answers were applied in between, by running the check for subsequent offers as if it were in stable state. Candidate Correction 37:Don't fail sRD(offer) over rid mismatch, just answer with unicast. (PR #2794)
If applying description leads to modifying a transceiver transceiver, and transceiver.[[Sender]].[[SendEncodings]] is non-empty, and not equal to the encodings that would result from processing description, the process of applying description fails. This specification does not allow remotely initiated RID renegotiation.
-
If the process to apply description fails for any reason, then the user agent MUST queue a task that runs the following steps:
-
If connection.
[[IsClosed]]istrue, then abort these steps. -
If description.
typeis invalid for the current connection.[[SignalingState]]as described in [RFC9429] (section 5.5. and section 5.6.), then reject p with a newly createdInvalidStateErrorand abort these steps. -
If the content of description is not valid SDP syntax, then reject p with an
RTCError(witherrorDetailset to "sdp-syntax-error" and thesdpLineNumberattribute set to the line number in the SDP where the syntax error was detected) and abort these steps. -
If remote is
true, the connection'sRTCRtcpMuxPolicyisrequireand the description does not use RTCP mux, then reject p with a newly createdInvalidAccessErrorand abort these steps. -
If the description attempted to renegotiate RIDs, as described above, then reject p with a newly created
InvalidAccessErrorand abort these steps. -
If the content of description is invalid, then reject p with a newly created
InvalidAccessErrorand abort these steps. -
For all other errors, reject p with a newly created
OperationError.
-
-
If description is applied successfully, the user agent MUST queue a task that runs the following steps:
-
If connection.
[[IsClosed]]istrue, then abort these steps. -
If remote is
trueand description is of type "offer", then if anyaddTrack()methods on connection succeeded during the process to apply description, abort these steps and start the process over as if they had succeeded prior, to include the extra transceiver(s) in the process. -
If any promises from
setParametersmethods onRTCRtpSenders associated with connection are not settled, abort these steps and start the process over. -
If description is of type "
offer" and connection.[[SignalingState]]is "stable" then for each transceiver in connection's set of transceivers, run the following steps:-
Set transceiver.
[[Sender]].[[LastStableStateSenderTransport]]to transceiver.[[Sender]].[[SenderTransport]]. Candidate Correction 13:Rollback restores ridless encoding trounced by sRD(simulcastOffer). (PR #2797)
If transceiver.
[[Sender]].[[SendEncodings]].length is1and the lone encoding contains noridmember, then set transceiver.[[Sender]].[[LastStableRidlessSendEncodings]]to transceiver.[[Sender]].[[SendEncodings]]; Otherwise, set transceiver.[[Sender]].[[LastStableRidlessSendEncodings]]tonull.-
Set transceiver.
[[Receiver]].[[LastStableStateReceiverTransport]]to transceiver.[[Receiver]].[[ReceiverTransport]]. -
Set transceiver.
[[Receiver]].[[LastStableStateAssociatedRemoteMediaStreams]]to transceiver.[[Receiver]].[[AssociatedRemoteMediaStreams]]. -
Set transceiver.
[[Receiver]].[[LastStableStateReceiveCodecs]]to transceiver.[[Receiver]].[[ReceiveCodecs]].
-
-
If remote is
false, then run one of the following steps:-
If description is of type "
offer", set connection.[[PendingLocalDescription]]to a newRTCSessionDescriptionobject constructed from description, set connection.[[SignalingState]]to "have-local-offer", and release early candidates. -
If description is of type "
answer", then this completes an offer answer negotiation. Set connection.[[CurrentLocalDescription]]to a newRTCSessionDescriptionobject constructed from description, and set connection.[[CurrentRemoteDescription]]to connection.[[PendingRemoteDescription]]. Set both connection.[[PendingRemoteDescription]]and connection.[[PendingLocalDescription]]tonull. Set both connection.[[LastCreatedOffer]]and connection.[[LastCreatedAnswer]]to"", set connection.[[SignalingState]]to "stable", and release early candidates. Finally, if none of the ICE credentials in connection.[[LocalIceCredentialsToReplace]]are present in description, then set connection.[[LocalIceCredentialsToReplace]]to an empty set. -
If description is of type "
pranswer", then set connection.[[PendingLocalDescription]]to a newRTCSessionDescriptionobject constructed from description, set connection.[[SignalingState]]to "have-local-pranswer", and release early candidates.
-
-
Otherwise, (if remote is
true) run one of the following steps:-
If description is of type "
offer", set connection.[[PendingRemoteDescription]]attribute to a newRTCSessionDescriptionobject constructed from description, and set connection.[[SignalingState]]to "have-remote-offer". -
If description is of type "
answer", then this completes an offer answer negotiation. Set connection.[[CurrentRemoteDescription]]to a newRTCSessionDescriptionobject constructed from description, and set connection.[[CurrentLocalDescription]]to connection.[[PendingLocalDescription]]. Set both connection.[[PendingRemoteDescription]]and connection.[[PendingLocalDescription]]tonull. Set both connection.[[LastCreatedOffer]]and connection.[[LastCreatedAnswer]]to"", and set connection.[[SignalingState]]to "stable". Finally, if none of the ICE credentials in connection.[[LocalIceCredentialsToReplace]]are present in the newly set connection.[[CurrentLocalDescription]], then set connection.[[LocalIceCredentialsToReplace]]to an empty set. -
If description is of type "
pranswer", then set connection.[[PendingRemoteDescription]]to a newRTCSessionDescriptionobject constructed from description and set connection.[[SignalingState]]to "have-remote-pranswer".
-
-
If description is of type "
answer", and it initiates the closure of an existing SCTP association, as defined in [RFC8841], Sections 10.3 and 10.4, set the value of connection.[[SctpTransport]]tonull. -
Let trackEventInits, muteTracks, addList, removeList and errorList be empty lists.
-
If description is of type "
answer" or "pranswer", then run the following steps:-
If description initiates the establishment of a new SCTP association, as defined in [RFC8841], Sections 10.3 and 10.4, create an RTCSctpTransport with an initial state of "
connecting" and assign the result to the[[SctpTransport]]slot. Otherwise, if an SCTP association is established, but themax-message-sizeSDP attribute is updated, update the data max message size of connection.[[SctpTransport]]. -
If description negotiates the DTLS role of the SCTP transport, then for each
RTCDataChannel, channel, with anullid, run the following step:- Give channel a new ID generated
according to [RFC8832]. If no
available ID could be generated, set
channel.
[[ReadyState]]to "closed", and add channnel to errorList.
- Give channel a new ID generated
according to [RFC8832]. If no
available ID could be generated, set
channel.
-
-
If description is not of type "
rollback", then run the following steps:-
If remote is
false, then run the following steps for each media description in description:Candidate Correction 26:Prune createAnswer()'s encodings and SendEncodings in sLD(answer). (PR #2801)
If the media description was not yet associated with an
RTCRtpTransceiverobject then run the following steps:Let transceiver be the
RTCRtpTransceiverused to create the media description.Set transceiver.
[[Mid]]to transceiver.[[JsepMid]].If transceiver.
[[Stopped]]istrue, abort these sub steps.If the media description is indicated as using an existing
mediamedia transport according to [RFC8843], let transport be theRTCDtlsTransportobject representing the RTP/RTCP component of that transport.Otherwise, let transport be a newly created
RTCDtlsTransportobject with a new underlyingRTCIceTransport.Set transceiver.
[[Sender]].[[SenderTransport]]to transport.Set transceiver.
[[Receiver]].[[ReceiverTransport]]to transport.
Let transceiver be the
RTCRtpTransceiverassociated with the media description.If transceiver.
[[Stopped]]istrue, abort these sub steps.Let direction be an
RTCRtpTransceiverDirectionvalue representing the direction from themediamedia description.If direction is "
sendrecv" or "recvonly", set transceiver.[[Receptive]]totrue, otherwise set it tofalse.Set transceiver.
[[Receiver]].[[ReceiveCodecs]]to the codecs that description negotiates for receiving and which the user agent is currently prepared to receive.If description is of type "
answer" or "pranswer", then run the following steps:If transceiver.
[[Sender]].[[SendEncodings]].length is greater than1, then run the following steps:If description is missing all of the previously negotiated layers, then remove all dictionaries in transceiver.
[[Sender]].[[SendEncodings]]except the first one, and skip the next step.If description is missing any of the previously negotiated layers, then remove the dictionaries that correspond to the missing layers from transceiver.
[[Sender]].[[SendEncodings]].
Set transceiver.
[[Sender]].[[SendCodecs]]to the codecs that description negotiates for sending and which the user agent is currently capable of sending, and set transceiver.[[Sender]].[[LastReturnedParameters]]tonull.If direction is "
sendonly" or "inactive", and transceiver.[[FiredDirection]]is either "sendrecv" or "recvonly", then run the following steps:Set the associated remote streams given transceiver.
[[Receiver]], an empty list, another empty list, and removeList.process the removal of a
remoteremote track for the media description, given transceiver and muteTracks.
Set transceiver.
[[CurrentDirection]]and transceiver.[[FiredDirection]]to direction.
-
Otherwise, (if remote is
true) run the following steps for each media description in description:Candidate Correction 12:Remove interaction between encoding.active and simulcast ~rid (PR #2754)
Candidate Correction 14:Make RTCTransceiver.direction reflects local preference in offers and answers (PR #2759)
Candidate Correction 22:Allow remote offer rid pruning of encodings through the client answer. (PR #2758)
Candidate Correction 37:Don't fail sRD(offer) over rid mismatch, just answer with unicast. (PR #2794)
Candidate Correction 25:Remove duplicate rids in proposedSendEncodings. (PR #2800)
Candidate Correction 27:Ignore comma-separated rid alternatives. (PR #2813)
If the description is of type "
offer" and the media description contains a request to receive simulcast, use the order of the rid values specified in the simulcast attribute to create anRTCRtpEncodingParametersdictionary for each of the simulcast layers, populating theridmember according to the corresponding ridvaluevalue (using only the first value if comma-separated alternatives exist), and letsendEncodingsproposedSendEncodings bethe listthe list containing the created dictionaries. Otherwise, letsendEncodingsproposedSendEncodings beanan empty list.For each encoding, encoding, in proposedSendEncodings in reverse order, if encoding's
ridmatches that of another encoding in proposedSendEncodings, remove encoding from proposedSendEncodings.- Let supportedEncodings be the
maximum number of encodings that the
implementation can support. If the length of
sendEncodingsproposedSendEncodings is greater than supportedEncodings, truncatesendEncodingsproposedSendEncodings so that its length is supportedEncodings. - If
sendEncodingsproposedSendEncodings is non-empty,setset each encoding'sscaleResolutionDownByto2^(length of.sendEncodingsproposedSendEncodings - encoding index - 1) As described by [
RFC8829RFC9429] (section 5.10.), attempt to find an existingRTCRtpTransceiverobject, transceiver, to represent the media description.If a suitable transceiver was found (transceiver is set), and
sendEncodingsproposedSendEncodings is non-empty,set transceiver.[[Sender]].[[SendEncodings]]to sendEncodings, and set transceiver.[[Sender]].[[LastReturnedParameters]] torun the following steps:null.If the length of transceiver.
[[Sender]].[[SendEncodings]]is1, and the lone encoding contains noridmember, set transceiver.[[Sender]].[[SendEncodings]]to proposedSendEncodings, and set transceiver.[[Sender]].[[LastReturnedParameters]]tonull.
If no suitable transceiver was found (transceiver is unset), run the following steps:
Create an RTCRtpSender, sender, from the
mediamedia description usingsendEncodingsproposedSendEncodings.Create an RTCRtpReceiver, receiver, from the
mediamedia description.Create an RTCRtpTransceiver with sender, receiver and an
RTCRtpTransceiverDirectionvalue of "recvonly", and let transceiver be the result.Add transceiver to the connection's set
ofof transceivers.
If description is of type "
answer" or "pranswer", and transceiver.[[Sender]].[[SendEncodings]].length is greater than1, then run the following steps:If description indicates that simulcast is not supported or desired, or description is missing all of the previously negotiated layers, then remove all dictionaries in transceiver.
[[Sender]].[[SendEncodings]]except the first one and abort these sub steps.If description
rejectsis missing any of theofferedpreviously negotiated layers,thenthen removethethe dictionaries that correspondto rejectedto the missing layers from transceiver.[[Sender]].[[SendEncodings]].Update the paused status as indicated by [RFC8853] of each simulcast layer by setting the
member on the corresponding dictionaries in transceiver.[[Sender]].[[SendEncodings]] toactivetruefor unpaused or tofalsefor paused.
Set transceiver.
[[Mid]]to transceiver.[[JsepMid]].Let direction be an
RTCRtpTransceiverDirectionvalue representing the direction from themediamedia description, but with the send and receive directions reversed to represent this peer's point of view. If the media description is rejected, set direction to "inactive".If direction is "
sendrecv" or "recvonly", let msids be a list of the MSIDs that the media description indicates transceiver.[[Receiver]].[[ReceiverTrack]]is to be associated with. Otherwise, let msids be an empty list.Note
msids will be an empty list here if media description is rejected.
Process remote tracks with transceiver, direction, msids, addList, removeList, and trackEventInits.
Set transceiver.
[[Receiver]].[[ReceiveCodecs]]to the codecs that description negotiates for receiving and which the user agent is currently prepared to receive.If description is of type "
answer" or "pranswer", then run the following steps:Set transceiver.
[[Sender]].[[SendCodecs]]to the codecs that description negotiates for sending and which the user agent is currently capable of sending.Set transceiver.
[[CurrentDirection]]and transceiver.[[Direction]]sto direction.Let transport be the
RTCDtlsTransportobject representing the RTP/RTCP component of themediamedia transport used by transceiver's associated media description, according to [RFC8843].Set transceiver.
[[Sender]].[[SenderTransport]]to transport.Set transceiver.
[[Receiver]].[[ReceiverTransport]]to transport.Set the
[[IceRole]]of transport according to the rules of [RFC8445].Note
The rules of [RFC8445] that apply here are:
- If
[[IceRole]]is notunknown, do not modify[[IceRole]]. - If description is a
local offer, set it to
controlling. - If description is a
remote offer, and contains
a=ice-lite, set[[IceRole]]tocontrolling. - If description is a
remote offer, and does not contain
a=ice-lite, set[[IceRole]]tocontrolled.
This ensures that
[[IceRole]]always has a value after the first offer is processed.- If
If the media description is rejected, and transceiver.
[[Stopped]]isfalse, then stopthethe RTCRtpTransceiver transceiver.
-
-
Otherwise, (if description is of type "
rollback") run the following steps:-
Let pendingDescription be either connection.
[[PendingLocalDescription]]or connection.[[PendingRemoteDescription]], whichever one is notnull. -
For each transceiver in the connection's set of transceivers run the following steps:
-
If transceiver was not associated with a media description prior to pendingDescription being set, disassociate it and set both transceiver.
[[JsepMid]]and transceiver.[[Mid]]tonull. -
Set transceiver.
[[Sender]].[[SenderTransport]]to transceiver.[[Sender]].[[LastStableStateSenderTransport]]. Candidate Correction 13:Rollback restores ridless encoding trounced by sRD(simulcastOffer). (PR #2797)
If transceiver.
[[Sender]].[[LastStableRidlessSendEncodings]]is notnull, and any encoding in transceiver.[[Sender]].[[SendEncodings]]contains aridmember, then set transceiver.[[Sender]].[[SendEncodings]]to transceiver.[[Sender]].[[LastStableRidlessSendEncodings]].-
Set transceiver.
[[Receiver]].[[ReceiverTransport]]to transceiver.[[Receiver]].[[LastStableStateReceiverTransport]]. -
Set transceiver.
[[Receiver]].[[ReceiveCodecs]]to transceiver.[[Receiver]].[[LastStableStateReceiveCodecs]]. -
If connection.
[[SignalingState]]is "have-remote-offer", run the following sub steps:-
Let msids be a list of the
ids of allMediaStreamobjects in transceiver.[[Receiver]].[[LastStableStateAssociatedRemoteMediaStreams]], or an empty list if there are none. -
Process remote tracks with transceiver, transceiver.
[[CurrentDirection]], msids, addList, removeList, and trackEventInits.
-
-
If transceiver was created when pendingDescription was set, and a track has never been attached to it via
addTrack(), then stop the RTCRtpTransceiver transceiver, and remove it from connection's set of transceivers.
-
-
Set connection.
[[PendingLocalDescription]]and connection.[[PendingRemoteDescription]]tonull, and set connection.[[SignalingState]]to "stable".
-
-
If description is of type "
answer", then run the following steps:-
For each transceiver in the connection's set of transceivers run the following steps:
-
If transceiver is
stopped, associated with an m= section and the associated m= section is rejected in connection.[[CurrentLocalDescription]]or connection.[[CurrentRemoteDescription]], remove the transceiver from the connection's set of transceivers.
-
-
-
If connection.
[[SignalingState]]is now "stable", run the following steps:-
For any transceiver that was removed from the set of transceivers in a previous step, if any of its transports (transceiver.
[[Sender]].[[SenderTransport]]or transceiver.[[Receiver]].[[ReceiverTransport]]) are still not closed and they're no longer referenced by a non-stopped transceiver, close theRTCDtlsTransports and their associatedRTCIceTransports. This results in events firing on these objects in a queued task. Candidate Addition 49:Add codec to RTCRtpEncodingParameters (PR #2985)
For each transceiver in connection's set of transceivers:
-
Let codecs be transceiver.
[[Sender]].[[SendCodecs]]. -
If codecs is not an empty list:
-
For each encoding in transceiver.
[[Sender]].[[SendEncodings]], if encoding.codecdoes not match any entry in codecs, using the codec dictionary match algorithm with ignoreLevels set totrue, remove encoding.codec.
-
-
-
Clear the negotiation-needed flag and update the negotiation-needed flag.
-
-
If connection.
[[SignalingState]]changed above, fire an event namedsignalingstatechangeat connection. -
For each channel in errorList, fire an event named
errorusing theRTCErrorEventinterface with theerrorDetailattribute set to "data-channel-failure" at channel. -
For each track in muteTracks, set the muted state of track to the value
true. -
For each stream and track pair in removeList, remove the track track from stream.
-
For each stream and track pair in addList, add the track track to stream.
-
For each entry entry in trackEventInits, fire an event named
trackusing theRTCTrackEventinterface with itsreceiverattribute initialized to entry.receiver, itstrackattribute initialized to entry.track, itsstreamsattribute initialized to entry.streamsand itstransceiverattribute initialized to entry.transceiverat the connection object. -
Resolve p with
undefined.
-
-
-
Return p.
To set a configuration with configuration, run the following steps:
-
Let connection be the target
RTCPeerConnectionobject. -
Let oldConfig be connection.
[[Configuration]]. -
If oldConfig is not
null, run the following steps, and if any of them fail, throw anInvalidModificationError:-
If the length of configuration.
certificatesis different from the length of oldConfig.certificates, fail. -
Let index be 0.
-
While index is less than the length of configuration.
certificates, run the following steps:-
If the ECMAScript object represented by the value of configuration.
certificatesat index is not the same as the ECMAScript object represented by the value of oldConfig.certificatesat index, then fail. -
Increment index by 1.
-
-
If the value of configuration.
bundlePolicydiffers from oldConfig.bundlePolicy, then fail. -
If the value of configuration.
rtcpMuxPolicydiffers from oldConfig.rtcpMuxPolicy, then fail. -
If the value of configuration.
iceCandidatePoolSizediffers from oldConfig.iceCandidatePoolSize, andsetLocalDescriptionhas already been called, then fail.
-
-
Let iceServers be configuration.
iceServers. -
Truncate iceServers to the maximum number of supported elements.
-
For each server in iceServers, run the following steps:
-
Let urls be server.
urls. -
If urls is a string, set urls to a list consisting of just that string.
-
If urls is empty, throw a "
SyntaxError"DOMException. -
For each url in urls, run the validate an ICE server URL algorithm on url.
-
-
Set the ICE Agent's ICE transports setting to the value of configuration.
iceTransportPolicy. As defined in [RFC9429] (section 4.1.18.), if the new ICE transports setting changes the existing setting, no action will be taken until the next gathering phase. If a script wants this to happen immediately, it should do an ICE restart. -
Set the ICE Agent's prefetched ICE candidate pool size as defined in [RFC9429] (section 3.5.4. and section 4.1.1.) to the value of configuration.
iceCandidatePoolSize. If the new ICE candidate pool size changes the existing setting, this may result in immediate gathering of new pooled candidates, or discarding of existing pooled candidates, as defined in [RFC9429] (section 4.1.18.). -
Set the ICE Agent's ICE servers list to iceServers.
As defined in [RFC9429] (section 4.1.18.), if a new list of servers replaces the ICE Agent's existing ICE servers list, no action will be taken until the next gathering phase. If a script wants this to happen immediately, it should do an ICE restart. However, if the ICE candidate pool has a nonzero size, any existing pooled candidates will be discarded, and new candidates will be gathered from the new servers.
-
Store configuration in the
[[Configuration]]internal slot.
To validate an ICE server URL url, run the following steps:
Parse the url using the generic URI syntax defined in [RFC3986] and obtain the scheme name. If the parsing based on the syntax defined in [RFC3986] fails, throw a
SyntaxError. If the scheme name is not implemented by the browser throw aNotSupportedError. If scheme name isturnorturns, and parsing the url using the syntax defined in [RFC7065] fails, throw aSyntaxError. If scheme name isstunorstuns, and parsing the url using the syntax defined in [RFC7064] fails, throw aSyntaxError.Let parsedURL be the result of parsing url.
If any of the following conditions apply, then throw a "
SyntaxError"DOMException:- parsedURL is failure
- parsedURL's scheme is neither
"stun","stuns","turn", nor"turns" - parsedURL does not have an opaque path
- parsedURL's opaque path contains one or more
"/"or"@" - parsedURL's fragment is non-null
- parsedURL's scheme is
"stun"or"stuns", and parsedURL's query is non-null
If parsedURL's scheme is not implemented by the user agent, then throw a
NotSupportedError.Let hostAndPortURL be result of parsing the concatenation of
"https://"and parsedURL's path.If hostAndPortURL is failure, then throw a "
SyntaxError"DOMException.If hostAndPortURL's path, username, or password is non-null, then throw a "
SyntaxError"DOMException.If parsedURL's query is non-null and if parsedURL's query is different from either
"transport=udp"or"transport=tcp", throw a "SyntaxError"DOMException.If
scheme nameparsedURL's' scheme isturn"turn"ororturns"turns", and either of server.usernameor server.credentialare omitteddo not exist, then throw anInvalidAccessError.If scheme name is
turnorturns, and server.credentialTypeis "", and server.passwordcredentialis not a DOMString, then throw anInvalidAccessError.
The RTCPeerConnection interface presented in this
section is extended by several partial interfaces throughout this
specification. Notably, the RTP Media API section, which adds
the APIs to send and receive MediaStreamTrack objects.
[Exposed=Window]
interface RTCPeerConnection : EventTarget {
constructor(optional RTCConfiguration configuration = {});
Promise<RTCSessionDescriptionInit> createOffer(optional RTCOfferOptions options = {});
Promise<RTCSessionDescriptionInit> createAnswer(optional RTCAnswerOptions options = {});
Promise<undefined> setLocalDescription(optional RTCLocalSessionDescriptionInit description = {});
readonly attribute RTCSessionDescription? localDescription;
readonly attribute RTCSessionDescription? currentLocalDescription;
readonly attribute RTCSessionDescription? pendingLocalDescription;
Promise<undefined> setRemoteDescription(RTCSessionDescriptionInit description);
readonly attribute RTCSessionDescription? remoteDescription;
readonly attribute RTCSessionDescription? currentRemoteDescription;
readonly attribute RTCSessionDescription? pendingRemoteDescription;
Promise<undefined> addIceCandidate(optional RTCIceCandidateInit candidate = {});
readonly attribute RTCSignalingState signalingState;
readonly attribute RTCIceGatheringState iceGatheringState;
readonly attribute RTCIceConnectionState iceConnectionState;
readonly attribute RTCPeerConnectionState connectionState;
readonly attribute boolean? canTrickleIceCandidates;
undefined restartIce();
RTCConfiguration getConfiguration();
undefined setConfiguration(optional RTCConfiguration configuration = {});
undefined close();
attribute EventHandler onnegotiationneeded;
attribute EventHandler onicecandidate;
attribute EventHandler onicecandidateerror;
attribute EventHandler onsignalingstatechange;
attribute EventHandler oniceconnectionstatechange;
attribute EventHandler onicegatheringstatechange;
attribute EventHandler onconnectionstatechange;
// Legacy Interface Extensions
// Supporting the methods in this section is optional.
// If these methods are supported
// they must be implemented as defined
// in section "Legacy Interface Extensions"
Promise<undefined> createOffer(RTCSessionDescriptionCallback successCallback,
RTCPeerConnectionErrorCallback failureCallback,
optional RTCOfferOptions options = {});
Promise<undefined> setLocalDescription(RTCLocalSessionDescriptionInit description,
VoidFunction successCallback,
RTCPeerConnectionErrorCallback failureCallback);
Promise<undefined> createAnswer(RTCSessionDescriptionCallback successCallback,
RTCPeerConnectionErrorCallback failureCallback);
Promise<undefined> setRemoteDescription(RTCSessionDescriptionInit description,
VoidFunction successCallback,
RTCPeerConnectionErrorCallback failureCallback);
Promise<undefined> addIceCandidate(RTCIceCandidateInit candidate,
VoidFunction successCallback,
RTCPeerConnectionErrorCallback failureCallback);
};
-
localDescriptionof typeRTCSessionDescription, readonly, nullable -
The
localDescriptionattribute MUST return[[PendingLocalDescription]]if it is notnulland otherwise it MUST return[[CurrentLocalDescription]].Note that
[[CurrentLocalDescription]].sdpand[[PendingLocalDescription]].sdpneed not be string-wise identical to thesdpvalue passed to the correspondingsetLocalDescriptioncall (i.e. SDP may be parsed and reformatted, and ICE candidates may be added). -
currentLocalDescriptionof typeRTCSessionDescription, readonly, nullable -
The
currentLocalDescriptionattribute MUST return[[CurrentLocalDescription]].It represents the local description that was successfully negotiated the last time the
RTCPeerConnectiontransitioned into the stable state plus any local candidates that have been generated by the ICE Agent since the offer or answer was created. -
pendingLocalDescriptionof typeRTCSessionDescription, readonly, nullable -
The
pendingLocalDescriptionattribute MUST return[[PendingLocalDescription]].It represents a local description that is in the process of being negotiated plus any local candidates that have been generated by the ICE Agent since the offer or answer was created. If the
RTCPeerConnectionis in the stable state, the value isnull. -
remoteDescriptionof typeRTCSessionDescription, readonly, nullable -
The
remoteDescriptionattribute MUST return[[PendingRemoteDescription]]if it is notnulland otherwise it MUST return[[CurrentRemoteDescription]].Note that
[[CurrentRemoteDescription]].sdpand[[PendingRemoteDescription]].sdpneed not be string-wise identical to thesdpvalue passed to the correspondingsetRemoteDescriptioncall (i.e. SDP may be parsed and reformatted, and ICE candidates may be added). -
currentRemoteDescriptionof typeRTCSessionDescription, readonly, nullable -
The
currentRemoteDescriptionattribute MUST return[[CurrentRemoteDescription]].It represents the last remote description that was successfully negotiated the last time the
RTCPeerConnectiontransitioned into the stable state plus any remote candidates that have been supplied viaaddIceCandidate()since the offer or answer was created. -
pendingRemoteDescriptionof typeRTCSessionDescription, readonly, nullable -
The
pendingRemoteDescriptionattribute MUST return[[PendingRemoteDescription]].It represents a remote description that is in the process of being negotiated, complete with any remote candidates that have been supplied via
addIceCandidate()since the offer or answer was created. If the "