Initial Author of this Specification was Ian Hickson, Google Inc., with
the following copyright statement:
© Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and Opera
Software ASA. You are granted a license to use, reproduce and create
derivative works of this document. All subsequent changes since 26 July
2011 done by the W3C WebRTC Working Group are under the following
Copyright:
© 2011-2018 W3C® (MIT, ERCIM,
Keio, Beihang). W3C liability,
trademark and permissive document license rules
apply.
This document defines a set of ECMAScript APIs in WebIDL to allow media 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.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. 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/.
The API is based on preliminary work done in the WHATWG.
The specification is feature complete and is expected to be stable with no further substantive change. Since the previous Candidate Recommendation, the following substantive changes have been brought to the specification:
voiceActivityFlag
has been marked at risk for lack of
implementation
PeerConnection
has
been clarified
Its associated test suite will be used to build an implementation report of the API.
To go into Proposed Recommendation status, the group expects to demonstrate implementation of each feature in at least two deployed browsers, and at least one implementation of each optional feature. Mandatory feature with only one implementation may be marked as optional in a revised Candidate Recommendation where applicable.
This document was published by the Web Real-Time Communications Working Group as a Candidate Recommendation Draft. This document is intended to become a W3C Recommendation.
GitHub Issues are preferred for discussion of this specification. Alternatively, you can send comments to our mailing list. Please send them to public-webrtc@w3.org (archives).
Publication as a Candidate Recommendation does not imply endorsement by the W3C Membership. A Candidate Recommendation Draft integrates changes from the previous Candidate Recommendation that the Working Group intends to include in a subsequent Candidate Recommendation Snapshot.
This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
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 15 September 2020 W3C Process Document.
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:
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 [RTCWEB-OVERVIEW] and [RTCWEB-SECURITY].
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 [TRICKLE-ICE] 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, pending and settled used in the context of Promises are defined in [ECMASCRIPT-6.0].
The terms bundle, bundle-only and bundle-policy are defined in [JSEP].
The AlgorithmIdentifier is defined in [WebCryptoAPI].
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.
An
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 Web
Sockets or RTCPeerConnection
XMLHttpRequest
[xhr].
RTCConfiguration
Dictionary
The
defines a set of parameters to configure
how the peer-to-peer communication established via
RTCConfiguration
is established or re-established.
RTCPeerConnection
WebIDLdictionaryRTCConfiguration
{ sequence<RTCIceServer
>iceServers
;RTCIceTransportPolicy
iceTransportPolicy
;RTCBundlePolicy
bundlePolicy
;RTCRtcpMuxPolicy
rtcpMuxPolicy
; sequence<RTCCertificate
>certificates
; [EnforceRange] octeticeCandidatePoolSize
= 0; };
RTCConfiguration
Members
iceServers
of type sequence<RTCIceServer
>
An array of objects describing servers available to be used by ICE, such as STUN and TURN servers.
iceTransportPolicy
of type
RTCIceTransportPolicy
.
Indicates which candidates the ICE Agent is allowed to use.
bundlePolicy
of type RTCBundlePolicy
.
Indicates which media-bundling policy to use when gathering ICE candidates.
rtcpMuxPolicy
of type RTCRtcpMuxPolicy
.
Indicates which rtcp-mux policy to use when gathering ICE candidates.
certificates
of type sequence<RTCCertificate
>
A set of certificates that the
uses
to authenticate.
RTCPeerConnection
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
implementation selects
which of the certificates is used for a given connection;
how certificates are selected is outside the scope of this
specification.
RTCPeerConnection
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
instance.
RTCPeerConnection
This option allows applications to establish key
continuity. An
can be persisted in
[INDEXEDDB] and reused. Persistence and reuse also
avoids the cost of key generation.
RTCCertificate
The value for this configuration option cannot change after its value is initially selected.
iceCandidatePoolSize
of type
octet, defaulting to
0
Size of the prefetched ICE pool as defined in [JSEP] (section 3.5.4. and section 4.1.1.).
RTCIceCredentialType
Enum
WebIDLenumRTCIceCredentialType
{ "password
" };
Enumeration description | |
---|---|
password
|
The credential is a long-term authentication username and password, as described in [RFC5389], Section 10.2. |
RTCIceServer
Dictionary
The
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.
RTCIceServer
WebIDLdictionaryRTCIceServer
{ required (DOMString or sequence<DOMString>)urls
; DOMStringusername
; DOMStringcredential
;RTCIceCredentialType
credentialType
= "password"; };
RTCIceServer
Members
urls
of type (DOMString or
sequence<DOMString>), required
STUN or TURN URI(s) as defined in [RFC7064] and [RFC7065] or other URI types.
username
of type DOMString
If this
object represents a TURN server,
and RTCIceServer
is
"credentialType
", then this attribute
specifies the username to use with that TURN server.
password
credential
of type DOMString
If this
object represents a TURN server,
then this attribute specifies the credential to use with
that TURN server.
RTCIceServer
If
is
"credentialType
", password
represents a long-term authentication password, as
described in [RFC5389], Section 10.2.
credential
To support additional values of
,
credentialType
may evolve in future as a union.
credential
credentialType
of type RTCIceCredentialType
, defaulting
to "password
"
If this
object represents a TURN server,
then this attribute specifies how credential
should be used when that TURN server requests
authorization.
RTCIceServer
An example array of
objects is:
RTCIceServer
[
{urls: 'stun:stun1.example.net'},
{urls: ['turns:turn.example.org', 'turn:turn.example.net'],
username: 'user',
credential: 'myPassword',
credentialType: 'password'},
];
RTCIceTransportPolicy
Enum
As described in [JSEP] (section 4.1.1.), if
the
member of the
iceTransportPolicy
is specified, it defines the ICE candidate policy [JSEP] (section 3.5.3.) the
browser uses to surface the permitted candidates to the
application; only these candidates will be used for connectivity
checks.
RTCConfiguration
WebIDLenumRTCIceTransportPolicy
{ "relay
", "all
" };
Enumeration description (non-normative) | |
---|---|
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 . .
|
RTCBundlePolicy
Enum
As described in [JSEP] (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.
WebIDLenumRTCBundlePolicy
{ "balanced
", "max-compat
", "max-bundle
" };
Enumeration description (non-normative) | |
---|---|
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. |
RTCRtcpMuxPolicy
Enum
As described in [JSEP] (section 4.1.1.), the
affects what ICE candidates are gathered to
support non-multiplexed RTCP. The only value defined in this spec
is "RTCRtcpMuxPolicy
".
require
WebIDL enumRTCRtcpMuxPolicy
{ "require
" };
Enumeration description (non-normative) | |
---|---|
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.
WebIDLdictionary RTCOfferAnswerOptions
{};
RTCOfferAnswerOptions
Members
WebIDL dictionaryRTCOfferOptions
:RTCOfferAnswerOptions
{ booleaniceRestart
= false; };
RTCOfferOptions
Members
iceRestart
of type boolean, defaulting to
false
When the value of this dictionary member is
true
, or the relevant
object's [[LocalIceCredentialsToReplace]] slot is
not empty, then the generated description will have ICE
credentials that are different from the current credentials
(as visible in the
RTCPeerConnection
attribute's
SDP). Applying the generated description will restart ICE,
as described in section 9.1.1.1 of [ICE].
currentLocalDescription
When the value of this dictionary member is
false
, and the relevant
object's [[LocalIceCredentialsToReplace]] slot is
empty, and the
RTCPeerConnection
attribute has
valid ICE credentials, then the generated description will
have the same ICE credentials as the current value from the
currentLocalDescription
attribute.
currentLocalDescription
Performing an ICE restart is recommended when
transitions to
"iceConnectionState
". An application may
additionally choose to listen for the
failed
transition to
"iceConnectionState
" and then use other
sources of information (such as using
disconnected
to measure if the number of
bytes sent or received over the next couple of seconds
increases) to determine whether an ICE restart is
advisable.
getStats
The RTCAnswerOptions
dictionary describe options
specific to session description of type "
"
(none in this version of the specification).
answer
WebIDLdictionaryRTCAnswerOptions
:RTCOfferAnswerOptions
{};
RTCSignalingState
Enum
WebIDLenumRTCSignalingState
{ "stable
", "have-local-offer
", "have-remote-offer
", "have-local-pranswer
", "have-remote-pranswer
", "closed
" };
Enumeration 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 " ", has
been successfully applied.
|
have-remote-offer
|
A remote description, of type " ", has
been successfully applied.
|
have-local-pranswer
|
A remote description of type " " has
been successfully applied and a local description of type
" " has been successfully applied.
|
have-remote-pranswer
|
A local description of type " " has been
successfully applied and a remote description of type
" " has been successfully applied.
|
closed
|
The has been closed; its
[[IsClosed]] slot is true .
|
An example set of transitions might be:
stable
"
have-local-offer
"
have-remote-pranswer
"
stable
"
stable
"
have-remote-offer
"
have-local-pranswer
"
stable
"
RTCIceGatheringState
Enum
WebIDLenumRTCIceGatheringState
{ "new
", "gathering
", "complete
" };
Enumeration description | |
---|---|
new
|
Any of the s are in the
" " gathering state and none of
the transports are in the
" " state, or there are no
transports.
|
gathering
|
Any of the s are in the
" " state.
|
complete
|
At least one exists, and all
s are in the
" " gathering state.
|
The set of transports considered is the set of transports presently referenced by the PeerConnection's set of transceivers.
RTCPeerConnectionState
Enum
WebIDLenumRTCPeerConnectionState
{ "closed
", "failed
", "disconnected
", "new
", "connecting
", "connected
" };
Enumeration description | |
---|---|
closed
|
The object's [[IsClosed]]
slot is true .
|
failed
|
The previous state doesn't apply and any
s are in the
" " state or any
s are in the
" " state.
|
disconnected
|
None of the previous states apply and any
s are in the
" " state.
|
new
|
None of the previous states apply and all
s are in the
" " or
" " state, and all
s are in the
" " or
" " state, or there are no
transports.
|
connecting
|
None of the previous states apply and any
is in the
" " state or any
is in the
" " state.
|
connected
|
None of the previous states apply and all
s are in the
" ",
" " or
" " state, and all
s are in the
" " or
" " state.
|
The set of transports considered is the set of transports presently referenced by the PeerConnection's set of transceivers.
RTCIceConnectionState
Enum
WebIDLenumRTCIceConnectionState
{ "closed
", "failed
", "disconnected
", "new
", "checking
", "completed
", "connected
" };
Enumeration description | |
---|---|
closed
|
The object's [[IsClosed]]
slot is true .
|
failed
|
The previous state doesn't apply and any
s are in the
" " state.
|
disconnected
|
None of the previous states apply and any
s are in the
" " state.
|
new
|
None of the previous states apply and all
s are in the
" " or
" " state, or there are no
transports.
|
checking
|
None of the previous states apply and any
s are in the
" " or
" " state.
|
completed
|
None of the previous states apply and all
s are in the
" " or
" " state.
|
connected
|
None of the previous states apply and all
s are in the
" ",
" " or
" " state.
|
The set of transports considered is the set of transports presently referenced by the PeerConnection's set of transceivers.
Note that if an
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.
RTCIceTransport
The [JSEP] specification, as a whole, describes the details of how
the
operates. References to specific
subsections of [JSEP] are provided as appropriate.
RTCPeerConnection
Calling new
creates an
(configuration)RTCPeerConnection
object.
RTCPeerConnection
configuration.
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.
iceServers
An
object has a signaling state, a
connection state, an ICE gathering state, and
an ICE connection state. These are initialized when the
object is created.
RTCPeerConnection
The ICE protocol implementation of an
is
represented by an ICE agent [ICE]. Certain
RTCPeerConnection
methods involve interactions with the ICE
Agent, namely RTCPeerConnection
, addIceCandidate
,
setConfiguration
, setLocalDescription
and setRemoteDescription
.
These interactions are described in the relevant sections in this
document and in [JSEP]. The ICE Agent also provides
indications to the user agent when the state of its internal
representation of an close
changes, as described in
§ 5.6
RTCIceTransport
RTCIceTransport
Interface
.
The task source for the tasks listed in this section is the networking task source.
The state of the SDP negotiation is represented by the signaling
state and the internal variables
[[CurrentLocalDescription]],
[[CurrentRemoteDescription]],
[[PendingLocalDescription]] and
[[PendingRemoteDescription]]. These are only set inside the
and setLocalDescription
operations,
and modified by the setRemoteDescription
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.
addIceCandidate
As one of the unloading document cleanup steps, run the following steps:
Let window be document's relevant global object.
For each
object connection
whose relevant
global object is window, close the connection with connection and the value RTCPeerConnection
true
.
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 UnknownError
with the
attribute set to an
appropriate description.
message
Let connection be a newly created
object.
RTCPeerConnection
Let connection have a [[DocumentOrigin]] internal slot, initialized to the current settings object's origin.
If the
value in
configuration is non-empty, run the following
steps for each certificate in certificates:
certificates
If the value of
certificate.
is less
than the current time, throw an
expires
InvalidAccessError
.
If certificate.[[Origin]] is not
same origin with
connection.[[DocumentOrigin]], throw an InvalidAccessError
.
Store certificate.
Else, generate one or more new
instances
with this RTCCertificate
instance and store them. This
MAY happen asynchronously and the value of
RTCPeerConnection
remains
certificates
undefined
for the subsequent steps. As noted in
Section 4.3.2.3 of [RTCWEB-SECURITY], 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.
If the value of
configuration.
is iceTransportPolicy
undefined
, set it to
"
".
all
If the value of
configuration.
is
bundlePolicy
undefined
, set it to
"
".
balanced
If the value of
configuration.
is rtcpMuxPolicy
undefined
, set it to
"
".
require
Let connection have a [[Configuration]] internal slot. 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 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.
Set connection's signaling state to
"
".
stable
Set connection's ICE connection state to
"
".
new
Set connection's ICE gathering state to
"
".
new
Set connection's connection state 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
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.
RTCPeerConnection
To chain an operation to an
object's operations chain, run the
following steps:
RTCPeerConnection
Let connection be the
object.
RTCPeerConnection
If connection.[[IsClosed]] is
true
, return a promise rejected with a
newly created InvalidStateError
.
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]] is
true
, 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]] is
true
, 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]]
is false
, abort these steps.
Set
connection.[[UpdateNegotiationNeededFlagOnEmptyChain]]
to false
.
Update the negotiation-needed flag for connection.
Return p.
An
object has an aggregated connection
state. Whenever the state of an RTCPeerConnection
changes
or when the [[IsClosed]] slot turns RTCDtlsTransport
true
,
the user agent MUST update the connection state by queueing a
task that runs the following steps:
Let connection be this
object.
RTCPeerConnection
Let newState be the value of deriving a new state
value as described by the
enum.
RTCPeerConnectionState
If connection's connection state is equal to newState, abort these steps.
Let connection's connection state be newState.
Fire an event named
at
connection.
connectionstatechange
To update the ICE
gathering state of an
instance
connection, the user agent MUST queue a task that runs
the following steps:
RTCPeerConnection
If connection.[[IsClosed]] is
true
, abort these steps.
Let newState be the value of deriving a new state
value as described by the
enum.
RTCIceGatheringState
If connection's ICE gathering state is equal to newState, abort these steps.
Set connection's ICE gathering state to newState.
Fire an event named
at
connection.
icegatheringstatechange
If newState is
"
", fire an event
named complete
using the
icecandidate
interface with the candidate
attribute set to RTCPeerConnectionIceEvent
null
at connection.
RTCIceTransport
and/or RTCPeerConnection
.
To
set a local RTCSessionDescription description on
an
object connection, run the set an RTCSessionDescription algorithm with remote
set to RTCPeerConnection
false
.
To
set a remote RTCSessionDescription description
on an
object connection, run the
set an RTCSessionDescription algorithm with
remote set to RTCPeerConnection
true
.
To set
an RTCSessionDescription description on an
object connection, given a
remote boolean, run the following steps:
RTCPeerConnection
Let p be a new promise.
If description.
is
"type
" and connection's signaling state is either "rollback
",
"stable
", or
"have-local-pranswer
", then reject p with a newly created
have-remote-pranswer
InvalidStateError
and 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 [JSEP] (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".
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.
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]] is
true
, then abort these steps.
If
description.
is invalid for the current signaling state of
connection as described in
[JSEP] (section 5.5. and section 5.6.), then reject p with
a newly created type
InvalidStateError
and abort these steps.
If the content of description is not valid
SDP syntax, then reject p with an
(with RTCError
set to
"errorDetail
" and the
sdp-syntax-error
attribute set to the line
number in the SDP where the syntax error was
detected) and abort these steps.
sdpLineNumber
If remote is true
, the
connection's
is
RTCRtcpMuxPolicy
and the description does
not use RTCP mux, then reject p with
a newly created
require
InvalidAccessError
and abort these steps.
If the description attempted to renegotiate RIDs, as
described above, then reject p with
a newly created
InvalidAccessError
and abort these steps.
If the content of description is invalid,
then reject p with a newly created InvalidAccessError
and 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]] is
true
, then abort these steps.
If remote is true
and
description is of type
"
", then if any
offer
addTrack
()
methods 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 description is of type
"
" and the signaling state
of connection is
"offer
" then for each
transceiver in connection's set of transceivers, run the following steps:
stable
Set transceiver.[[Sender]].[[LastStableStateSenderTransport]] to transceiver.[[Sender]].[[SenderTransport]].
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
"
", set
connection.[[PendingLocalDescription]]
to a new offer
object
constructed from description, set
connection's signaling state to
"RTCSessionDescription
", and release early candidates.
have-local-offer
If description is of type
"
", then this completes an
offer answer negotiation. Set
connection.[[CurrentLocalDescription]]
to a new answer
object
constructed from description, and set
connection.[[CurrentRemoteDescription]]
to
connection.[[PendingRemoteDescription]].
Set both
connection.[[PendingRemoteDescription]]
and
connection.[[PendingLocalDescription]]
to RTCSessionDescription
null
. Set both
connection.[[LastCreatedOffer]]
and
connection.[[LastCreatedAnswer]]
to ""
, set connection's
signaling state to
"
", 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.
stable
If description is of type
"
", then set
connection.[[PendingLocalDescription]]
to a new pranswer
object
constructed from description, set
connection's signaling state to
"RTCSessionDescription
", and
release early candidates.
have-local-pranswer
Otherwise, (if remote is
true
) run one of the following steps:
If description is of type
"
", set
connection.[[PendingRemoteDescription]]
attribute to a new offer
object constructed from description,
and set connection's signaling
state to
"RTCSessionDescription
".
have-remote-offer
If description is of type
"
", then this completes an
offer answer negotiation. Set
connection.[[CurrentRemoteDescription]]
to a new answer
object
constructed from description, and set
connection.[[CurrentLocalDescription]]
to
connection.[[PendingLocalDescription]].
Set both
connection.[[PendingRemoteDescription]]
and
connection.[[PendingLocalDescription]]
to RTCSessionDescription
null
. Set both
connection.[[LastCreatedOffer]]
and
connection.[[LastCreatedAnswer]]
to ""
, and set
connection's signaling state to
"
". 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.
stable
If description is of type
"
", then set
connection.[[PendingRemoteDescription]]
to a new pranswer
object
constructed from description and set
connection's signaling state to
"RTCSessionDescription
".
have-remote-pranswer
If description is of type
"
", and it initiates the closure
of an existing SCTP association, as defined in
[SCTP-SDP], Sections 10.3 and 10.4, set the value
of connection.[[SctpTransport]] to
answer
null
.
Let trackEventInits, muteTracks, addList, removeList and errorList be empty lists.
If description is of type
"
" or "answer
",
then run the following steps:
pranswer
If description initiates the
establishment of a new SCTP association, as
defined in [SCTP-SDP], Sections 10.3 and 10.4,
create an RTCSctpTransport with an initial
state of "
"
and assign the result to the
[[SctpTransport]] slot. Otherwise, if an
SCTP association is established, but the
connecting
max-message-size
SDP
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
, channel, with a
RTCDataChannel
null
, run the
following step:
id
closed
", and add
channnel to errorList.
If description is not of type
"
", then run the following
steps:
rollback
If remote is false
, then
run the following steps for each media
description in description:
If the media description was not yet associated with an
object then run the following steps:
RTCRtpTransceiver
Let transceiver be the
used to create the
media description.
RTCRtpTransceiver
Set transceiver.[[Mid]] to transceiver.[[JsepMid]].
If
transceiver.[[Stopped]]
is true
, abort these sub
steps.
If the media description is
indicated as using an existing media
transport according to [BUNDLE],
let transport be the
object representing
the RTP/RTCP component of that transport.
RTCDtlsTransport
Otherwise, let transport be a
newly created
object
with a new underlying
RTCDtlsTransport
.
RTCIceTransport
Set transceiver.[[Sender]].[[SenderTransport]] to transport.
Set transceiver.[[Receiver]].[[ReceiverTransport]] to transport.
Let transceiver be the
associated with
the media description.
RTCRtpTransceiver
If transceiver.[[Stopped]]
is true
, abort these sub steps.
Let direction be an
value
representing the direction from the media
description.
RTCRtpTransceiverDirection
If direction is
"
" or
"sendrecv
",
set
transceiver.[[Receptive]]
to recvonly
true
, otherwise set it to
false
.
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
"
" or
"answer
", then run the
following steps:
pranswer
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]]
to null
.
If direction is
"
"
or
"sendonly
",
and
transceiver.[[FiredDirection]]
is either
"inactive
"
or
"sendrecv
",
then run the following steps:
recvonly
Set the associated remote streams given transceiver.[[Receiver]], an empty list, another empty list, and removeList.
process the removal of a remote 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:
If the description is of type
"
" and contains a request
to receive simulcast, use the order of the
rid values specified in the simulcast
attribute to create an
offer
dictionary for
each of the simulcast layers, populating the
RTCRtpEncodingParameters
member
according to the corresponding rid value, and
let sendEncodings be the list
containing the created dictionaries.
Otherwise, let sendEncodings be an
empty list.
rid
scaleResolutionDownBy
to 2^(length of sendEncodings -
encoding index - 1)
.
As described by [JSEP] (section 5.10.),
attempt to find an existing
object,
transceiver, to represent the media description.
RTCRtpTransceiver
If a suitable transceiver was found
(transceiver is set) and
sendEncodings is non-empty, set
transceiver.[[Sender]].[[SendEncodings]]
to sendEncodings, and set
transceiver.[[Sender]].[[LastReturnedParameters]]
to null
.
If no suitable transceiver was found (transceiver is unset), run the following steps:
Create an RTCRtpSender, sender, from the media description using sendEncodings.
Create an RTCRtpReceiver, receiver, from the media description.
Create an RTCRtpTransceiver with
sender, receiver
and an
value of
"RTCRtpTransceiverDirection
",
and let transceiver be the
result.
recvonly
Add transceiver to the connection's set of transceivers.
If description is of type
"
" or
"answer
", and
transceiver.
[[Sender]].[[SendEncodings]]
.length is greater than pranswer
1
, then
run the following steps:
If description indicates that simulcast is not supported or desired, then remove all dictionaries in transceiver.[[Sender]].[[SendEncodings]] except the first one and abort these sub steps.
If description rejects any of the offered layers, then remove the dictionaries that correspond to rejected layers from transceiver.[[Sender]].[[SendEncodings]].
Update the paused status as indicated by
[MMUSIC-SIMULCAST] of each simulcast
layer by setting the
member on the corresponding dictionaries
in
transceiver.[[Sender]].[[SendEncodings]]
to active
true
for unpaused or to
false
for paused.
Set transceiver.[[Mid]] to transceiver.[[JsepMid]].
Let direction be an
value
representing the direction from the media
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
"RTCRtpTransceiverDirection
".
inactive
If direction is
"
" or
"sendrecv
",
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.
recvonly
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
"
" or
"answer
", then run the
following steps:
pranswer
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]]s to direction.
Let transport be the
object representing
the RTP/RTCP component of the media
transport used by
transceiver's associated
media description, according to
[BUNDLE].
RTCDtlsTransport
Set transceiver.[[Sender]].[[SenderTransport]] to transport.
Set transceiver.[[Receiver]].[[ReceiverTransport]] to transport.
Set the [[IceRole]] of transport according to the rules of [RFC8445].
unknown
, do not modify
[[IceRole]].
controlling
.
a=ice-lite
,
set [[IceRole]] to
controlling
.
a=ice-lite
,
set [[IceRole]] to
controlled
.
If the media description is rejected,
and
transceiver.[[Stopped]] is
false
, then stop the
RTCRtpTransceiver transceiver.
Otherwise, (if description is of type
"
") run the following steps:
rollback
For each transceiver in the connection's set of transceivers run the following steps:
If the transceiver was not associated with a media description
prior to applying the
that is being
rolled back, disassociate it and set both
transceiver.[[JsepMid]]
and transceiver.[[Mid]] to
RTCSessionDescription
null
.
Set transceiver.[[Sender]].[[SenderTransport]] to transceiver.[[Sender]].[[LastStableStateSenderTransport]].
Set transceiver.[[Receiver]].[[ReceiverTransport]] to transceiver.[[Receiver]].[[LastStableStateReceiverTransport]].
Set transceiver.[[Receiver]].[[ReceiveCodecs]] to transceiver.[[Receiver]].[[LastStableStateReceiveCodecs]].
If the signaling state of
connection is
"
",
run the following sub steps:
have-remote-offer
Let msids be a list of the
id
s of all
MediaStream
objects 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 the transceiver was created by
applying the
that
is being rolled back, and a track has never
been attached to it via
RTCSessionDescription
addTrack
()
, then stop the RTCRtpTransceiver
transceiver, and remove it from
connection's set of
transceivers.
Set
connection.[[PendingLocalDescription]]
and
connection.[[PendingRemoteDescription]]
to null
, and set
connection's signaling state to
"
".
stable
If description is of type
"
", then run the following
steps:
answer
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's signaling state is
now "
", run the following
steps:
stable
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
the
s and their associated
RTCDtlsTransport
s. This results in events
firing on these objects in a queued task.
RTCIceTransport
Clear the negotiation-needed flag and update the negotiation-needed flag.
If connection's signaling state
changed above, fire an event named
at connection.
signalingstatechange
For each channel in errorList,
fire an event named
using the error
interface with the
RTCErrorEvent
attribute set to
"errorDetail
" at
channel.
data-channel-failure
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
using the track
interface with
its RTCTrackEvent
attribute initialized
to entry.receiver
,
its receiver
attribute initialized to
entry.track
, its
track
attribute initialized to
entry.streams
and
its streams
attribute
initialized to
entry.transceiver
at
the connection object.
transceiver
Resolve p with
undefined
.
Return p.
To set a configuration, run the following steps:
Let configuration be the
dictionary to be processed.
RTCConfiguration
Let connection be the target
object.
RTCPeerConnection
If configuration.
is set, run the following steps:
certificates
If the length of
configuration.
is different from the length of
connection.[[Configuration]].certificates
,
throw an certificates
InvalidModificationError
.
Let index be initialized to 0.
Let size be initialized to the length of
configuration.
.
certificates
While index is less than size, run the following steps:
If the ECMAScript object represented by the value of
configuration.
at index is not the same as the ECMAScript
object represented by the value of
connection.[[Configuration]].certificates
at index, throw an
certificates
InvalidModificationError
.
Increment index by 1.
If the value of
configuration.
is
set and its value differs from the connection's
bundle policy, throw an
bundlePolicy
InvalidModificationError
.
If the value of
configuration.
is set and its value differs from the connection's
rtcpMux policy, throw an
rtcpMuxPolicy
InvalidModificationError
.
If the value of
configuration.
is set and its value differs from the connection's
previously set iceCandidatePoolSize
, and
iceCandidatePoolSize
has already been
called, throw an
setLocalDescription
InvalidModificationError
.
Set the ICE Agent's ICE transports setting to the
value of
configuration.
.
As defined in [JSEP] (section 4.1.16.), 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.
iceTransportPolicy
Set the ICE Agent's prefetched ICE candidate pool
size as defined in [JSEP] (section 3.5.4. and section 4.1.1.) to the
value of
configuration.
.
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 [JSEP] (section 4.1.16.).
iceCandidatePoolSize
Let validatedServers be an empty list.
If configuration.
is defined, then run the following steps for each element:
iceServers
Let server be the current list element.
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
.
For each url in urls 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
a NotSupportedError
. If scheme name is
turn
or turns
, and parsing the url
using the syntax defined in [RFC7065] fails, throw a SyntaxError
. If scheme
name is stun
or
stuns
, and parsing the
url using the syntax defined in
[RFC7064] fails, throw a
SyntaxError
.
If scheme name is turn
or turns
, and either of
server.
or
server.username
are
omitted, then throw an
credential
InvalidAccessError
.
If scheme name is turn
or turns
, and
server.
is
"credentialType
", and
server.password
is not
a DOMString, then
throw an credential
InvalidAccessError
.
Append server to validatedServers.
Set the ICE Agent's ICE servers list to validatedServers.
As defined in [JSEP] (section 4.1.16.), 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.
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.
WebIDL[Exposed=Window] interfaceRTCPeerConnection
: EventTarget {constructor
(optionalRTCConfiguration
configuration = {}); Promise<RTCSessionDescriptionInit
>createOffer
(optionalRTCOfferOptions
options = {}); Promise<RTCSessionDescriptionInit
>createAnswer
(optionalRTCAnswerOptions
options = {}); Promise<undefined>setLocalDescription
(optionalRTCLocalSessionDescriptionInit
description = {}); readonly attributeRTCSessionDescription
?localDescription
; readonly attributeRTCSessionDescription
?currentLocalDescription
; readonly attributeRTCSessionDescription
?pendingLocalDescription
; Promise<undefined>setRemoteDescription
(RTCSessionDescriptionInit
description); readonly attributeRTCSessionDescription
?remoteDescription
; readonly attributeRTCSessionDescription
?currentRemoteDescription
; readonly attributeRTCSessionDescription
?pendingRemoteDescription
; Promise<undefined>addIceCandidate
(optionalRTCIceCandidateInit
candidate = {}); readonly attributeRTCSignalingState
signalingState
; readonly attributeRTCIceGatheringState
iceGatheringState
; readonly attributeRTCIceConnectionState
iceConnectionState
; readonly attributeRTCPeerConnectionState
connectionState
; readonly attribute boolean?canTrickleIceCandidates
; undefinedrestartIce
();RTCConfiguration
getConfiguration
(); undefinedsetConfiguration
(optionalRTCConfiguration
configuration = {}); undefinedclose
(); attribute EventHandleronnegotiationneeded
; attribute EventHandleronicecandidate
; attribute EventHandleronicecandidateerror
; attribute EventHandleronsignalingstatechange
; attribute EventHandleroniceconnectionstatechange
; attribute EventHandleronicegatheringstatechange
; attribute EventHandleronconnectionstatechange
; // 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, optionalRTCOfferOptions
options = {}); Promise<undefined>setLocalDescription
(optionalRTCLocalSessionDescriptionInit
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); };
localDescription
of type RTCSessionDescription
, readonly,
nullable
The
attribute MUST return
[[PendingLocalDescription]] if it is not
localDescription
null
and otherwise it MUST return
[[CurrentLocalDescription]].
Note that
[[CurrentLocalDescription]].
and
[[PendingLocalDescription]].sdp
need not be string-wise identical to the SDP value passed
to the corresponding sdp
call (i.e. SDP
may be parsed and reformatted, and ICE candidates may be
added).
setLocalDescription
currentLocalDescription
of type RTCSessionDescription
, readonly,
nullable
The
attribute MUST return
[[CurrentLocalDescription]].
currentLocalDescription
It represents the local description that was successfully
negotiated the last time the
transitioned into the stable state plus any local
candidates that have been generated by the ICE Agent
since the offer or answer was created.
RTCPeerConnection
pendingLocalDescription
of type RTCSessionDescription
, readonly,
nullable
The
attribute MUST return
[[PendingLocalDescription]].
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
is in the stable
state, the value is RTCPeerConnection
null
.
remoteDescription
of type RTCSessionDescription
, readonly,
nullable
The
attribute MUST return
[[PendingRemoteDescription]] if it is not
remoteDescription
null
and otherwise it MUST return
[[CurrentRemoteDescription]].
Note that
[[CurrentRemoteDescription]].
and
[[PendingRemoteDescription]].sdp
need not be string-wise identical to the SDP value passed
to the corresponding sdp
call (i.e.
SDP may be parsed and reformatted, and ICE candidates may
be added).
setRemoteDescription
currentRemoteDescription
of type RTCSessionDescription
, readonly,
nullable
The
attribute MUST return
[[CurrentRemoteDescription]].
currentRemoteDescription
It represents the last remote description that was
successfully negotiated the last time the
transitioned into the stable state
plus any remote candidates that have been supplied via
RTCPeerConnection
addIceCandidate
()
since the offer or
answer was created.
pendingRemoteDescription
of type RTCSessionDescription
, readonly,
nullable
The
attribute MUST return
[[PendingRemoteDescription]].
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
is in the
stable state, the value is RTCPeerConnection
null
.
signalingState
of
type RTCSignalingState
,
readonly
The
attribute MUST return the
signalingState
object's signaling state.
RTCPeerConnection
iceGatheringState
of type RTCIceGatheringState
, readonly
The
attribute MUST return the ICE
gathering state of the iceGatheringState
instance.
RTCPeerConnection
iceConnectionState
of type RTCIceConnectionState
, readonly
The
attribute MUST return the ICE
connection state of the iceConnectionState
instance.
RTCPeerConnection
connectionState
of type RTCPeerConnectionState
, readonly
The
attribute MUST return the connection state of the connectionState
instance.
RTCPeerConnection
canTrickleIceCandidates
of type
boolean, readonly, nullable
The
attribute indicates whether
the remote peer is able to accept trickled ICE candidates
[TRICKLE-ICE]. The value is determined based on whether a
remote description indicates support for trickle ICE, as
defined in [JSEP] (section 4.1.15.).
Prior to the completion of
canTrickleIceCandidates
, this value is
setRemoteDescription
null
.
onnegotiationneeded
of type
EventHandler
negotiationneeded
.
onicecandidate
of type EventHandler
icecandidate
.
onicecandidateerror
of type
EventHandler
icecandidateerror
.
onsignalingstatechange
of type
EventHandler
signalingstatechange
.
oniceconnectionstatechange
of type
EventHandler
iceconnectionstatechange
onicegatheringstatechange
of type
EventHandler
icegatheringstatechange
.
onconnectionstatechange
of type
EventHandler
connectionstatechange
.
createOffer
The
method generates a blob of SDP that
contains an RFC 3264 offer with the supported
configurations for the session, including descriptions of
the local createOffer
MediaStreamTrack
s attached to this
, the codec/RTP/RTCP capabilities
supported by this implementation, and parameters of the ICE agent and the DTLS connection. The
options parameter may be supplied to provide
additional control over the offer generated.
RTCPeerConnection
If a system has limited resources (e.g. a finite number of
decoders),
needs to return an offer that
reflects the current state of the system, so that
createOffer
will succeed when it attempts to
acquire those resources. The session descriptions MUST
remain usable by setLocalDescription
without causing an
error until at least the end of the fulfillment
callback of the returned promise.
setLocalDescription
Creating the SDP MUST follow the appropriate process for
generating an offer described in [JSEP], except the user
agent MUST treat a stopping
transceiver as stopped
for the
purposes of JSEP in this case.
As an offer, the generated SDP will contain the full set of
codec/RTP/RTCP capabilities supported or preferred by the
session (as opposed to an answer, which will include only a
specific negotiated subset to use). In the event
is called after the session is established,
createOffer
will generate an offer that is compatible
with the current session, incorporating any changes that
have been made to the session since the last complete
offer-answer exchange, such as addition or removal of
tracks. If no changes have been made, the offer will
include the capabilities of the current local description
as well as any additional capabilities that could be
negotiated in an updated offer.
createOffer
The generated SDP will also contain the ICE agent's
,
usernameFragment
and ICE options (as defined
in [ICE], Section 14) and may also contain any local
candidates that have been gathered by the agent.
password
The
value in
configuration for the certificates
provides the certificates configured by the application for
the RTCPeerConnection
. These certificates, along with
any default certificates are used to produce a set of
certificate fingerprints. These certificate fingerprints
are used in the construction of SDP.
RTCPeerConnection
The process of generating an SDP exposes a subset of the media capabilities of the underlying system, which provides generally persistent cross-origin information on the device. It thus increases the fingerprinting surface of the application. In privacy-sensitive contexts, browsers can consider mitigations such as generating SDP matching only a common subset of the capabilities.
When the method is called, the user agent MUST run the following steps:
Let connection be the
object on which the method was invoked.
RTCPeerConnection
If connection.[[IsClosed]] is
true
, return a promise rejected with
a newly created InvalidStateError
.
Return the result of chaining the result of creating an offer with connection to connection's operations chain.
To create an offer given connection run the following steps:
If connection's signaling state is
neither "
" nor
"stable
", return a
promise rejected with a newly created have-local-offer
InvalidStateError
.
Let p be a new promise.
In parallel, begin the in-parallel steps to create an offer given connection and p.
Return p.
The in-parallel steps to create an offer given connection and a promise p are as follows:
If connection was not constructed with a set of certificates, and one has not yet been generated, wait for it to be generated.
Inspect the offerer's system state to determine the currently available resources as necessary for generating the offer, as described in [JSEP] (section 4.1.6.).
If this inspection failed for any reason, reject
p with a newly created
OperationError
and abort these steps.
Queue a task that runs the final steps to create an offer given connection and p.
The final steps to create an offer given connection and a promise p are as follows:
If connection.[[IsClosed]] is
true
, then abort these steps.
If connection was modified in such a way that additional inspection of the offerer's system state is necessary, then in parallel begin the in-parallel steps to create an offer again, given connection and p, and abort these steps.
createOffer
was called when only an audio RTCRtpTransceiver
was
added to connection, but while performing
the in-parallel steps to create an offer, a video
RTCRtpTransceiver
was added, requiring additional
inspection of video system resources.
Given the information that was obtained from previous
inspection, the current state of connection
and its
s, generate an SDP offer,
sdpString, as described in [JSEP] (section 5.2.).
RTCRtpTransceiver
As described in [BUNDLE] (Section 7), if
bundling is used (see
) an
offerer tagged m= section must be selected in order
to negotiate a BUNDLE group. The user agent MUST
choose the m= section that corresponds to the first
non-stopped transceiver in the set of
transceivers as the offerer tagged m= section.
This allows the remote endpoint to predict which
transceiver is the offerer tagged m= section
without having to parse the SDP.
RTCBundlePolicy
The codec preferences of a media
description's associated transceiver is
said to be the value of the
.[[PreferredCodecs]]
with the following filtering applied (or said not
to be set if [[PreferredCodecs]] is empty):
RTCRtpTransceiver
If the
is
"direction
",
exclude any codecs not included in the
intersection of
sendrecv
.RTCRtpSender
(kind).getCapabilities
and
codecs
.RTCRtpReceiver
(kind).getCapabilities
.
codecs
If the
is
"direction
",
exclude any codecs not included in
sendonly
.RTCRtpSender
(kind).getCapabilities
.
codecs
If the
is
"direction
",
exclude any codecs not included in
recvonly
.RTCRtpReceiver
(kind).getCapabilities
.
codecs
The filtering MUST NOT change the order of the codec preferences.
If the length of the [[SendEncodings]] slot
of the
is larger than 1, then for
each encoding given in [[SendEncodings]] of
the RTCRtpSender
, add an RTCRtpSender
a=rid send
line to the corresponding
media section, and add an a=simulcast:send
line giving the RIDs
in the same order as given in the
field. No RID
restrictions are set.
encodings
[SDP-SIMULCAST] section 5.2 specifies that the order of RIDs in the a=simulcast line suggests a proposed order of preference. If the browser decides not to transmit all encodings, one should expect it to stop sending the last encoding in the list first.
Let offer be a newly created
dictionary with its
RTCSessionDescriptionInit
member initialized
to the string "type
" and its
offer
member initialized to
sdpString.
sdp
Set the [[LastCreatedOffer]] internal slot to sdpString.
Resolve p with offer.
createAnswer
The
method generates an [SDP] answer
with the supported configuration for the session that is
compatible with the parameters in the remote configuration.
Like createAnswer
, the returned blob of SDP contains
descriptions of the local createOffer
MediaStreamTrack
s attached to
this
, the codec/RTP/RTCP options
negotiated for this session, and any candidates that have
been gathered by the ICE Agent. The
options parameter may be supplied to provide
additional control over the generated answer.
RTCPeerConnection
Like
, the returned description SHOULD
reflect the current state of the system. The session
descriptions MUST remain usable by createOffer
without causing an error until at least the end of the fulfillment callback of the returned promise.
setLocalDescription
As an answer, the generated SDP will contain a specific codec/RTP/RTCP configuration that, along with the corresponding offer, specifies how the media plane should be established. The generation of the SDP MUST follow the appropriate process for generating an answer described in [JSEP].
The generated SDP will also contain the ICE agent's
,
usernameFragment
and ICE options (as defined
in [ICE], Section 14) and may also contain any local
candidates that have been gathered by the agent.
password
The
value in
configuration for the certificates
provides the certificates configured by the application for
the RTCPeerConnection
. These certificates, along with
any default certificates are used to produce a set of
certificate fingerprints. These certificate fingerprints
are used in the construction of SDP.
RTCPeerConnection
An answer can be marked as provisional, as described in
[JSEP] (section 4.1.8.1.), by setting
the
to
"type
".
pranswer
When the method is called, the user agent MUST run the following steps:
Let connection be the
object on which the method was invoked.
RTCPeerConnection
If connection.[[IsClosed]] is
true
, return a promise rejected with
a newly created InvalidStateError
.
Return the result of chaining the result of creating an answer with connection to connection's operations chain.
To create an answer given connection run the following steps:
If connection's signaling state is
neither "
" nor
"have-remote-offer
", return a
promise rejected with a newly created have-local-pranswer
InvalidStateError
.
Let p be a new promise.
In parallel, begin the in-parallel steps to create an answer given connection and p.
Return p.
The in-parallel steps to create an answer given connection and a promise p are as follows:
If connection was not constructed with a set of certificates, and one has not yet been generated, wait for it to be generated.
Inspect the answerer's system state to determine the currently available resources as necessary for generating the answer, as described in [JSEP] (section 4.1.7.).
If this inspection failed for any reason, reject
p with a newly created
OperationError
and abort these steps.
Queue a task that runs the final steps to create an answer given p.
The final steps to create an answer given a promise p are as follows:
If connection.[[IsClosed]] is
true
, then abort these steps.
If connection was modified in such a way that additional inspection of the answerer's system state is necessary, then in parallel begin the in-parallel steps to create an answer again given connection and p, and abort these steps.
createAnswer
was called when an RTCRtpTransceiver
's direction
was "recvonly
", but
while performing the in-parallel steps to create an
answer, the direction was changed to
"sendrecv
", requiring
additional inspection of video encoding resources.
Given the information that was obtained from previous
inspection and the current state of
connection and its
s,
generate an SDP answer, sdpString, as
described in [JSEP] (section 5.3.).
RTCRtpTransceiver
The codec preferences of an m= section's
associated transceiver is said to be the value of
the
.[[PreferredCodecs]]
with the following filtering applied (or said not
to be set if [[PreferredCodecs]] is empty):
RTCRtpTransceiver
If the
is
"direction
",
exclude any codecs not included in the
intersection of
sendrecv
.RTCRtpSender
(kind).getCapabilities
and
codecs
.RTCRtpReceiver
(kind).getCapabilities
.
codecs
If the
is
"direction
",
exclude any codecs not included in
sendonly
.RTCRtpSender
(kind).getCapabilities
.
codecs
If the
is
"direction
",
exclude any codecs not included in
recvonly
.RTCRtpReceiver
(kind).getCapabilities
.
codecs
The filtering MUST NOT change the order of the codec preferences.
If the length of the [[SendEncodings]] slot
of the
is larger than 1, then for
each encoding given in [[SendEncodings]] of
the RTCRtpSender
, add an RTCRtpSender
a=rid send
line to the corresponding
media section, and add an a=simulcast:send
line giving the RIDs
in the same order as given in the
field. No RID
restrictions are set.
encodings
Let answer be a newly created
dictionary with its
RTCSessionDescriptionInit
member initialized
to the string "type
" and its
answer
member initialized to
sdpString.
sdp
Set the [[LastCreatedAnswer]] internal slot to sdpString.
Resolve p with answer.
setLocalDescription
The
method instructs the
setLocalDescription
to apply the supplied
RTCPeerConnection
as the local
description.
RTCLocalSessionDescriptionInit
This API changes the local media state. In order to
successfully handle scenarios where the application wants
to offer to change from one media format to a different,
incompatible format, the
MUST be able
to simultaneously support use of both the current and
pending local descriptions (e.g. support codecs that exist
in both descriptions) until a final answer is received, at
which point the RTCPeerConnection
can fully adopt the
pending local description, or rollback to the current
description if the remote side rejected the change.
RTCPeerConnection
Passing in a description is optional. If left out, then
will implicitly create an offer or create an answer, as needed. As noted in
[JSEP] (section 5.4.), if a
description with SDP is passed in, that SDP is not allowed
to have changed from when it was returned from either
setLocalDescription
or createOffer
.
createAnswer
When the method is invoked, the user agent MUST run the following steps:
Let description be the method's first argument.
Let connection be the
object on which the method was invoked.
RTCPeerConnection
Let sdp be
description.
.
sdp
Return the result of chaining the following steps to connection's operations chain:
Let type be
description.
if present, or "type
" if not
present and connection's signaling
state is either "offer
",
"stable
", or
"have-local-offer
";
otherwise "have-remote-pranswer
".
answer
If type is "
", and
sdp is not the empty string and not
equal to
connection.[[LastCreatedOffer]],
then return a promise rejected with a newly
created
offer
InvalidModificationError
and abort these steps.
If type is "
" or
"answer
", and sdp is
not the empty string and not equal to
connection.[[LastCreatedAnswer]],
then return a promise rejected with a newly
created
pranswer
InvalidModificationError
and abort these steps.
If sdp is the empty string, and
type is "
", then run
the following sub steps:
offer
Set sdp to the value of connection.[[LastCreatedOffer]].
If sdp is the empty string, or if it no longer accurately represents the offerer's system state of connection, then let p be the result of creating an offer with connection, and return the result of reacting to p with a fulfillment step that sets the local RTCSessionDescription indicated by its first argument.
If sdp is the empty string, and
type is "
" or
"answer
", then run the following
sub steps:
pranswer
Set sdp to the value of connection.[[LastCreatedAnswer]].
If sdp is the empty string, or if it no longer accurately represents the answerer's system state of connection, then let p be the result of creating an answer with connection, and return the result of reacting to p with the following fulfillment steps:
Let answer be the first argument to these fulfillment steps.
Return the result of setting the local
RTCSessionDescription indicated by
{type,
answer.
.
}sdp
Return the result of setting the local
RTCSessionDescription indicated by {type, sdp}
.
As noted in [JSEP] (section 5.9.), calling this method may trigger the ICE candidate gathering process by the ICE Agent.
setRemoteDescription
The
method instructs the
setRemoteDescription
to apply the supplied
RTCPeerConnection
as the remote offer or
answer. This API changes the local media state.
RTCSessionDescriptionInit
When the method is invoked, the user agent MUST run the following steps:
Let description be the method's first argument.
Let connection be the
object on which the method was invoked.
RTCPeerConnection
Return the result of chaining the following steps to connection's operations chain:
If
description.
is "type
" and is invalid for the
current signaling state of
connection as described in
[JSEP] (section 5.5. and section 5.6.),
then run the following sub steps:
offer
Let p be the result of setting
the local RTCSessionDescription indicated by
{type:
"
.
"}rollback
Return the result of reacting to p with a fulfillment step that sets the remote RTCSessionDescription description, and abort these steps.
Return the result of setting the remote RTCSessionDescription description.
addIceCandidate
The
method provides a remote candidate
to the ICE Agent. This method can also be used to
indicate the end of remote candidates when called with an
empty string for the addIceCandidate
member.
The only members of the argument used by this method are
candidate
, candidate
,
sdpMid
, and
sdpMLineIndex
; the rest are ignored.
When the method is invoked, the user agent MUST run the
following steps:
usernameFragment
Let candidate be the method's argument.
Let connection be the
object on which the method was invoked.
RTCPeerConnection
If candidate.
is not an empty string and both
candidate.candidate
and
candidate.sdpMid
are sdpMLineIndex
null
, return a promise rejected
with a newly created TypeError
.
Return the result of chaining the following steps to connection's operations chain:
If
is
remoteDescription
null
return a promise rejected
with a newly created
InvalidStateError
.
If candidate.
is not sdpMid
null
, run the following steps:
If
candidate.
is not equal to the mid of any media
description in
sdpMid
, return
a promise rejected with a newly created remoteDescription
OperationError
.
Else, if
candidate.
is not sdpMLineIndex
null
, run the following steps:
If
candidate.
is equal to or larger than the number of media
descriptions in
sdpMLineIndex
, return
a promise rejected with a newly created remoteDescription
OperationError
.
If either
candidate.
or
candidate.sdpMid
indicate a media description in
sdpMLineIndex
whose
associated transceiver is remoteDescription
stopped
, return a promise resolved with
undefined
.
If
candidate.
is not usernameFragment
null
, and is not equal to any
username fragment present in the corresponding media description of an applied remote
description, return a promise rejected with a
newly created OperationError
.
Let p be a new promise.
In parallel, if the candidate is not administratively prohibited, add the ICE
candidate candidate as described in
[JSEP] (section 4.1.17.).
Use
candidate.
to identify the ICE generation; if
usernameFragment
is
usernameFragment
null
, process the candidate
for the most recent ICE generation.
If
candidate.
is an empty string, process candidate as
an end-of-candidates indication for the
corresponding media description and ICE
candidate generation. If both
candidate.candidate
and
candidate.sdpMid
are sdpMLineIndex
null
, then this end-of-candidates
indication applies to all media descriptions.
If candidate could not be successfully added the user agent MUST queue a task that runs the following steps:
If
connection.[[IsClosed]]
is true
, then abort these
steps.
Reject p with a newly created OperationError
and
abort these steps.
If candidate is applied successfully, or if the candidate was administratively prohibited the user agent MUST queue a task that runs the following steps:
If
connection.[[IsClosed]]
is true
, then abort these
steps.
If
connection.[[PendingRemoteDescription]]
is not null
, and represents
the ICE generation for which
candidate was processed, add
candidate to
connection.[[PendingRemoteDescription]].sdp.
If
connection.[[CurrentRemoteDescription]]
is not null
, and represents
the ICE generation for which
candidate was processed, add
candidate to
connection.[[CurrentRemoteDescription]].sdp.
Resolve p with
undefined
.
Return p.
A candidate is administratively prohibited if the UA has decided not to allow connection attempts to this address.
For privacy reasons, there is no indication to the developer about whether or not an address/port is blocked; it behaves exactly as if there was no response from the address.
The UA MUST prohibit connections to addresses on the [Fetch] block bad port list, and MAY choose to prohibit connections to other addresses.
If the
member of
the iceTransportPolicy
is
RTCConfiguration
, candidates requiring
external resolution, such as mDNS candidates and DNS
candidates, MUST be prohibited.
relay
Due to WebIDL processing,
(addIceCandidate
null
) is
interpreted as a call with the default dictionary present,
which, in the above algorithm, indicates end-of-candidates
for all media descriptions and ICE candidate generation.
This is by design for legacy reasons.
restartIce
The
method tells the restartIce
that ICE should be restarted. Subsequent calls to
RTCPeerConnection
will create descriptions that will restart
ICE, as described in section 9.1.1.1 of [ICE].
createOffer
When this method is invoked, the user agent MUST run the following steps:
Let connection be the
on which the method was invoked.
RTCPeerConnection
Empty connection.[[LocalIceCredentialsToReplace]], and populate it with all ICE credentials (ice-ufrag and ice-pwd as defined in section 15.4 of [ICE]) found in connection.[[CurrentLocalDescription]], as well as all ICE credentials found in connection.[[PendingLocalDescription]].
Update the negotiation-needed flag for connection.
getConfiguration
Returns an
object representing the
current configuration of this RTCConfiguration
object.
RTCPeerConnection
When this method is called, the user agent MUST return the
object stored in the
[[Configuration]] internal slot.
RTCConfiguration
setConfiguration
The
method updates the configuration
of this setConfiguration
object. This includes
changing the configuration of the ICE Agent. As noted
in [JSEP] (section 3.5.1.),
when the ICE configuration changes in a way that requires a
new gathering phase, an ICE restart is required.
RTCPeerConnection
When the
method is invoked, the user
agent MUST run the following steps:
setConfiguration
Let connection be the
on which the method was invoked.
RTCPeerConnection
If connection.[[IsClosed]] is
true
, throw an
InvalidStateError
.
Set the configuration specified by configuration.
close
When the
method is invoked, the user agent MUST
run the following steps:
close
Let connection be the
object on which the method was invoked.
RTCPeerConnection
false
.
The close the connection algorithm given a connection and a disappear boolean, is as follows:
If connection.[[IsClosed]] is
true
, abort these steps.
Set connection.[[IsClosed]] to
true
.
Set connection's signaling state to
"
". This does not fire any
event.
closed
Let transceivers be the result of executing
the CollectTransceivers
algorithm. For every
transceiver in
transceivers, run the following steps:
RTCRtpTransceiver
If transceiver.[[Stopped]] is
true
, abort these sub steps.
Stop the RTCRtpTransceiver with transceiver and disappear.
Set the [[ReadyState]] slot of each of
connection's
s to
"RTCDataChannel
".
closed
RTCDataChannel
s will be closed abruptly and the
closing procedure will not be invoked.
If connection.[[SctpTransport]] is
not null
, tear down the underlying SCTP
association by sending an SCTP ABORT chunk and set the
[[SctpTransportState]] to
"
".
closed
Set the [[DtlsTransportState]] slot of each of
connection's
s to
"RTCDtlsTransport
".
closed
Destroy connection's ICE Agent, abruptly ending any active ICE processing and releasing any relevant resources (e.g. TURN permissions).
Set the [[IceTransportState]] slot of each of
connection's
s to
"RTCIceTransport
".
closed
Set connection's ICE connection state
to "
". This does not
fire any event.
closed
Set connection's connection state to
"
". This does not fire
any event.
closed
RTCPeerConnection
interface since overloaded
functions are not allowed to be defined in partial interfaces.
Supporting the methods in this section is optional. However, if these methods are supported it is mandatory to implement according to what is specified here.
addStream
method that used to exist on
RTCPeerConnection
is easy to polyfill as:
RTCPeerConnection.prototype.addStream = function(stream) {
stream.getTracks().forEach((track) => this.addTrack(track, stream));
};
createOffer
When the createOffer
method
is called, the user agent MUST run the following steps:
Let successCallback be the method's first argument.
Let failureCallback be the callback indicated by the method's second argument.
Let options be the callback indicated by the method's third argument.
Run the steps specified by
's
RTCPeerConnection
createOffer
()
method with
options as the sole argument, and let
p be the resulting promise.
Upon fulfillment of p with value offer, invoke successCallback with offer as the argument.
Upon rejection of p with reason r, invoke failureCallback with r as the argument.
Return a promise resolved with
undefined
.
setLocalDescription
When the setLocalDescription
method is called,
the user agent MUST run the following steps:
Let description be the method's first argument.
Let successCallback be the callback indicated by the method's second argument.
Let failureCallback be the callback indicated by the method's third argument.
Run the steps specified by
's
RTCPeerConnection
method with
description as the sole argument, and let
p be the resulting promise.
setLocalDescription
Upon fulfillment of p, invoke
successCallback with
undefined
as the argument.
Upon rejection of p with reason r, invoke failureCallback with r as the argument.
Return a promise resolved with
undefined
.
createAnswer
createAnswer
method does not take an RTCAnswerOptions
parameter,
since no known legacy createAnswer
implementation ever
supported it.
When the createAnswer
method is called, the user agent MUST run the following
steps:
Let successCallback be the method's first argument.
Let failureCallback be the callback indicated by the method's second argument.
Run the steps specified by
's
RTCPeerConnection
createAnswer
()
method with no
arguments, and let p be the resulting
promise.
Upon fulfillment of p with value answer, invoke successCallback with answer as the argument.
Upon rejection of p with reason r, invoke failureCallback with r as the argument.
Return a promise resolved with
undefined
.
setRemoteDescription
When the setRemoteDescription
method is called,
the user agent MUST run the following steps:
Let description be the method's first argument.
Let successCallback be the callback indicated by the method's second argument.
Let failureCallback be the callback indicated by the method's third argument.
Run the steps specified by
's
RTCPeerConnection
method
with description as the sole argument, and
let p be the resulting promise.
setRemoteDescription
Upon fulfillment of p, invoke
successCallback with
undefined
as the argument.
Upon rejection of p with reason r, invoke failureCallback with r as the argument.
Return a promise resolved with
undefined
.
addIceCandidate
When the addIceCandidate
method is called, the user agent MUST run the following
steps:
Let candidate be the method's first argument.
Let successCallback be the callback indicated by the method's second argument.
Let failureCallback be the callback indicated by the method's third argument.
Run the steps specified by
's
RTCPeerConnection
addIceCandidate
()
method with
candidate as the sole argument, and let
p be the resulting promise.
Upon fulfillment of p, invoke
successCallback with
undefined
as the argument.
Upon rejection of p with reason r, invoke failureCallback with r as the argument.
Return a promise resolved with
undefined
.
These callbacks are only used on the legacy APIs.
RTCPeerConnectionErrorCallback
WebIDLcallback RTCPeerConnectionErrorCallback
= undefined (DOMException error);
RTCPeerConnectionErrorCallback
Parameters
error
of type
DOMException
RTCSessionDescriptionCallback
WebIDLcallbackRTCSessionDescriptionCallback
= undefined (RTCSessionDescriptionInit
description);
RTCSessionDescriptionCallback
Parameters
RTCSessionDescriptionInit
This section describes a set of legacy extensions that may be
used to influence how an offer is created, in addition to the
media added to the
. Developers are
encouraged to use the RTCPeerConnection
API instead.
RTCRtpTransceiver
When
is called with any of the
legacy options specified in this section, run the followings
steps instead of the regular createOffer
steps:
createOffer
Let options be the methods first argument.
Let connection be the current
object.
RTCPeerConnection
For each offerToReceive<Kind>
member in options with kind, kind, run
the following steps:
For each non-stopped
"
" transceiver
of transceiver kind kind, set
transceiver.[[Direction]] to
"sendrecv
".
sendonly
For each non-stopped
"
" transceiver
of transceiver kind kind, set
transceiver.[[Direction]] to
"recvonly
".
inactive
Continue with the next option, if any.
If connection has any non-stopped
"
" or
"sendrecv
" transceivers of
transceiver kind kind, continue with the
next option, if any.
recvonly
Let transceiver be the result of invoking the
equivalent of
connection.
(kind),
except that this operation MUST NOT update the
negotiation-needed flag.
addTransceiver
If transceiver is unset because the previous operation threw an error, abort these steps.
Set transceiver.[[Direction]] to
"
".
recvonly
Run the steps specified by
to create the offer.
createOffer
WebIDLpartial dictionaryRTCOfferOptions
{ booleanofferToReceiveAudio
; booleanofferToReceiveVideo
; };
offerToReceiveAudio
of type boolean
This setting provides additional control over the directionality of audio. For example, it can be used to ensure that audio can be received, regardless if audio is sent or not.
offerToReceiveVideo
of type boolean
This setting provides additional control over the directionality of video. For example, it can be used to ensure that video can be received, regardless if video is sent or not.
An
object MUST not be garbage collected as
long as any event can cause an event handler to be triggered on the
object. When the object's [[IsClosed]] internal slot is
RTCPeerConnection
true
, no such event handler can be triggered and it is
therefore safe to garbage collect the object.
All
and RTCDataChannel
MediaStreamTrack
objects that are
connected to an
have a strong reference to
the RTCPeerConnection
object.
RTCPeerConnection
All methods that return promises are governed by the standard error handling rules of promises. Methods that do not return promises may throw exceptions to indicate errors.
RTCSdpType
The
enum describes the type of an
RTCSdpType
, RTCSessionDescriptionInit
,
or RTCLocalSessionDescriptionInit
instance.
RTCSessionDescription
WebIDLenumRTCSdpType
{ "offer
", "pranswer
", "answer
", "rollback
" };
Enumeration description | |
---|---|
offer
|
An |
pranswer
|
An |
answer
|
An |
rollback
|
An |
RTCSessionDescription
Class
The
class is used by
RTCSessionDescription
to expose local and remote session
descriptions.
RTCPeerConnection
WebIDL[Exposed=Window] interfaceRTCSessionDescription
{constructor
(RTCSessionDescriptionInit
descriptionInitDict); readonly attributeRTCSdpType
type
; readonly attribute DOMStringsdp
; [Default] objecttoJSON
(); };
constructor()
The RTCSessionDescription()
constructor takes a dictionary argument,
description, whose content is used to initialize
the new
object. This constructor
is deprecated; it exists for legacy compatibility reasons
only.
RTCSessionDescription
type
of type RTCSdpType
, readonly
sdp
of type DOMString, readonly, defaulting to
""
toJSON()
WebIDLdictionaryRTCSessionDescriptionInit
{ requiredRTCSdpType
type
; DOMStringsdp
= ""; };
RTCSessionDescriptionInit
Members
type
of type RTCSdpType
, required
sdp
of type DOMString
type
is "rollback
",
this member is unused.
WebIDLdictionaryRTCLocalSessionDescriptionInit
{RTCSdpType
type
; DOMStringsdp
= ""; };
RTCLocalSessionDescriptionInit
Members
type
of type RTCSdpType
setLocalDescription
will infer the type
based on the RTCPeerConnection
's signaling state.
sdp
of type DOMString
type
is "rollback
",
this member is unused.
Many changes to state of an
will require
communication with the remote side via the signaling channel, in
order to have the desired effect. The app can be kept informed as to
when it needs to do signaling, by listening to the RTCPeerConnection
negotiationneeded
event. This event is fired according
to the state of the connection's negotiation-needed flag,
represented by a [[NegotiationNeeded]] internal slot.
This section is non-normative.
If an operation is performed on an
that
requires signaling, the connection will be marked as needing
negotiation. Examples of such operations include adding or stopping
an RTCPeerConnection
, or adding the first RTCRtpTransceiver
.
RTCDataChannel
Internal changes within the implementation can also result in the connection being marked as needing negotiation.
Note that the exact procedures for updating the negotiation-needed flag are specified below.
This section is non-normative.
The negotiation-needed flag is cleared when an
of type "RTCSessionDescription
" is applied, and the supplied description
matches the state of the answer
s and
RTCRtpTransceiver
s that currently exist on the
RTCDataChannel
. Specifically, this means that all
non-RTCPeerConnection
stopped
transceivers have an associated section in the local description with matching
properties, and, if any data channels have been created, a data
section exists in the local description.
Note that the exact procedures for updating the negotiation-needed flag are specified below.
The process below occurs where referenced elsewhere in this document. It also may occur as a result of internal changes within the implementation that affect negotiation. If such changes occur, the user agent MUST update the negotiation-needed flag.
To update the negotiation-needed flag for connection, run the following steps:
If the length of connection.[[Operations]]
is not 0
, then set
connection.[[UpdateNegotiationNeededFlagOnEmptyChain]]
to true
, and abort these steps.
Queue a task to run the following steps:
If connection.[[IsClosed]] is
true
, abort these steps.
If the length of
connection.[[Operations]] is not
0
, then set
connection.[[UpdateNegotiationNeededFlagOnEmptyChain]]
to true
, and abort these steps.
If connection's signaling state is not
"
", abort these steps.
stable
The negotiation-needed flag will be updated once the state
transitions to "
", as part of
the steps for setting an RTCSessionDescription.
stable
If the result of checking if negotiation is needed is false
,
clear the negotiation-needed flag by setting
connection.[[NegotiationNeeded]] to
false
, and abort these steps.
If connection.[[NegotiationNeeded]] is
already true
, abort these steps.
Set connection.[[NegotiationNeeded]] to
true
.
Fire an event named
at
connection.
negotiationneeded
The task queueing prevents
from firing
prematurely, in the common situation where multiple
modifications to connection are being made at
once.
negotiationneeded
Additionally, we avoid racing with negotiation methods by
only firing
when the operations
chain is empty.
negotiationneeded
To check if negotiation is needed for connection, perform the following checks:
If any implementation-specific negotiation is required, as
described at the start of this section, return
true
.
If
connection.[[LocalIceCredentialsToReplace]]
is not empty, return true
.
Let description be connection.[[CurrentLocalDescription]].
If connection has created any
s,
and no m= section in description has been negotiated
yet for data, return RTCDataChannel
true
.
For each transceiver in connection's set of transceivers, perform the following checks:
If transceiver.[[Stopping]] is
true
and
transceiver.[[Stopped]] is
false
, return true
.
If transceiver isn't stopped
and isn't yet associated with an m= section
in description, return true
.
If transceiver isn't stopped
and is associated with an m= section in
description then perform the following checks:
If transceiver.[[Direction]] is
"
" or
"sendrecv
", and the associated m= section in description
either doesn't contain a single sendonly
a=msid
line, or the number of MSIDs from
the a=msid
lines in this
m=
section, or the MSID values
themselves, differ from what is in
transceiver.sender.[[AssociatedMediaStreamIds]],
return true
.
If description is of type
"
", and the direction of the associated m= section in neither
connection.[[CurrentLocalDescription]]
nor
connection.[[CurrentRemoteDescription]]
matches transceiver.[[Direction]],
return offer
true
. In this step, when the
direction is compared with a direction found in
[[CurrentRemoteDescription]], the description's
direction must be reversed to represent the peer's
point of view.
If description is of type
"
", and the direction of the associated m= section in the description
does not match
transceiver.[[Direction]]
intersected with the offered direction (as described in
[JSEP] (section 5.3.1.)),
return answer
true
.
If transceiver is stopped
and is associated with an m= section, but the
associated m= section is not yet rejected in
connection.[[CurrentLocalDescription]]
or
connection.[[CurrentRemoteDescription]],
return true
.
If all the preceding checks were performed and
true
was not returned, nothing remains to be
negotiated; return false
.
RTCIceCandidate
Interface
This interface describes an ICE candidate, described in [ICE]
Section 2. Other than
,
candidate
,
sdpMid
, and
sdpMLineIndex
, the remaining attributes
are derived from parsing the usernameFragment
member in candidateInitDict, if it is well formed.
candidate
WebIDL[Exposed=Window] interfaceRTCIceCandidate
{constructor
(optionalRTCIceCandidateInit
candidateInitDict = {}); readonly attribute DOMStringcandidate
; readonly attribute DOMString?sdpMid
; readonly attribute unsigned short?sdpMLineIndex
; readonly attribute DOMString?foundation
; readonly attributeRTCIceComponent
?component
; readonly attribute unsigned long?priority
; readonly attribute DOMString?address
; readonly attributeRTCIceProtocol
?protocol
; readonly attribute unsigned short?port
; readonly attributeRTCIceCandidateType
?type
; readonly attributeRTCIceTcpCandidateType
?tcpType
; readonly attribute DOMString?usernameFragment
;RTCIceCandidateInit
toJSON
(); };
constructor()
The RTCIceCandidate()
constructor
takes a dictionary argument, candidateInitDict,
whose content is used to initialize the new
object.
RTCIceCandidate
When invoked, run the following steps:
sdpMid
and
sdpMLineIndex
members of
candidateInitDict are null
, throw a TypeError
.
Return the result of creating an RTCIceCandidate with candidateInitDict.
To create an RTCIceCandidate with a candidateInitDict dictionary, run the following steps:
RTCIceCandidate
object.
null
:
foundation
, component
, priority
, address
,
protocol
, port
, type
, tcpType
,
relatedAddress
, and relatedPort
.
candidate
, sdpMid
,
sdpMLineIndex
, usernameFragment
.
candidate
dictionary member of
candidateInitDict. If candidate is
not an empty string, run the following steps:
candidate-attribute
grammar.
candidate-attribute
has failed,
abort these steps.
The constructor for
only does basic
parsing and type checking for the dictionary members in
candidateInitDict. Detailed validation on the
well-formedness of RTCIceCandidate
,
candidate
,
sdpMid
,
sdpMLineIndex
with the
corresponding session description is done when passing
the usernameFragment
object to
RTCIceCandidate
addIceCandidate
()
.
To maintain backward compatibility, any error on parsing
the candidate attribute is ignored. In such
case, the
attribute holds the raw
candidate
string given in
candidateInitDict, but derivative attributes
such as candidate
, foundation
, etc are set to
priority
null
.
Most attributes below are defined in section 15.1 of [ICE].
candidate
of type DOMString, readonly
candidate-attribute
as defined in
section 15.1 of [ICE]. If this RTCIceCandidate
represents an end-of-candidates indication or a peer
reflexive remote candidate, candidate
is an empty string.
sdpMid
of type DOMString, readonly, nullable
null
, this contains the media stream
"identification-tag" defined in [RFC5888] for the
media component this candidate is associated with.
sdpMLineIndex
of type unsigned short, readonly, nullable
null
, this indicates the index (starting
at zero) of the media description in the SDP this
candidate is associated with.
foundation
of type DOMString, readonly, nullable
RTCIceTransport
s.
component
of type RTCIceComponent
, readonly, nullable
rtp
" or "rtcp
").
This corresponds to the component-id
field in candidate-attribute
, decoded to the string
representation as defined in RTCIceComponent
.
priority
of type unsigned long, readonly, nullable
address
of type DOMString, readonly, nullable
The address of the candidate, allowing for IPv4 addresses,
IPv6 addresses, and fully qualified domain names (FQDNs).
This corresponds to the connection-address
field in candidate-attribute
.
Remote candidates may be exposed, for instance via
[[SelectedCandidatePair]].
.
By default, the user agent MUST leave the
remote
attribute as address
null
for any exposed remote candidate. Once a
instance learns on an address by the
web application using
RTCPeerConnection
, the user agent can
expose the addIceCandidate
attribute value in any
address
of the RTCIceCandidate
instance
representing a remote candidate with that newly learnt
address.
RTCPeerConnection
The addresses exposed in candidates gathered via ICE and
made visibile to the application in
instances can reveal more information about the device
and the user (e.g. location, local network topology) than
the user might have expected in a non-WebRTC enabled
browser.
RTCIceCandidate
These addresses are always exposed to the application, and potentially exposed to the communicating party, and can be exposed without any specific user consent (e.g. for peer connections used with data channels, or to receive media only).
These addresses can also be used as temporary or persistent cross-origin states, and thus contribute to the fingerprinting surface of the device.
Applications can avoid exposing addresses to the
communicating party, either temporarily or permanently,
by forcing the ICE Agent to report only relay
candidates via the
member of
iceTransportPolicy
.
RTCConfiguration
To limit the addresses exposed to the application itself, browsers can offer their users different policies regarding sharing local addresses, as defined in [RTCWEB-IP-HANDLING].
protocol
of type RTCIceProtocol
, readonly, nullable
udp
"/"tcp
"). This
corresponds to the transport
field
in candidate-attribute
.
port
of type unsigned short, readonly, nullable
type
of type RTCIceCandidateType
, readonly,
nullable
candidate-types
field in candidate-attribute
.
tcpType
of type RTCIceTcpCandidateType
, readonly,
nullable
protocol
is "tcp
", tcpType
represents the type of TCP candidate. Otherwise, tcpType
is null
. This corresponds to the tcp-type
field in candidate-attribute
.
relatedAddress
of type DOMString, readonly, nullable
relatedAddress
is the IP
address of the candidate that it is derived from. For host
candidates, the relatedAddress
is null
. This
corresponds to the rel-address
field
in candidate-attribute
.
relatedPort
of type unsigned short, readonly, nullable
relatedPort
is the port of
the candidate that it is derived from. For host candidates,
the relatedPort
is null
. This corresponds to
the rel-port
field in candidate-attribute
.
usernameFragment
of type DOMString, readonly, nullable
ufrag
as defined in
section 15.4 of [ICE].
toJSON()
toJSON
()
operation of the
RTCIceCandidate
interface, run the following steps:
RTCIceCandidateInit
dictionary.
candidate
, sdpMid
,
sdpMLineIndex
, usernameFragment
»:
RTCIceCandidate
object.
json[attr]
to value.
WebIDLdictionaryRTCIceCandidateInit
{ DOMStringcandidate
= ""; DOMString?sdpMid
= null; unsigned short?sdpMLineIndex
= null; DOMString?usernameFragment
= null; };
RTCIceCandidateInit
Members
candidate
of type DOMString, defaulting to
""
candidate-attribute
as defined in
section 15.1 of [ICE]. If this represents an
end-of-candidates indication, candidate
is an empty
string.
sdpMid
of type DOMString, nullable, defaulting to
null
null
, this contains the media stream
"identification-tag" defined in [RFC5888] for the media
component this candidate is associated with.
sdpMLineIndex
of type unsigned short, nullable, defaulting
to null
null
, this indicates the index (starting
at zero) of the media description in the SDP this
candidate is associated with.
usernameFragment
of type DOMString, nullable, defaulting to
null
null
, this carries the ufrag
as defined in section 15.4 of [ICE].
candidate-attribute
Grammar
The candidate-attribute
grammar is used to parse the
member of
candidateInitDict in the candidate
RTCIceCandidate
()
constructor.
The primary grammar for candidate-attribute
is defined in
section 15.1 of [ICE]. In addition, the browser MUST support
the grammar extension for ICE TCP as defined in section 4.5 of
[RFC6544].
The browser MAY support other grammar extensions for candidate-attribute
as defined in other RFCs.
RTCIceProtocol
Enum
The
represents the protocol of the ICE
candidate.
RTCIceProtocol
RTCIceTcpCandidateType
Enum
The
represents the type of the ICE TCP
candidate, as defined in [RFC6544].
RTCIceTcpCandidateType
WebIDLenumRTCIceTcpCandidateType
{ "active
", "passive
", "so
" };
Enumeration description | |
---|---|
active
|
An " " TCP candidate is
one for which the transport will attempt to open an
outbound connection but will not receive incoming
connection requests.
|
passive
|
A " " TCP candidate is
one for which the transport will receive incoming
connection attempts but not attempt a connection.
|
so
|
An " " candidate is one for
which the transport will attempt to open a connection
simultaneously with its peer.
|
The user agent will typically only gather
ICE TCP candidates.
active
RTCIceCandidateType
Enum
The
represents the type of the ICE
candidate, as defined in [ICE] section 15.1.
RTCIceCandidateType
WebIDLenumRTCIceCandidateType
{ "host
", "srflx
", "prflx
", "relay
" };
Enumeration description | |
---|---|
host
|
A host candidate, as defined in Section 4.1.1.1 of [ICE]. |
srflx
|
A server reflexive candidate, as defined in Section 4.1.1.2 of [ICE]. |
prflx
|
A peer reflexive candidate, as defined in Section 4.1.1.2 of [ICE]. |
relay
|
A relay candidate, as defined in Section 7.1.3.2.1 of [ICE]. |
RTCPeerConnectionIceEvent
The icecandidate
event of the
uses the RTCPeerConnection
interface.
RTCPeerConnectionIceEvent
When firing an
event that contains an
RTCPeerConnectionIceEvent
object, it MUST include values for both
RTCIceCandidate
and sdpMid
.
If the sdpMLineIndex
is of type
"RTCIceCandidate
" or type
"srflx
", the
relay
property of the event MUST be set
to the URL of the ICE server from which the candidate was obtained.
url
icecandidate
event is used for three different types of
indications:
A candidate has been gathered. The
member of the event
will be populated normally. It should be signaled to the
remote peer and passed into
candidate
.
addIceCandidate
An
has finished gathering a generation of candidates, and is providing an end-of-candidates
indication as defined by Section 8.2 of [TRICKLE-ICE]. This
is indicated by
RTCIceTransport
.candidate
being set to an empty string. The
candidate
object should be
signaled to the remote peer and passed into
candidate
like a typical ICE
candidate, in order to provide the end-of-candidates
indication to the remote peer.
addIceCandidate
All
s have finished gathering candidates,
and the RTCIceTransport
's RTCPeerConnection
has
transitioned to "RTCIceGatheringState
". This is
indicated by the complete
member of the event being set to candidate
null
. This only
exists for backwards compatibility, and this event does not
need to be signaled to the remote peer. It's equivalent to an
event with the
"icegatheringstatechange
" state.
complete
WebIDL[Exposed=Window] interfaceRTCPeerConnectionIceEvent
: Event {constructor
(DOMString type, optionalRTCPeerConnectionIceEventInit
eventInitDict = {}); readonly attributeRTCIceCandidate
?candidate
; readonly attribute DOMString?url
; };
RTCPeerConnectionIceEvent.constructor()
candidate
of type RTCIceCandidate
, readonly, nullable
The
attribute is the candidate
object with the new ICE candidate that caused the event.
RTCIceCandidate
This attribute is set to null
when an event is
generated to indicate the end of candidate gathering.
Even where there are multiple media components, only one
event containing a null
candidate is fired.
url
of type DOMString, readonly, nullable
The
attribute is the STUN or TURN URL that
identifies the STUN or TURN server used to gather this
candidate. If the candidate was not gathered from a STUN or
TURN server, this parameter will be set to
url
null
.
WebIDL dictionaryRTCPeerConnectionIceEventInit
: EventInit {RTCIceCandidate
?candidate
; DOMString?url
; };
RTCPeerConnectionIceEventInit
Members
candidate
of type RTCIceCandidate
, nullable
See the
attribute
of the candidate
interface.
RTCPeerConnectionIceEvent
url
of type DOMString, nullable
url
attribute is the STUN or TURN URL that identifies
the STUN or TURN server used to gather this candidate.
RTCPeerConnectionIceErrorEvent
The icecandidateerror
event of the
uses the RTCPeerConnection
interface.
RTCPeerConnectionIceErrorEvent
WebIDL[Exposed=Window] interfaceRTCPeerConnectionIceErrorEvent
: Event {constructor
(DOMString type,RTCPeerConnectionIceErrorEventInit
eventInitDict); readonly attribute DOMString?address
; readonly attribute unsigned short?port
; readonly attribute DOMStringurl
; readonly attribute unsigned shorterrorCode
; readonly attribute USVStringerrorText
; };
RTCPeerConnectionIceErrorEvent.constructor()
address
of type DOMString, readonly, nullable
The
attribute is the local IP address used to
communicate with the STUN or TURN server.
address
On a multihomed system, multiple interfaces may be used to contact the server, and this attribute allows the application to figure out on which one the failure occurred.
If the local IP address value is not already exposed as
part of a local candidate, the
attribute will
be set to address
null
.
port
of type unsigned short, readonly, nullable
The
attribute is the port used to communicate with
the STUN or TURN server.
port
If the
attribute is address
null
, the
attribute is also set to port
null
.
url
of type DOMString, readonly
The
attribute is the STUN or TURN URL that
identifies the STUN or TURN server for which the failure
occurred.
url
errorCode
of type unsigned short, readonly
The
attribute is the numeric STUN error code
returned by the STUN or TURN server [STUN-PARAMETERS].
errorCode
If no host candidate can reach the server,
will be set to the value 701 which is outside the STUN
error code range. This error is only fired once per server
URL while in the errorCode
of
"RTCIceGatheringState
".
gathering
errorText
of type USVString, readonly
The
attribute is the STUN reason text
returned by the STUN or TURN server [STUN-PARAMETERS].
errorText
If the server could not be reached,
will be
set to an implementation-specific value providing details
about the error.
errorText
WebIDL dictionaryRTCPeerConnectionIceErrorEventInit
: EventInit { DOMString?address
; unsigned short?port
; DOMStringurl
; required unsigned shorterrorCode
; USVStringstatusText
; };
RTCPeerConnectionIceErrorEventInit
Members
address
of type DOMString, nullable
The local address used to communicate with the STUN or TURN
server, or null
.
port
of type unsigned short, nullable
The local port used to communicate with the STUN or TURN
server, or null
.
url
of type DOMString
The STUN or TURN URL that identifies the STUN or TURN server for which the failure occurred.
errorCode
of type unsigned short, required
The numeric STUN error code returned by the STUN or TURN server.
statusText
of type USVString
The STUN reason text returned by the STUN or TURN server.
The certificates that
instances use to
authenticate with peers use the RTCPeerConnection
interface. These
objects can be explicitly generated by applications using the
RTCCertificate
method and can be provided
in the generateCertificate
when constructing a new
RTCConfiguration
instance.
RTCPeerConnection
The explicit certificate management functions provided here are
optional. If an application does not provide the
configuration option when
constructing an certificates
a new set of certificates MUST
be generated by the user agent. That set MUST include an ECDSA
certificate with a private key on the P-256 curve and a signature
with a SHA-256 hash.
RTCPeerConnection
WebIDLpartial interfaceRTCPeerConnection
{ static Promise<RTCCertificate
>generateCertificate
(AlgorithmIdentifier keygenAlgorithm); };
generateCertificate
, static
The
function causes the user
agent to create an X.509 certificate [X509V3] and
corresponding private key. A handle to information is
provided in the form of the generateCertificate
interface. The
returned RTCCertificate
can be used to control the
certificate that is offered in the DTLS sessions established
by RTCCertificate
.
RTCPeerConnection
The keygenAlgorithm argument is used to control how the private key associated with the certificate is generated. The keygenAlgorithm argument uses the WebCrypto [WebCryptoAPI] AlgorithmIdentifier type.
The following values MUST be supported by a user
agent: { name: "RSASSA-PKCS1-v1_5",
modulusLength: 2048, publicExponent: new Uint8Array([1, 0,
1]), hash: "SHA-256" }
, and { name:
"ECDSA", namedCurve:
"P-256"
}
.
It is expected that a user agent will have a small or even fixed set of values that it will accept.
The certificate produced by this process also contains a
signature. The validity of this signature is only relevant
for compatibility reasons. Only the public key and the
resulting certificate fingerprint are used by
, but it is more likely that a
certificate will be accepted if the certificate is well
formed. The browser selects the algorithm used to sign the
certificate; a browser SHOULD select SHA-256 [FIPS-180-4]
if a hash algorithm is needed.
RTCPeerConnection
The resulting certificate MUST NOT include information that can be linked to a user or user agent. Randomized values for distinguished name and serial number SHOULD be used.
When the method is called, the user agent MUST run the following steps:
Let keygenAlgorithm be the first argument to
.
generateCertificate
Let expires be a DOMTimeStamp
value of
2592000000.
This means the certificate will by default expire in 30
days from the time of the
call.
generateCertificate
If keygenAlgorithm is an object, run the following steps:
Let certificateExpiration be the result of
converting
the ECMAScript object represented by
keygenAlgorithm to an
dictionary.
RTCCertificateExpiration
If the conversion fails with an error, return a promise that is rejected with error.
If
certificateExpiration.
is not expires
undefined
, set expires
to
certificateExpiration.
.
expires
If expires is greater than 31536000000, set expires to 31536000000.
This means the certificate cannot be valid for
longer than 365 days from the time of the
call.
generateCertificate
A user agent MAY further cap the value of expires.
Let normalizedKeygenAlgorithm be the result of
normalizing an
algorithm with an operation name of generateKey
and a supportedAlgorithms
value specific to production of certificates for
.
RTCPeerConnection
If the above normalization step fails with an error, return a promise that is rejected with error.
If the normalizedKeygenAlgorithm parameter
identifies an algorithm that the user agent cannot
or will not use to generate a certificate for
, return a promise that is rejected with a RTCPeerConnection
DOMException
of type
NotSupportedError
. In particular,
normalizedKeygenAlgorithm MUST be an
asymmetric algorithm that can be used to produce a
signature used to authenticate DTLS connections.
Let p be a new promise.
Run the following steps in parallel:
Perform the generate key operation specified by normalizedKeygenAlgorithm using keygenAlgorithm.
Let generatedKeyingMaterial and generatedKeyCertificate be the private keying material and certificate generated by the above step.
Let certificate be a new
object.
RTCCertificate
Set certificate.[[Expires]] to the current time plus expires value.
Set certificate.[[Origin]] to the current settings object's origin.
Store the generatedKeyingMaterial in a secure module, and let handle be a reference identifier to it.
Set certificate.[[KeyingMaterialHandle]] to handle.
Set certificate.[[Certificate]] to generatedCertificate.
Resolve p with certificate.
Return p.
RTCCertificateExpiration
Dictionary
is used to set an expiration date on
certificates generated by
RTCCertificateExpiration
.
generateCertificate
WebIDLdictionaryRTCCertificateExpiration
{ [EnforceRange] DOMTimeStampexpires
; };
expires
, of type DOMTimeStamp
An optional
attribute MAY be added to the
definition of the algorithm that is passed to
expires
. If this parameter is
present it indicates the maximum time that the
generateCertificate
is valid for relative to the current time.
RTCCertificate
RTCCertificate
Interface
The
interface represents a certificate used to
authenticate WebRTC communications. In addition to the visible
properties, internal slots contain a handle to the generated
private keying materal ([[KeyingMaterialHandle]]), a
certificate ([[Certificate]]) that
RTCCertificate
uses to authenticate with a peer, and the
origin ([[Origin]]) that created the object.
RTCPeerConnection
WebIDL[Exposed=Window, Serializable] interfaceRTCCertificate
{ readonly attribute DOMTimeStampexpires
; sequence<RTCDtlsFingerprint
>getFingerprints
(); };
expires
of type DOMTimeStamp, readonly
The expires attribute indicates the date and
time in milliseconds relative to 1970-01-01T00:00:00Z after
which the certificate will be considered invalid by the
browser. After this time, attempts to construct an
using this certificate fail.
RTCPeerConnection
Note that this value might not be reflected in a
notAfter
parameter in the
certificate itself.
getFingerprints
Returns the list of certificate fingerprints, one of which is computed with the digest algorithm used in the certificate signature.
For the purposes of this API, the [[Certificate]] slot
contains unstructured binary data. No mechanism is provided for
applications to access the [[KeyingMaterialHandle]]
internal slot or the keying material it references. Implementations
MUST support applications storing and retrieving
objects from persistent storage, in a manner that also preserves
the keying material referenced by [[KeyingMaterialHandle]].
Implementations SHOULD store the sensitive keying material in a
secure module safe from same-process memory attacks. This allows
the private key to be stored and used, but not easily read using a
memory attack.
RTCCertificate
objects are serializable objects
[HTML]. Their serialization steps, given value
and serialized, are:
RTCCertificate
expires
attribute.
Their deserialization steps, given serialized and value, are:
expires
attribute to contain serialized.[[Expires]].
Supporting structured cloning in this manner allows
instances to be persisted to stores. It also
allows instances to be passed to other origins using APIs like
RTCCertificate
postMessage
()
[html]. However, the object cannot
be used by any other origin than the one that originally created
it.
The RTP media API lets a web application send and receive
MediaStreamTrack
s over a peer-to-peer connection. Tracks, when
added to an
, result in signaling; when this
signaling is forwarded to a remote peer, it causes corresponding tracks
to be created on the remote side.
RTCPeerConnection
There is not an exact 1:1 correspondence between tracks sent by one
and received by the other. For one, IDs of tracks
sent have no mapping to the IDs of tracks received. Also,
RTCPeerConnection
changes the track sent by an
replaceTrack
without creating a new track on the receiver side; the
corresponding RTCRtpSender
will only have a single track,
potentially representing multiple sources of media stitched together.
Both RTCRtpReceiver
and
addTransceiver
can be used to cause the same track to be
sent multiple times, which will be observed on the receiver side as
multiple receivers each with its own separate track. Thus it's more
accurate to think of a 1:1 relationship between an replaceTrack
on
one side and an RTCRtpSender
's track on the other side, matching
senders and receivers using the RTCRtpReceiver
's
RTCRtpTransceiver
if necessary.
mid
When sending media, the sender may need to rescale or resample the media to meet various requirements including the envelope negotiated by SDP.
Following the rules in [JSEP] (section 3.6.), the video MAY be downscaled in order to fit the SDP constraints. The media MUST NOT be upscaled to create fake data that did not occur in the input source, the media MUST NOT be cropped except as needed to satisfy constraints on pixel counts, and the aspect ratio MUST NOT be changed.
The WebRTC Working Group is seeking implementation feedback on the need and timeline for a more complex handling of this situation. Some possible designs have been discussed in GitHub issue 1283.
When video is rescaled, for example for certain combinations of width
or height and
values, situations when the resulting width or height is not an integer
may occur. In such situations the user agent MUST use the integer part of the
result. What to transmit if the integer part of the scaled width or
height is zero is implementation-specific.
scaleResolutionDownBy
The actual encoding and transmission of MediaStreamTrack
s is
managed through objects called
s. Similarly, the
reception and decoding of RTCRtpSender
MediaStreamTrack
s is managed through
objects called
s. Each RTCRtpReceiver
is associated
with at most one track, and each track to be received is associated
with exactly one RTCRtpSender
.
RTCRtpReceiver
The encoding and transmission of each MediaStreamTrack
SHOULD be
made such that its characteristics (width
,
height
and frameRate
for video tracks; sampleSize
, sampleRate
and
channelCount
for audio tracks) are to a
reasonable degree retained by the track created on the remote side.
There are situations when this does not apply, there may for example be
resource constraints at either endpoint or in the network or there may
be
settings applied that instruct the implementation
to act differently.
RTCRtpSender
An
object contains a set of RTCPeerConnection
s,
representing the paired senders and receivers with some shared state.
This set is
initialized to the empty set when the RTCRtpTransceiver
object is
created. RTCPeerConnection
s and RTCRtpSender
s are always
created at the same time as an RTCRtpReceiver
, which they will
remain attached to for their lifetime. RTCRtpTransceiver
s are
created implicitly when the application attaches a RTCRtpTransceiver
MediaStreamTrack
to an
via the RTCPeerConnection
addTrack
()
method, or explicitly when the application uses the
method. They are also created when
a remote description is applied that includes a new media description.
Additionally, when a remote description is applied that indicates the
remote endpoint has media to send, the relevant addTransceiver
MediaStreamTrack
and
are surfaced to the application via the
RTCRtpReceiver
event.
track
In order for an
to send and/or receive media with
another endpoint this must be negotiated with SDP such that both
endpoints have an RTCRtpTransceiver
object that is associated
with the same media description.
RTCRtpTransceiver
When creating an offer, enough media descriptions will be generated to cover all transceivers on that end. When this offer is set as the local description, any disassociated transceivers get associated with media descriptions in the offer.
When an offer is set as the remote description, any media descriptions
in it not yet associated with a transceiver get associated with a new
or existing transceiver. In this case, only disassociated transceivers
that were created via the addTrack
()
method may
be associated. Disassociated transceivers created via the
addTransceiver
()
method, however, won't get
associated even if media descriptions are available in the remote
offer. Instead, new transceivers will be created and associated if
there aren't enough addTrack
()
-created
transceivers. This sets addTrack
()
-created and
addTransceiver
()
-created transceivers apart in a
critical way that is not observable from inspecting their attributes.
When creating an answer, only media media descriptions that were
present in the offer may be listed in the answer. As a consequence, any
transceivers that were not associated when setting the remote offer
remain disassociated after setting the local answer. This can be
remedied by the answerer creating a follow-up offer, initiating another
offer/answer exchange, or in the case of using
addTrack
()
-created transceivers, making sure that
enough media descriptions are offered in the initial exchange.
The RTP media API extends the
interface as
described below.
RTCPeerConnection
WebIDL partial interfaceRTCPeerConnection
{ sequence<RTCRtpSender
>getSenders
(); sequence<RTCRtpReceiver
>getReceivers
(); sequence<RTCRtpTransceiver
>getTransceivers
();RTCRtpSender
addTrack
(MediaStreamTrack track, MediaStream... streams); undefinedremoveTrack
(RTCRtpSender
sender);RTCRtpTransceiver
addTransceiver
((MediaStreamTrack or DOMString) trackOrKind, optionalRTCRtpTransceiverInit
init = {}); attribute EventHandlerontrack
; };
ontrack
of type EventHandler
The event type of this event handler is
.
track
getSenders
Returns a sequence of
objects representing
the RTP senders that belong to non-stopped
RTCRtpSender
objects currently attached to this
RTCRtpTransceiver
object.
RTCPeerConnection
When the
method is invoked, the user agent
MUST return the result of executing the getSenders
CollectSenders
algorithm.
We define the CollectSenders algorithm as follows:
CollectTransceivers
algorithm.
false
, add
transceiver.[[Sender]] to
senders.
getReceivers
Returns a sequence of
objects representing
the RTP receivers that belong to non-stopped
RTCRtpReceiver
objects currently attached to this
RTCRtpTransceiver
object.
RTCPeerConnection
When the
method is invoked, the user agent
MUST run the following steps:
getReceivers
CollectTransceivers
algorithm.
false
, add
transceiver.[[Receiver]] to
receivers.
getTransceivers
Returns a sequence of
objects
representing the RTP transceivers that are currently attached
to this RTCRtpTransceiver
object.
RTCPeerConnection
The
method MUST return the result of
executing the getTransceivers
CollectTransceivers
algorithm.
We define the CollectTransceivers algorithm as follows:
RTCRtpTransceiver
objects in this RTCPeerConnection
object's set of transceivers, in insertion order.
addTrack
Adds a new track to the
, and indicates
that it is contained in the specified RTCPeerConnection
MediaStream
s.
When the
method is invoked, the user agent MUST
run the following steps:
addTrack
Let connection be the
object on which this method was invoked.
RTCPeerConnection
Let track be the MediaStreamTrack
object
indicated by the method's first argument.
Let kind be track.kind.
Let streams be a list of MediaStream
objects constructed from the method's remaining
arguments, or an empty list if the method was called with
a single argument.
If connection.[[IsClosed]] is
true
, throw an
InvalidStateError
.
Let senders be the result of executing the
CollectSenders
algorithm. If an
for
track already exists in senders, throw an RTCRtpSender
InvalidAccessError
.
The steps below describe how to determine if an existing
sender can be reused. Doing so will cause future calls to
and
createOffer
to mark the
corresponding media description as createAnswer
sendrecv
or sendonly
and add the MSID of the sender's
streams, as defined in [JSEP] (section 5.2.2. and section 5.3.2.).
If any
object in senders
matches all the following criteria, let sender
be that object, or RTCRtpSender
null
otherwise:
The sender's track is null.
The transceiver kind of the
, associated with the sender,
matches kind.
RTCRtpTransceiver
The [[Stopping]] slot of the
associated with the sender is
RTCRtpTransceiver
false
.
The sender has never been used to send. More
precisely, the [[CurrentDirection]] slot of
the
associated with the sender
has never had a value of
"RTCRtpTransceiver
" or
"sendrecv
".
sendonly
If sender is not null
, run the
following steps to use that sender:
Set sender.[[SenderTrack]] to track.
Set sender.[[AssociatedMediaStreamIds]] to an empty set.
For each stream in streams, add stream.id to [[AssociatedMediaStreamIds]] if it's not already there.
Let transceiver be the
associated with
sender.
RTCRtpTransceiver
If transceiver.[[Direction]] is
"
", set
transceiver.[[Direction]] to
"recvonly
".
sendrecv
If transceiver.[[Direction]] is
"
", set
transceiver.[[Direction]] to
"inactive
".
sendonly
If sender is null
, run the
following steps:
Create an RTCRtpSender with track, kind and streams, and let sender be the result.
Create an RTCRtpReceiver with kind, and let receiver be the result.
Create an RTCRtpTransceiver with
sender, receiver and an
value of
"RTCRtpTransceiverDirection
", and let
transceiver be the result.
sendrecv
Add transceiver to connection's set of transceivers.
A track could have contents that are inaccessible to the
application. This can be due to anything that would make
a track CORS
cross-origin. These tracks can be supplied to the
addTrack
()
method, and have an
created for them, but content MUST NOT
be transmitted. Silence (audio), black frames (video) or
equivalently absent content is sent in place of track
content.
RTCRtpSender
Note that this property can change over time.
Update the negotiation-needed flag for connection.
Return sender.
removeTrack
Stops sending media from sender. The
will still appear in RTCRtpSender
. Doing
so will cause future calls to getSenders
to mark the media description for the corresponding transceiver as
"createOffer
" or
"recvonly
", as defined in
[JSEP] (section 5.2.2.).
inactive
When the other peer stops sending a track in this manner, the
track is removed from any remote MediaStream
s that were
initially revealed in the track
event, and if the MediaStreamTrack
is not already muted,
a mute
event is fired at the
track.
removeTrack
()
can be achieved by
setting the
RTCRtpTransceiver
.direction
attribute of the corresponding transceiver and invoking
RTCRtpSender
.replaceTrack
(null) on the
sender. One minor difference is that
replaceTrack
()
is asynchronous and
removeTrack
()
is synchronous.
When the
method is invoked, the user agent
MUST run the following steps:
removeTrack
Let sender be the argument to
.
removeTrack
Let connection be the
object on which the method was invoked.
RTCPeerConnection
If connection.[[IsClosed]] is
true
, throw an
InvalidStateError
.
If sender was not created by
connection, throw an
InvalidAccessError
.
Let senders be the result of executing the
CollectSenders
algorithm.
If sender is not in senders (which
indicates its transceiver was stopped or removed due to
setting an RTCSessionDescription of type
"
"), then abort these steps.
rollback
If sender.[[SenderTrack]] is null, abort these steps.
Set sender.[[SenderTrack]] to null.
Let transceiver be the
object corresponding to sender.
RTCRtpTransceiver
If transceiver.[[Direction]] is
"
", set
transceiver.[[Direction]] to
"sendrecv
".
recvonly
If transceiver.[[Direction]] is
"
", set
transceiver.[[Direction]] to
"sendonly
".
inactive
Update the negotiation-needed flag for connection.
addTransceiver
Create a new
and add it to the set
of transceivers.
RTCRtpTransceiver
Adding a transceiver will cause future calls to
to add a media description for the
corresponding transceiver, as defined in [JSEP] (section 5.2.2.).
createOffer
The initial value of
is null.
Setting a new mid
may change it to a
non-null value, as defined in [JSEP] (section 5.5. and section 5.6.)
and setting an RTCSessionDescription.
RTCSessionDescription
The
argument can be
used to specify the number of offered simulcast encodings,
and optionally their RIDs and encoding parameters.
sendEncodings
When this method is invoked, the user agent MUST run the following steps:
Let init be the second argument.
Let streams be
init.
.
streams
Let sendEncodings be
init.
.
sendEncodings
Let direction be
init.
.
direction
If the first argument is a string, let it be kind and run the following steps:
If kind is not a legal
MediaStreamTrack
kind
,
throw a TypeError
.
Let track be null
.
If the first argument is a MediaStreamTrack
, let it
be track and let kind be
track.kind.
If connection.[[IsClosed]] is
true
, throw an
InvalidStateError
.
Verify that each
value
in sendEncodings conforms to the grammar
specified in Section 10 of [MMUSIC-RID]. If one of
the RIDs does not meet these requirements, throw a rid
TypeError
.
If any
dictionary in
sendEncodings contains a read-only
parameter other than
RTCRtpEncodingParameters
, throw
an rid
InvalidAccessError
.
Verify that each
value in sendEncodings is greater than or
equal to 1.0. If one of the
scaleResolutionDownBy
values does not meet this requirement, throw a scaleResolutionDownBy
RangeError
.
Let maxN be the maximum number of total
simultaneous encodings the user agent may support for
this kind, at minimum 1
.This
should be an optimistic number since the codec to be
used is not known yet.
If sendEncodings contains any encoding
whose
attribute is defined, set any undefined
scaleResolutionDownBy
of
the other encodings to 1.0.
scaleResolutionDownBy
If the number of
stored
in sendEncodings exceeds maxN,
then trim sendEncodings from the tail
until its length is maxN.
RTCRtpEncodingParameters
scaleResolutionDownBy
attribues of sendEncodings are still
undefined, initialize each encoding's
scaleResolutionDownBy
to
2^(length of sendEncodings - encoding
index - 1)
. This results in smaller-to-larger
resolutions where the last encoding has no scaling
applied to it, e.g. 4:2:1 if the length is 3.
If the number of
now
stored in sendEncodings is RTCRtpEncodingParameters
1
,
then remove any
member
from the lone entry.
rid
RTCRtpEncodingParameters
in
sendEncodings allows the application to
subsequently set encoding parameters using
setParameters
, even when simulcast
isn't used.
Create an RTCRtpSender with track, kind, streams and sendEncodings and let sender be the result.
If sendEncodings is set, then subsequent calls
to
will be configured to send multiple
RTP encodings as defined in [JSEP] (section 5.2.2. and section 5.2.1.). When
createOffer
is called with
a corresponding remote description that is able to
receive multiple RTP encodings as defined in
[JSEP] (section 3.7.), the
setRemoteDescription
may send multiple RTP encodings and the
parameters retrieved via the transceiver's
RTCRtpSender
.sender
getParameters
()
will reflect the encodings negotiated.
Create an RTCRtpReceiver with kind and let receiver be the result.
Create an RTCRtpTransceiver with sender, receiver and direction, and let transceiver be the result.
Add transceiver to connection's set of transceivers.
Update the negotiation-needed flag for connection.
Return transceiver.
WebIDLdictionaryRTCRtpTransceiverInit
{RTCRtpTransceiverDirection
direction
= "sendrecv"; sequence<MediaStream>streams
= []; sequence<RTCRtpEncodingParameters
>sendEncodings
= []; };
RTCRtpTransceiverInit
Members
direction
of type RTCRtpTransceiverDirection
,
defaulting to "sendrecv
"
RTCRtpTransceiver
.
streams
of type sequence<MediaStream
>
When the remote PeerConnection's track event fires
corresponding to the
being added, these
are the streams that will be put in the event.
RTCRtpReceiver
sendEncodings
of type sequence<RTCRtpEncodingParameters
>
A sequence containing parameters for sending RTP encodings of media.
WebIDLenumRTCRtpTransceiverDirection
{ "sendrecv
", "sendonly
", "recvonly
", "inactive
", "stopped
" };
RTCRtpTransceiverDirection Enumeration description
|
|
---|---|
sendrecv
|
The 's
sender will offer to send RTP, and will send RTP
if the remote peer accepts and
sender.
() . [i].
is true for any value of i. The
's will offer to
receive RTP, and will receive RTP if the remote peer accepts.
|
sendonly
|
The 's
sender will offer to send RTP, and will send RTP
if the remote peer accepts and
sender.
() . [i].
is true for any value of i. The
's will not offer to
receive RTP, and will not receive RTP.
|
recvonly
|
The 's will not offer
to send RTP, and will not send RTP. The
's will offer to
receive RTP, and will receive RTP if the remote peer accepts.
|
inactive
|
The 's will not offer
to send RTP, and will not send RTP. The
's will not offer to
receive RTP, and will not receive RTP.
|
stopped
|
The will neither send nor receive RTP.
It will generate a zero port in the offer. In answers, its
will not offer to send RTP, and its
will not offer to receive RTP. This is a
terminal state.
|
An application can reject incoming media descriptions by setting
the transceiver's direction to either
"
" to turn off both
directions temporarily, or to
"inactive
" to reject only the
incoming side. To permanently reject an m-line in a manner that
makes it available for reuse, the application would need to call
sendonly
.RTCRtpTransceiver
stop
()
and subsequently
initiate negotiation from its end.
To process remote tracks
given an
transceiver,
direction, msids, addList,
removeList, and trackEventInits, run the
following steps:
RTCRtpTransceiver
Set the associated remote streams with transceiver.[[Receiver]], msids, addList, and removeList.
If direction is
"
" or
"sendrecv
" and
transceiver.[[FiredDirection]] is neither
"recvonly
" nor
"sendrecv
", or the previous step
increased the length of addList, process the
addition of a remote track with transceiver and
trackEventInits.
recvonly
If direction is
"
" or
"sendonly
", set
transceiver.[[Receptive]] to
inactive
false
.
If direction is
"
" or
"sendonly
", and
transceiver.[[FiredDirection]] is either
"inactive
" or
"sendrecv
", process the
removal of a remote track for the media description,
with transceiver and muteTracks.
recvonly
Set transceiver.[[FiredDirection]] to direction.
To process the addition of
a remote track given an
transceiver and trackEventInits, run the
following steps:
RTCRtpTransceiver
Let receiver be transceiver.[[Receiver]].
Let track be receiver.[[ReceiverTrack]].
Let streams be receiver.[[AssociatedRemoteMediaStreams]].
Create a new
dictionary with
receiver, track, streams and
transceiver as members and add it to
trackEventInits.
RTCTrackEventInit
To process the removal of a
remote track with an
transceiver and muteTracks, run the following
steps:
RTCRtpTransceiver
Let receiver be transceiver.[[Receiver]].
Let track be receiver.[[ReceiverTrack]].
If track.muted is false
, add
track to muteTracks.
To set the associated
remote streams given
receiver,
msids, addList, and removeList,
run the following steps:
RTCRtpReceiver
Let connection be the
object
associated with receiver.
RTCPeerConnection
For each MSID in msids, unless a MediaStream
object has previously been created with that id
for this connection, create a
MediaStream
object with that id
.
Let streams be a list of the MediaStream
objects
created for this connection with the id
s corresponding to msids.
Let track be receiver.[[ReceiverTrack]].
For each stream in receiver.[[AssociatedRemoteMediaStreams]] that is not present in streams, add stream and track as a pair to removeList.
For each stream in streams that is not present in receiver.[[AssociatedRemoteMediaStreams]], add stream and track as a pair to addList.
Set receiver.[[AssociatedRemoteMediaStreams]] to streams.
RTCRtpSender
Interface
The
interface allows an application to control how a
given RTCRtpSender
MediaStreamTrack
is encoded and transmitted to a remote
peer. When
is called on an
setParameters
object, the encoding is changed appropriately.
RTCRtpSender
To create an RTCRtpSender with a MediaStreamTrack
,
track, a string, kind, a list of
MediaStream
objects, streams, and optionally a list of
objects, sendEncodings, run
the following steps:
RTCRtpEncodingParameters
Let sender be a new
object.
RTCRtpSender
Let sender have a [[SenderTrack]] internal slot initialized to track.
Let sender have a [[SenderTransport]]
internal slot initialized to null
.
Let sender have a
[[LastStableStateSenderTransport]] internal slot
initialized to null
.
Let sender have a [[Dtmf]] internal slot
initialized to null
.
If kind is "audio"
then create an
RTCDTMFSender dtmf and set the [[Dtmf]]
internal slot to dtmf.
Let sender have an
[[AssociatedMediaStreamIds]] internal slot,
representing a list of Ids of MediaStream
objects that this
sender is to be associated with. The
[[AssociatedMediaStreamIds]] slot is used when
sender is represented in SDP as described in
[JSEP] (section 5.2.1.).
Set sender.[[AssociatedMediaStreamIds]] to an empty set.
For each stream in streams, add stream.id to [[AssociatedMediaStreamIds]] if it's not already there.
Let sender have a [[SendEncodings]]
internal slot, representing a list of
dictionaries.
RTCRtpEncodingParameters
If sendEncodings is given as input to this algorithm,
and is non-empty, set the [[SendEncodings]] slot to
sendEncodings. Otherwise, set it to a list containing
a single
with
RTCRtpEncodingParameters
set to active
true
.
Let sender have a [[SendCodecs]] internal
slot, representing a list of
dictionaries, and initialized to an empty list.
RTCRtpCodecParameters
Let sender have a
[[LastReturnedParameters]] internal slot, which will
be used to match
and
getParameters
transactions.
setParameters
Return sender.
WebIDL[Exposed=Window] interfaceRTCRtpSender
{ readonly attribute MediaStreamTrack?track
; readonly attributeRTCDtlsTransport
?transport
; staticRTCRtpCapabilities
?getCapabilities
(DOMString kind); Promise<undefined>setParameters
(RTCRtpSendParameters
parameters);RTCRtpSendParameters
getParameters
(); Promise<undefined>replaceTrack
(MediaStreamTrack? withTrack); undefinedsetStreams
(MediaStream... streams); Promise<RTCStatsReport
>getStats
(); };
track
of type MediaStreamTrack
, readonly, nullable
The
attribute is the track that is associated with
this track
object. If RTCRtpSender
is ended, or if
the track's output is disabled, i.e. the track is disabled
and/or muted, the track
MUST send black frames
(video) and MUST NOT send (audio). In the case of video, the
RTCRtpSender
SHOULD send one black frame per second. If
RTCRtpSender
is track
null
then the
does
not send. On getting, the attribute MUST return the value of
the [[SenderTrack]] slot.
RTCRtpSender
transport
of type RTCDtlsTransport
, readonly, nullable
The
attribute is the transport over which media
from transport
is sent in the form of RTP packets. Prior to
construction of the track
object, the
RTCDtlsTransport
attribute will be null. When bundling is used,
multiple transport
objects will share one
RTCRtpSender
and will all send RTP and RTCP over the same
transport.
transport
On getting, the attribute MUST return the value of the [[SenderTransport]] slot.
getCapabilities
, static
The getCapabilities
()
method returns the most optimistic
view of the capabilities of the system for sending media of
the given kind. It does not reserve any resources, ports, or
other state but is meant to provide a way to discover the
types of capabilities of the browser including which codecs
may be supported. User agents MUST support kind
values of "audio"
and "video"
. If
the system has no capabilities corresponding to the value of
the kind argument,
returns
getCapabilities
null
.
These capabilities provide generally persistent cross-origin information on the device and thus increases the fingerprinting surface of the application. In privacy-sensitive contexts, browsers can consider mitigations such as reporting only a common subset of the capabilities.
setParameters
The
method updates how setParameters
is encoded
and transmitted to a remote peer.
track
When the
method is called, the user agent
MUST run the following steps:
setParameters
RTCRtpSender
object on which setParameters
is
invoked.
RTCRtpTransceiver
object associated with
sender (i.e. sender is
transceiver.[[Sender]]).
true
, return a promise rejected with a
newly created InvalidStateError
.
null
, return a promise rejected with a
newly created InvalidStateError
.
encodings
.
codecs
.
RTCRtpEncodingParameters
stored in
sender.[[SendEncodings]].
InvalidModificationError
:
encodings.length
is
different from N.
Verify that each
value in encodings is greater than or
equal to 1.0. If one of the
scaleResolutionDownBy
values does not meet this requirement, return a
promise rejected with a newly created scaleResolutionDownBy
RangeError
.
null
.
encodings
.
undefined
.
RTCError
whose
errorDetail
is set to
"hardware-encoder-not-available
"
and abort these steps.
RTCError
whose
errorDetail
is set to
"hardware-encoder-error
" and
abort these steps.
OperationError
.
does not cause SDP renegotiation and can
only be used to change what the media stack is sending or
receiving within the envelope negotiated by Offer/Answer. The
attributes in the setParameters
dictionary are
designed to not enable this, so attributes like
RTCRtpSendParameters
that cannot be changed are
read-only. Other things, like bitrate, are controlled using
limits such as cname
, where
the user agent needs to ensure it does not exceed the maximum
bitrate specified by maxBitrate
,
while at the same time making sure it satisfies constraints
on bitrate specified in other places such as the SDP.
maxBitrate
getParameters
The getParameters
()
method returns the
object's current parameters for how RTCRtpSender
is encoded and
transmitted to a remote track
.
RTCRtpReceiver
When
is called, the user agent MUST run the
following steps:
getParameters
Let sender be the
object on
which the getter was invoked.
RTCRtpSender
If sender.[[LastReturnedParameters]]
is not null
, return
sender.[[LastReturnedParameters]], and
abort these steps.
Let result be a new
dictionary constructed as follows:
RTCRtpSendParameters
transactionId
is set to a new
unique identifier.
encodings
is set to the value of
the [[SendEncodings]] internal slot.
headerExtensions
sequence is
populated based on the header extensions that have been
negotiated for sending.
codecs
is set to the value of the
[[SendCodecs]] internal slot.
rtcp
.cname
is
set to the CNAME of the associated RTCPeerConnection
.
rtcp
.reducedSize
is set to true
if reduced-size RTCP has been
negotiated for sending, and false
otherwise.
Set sender.[[LastReturnedParameters]] to result.
Queue a task that sets
sender.[[LastReturnedParameters]] to
null
.
Return result.
may be used with getParameters
to
change the parameters in the following way:
setParameters
async function updateParameters() {
try {
const params = sender.getParameters();
// ... make changes to parameters
params.encodings[0].active = false;
await sender.setParameters(params);
} catch (err) {
console.error(err);
}
}
After a completed call to
, subsequent calls
to setParameters
will return the modified set of
parameters.
getParameters
replaceTrack
Attempts to replace the
's current RTCRtpSender
with another track provided (or with a track
null
track), without renegotiation.
When the
method is invoked, the user agent
MUST run the following steps:
replaceTrack
Let sender be the
object on
which RTCRtpSender
is invoked.
replaceTrack
Let transceiver be the
object associated with sender.
RTCRtpTransceiver
Let connection be the
object associated with sender.
RTCPeerConnection
Let withTrack be the argument to this method.
If withTrack is non-null and
withTrack.kind
differs from the
transceiver kind of transceiver, return
a promise rejected with a newly created TypeError
.
Return the result of chaining the following steps to connection's operations chain:
If transceiver.[[Stopped]] is
true
, return a promise rejected
with a newly created
InvalidStateError
.
Let p be a new promise.
Let sending be true
if
transceiver.[[CurrentDirection]]
is "
" or
"sendrecv
", and
sendonly
false
otherwise.
Run the following steps in parallel:
If sending is true
, and
withTrack is null
, have
the sender stop sending.
If sending is true
, and
withTrack is not null
,
determine if withTrack can be sent
immediately by the sender without violating the
sender's already-negotiated envelope, and if it
cannot, then reject p with a
newly created
InvalidModificationError
, and abort these
steps.
If sending is true
, and
withTrack is not null
,
have the sender switch seamlessly to transmitting
withTrack instead of the sender's
existing track.
Queue a task that runs the following steps:
If connection.[[IsClosed]]
is true
, abort these steps.
Set sender.[[SenderTrack]] to withTrack.
Resolve p with
undefined
.
Return p.
Changing dimensions and/or frame rates might not require negotiation. Cases that may require negotiation include:
setStreams
Sets the MediaStream
s to be associated with this sender's
track.
When the
method is invoked, the user agent
MUST run the following steps:
setStreams
Let sender be the
object on
which this method was invoked.
RTCRtpSender
Let connection be the
object on which this method was invoked.
RTCPeerConnection
If connection.[[IsClosed]] is
true
, throw an
InvalidStateError
.
Let streams be a list of MediaStream
objects constructed from the method's arguments, or an
empty list if the method was called without arguments.
Set sender.[[AssociatedMediaStreamIds]] to an empty set.
For each stream in streams, add stream.id to [[AssociatedMediaStreamIds]] if it's not already there.
Update the negotiation-needed flag for connection.
getStats
Gathers stats for this sender only and reports the result asynchronously.
When the getStats
()
method is invoked, the user agent
MUST run the following steps:
Let selector be the
object on
which the method was invoked.
RTCRtpSender
Let p be a new promise, and run the following steps in parallel:
Gather the stats indicated by selector according to the stats selection algorithm.
Resolve p with the resulting
object, containing the gathered
stats.
RTCStatsReport
Return p.
RTCRtpParameters
Dictionary
WebIDLdictionaryRTCRtpParameters
{ required sequence<RTCRtpHeaderExtensionParameters
>headerExtensions
; requiredRTCRtcpParameters
rtcp
; required sequence<RTCRtpCodecParameters
>codecs
; };
RTCRtpParameters
Members
headerExtensions
of type sequence<RTCRtpHeaderExtensionParameters
>,
required
A sequence containing parameters for RTP header extensions. Read-only parameter.
rtcp
of type RTCRtcpParameters
, required
Parameters used for RTCP. Read-only parameter.
codecs
of type sequence<RTCRtpCodecParameters
>,
required
A sequence containing the media codecs that an
will choose from, as well as entries for
RTX, RED and FEC mechanisms. Corresponding to each media
codec where retransmission via RTX is enabled, there will
be an entry in RTCRtpSender
with a
codecs
attribute indicating
retransmission via mimeType
audio/rtx
or
video/rtx
, and an
attribute (providing
the "apt" and "rtx-time" parameters). Read-only
parameter.
sdpFmtpLine
RTCRtpSendParameters
Dictionary
WebIDL dictionaryRTCRtpSendParameters
:RTCRtpParameters
{ required DOMStringtransactionId
; required sequence<RTCRtpEncodingParameters
>encodings
; };
RTCRtpSendParameters
Members
transactionId
of type DOMString, required
A unique identifier for the last set of parameters applied.
Ensures that
can only be
called based on a previous setParameters
,
and that there are no intervening changes. Read-only
parameter.
getParameters
encodings
of type sequence<RTCRtpEncodingParameters
>,
required
A sequence containing parameters for RTP encodings of media.
RTCRtpReceiveParameters
Dictionary
WebIDL dictionaryRTCRtpReceiveParameters
:RTCRtpParameters
{ };
RTCRtpCodingParameters
Dictionary
WebIDLdictionaryRTCRtpCodingParameters
{ DOMStringrid
; };
RTCRtpCodingParameters
Members
rid
of type DOMString
If set, this RTP encoding will be sent with the RID header
extension as defined by [JSEP] (section 5.2.1.). The RID is not
modifiable via
. It can only
be set or modified in setParameters
on the sending side. Read-only parameter.
addTransceiver
RTCRtpDecodingParameters
Dictionary
WebIDLdictionaryRTCRtpDecodingParameters
:RTCRtpCodingParameters
{};
RTCRtpEncodingParameters
Dictionary
WebIDL dictionaryRTCRtpEncodingParameters
:RTCRtpCodingParameters
{ booleanactive
= true; unsigned longmaxBitrate
; doublescaleResolutionDownBy
; };
RTCRtpEncodingParameters
Members
active
of type boolean, defaulting to
true
Indicates that this encoding is actively being sent.
Setting it to false
causes this encoding to no
longer be sent. Setting it to true
causes this
encoding to be sent. Since setting the value to
false
does not cause the SSRC to be removed,
an RTCP BYE is not sent.
maxBitrate
of type unsigned long
When present, indicates the maximum bitrate that can be
used to send this encoding. The user agent is free to
allocate bandwidth between the encodings, as long as the
value is not exceeded. The encoding may also
be further constrained by other limits (such as
per-transport or per-session bandwidth limits) below the
maximum specified here. maxBitrate
is computed the same
way as the Transport Independent Application Specific
Maximum (TIAS) bandwidth defined in [RFC3890] Section
6.2.2, which is the maximum bandwidth needed without
counting IP or other transport layers like TCP or UDP. The
unit of maxBitrate
is bits per second.
maxBitrate
How the bitrate is achieved is media and encoding dependent. For video, a frame will always be sent as fast as possible, but frames may be dropped until bitrate is low enough. Thus, even a bitrate of zero will allow sending one frame. For audio, it might be necessary to stop playing if the bitrate does not allow the chosen encoding enough bandwidth to be sent.
scaleResolutionDownBy
of type
double
This member is only present if the sender's kind
is "video"
. The video's
resolution will be scaled down in each dimension by the
given value before sending. For example, if the value is
2.0, the video will be scaled down by a factor of 2 in each
dimension, resulting in sending a video of one quarter the
size. If the value is 1.0, the video will not be affected.
The value must be greater than or equal to 1.0. By default,
scaling is applied by a factor of two to the power of the
layer's number, in order of smaller to higher resolutions,
e.g. 4:2:1. If there is only one layer, the sender will by
default not apply any scaling, (i.e.
will be
1.0).
scaleResolutionDownBy
RTCRtcpParameters
Dictionary
WebIDLdictionaryRTCRtcpParameters
{ DOMStringcname
; booleanreducedSize
; };
RTCRtcpParameters
Members
cname
of type DOMString
The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages). Read-only parameter.
reducedSize
of type boolean
Whether reduced size RTCP [RFC5506] is configured (if true) or compound RTCP as specified in [RFC3550] (if false). Read-only parameter.
RTCRtpHeaderExtensionParameters
Dictionary
WebIDLdictionaryRTCRtpHeaderExtensionParameters
{ required DOMStringuri
; required unsigned shortid
; booleanencrypted
= false; };
RTCRtpHeaderExtensionParameters
Members
uri
of type DOMString, required
The URI of the RTP header extension, as defined in [RFC5285]. Read-only parameter.
id
of type unsigned short, required
The value put in the RTP packet to identify the header extension. Read-only parameter.
encrypted
of type boolean
Whether the header extension is encrypted or not. Read-only parameter.
The
dictionary enables an
application to determine whether a header extension is configured
for use within an RTCRtpHeaderExtensionParameters
or RTCRtpSender
. For an
RTCRtpReceiver
transceiver, an application can
determine the "direction" parameter (defined in Section 5 of
[RFC5285]) of a header extension as follows without having to
parse SDP:
RTCRtpTransceiver
sender
.getParameters
()
.headerExtensions
.
receiver
.getParameters
()
.headerExtensions
.
sender
.getParameters
()
.headerExtensions
and
transceiver.receiver
.getParameters
()
.headerExtensions
.
sender
.getParameters
()
.headerExtensions
nor
transceiver.receiver
.getParameters
()
.headerExtensions
.
RTCRtpCodecParameters
Dictionary
WebIDLdictionaryRTCRtpCodecParameters
{ required octetpayloadType
; required DOMStringmimeType
; required unsigned longclockRate
; unsigned shortchannels
; DOMStringsdpFmtpLine
; };
RTCRtpCodecParameters
Members
payloadType
of type octet, required
The RTP payload type used to identify this codec. Read-only parameter.
mimeType
of type DOMString, required
The codec MIME media type/subtype. Valid media types and subtypes are listed in [IANA-RTP-2]. Read-only parameter.
clockRate
of type unsigned long, required
The codec clock rate expressed in Hertz. Read-only parameter.
channels
of type unsigned short
When present, indicates the number of channels (mono=1, stereo=2). Read-only parameter.
sdpFmtpLine
of type DOMString
The "format specific parameters" field from the
a=fmtp
line in the SDP
corresponding to the codec, if one exists, as defined by
[JSEP] (section 5.8.). For an
, these parameters come from the remote
description, and for an RTCRtpSender
, they come from
the local description. Read-only parameter.
RTCRtpReceiver
RTCRtpCapabilities
Dictionary
WebIDLdictionaryRTCRtpCapabilities
{ required sequence<RTCRtpCodecCapability
>codecs
; required sequence<RTCRtpHeaderExtensionCapability
>headerExtensions
; };
RTCRtpCapabilities
Members
codecs
of type sequence<RTCRtpCodecCapability
>,
required
Supported media codecs as well as entries for RTX, RED and
FEC mechanisms. There will only be a single entry in
for retransmission via RTX, with
codecs
not present.
sdpFmtpLine
headerExtensions
of type sequence<RTCRtpHeaderExtensionCapability
>,
required
Supported RTP header extensions.
RTCRtpCodecCapability
Dictionary
WebIDLdictionaryRTCRtpCodecCapability
{ required DOMStringmimeType
; required unsigned longclockRate
; unsigned shortchannels
; DOMStringsdpFmtpLine
; };
RTCRtpCodecCapability
Members
The
dictionary provides information
about codec capabilities. Only capability combinations that
would utilize distinct payload types in a generated SDP offer
are provided. For example:
RTCRtpCodecCapability
mimeType
of type DOMString, required
The codec MIME media type/subtype. Valid media types and subtypes are listed in [IANA-RTP-2].
clockRate
of type unsigned long, required
The codec clock rate expressed in Hertz.
channels
of type unsigned short
If present, indicates the maximum number of channels (mono=1, stereo=2).
sdpFmtpLine
of type DOMString
The "format specific parameters" field from the
a=fmtp
line in the SDP
corresponding to the codec, if one exists.
RTCRtpHeaderExtensionCapability
Dictionary
WebIDLdictionaryRTCRtpHeaderExtensionCapability
{ DOMStringuri
; };
RTCRtpHeaderExtensionCapability
Members
uri
of type DOMString
The URI of the RTP header extension, as defined in [RFC5285].
RTCRtpReceiver
Interface
The
interface allows an application to inspect the
receipt of a RTCRtpReceiver
MediaStreamTrack
.
To create an RTCRtpReceiver with a string, kind, run the following steps:
Let receiver be a new
object.
RTCRtpReceiver
Let track be a new MediaStreamTrack
object
[GETUSERMEDIA]. The source of track is a
remote source provided by receiver. Note
that the track.id
is
generated by the user agent and does not map to any track
IDs on the remote side.
Initialize track.kind to kind.
Initialize track.label to the result of concatenating
the string "remote "
with kind.
Initialize track.readyState to live
.
Initialize track.muted to true
. See the
MediaStreamTrack
section about how the muted
attribute
reflects if a MediaStreamTrack
is receiving media data or
not.
Let receiver have a [[ReceiverTrack]] internal slot initialized to track.
Let receiver have a [[ReceiverTransport]]
internal slot initialized to null
.
Let receiver have a
[[LastStableStateReceiverTransport]] internal slot
initialized to null
.
Let receiver have an
[[AssociatedRemoteMediaStreams]] internal slot,
representing a list of MediaStream
objects that the
MediaStreamTrack
object of this receiver is associated with,
and initialized to an empty list.
Let receiver have a [[LastStableStateAssociatedRemoteMediaStreams]] internal slot and initialize it to an empty list.
Let receiver have a [[ReceiveCodecs]]
internal slot, representing a list of
dictionaries, and initialized to an empty list.
RTCRtpCodecParameters
Let receiver have a [[LastStableStateReceiveCodecs]] internal slot and initialize it to an empty list.
Return receiver.
WebIDL[Exposed=Window] interfaceRTCRtpReceiver
{ readonly attribute MediaStreamTracktrack
; readonly attributeRTCDtlsTransport
?transport
; staticRTCRtpCapabilities
?getCapabilities
(DOMString kind);RTCRtpReceiveParameters
getParameters
(); sequence<RTCRtpContributingSource
>getContributingSources
(); sequence<RTCRtpSynchronizationSource
>getSynchronizationSources
(); Promise<RTCStatsReport
>getStats
(); };
track
of type
MediaStreamTrack
, readonly
The
attribute is the track that is associated with
this track
object receiver.
RTCRtpReceiver
Note that
.track
stop()
is final,
although clones are not affected. Since
receiver.
.track
stop()
does not implicitly stop receiver, Receiver
Reports continue to be sent. On getting, the attribute MUST
return the value of the [[ReceiverTrack]] slot.
transport
of type RTCDtlsTransport
, readonly, nullable
The
attribute is the transport over which media
for the receiver's transport
is received in
the form of RTP packets. Prior to construction of the
track
object, the RTCDtlsTransport
attribute will
be transport
null
. When bundling is used, multiple
objects will share one RTCRtpReceiver
and
will all receive RTP and RTCP over the same transport.
transport
On getting, the attribute MUST return the value of the [[ReceiverTransport]] slot.
getCapabilities
, static
The getCapabilities
()
method returns the most optimistic
view of the capabilities of the system for receiving media of
the given kind. It does not reserve any resources, ports, or
other state but is meant to provide a way to discover the
types of capabilities of the browser including which codecs
may be supported. User agents MUST support kind
values of "audio"
and "video"
. If
the system has no capabilities corresponding to the value of
the kind argument,
returns
getCapabilities
null
.
These capabilities provide generally persistent cross-origin information on the device and thus increases the fingerprinting surface of the application. In privacy-sensitive contexts, browsers can consider mitigations such as reporting only a common subset of the capabilities.
getParameters
The getParameters
()
method returns the
object's current parameters for how RTCRtpReceiver
is decoded.
track
When
is called, the
getParameters
dictionary is constructed as
follows:
RTCRtpReceiveParameters
headerExtensions
sequence is populated
based on the header extensions that the receiver is currently
prepared to receive.
is set to the value of the
[[ReceiveCodecs]] internal slot.
codecs
getParameters
. But if the
remote endpoint only answers with two, the absent codec
will no longer be returned by getParameters
as the
receiver no longer needs to be prepared to receive it.
rtcp
.reducedSize
is set to true
if the receiver is currently
prepared to receive reduced-size RTCP packets, and
false
otherwise.
rtcp
.cname
is left
out.
getContributingSources
Returns an
for each unique CSRC
identifier received by this RTCRtpContributingSource
in the last 10
seconds, in descending RTCRtpReceiver
order.
timestamp
getSynchronizationSources
Returns an
for each unique
SSRC identifier received by this RTCRtpSynchronizationSource
in the
last 10 seconds, in descending
RTCRtpReceiver
order.
timestamp
getStats
Gathers stats for this receiver only and reports the result asynchronously.
When the getStats
()
method is invoked, the user agent
MUST run the following steps:
Let selector be the
object
on which the method was invoked.
RTCRtpReceiver
Let p be a new promise, and run the following steps in parallel:
Gather the stats indicated by selector according to the stats selection algorithm.
Resolve p with the resulting
object, containing the gathered
stats.
RTCStatsReport
Return p.
The RTCRtpContributingSource
and
RTCRtpSynchronizationSource
dictionaries contain
information about a given contributing source (CSRC) or
synchronization source (SSRC) respectively. When an audio or video
frame from one or more RTP packets is delivered to the
's RTCRtpReceiver
MediaStreamTrack
, the user agent MUST queue
a task to update the relevant information for the
and RTCRtpContributingSource
dictionaries based on the content of those packets. The information
relevant to the RTCRtpSynchronizationSource
dictionary
corresponding to the SSRC identifier, is updated each time, and if an
RTP packet contains CSRC identifiers, then the information relevant
to the RTCRtpSynchronizationSource
dictionaries corresponding to
those CSRC identifiers is also updated. The user agent MUST process
RTP packets in order of ascending RTP timestamps. The user agent MUST
keep information from RTP packets delivered to the
RTCRtpContributingSource
's RTCRtpReceiver
MediaStreamTrack
in the previous 10 seconds.
MediaStreamTrack
is not attached to any sink for
playout, getSynchronizationSources
and
getContributingSources
returns up-to-date
information as long as the track is not ended; sinks are not a
prerequisite for decoding RTP packets.
RTCRtpSynchronizationSource
and
RTCRtpContributingSource
dictionaries for a particular
RTCRtpReceiver
contain information from a single point in the RTP
stream.
WebIDLdictionaryRTCRtpContributingSource
{ required DOMHighResTimeStamptimestamp
; required unsigned longsource
; doubleaudioLevel
; required unsigned longrtpTimestamp
; };
timestamp
of type
DOMHighResTimeStamp
, required
The
indicating the most recent time a frame
from an RTP packet, originating from this source, was
delivered to the timestamp
's RTCRtpReceiver
MediaStreamTrack
.
The
is defined as timestamp
Performance
.timeOrigin
+
Performance
.now
()
at that time.
source
of type unsigned long, required
The CSRC or SSRC identifier of the contributing or synchronization source.
audioLevel
of type double
Only present for audio receivers. This is a value between 0..1 (linear), where 1.0 represents 0 dBov, 0 represents silence, and 0.5 represents approximately 6 dBSPL change in the sound pressure level from 0 dBov.
For CSRCs, this MUST be converted from the level value defined in [RFC6465] if the RFC 6465 header extension is present, otherwise this member MUST be absent.
For SSRCs, this MUST be converted from the level value defined in [RFC6464]. If the RFC 6464 header extension is not present in the received packets (such as if the other endpoint is not a user agent or is a legacy endpoint), this value SHOULD be absent.
Both RFCs define the level as an integral value from 0 to 127 representing the audio level in negative decibels relative to the loudest signal that the system could possibly encode. Thus, 0 represents the loudest signal the system could possibly encode, and 127 represents silence.
To convert these values to the linear 0..1 range, a value of
127 is converted to 0, and all other values are converted
using the equation: 10^(-rfc_level/20)
.
rtpTimestamp
of type unsigned long, required
The last RTP timestamp, as defined in [RFC3550] Section 5.1, of the media played out at timestamp.
WebIDL dictionaryRTCRtpSynchronizationSource
:RTCRtpContributingSource
{ booleanvoiceActivityFlag
; };
voiceActivityFlag
of type boolean
Only present for audio receivers. Whether the last RTP
packet, delivered from this source, contains voice activity
(true) or not (false). If the RFC 6464 extension header was
not present, or if the peer has signaled that it is not using
the V bit by setting the "vad" extension attribute to "off",
as described in [RFC6464], Section 4,
will be absent.
voiceActivityFlag
is marked
as a feature at risk, since there is no clear commitment
from implementers.
voiceActivityFlag
RTCRtpTransceiver
Interface
The
interface represents a combination of an
RTCRtpTransceiver
and an RTCRtpSender
that share a common media stream "identification-tag". As defined in [JSEP] (section 3.4.1.), an RTCRtpReceiver
is said
to be associated with a media description if its
"mid" property is non-null and matches a media stream
"identification-tag" in the media description; otherwise it
is said to be disassociated with that media description.
RTCRtpTransceiver
A
may become associated with a new pending
description in JSEP while still being disassociated with the
current description. This may happen in check if negotiation is
needed.
RTCRtpTransceiver
The transceiver kind of an
is
defined by the kind of the associated RTCRtpTransceiver
's
RTCRtpReceiver
MediaStreamTrack
object.
To create an RTCRtpTransceiver with an
object, receiver, RTCRtpReceiver
object,
sender, and an RTCRtpSender
value,
direction, run the following steps:
RTCRtpTransceiverDirection
Let transceiver be a new
object.
RTCRtpTransceiver
Let transceiver have a [[Sender]] internal slot, initialized to sender.
Let transceiver have a [[Receiver]] internal slot, initialized to receiver.
Let transceiver have a [[Stopping]]
internal slot, initialized to false
.
Let transceiver have a [[Stopped]]
internal slot, initialized to false
.
Let transceiver have a [[Direction]] internal slot, initialized to direction.
Let transceiver have a [[Receptive]]
internal slot, initialized to false
.
Let transceiver have a
[[CurrentDirection]] internal slot, initialized to
null
.
Let transceiver have a [[FiredDirection]]
internal slot, initialized to null
.
Let transceiver have a [[PreferredCodecs]] internal slot, initialized to an empty list.
Let transceiver have a [[JsepMid]]
internal slot, initialized to null
. This is the
"RtpTransceiver mid property" defined in [JSEP] (section 5.2.1. and section 5.3.1.), and is only
modified there.
Let transceiver have a [[Mid]] internal
slot, initialized to null
.
Return transceiver.
RTCDtlsTransport
and RTCIceTransport
objects. This will only
occur as part of the process of setting an RTCSessionDescription.
WebIDL[Exposed=Window] interfaceRTCRtpTransceiver
{ readonly attribute DOMString?mid
; [SameObject] readonly attributeRTCRtpSender
sender
; [SameObject] readonly attributeRTCRtpReceiver
receiver
; attributeRTCRtpTransceiverDirection
direction
; readonly attributeRTCRtpTransceiverDirection
?currentDirection
; undefinedstop
(); undefinedsetCodecPreferences
(sequence<RTCRtpCodecCapability
> codecs); };
mid
of type DOMString, readonly, nullable
The
attribute is the media stream
"identification-tag" negotiated and present in the local
and remote descriptions. On getting, the attribute MUST
return the value of the [[Mid]] slot.
mid
sender
of type RTCRtpSender
, readonly
The
attribute exposes the sender
corresponding to the RTP media that may be sent with mid =
[[Mid]]. On getting, the attribute MUST return the
value of the [[Sender]] slot.
RTCRtpSender
receiver
of type RTCRtpReceiver
, readonly
The
attribute is the receiver
corresponding to the RTP media that may be received with mid
= [[Mid]]. On getting the attribute MUST return the
value of the [[Receiver]] slot.
RTCRtpReceiver
direction
of type RTCRtpTransceiverDirection
As defined in [JSEP] (section 4.2.4.), the
direction attribute indicates the preferred
direction of this transceiver, which will be used in calls to
and
createOffer
. An update of
directionality does not take effect immediately. Instead,
future calls to createAnswer
and
createOffer
mark the corresponding media description as createAnswer
sendrecv
,
sendonly
, recvonly
or inactive
as
defined in [JSEP] (section 5.2.2. and section 5.3.2.)
On getting, the user agent MUST run the following steps:
Let transceiver be the
object on which the getter is invoked.
RTCRtpTransceiver
If transceiver.[[Stopping]] is
true
, return
"
".
stopped
Otherwise, return the value of the [[Direction]] slot.
On setting, the user agent MUST run the following steps:
Let transceiver be the
object on which the setter is invoked.
RTCRtpTransceiver
Let connection be the
object associated with transceiver.
RTCPeerConnection
If transceiver.[[Stopping]] is
true
, throw an
InvalidStateError
.
Let newDirection be the argument to the setter.
If newDirection is equal to transceiver.[[Direction]], abort these steps.
Set transceiver.[[Direction]] to newDirection.
Update the negotiation-needed flag for connection.
currentDirection
of type RTCRtpTransceiverDirection
, readonly,
nullable
As defined in [JSEP] (section 4.2.5.), the
currentDirection attribute indicates the current
direction negotiated for this transceiver. The value of
currentDirection is independent of the value of
.RTCRtpEncodingParameters
since one cannot be deduced from the other. If this
transceiver has never been represented in an offer/answer
exchange, the value is active
null
. If the transceiver
is stopped
, the value is
"
".
stopped
On getting, the user agent MUST run the following steps:
Let transceiver be the
object on which the getter is invoked.
RTCRtpTransceiver
If transceiver.[[Stopped]] is
true
, return
"
".
stopped
Otherwise, return the value of the [[CurrentDirection]] slot.
stop
Irreversibly marks the transceiver as stopping
, unless it
is already stopped
. This will immediately cause the
transceiver's sender to no longer send, and its receiver to
no longer receive. Calling stop
()
also updates the negotiation-needed flag for the
's associated
RTCRtpTransceiver
.
RTCPeerConnection