RTCPeerConnection
interface represents a WebRTC connection between the local computer and a remote peer. It provides methods to connect to a remote peer, maintain and monitor the connection, and close the connection once it's no longer needed.
<div id="interfaceDiagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 11.666666666666666%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 70" preserveAspectRatio="xMinYMin meet"><a xlink:href="../API/EventTarget.html" target="_top"><rect x="1" y="1" width="110" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text x="56" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">EventTarget</text></a><polyline points="111,25 121,20 121,30 111,25" stroke="#D4DDE4" fill="none"/><line x1="121" y1="25" x2="151" y2="25" stroke="#D4DDE4"/><a xlink:href="../API/RTCPeerConnection" target="_top"><rect x="151" y="1" width="170" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="236" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">RTCPeerConnection</text></a></svg></div>
a:hover text { fill: #0095DD; pointer-events: all;}
RTCPeerConnection()
RTCPeerConnection()
constructor returns a newly-created
RTCPeerConnection
, which represents a connection between the local device and a remote peer.
Also inherits properties from:
EventTarget
canTrickleIceCandidates
RTCPeerConnection
property
canTrickleIceCandidates
返回
布尔
which indicates whether or not the remote peer can accept
trickled ICE candidates
.
connectionState
connectionState
特性为
RTCPeerConnection
interface indicates the current state of the peer connection by returning one of the string values specified by the enum
RTCPeerConnectionState
.
currentLocalDescription
只读
RTCPeerConnection.currentLocalDescription
返回
RTCSessionDescription
object describing the local end of the connection as it was most recently successfully negotiated since the last time the
RTCPeerConnection
finished negotiating and connecting to a remote peer. Also included is a list of any ICE candidates that may already have been generated by the ICE agent since the offer or answer represented by the description was first instantiated.
currentRemoteDescription
只读
RTCPeerConnection.currentRemoteDescription
返回
RTCSessionDescription
object describing the remote end of the connection as it was most recently successfully negotiated since the last time the
RTCPeerConnection
finished negotiating and connecting to a remote peer. Also included is a list of any ICE candidates that may already have been generated by the ICE agent since the offer or answer represented by the description was first instantiated.
getDefaultIceServers()
getDefaultIceServers()
方法在
RTCPeerConnection
interface returns an array of objects based on the
RTCIceServer
dictionary, which indicates what, if any, ICE servers the browser will use by default if none are provided to the
RTCPeerConnection
在其
RTCConfiguration
. However, browsers are
not
required to provide any default ICE servers at all.
iceConnectionState
只读
RTCPeerConnection.iceConnectionState
returns an enum of type
RTCIceConnectionState
which state of the ICE agent associated with the
RTCPeerConnection
.
iceGatheringState
只读
RTCPeerConnection.iceGatheringState
returns an enum of type
RTCIceGatheringState
that describes connection's ICE gathering state. This lets you detect, for example, when collection of ICE candidates has finished.
localDescription
只读
RTCPeerConnection.localDescription
返回
RTCSessionDescription
describing the session for the local end of the connection. If it has not yet been set, this is
null
.
peerIdentity
只读
RTCPeerConnection
property
peerIdentity
returns a JavaScript
Promise
that resolves to an
RTCIdentityAssertion
which contains a
DOMString
identifying the remote peer.
pendingLocalDescription
只读
RTCPeerConnection.pendingLocalDescription
返回
RTCSessionDescription
object describing a pending configuration change for the local end of the connection. This does not describe the connection as it currently stands, but as it may exist in the near future. Use
RTCPeerConnection.currentLocalDescription
or
RTCPeerConnection.localDescription
to get the current state of the endpoint. For details on the difference, see
Pending and current descriptions
in
WebRTC connectivity
.
pendingRemoteDescription
只读
RTCPeerConnection.pendingRemoteDescription
返回
RTCSessionDescription
object describing a pending configuration change for the remote end of the connection. This does not describe the connection as it currently stands, but as it may exist in the near future. Use
RTCPeerConnection.currentRemoteDescription
or
RTCPeerConnection.remoteDescription
to get the current session description for the remote endpoint. For details on the difference, see
Pending and current descriptions
in
WebRTC connectivity
.
remoteDescription
只读
RTCPeerConnection.remoteDescription
返回
RTCSessionDescription
describing the session (which includes configuration and media information) for the remote end of the connection. If this hasn't been set yet, this is
null
.
sctp
sctp
property on the
RTCPeerConnection
interface returns an
RTCSctpTransport
describing the
SCTP
transport over which SCTP data is being sent and received. If SCTP hasn't been negotiated, this value is
null
.
signalingState
只读
signalingState
property on the
RTCPeerConnection
interface returns one of the string values specified by the
RTCSignalingState
enum; these values describe the state of the signaling process on the local end of the connection while connecting or reconnecting to another peer. See
Signaling
in
Lifetime of a WebRTC session
for more details about the signaling process.
Also inherits event handlers from:
EventTarget
onaddstream
RTCPeerConnection.onaddstream
event handler is a property containing the code to execute when the
addstream
event, of type
MediaStreamEvent
, is received by this
RTCPeerConnection
. Such an event is sent when a
MediaStream
is added to this connection by the remote peer. The event is sent immediately after the call
setRemoteDescription()
and doesn't wait for the result of the SDP negotiation.
onconnectionstatechange
RTCPeerConnection.onconnectionstatechange
property specifies an
EventHandler
which is called to handle the
connectionstatechange
event when it occurs on an instance of
RTCPeerConnection
. This happens whenever the aggregate state of the connection changes.
ondatachannel
RTCPeerConnection.ondatachannel
property is an
EventHandler
which specifies a function which is called when the
datachannel
event occurs on an
RTCPeerConnection
. This event, of type
RTCDataChannelEvent
, is sent when an
RTCDataChannel
is added to the connection by the remote peer calling
createDataChannel()
.
onicecandidate
RTCPeerConnection
property
onicecandidate
property is an
EventHandler
which specifies a function to be called when the
icecandidate
event occurs on an
RTCPeerConnection
instance. This happens whenever the local
ICE
agent needs to deliver a message to the other peer through the signaling server.
oniceconnectionstatechange
RTCPeerConnection.oniceconnectionstatechange
property is an event handler which specifies a function to be called when the
iceconnectionstatechange
event is fired on an
RTCPeerConnection
instance. This happens when the state of the connection's ICE agent, as represented by the
iceConnectionState
property, changes.
onicegatheringstatechange
RTCPeerConnection.onicegatheringstatechange
property is an
EventHandler
which specifies a function to be called when the
icegatheringstatechange
event is sent to an
RTCPeerConnection
instance. This happens when the ICE gathering state—that is, whether or not the ICE agent is actively gathering candidates—changes.
onidentityresult
RTCPeerConnection.onidentityresult
event handler is a property containing the code to execute when the
identityresult
event, of type
RTCIdentityEvent
, is received by this
RTCPeerConnection
. Such an event is sent when an identity assertion is generated, via
getIdentityAssertion()
or during the creation of an offer or an answer.
onidpassertionerror
RTCPeerConnection.onidpassertionerror
event handler is a property containing the code to execute whent the
idpassertionerror
event, of type
RTCIdentityErrorEvent
, is received by this
RTCPeerConnection
. Such an event is sent when the associated identity provider (IdP) encounters an error while generating an identity assertion.
onidpvalidationerror
RTCPeerConnection.onidpvalidationerror
event handler is a property containing the code to execute whent the
idpvalidationerror
event, of type
RTCIdentityErrorEvent
, is received by this
RTCPeerConnection
. Such an event is sent when the associated identity provider (IdP) encounters an error while validating an identity assertion.
onnegotiationneeded
RTCPeerConnection
接口的
onnegotiationneeded
property is an
EventListener
which specifies a function which is called to handle the
negotiationneeded
event when it occurs on an
RTCPeerConnection
instance. This event is fired when a change has occurred which requires session negotiation. This negotiation should be carried out as the offerer, because some session changes cannot be negotiated as the answerer.
onpeeridentity
RTCPeerConnection.onpeeridentity
event handler is a property containing the code to execute whent the
peeridentity
event, of type
事件
, is received by this
RTCPeerConnection
. Such an event is sent when an identity assertion, received from a peer, has been successfully validated.
onremovestream
RTCPeerConnection.onremovestream
event handler is a property containing the code to execute when the
removestream
event, of type
MediaStreamEvent
, is received by this
RTCPeerConnection
. Such an event is sent when a
MediaStream
is removed from this connection.
onsignalingstatechange
onsignalingstatechange
event handler property of the
RTCPeerConnection
interface specifies a function to be called when the
signalingstatechange
event occurs on an
RTCPeerConnection
接口。
ontrack
RTCPeerConnection
property
ontrack
是
EventHandler
which specifies a function to be called when the
track
event occurs, indicating that a track has been added to the
RTCPeerConnection
.
Also inherits methods from:
EventTarget
addIceCandidate()
RTCPeerConnection
receives a new ICE candidate from the remote peer over its signaling channel, it delivers the newly-received candidate to the browser's
ICE
agent by calling
RTCPeerConnection.addIceCandidate()
.
addStream()
RTCPeerConnection
方法
addStream()
adds a
MediaStream
as a local source of audio or video. Instead of using this obsolete method, you should instead use
addTrack()
once for each track you wish to send to the remote peer.
addTrack()
RTCPeerConnection
方法
addTrack()
adds a new media track to the set of tracks which will be transmitted to the other peer.
close()
RTCPeerConnection.close()
method closes the current peer connection.
createAnswer()
createAnswer()
method on the
RTCPeerConnection
interface creates an
SDP
answer to an offer received from a remote peer during the offer/answer negotiation of a WebRTC connection. The answer contains information about any media already attached to the session, codecs and options supported by the browser, and any
ICE
candidates already gathered. The answer is delivered to the returned
Promise
, and should then be sent to the source of the offer to continue the negotiation process.
createDataChannel()
createDataChannel()
method on the
RTCPeerConnection
interface creates a new channel linked with the remote peer, over which any kind of data may be transmitted.
createOffer()
createOffer()
方法在
RTCPeerConnection
interface initiates the creation of an
SDP
offer for the purpose of starting a new WebRTC connection to a remote peer.
generateCertificate() static function
RTCPeerConnection.generateCertificate()
function creates an X.509 certificate and corresponding private key, returning a promise that resolves with the new
RTCCertificate
once it's generated.
getConfiguration()
RTCPeerConnection.getConfiguration()
method returns an
RTCConfiguration
object which indicates the current configuration of the
RTCPeerConnection
on which the method is called.
getIdentityAssertion()
RTCPeerConnection.getIdentityAssertion()
method initiates the gathering of an identity assertion. This has an effect only if the
signalingState
不是
"closed"
.
getReceivers()
RTCPeerConnection.getReceivers()
method returns an array of
RTCRtpReceiver
objects, each of which represents one RTP receiver. Each RTP receiver manages the reception and decoding of data for a
MediaStreamTrack
在
RTCPeerConnection
getSenders()
RTCPeerConnection
方法
getSenders()
returns an array of
RTCRtpSender
objects, each of which represents the RTP sender responsible for transmitting one track's data.
getStats()
RTCPeerConnection
方法
getStats()
returns a promise which resolves with data providing statistics about either the overall connection or about the specified
MediaStreamTrack
.
getStreamById()
RTCPeerConnection.getStreamById()
方法返回
MediaStream
with the given id that is associated with local or remote end of the connection. If no stream matches, it returns
null
.
getTransceivers()
RTCPeerConnection
接口的
getTransceivers()
method returns a list of the
RTCRtpTransceiver
objects being used to send and receive data on the connection.
removeStream()
RTCPeerConnection.removeStream()
method removes a
MediaStream
as a local source of audio or video. If the negotiation already happened, a new one will be needed for the remote peer to be able to use it. Because this method has been deprecated, you should instead use
removeTrack()
if your target browser versions have implemented it.
removeTrack()
RTCPeerConnection.removeTrack()
method tells the local end of the connection to stop sending media from the specified track, without actually removing the corresponding
RTCRtpSender
from the list of senders as reported by
RTCPeerConnection.getSenders()
.
restartIce()
RTCPeerConnection
interface offers the
restartIce()
method to allow a web application to easily request that
ICE
candidate gathering be redone on both ends of the connection.
setConfiguration()
RTCPeerConnection.setConfiguration()
method sets the current configuration of the
RTCPeerConnection
based on the values included in the specified
RTCConfiguration
object. This lets you change the ICE servers used by the connection and which transport policies to use.
setIdentityProvider()
RTCPeerConnection.setIdentityProvider()
method sets the Identity Provider (IdP) to the triplet given in parameter: its name, the protocol used to communicate with it (optional) and an optional username. The IdP will be used only when an assertion is needed.
setLocalDescription()
RTCPeerConnection
方法
setLocalDescription()
changes the local description associated with the connection. This description specifies the properties of the local end of the connection, including the media format.
setRemoteDescription()
RTCPeerConnection
方法
setRemoteDescription()
sets the specified session description as the remote peer's current offer or answer. The description specifies the properties of the remote end of the connection, including the media format.
The following method was obsoleted long ago and was never implemented in all major browsers.
RTCPeerConnection.createDTMFSender()
RTCDTMFSender
, associated to a specific
MediaStreamTrack
, that will be able to send
DTMF
phone signaling over the connection.
监听这些事件使用
addEventListener()
或通过把事件监听器赋值给
on
eventname
特性为此接口。
connectionstatechange
RTCPeerConnection
object when the overall connectivity status of the
RTCPeerConnection
改变。
onconnectionstatechange
event handler property.
datachannel
RTCPeerConnection
object when the remote peer adds an
RTCDataChannel
to the connection.
ondatachannel
event handler property.
icecandidate
onicecandidate
event handler property.
icecandidateerror
RTCPeerConnectionIceErrorEvent
which is sent to the connection if an error occurred during ICE candidate gathering. The event's properties describe the error.
onicecandidateerror
event handler property.
iceconnectionstatechange
RTCPeerConnection
when the state of the ICE connection changes, such as when it disconnects.
oniceconnectionstatechange
event handler property.
icegatheringstatechange
RTCPeerConnection
when the ICE layer's gathering state, reflected by
iceGatheringState
, changes. This indicates whether ICE negotiation has not yet begun (
new
), has begun gathering candidates (
gathering
), or has completed (
complete
).
onicegatheringstatechange
event handler property.
isolationchange
RTCPeerConnection
当
isolated
property on one of the
MediaStreamTrack
objects associated with the connection changes value. A track is
isolated
if its content cannot be accessed by the owning document due to lack of authentication or if the track comes from a cross-origin source.
onisolationchange
event handler property.
negotiationneeded
RTCPeerConnection
when negotiation or renegotiation of the ICE connection needs to be performed; this can happen both when first opening a connection as well as when it's neccessary to adapt to changing network conditions. The receiver should respond by creating an offer and sending it to the other peer.
onnegotiationneeded
event handler property.
signalingstatechange
signalingstatechange
event is sent to the
RTCPeerConnection
when the connection's ICE signaling state changes.
onsignalingstatechange
event handler property.
track
track
event is sent after a new track has been added to one of the
RTCRtpReceiver
instances which comprise the connection.
ontrack
event handler property.
addstream
MediaStream
has been added to the connection. Instead of watching for this obsolete event, you should watch each for
track
events; one is sent for each
MediaStreamTrack
added to the connection.
onaddstream
event handler property.
identityresult
peerIdentity
to resolve with an identity.
onidentityresult
event handler property.
idpassertionerror
peerIdentity
to be rejected with an error.
onidpinsertionerror
event handler property.
idpvalidationerror
peerIdentity
to be rejected with an error.
onpeerdentity
event handler property.
peeridentity
peerIdentity
to resolve with an identity.
removestream
RTCPeerConnection
当
MediaStream
is removed from the connection. Instead of watching for this obsolete event, you should watch each stream for
removetrack
events on each stream within the
RTCPeerConnection
.
onaddstream
event handler property.
RTCBundlePolicy
enum defines string constants which are used to request a specific policy for gathering ICE candidates if the remote peer isn't "BUNDLE-aware" (compatible with the
SDP BUNDLE standard
for bundling multiple media streams on a single transport link). All browser implementations are BUNDLE-aware.
If the remote endpoint is BUNDLE-aware, all media tracks and data channels are bundled onto a single transport at the completion of negotiation, regardless of policy used, and any superfluous transports that were created initially are closed at that point.
注意: In technical terms, a BUNDLE lets all media flow between two peers flow across a single 5-tuple ; that is, from a single IP and port on one peer to a single IP and port on the other peer, using the same transport protocol.
| 常量 | 描述 |
|---|---|
"balanced"
|
The ICE agent initially creates one
RTCDtlsTransport
for each type of content added: audio, video, and data channels. If the remote endpoint is not BUNDLE-aware, then each of these DTLS transports then handles all the communication for one type of data.
|
"max-compat"
|
The ICE agent initially creates one
RTCDtlsTransport
per media track and a separate one for data channels. If the remote endpoint is not BUNDLE-aware, everything is negotiated on these separate DTLS transports.
|
"max-bundle"
|
The ICE agent initially creates only a single
RTCDtlsTransport
to carry all of the
RTCPeerConnection
's data. If the remote endpoint is not BUNDLE-aware, then only a single track will be negotiated and the rest ignored.
|
RTCIceConnectionState
enum defines the string constants used to describe the current state of the ICE agent and its connection to the ICE server (that is, the
STUN
or
TURN
server).
| 常量 | 描述 |
|---|---|
"new"
|
The ICE agent is gathering addresses or is waiting to be given remote candidates through calls to
RTCPeerConnection.addIceCandidate()
(or both).
|
"checking"
|
The ICE agent has been given one or more remote candidates and is checking pairs of local and remote candidates against one another to try to find a compatible match, but has not yet found a pair which will allow the peer connection to be made. It's possible that gathering of candidates is also still underway. |
"connected"
|
A usable pairing of local and remote candidates has been found for all components of the connection, and the connection has been established. It's possible that gathering is still underway, and it's also possible that the ICE agent is still checking candidates against one another looking for a better connection to use. |
"completed"
|
The ICE agent has finished gathering candidates, has checked all pairs against one another, and has found a connection for all components. |
"failed"
|
The ICE candidate has checked all candidates pairs against one another and has failed to find compatible matches for all components of the connection. It is, however, possible that the ICE agent did find compatible connections for some components. |
"disconnected"
|
Checks to ensure that components are still connected failed for at least one component of the
RTCPeerConnection
. This is a less stringent test than
"failed"
and may trigger intermittently and resolve just as spontaneously on less reliable networks, or during temporary disconnections. When the problem resolves, the connection may return to the
"connected"
状态。
|
"closed"
|
The ICE agent for this
RTCPeerConnection
has shut down and is no longer handling requests.
|
RTCIceGatheringState
enum defines string constants which reflect the current status of ICE gathering, as returned using the
RTCPeerConnection.iceGatheringState
property. You can detect when this value changes by watching for an event of type
icegatheringstatechange
.
| 常量 | 描述 |
|---|---|
"new"
|
The peer connection was just created and hasn't done any networking yet. |
"gathering"
|
The ICE agent is in the process of gathering candidates for the connection. |
"complete"
|
The ICE agent has finished gathering candidates. If something happens that requires collecting new candidates, such as a new interface being added or the addition of a new ICE server, the state will revert to "gathering" to gather those candidates. |
RTCIceTransportPolicy
enum defines string constants which can be used to limit the transport policies of the ICE candidates to be considered during the connection process.
| 常量 | 描述 |
|---|---|
"all"
|
All ICE candidates will be considered. |
"public"
|
Only ICE candidates with public IP addresses will be considered. Removed from the specification's May 13, 2016 working draft. |
"relay"
|
Only ICE candidates whose IP addresses are being relayed, such as those being passed through a TURN server, will be considered. |
RTCPeerConnectionState
enum defines string constants which describe states in which the
RTCPeerConnection
may be. These values are returned by the
connectionState
property. This state essentially represents the aggregate state of all ICE transports (which are of type
RTCIceTransport
or
RTCDtlsTransport
) being used by the connection.
| 常量 | 描述 |
|---|---|
"new"
|
At least one of the connection's ICE transports (
RTCIceTransport
s or
RTCDtlsTransport
s) are in the
"new"
state, and none of them are in one of the following states:
"connecting"
,
"checking"
,
"failed"
,或
"disconnected"
,
or
all of the connection's transports are in the
"closed"
状态。
|
"connecting"
|
One or more of the ICE transports are currently in the process of establishing a connection; that is, their
RTCIceConnectionState
是
"checking"
or
"connected"
, and no transports are in the
"failed"
状态。
<<< Make this a link once I know where that will be documented
|
"connected"
|
Every ICE transport used by the connection is either in use (state
"connected"
or
"completed"
) or is closed (state
"closed"
); in addition, at least one transport is either
"connected"
or
"completed"
.
|
"disconnected"
|
At least one of the ICE transports for the connection is in the
"disconnected"
state and none of the other transports are in the state
"failed"
,
"connecting"
,或
"checking"
.
|
"failed"
|
One or more of the ICE transports on the connection is in the
"failed"
状态。
|
"closed"
|
RTCPeerConnection
is closed.
This value was in the
|
RTCRtcpMuxPolicy
enum defines string constants which specify what ICE candidates are gathered to support non-multiplexed RTCP.
<<<add a link to info about multiplexed RTCP.
| 常量 | 描述 |
|---|---|
"negotiate"
|
Instructs the ICE agent to gather both RTP and RTCP candidates. If the remote peer can multiplex RTCP, then RTCP candidates are multiplexed atop the corresponding RTP candidates. Otherwise, both the RTP and RTCP candidates are returned, separately. |
"require"
|
Tells the ICE agent to gather ICE candidates for only RTP, and to multiplex RTCP atop them. If the remote peer doesn't support RTCP multiplexing, then session negotiation fails. |
RTCSignalingState
enum specifies the possible values of
RTCPeerConnection.signalingState
, which indicates where in the process of signaling the exchange of offer and answer the connection currently is.
| 常量 | 描述 |
|---|---|
"stable"
|
There is no ongoing exchange of offer and answer underway. This may mean that the
RTCPeerConnection
object is new, in which case both the
localDescription
and
remoteDescription
are
null
; it may also mean that negotiation is complete and a connection has been established.
|
"have-local-offer"
|
The local peer has called
RTCPeerConnection.setLocalDescription()
, passing in SDP representing an offer (usually created by calling
RTCPeerConnection.createOffer()
), and the offer has been applied successfully.
|
"have-remote-offer"
|
The remote peer has created an offer and used the signaling server to deliver it to the local peer, which has set the offer as the remote description by calling
RTCPeerConnection.setRemoteDescription()
.
|
"have-local-pranswer"
|
The offer sent by the remote peer has been applied and an answer has been created (usually by calling
RTCPeerConnection.createAnswer()
) and applied by calling
RTCPeerConnection.setLocalDescription()
. This provisional answer describes the supported media formats and so forth, but may not have a complete set of ICE candidates included. Further candidates will be delivered separately later.
|
"have-remote-pranswer"
|
A provisional answer has been received and successfully applied in response to an offer previously sent and established by calling
setLocalDescription()
.
|
"closed"
|
The connection is closed.
注意:
This value moved into the
|
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCPeerConnection
|
Chrome 23 | Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android ≤37 | Chrome Android 25 |
Firefox Android
44
|
Opera Android
43
|
Safari iOS 11 |
Samsung Internet Android
6.0
|
RTCPeerConnection()
构造函数
|
Chrome
23
|
Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari ? |
WebView Android
Yes
|
Chrome Android
Yes
|
Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
addIceCandidate
|
Chrome
51
|
Edge 15 |
Firefox
22
|
IE No |
Opera
43
|
Safari 11 |
WebView Android
51
|
Chrome Android
51
|
Firefox Android
44
|
Opera Android
43
|
Safari iOS Yes |
Samsung Internet Android
6.0
|
addStream
弃用
|
Chrome 24 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
addstream
event
弃用
非标
|
Chrome 24 | Edge 15 | Firefox 22 | IE No | Opera 43 | Safari No | WebView Android Yes | Chrome Android 25 | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
addTrack
|
Chrome 64 | Edge ≤18 | Firefox 22 | IE No | Opera 51 | Safari 11 | WebView Android 64 | Chrome Android 64 | Firefox Android 44 | Opera Android 47 | Safari iOS Yes | Samsung Internet Android 6.0 |
addTransceiver
|
Chrome 69 | Edge 79 | Firefox 59 | IE No | Opera No | Safari 11 | WebView Android 69 | Chrome Android 69 | Firefox Android 59 | Opera Android No | Safari iOS Yes | Samsung Internet Android 10.0 |
canTrickleIceCandidates
|
Chrome No | Edge 15 — 79 | Firefox 47 | IE No | Opera No | Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 | Opera Android No | Safari iOS ? | Samsung Internet Android 6.0 |
close
|
Chrome 23 | Edge 15 | Firefox Yes | IE No | Opera Yes | Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
connectionState
|
Chrome 72 | Edge 79 | Firefox No | IE No | Opera No | Safari 11 | WebView Android 72 | Chrome Android 72 | Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android 11.0 |
connectionstatechange
event
|
Chrome 72 | Edge 79 | Firefox No | IE No | Opera No | Safari 11 | WebView Android 72 | Chrome Android 72 | Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android 11.0 |
createAnswer
|
Chrome
51
|
Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 |
WebView Android
51
|
Chrome Android
51
|
Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes |
Samsung Internet Android
6.0
|
createDataChannel
|
Chrome 25 | Edge 79 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android 25 | Firefox Android 44 |
Opera Android
43
|
Safari iOS 11 | Samsung Internet Android 6.0 |
createDTMFSender
弃用
|
Chrome 27 | Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android Yes | Chrome Android 27 | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
createOffer
|
Chrome
51
|
Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 |
WebView Android
51
|
Chrome Android
51
|
Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes |
Samsung Internet Android
6.0
|
currentLocalDescription
|
Chrome 70 | Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android 70 | Chrome Android 70 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
currentRemoteDescription
|
Chrome 70 | Edge 79 | Firefox 57 | IE No | Opera No | Safari 11 | WebView Android 70 | Chrome Android 70 | Firefox Android Yes | Opera Android No | Safari iOS No | Samsung Internet Android 10.0 |
datachannel
event
|
Chrome 25 | Edge ≤18 | Firefox 22 | IE No | Opera 43 | Safari 11 | WebView Android Yes | Chrome Android 25 | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
defaultIceServers
弃用
非标
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
generateCertificate
|
Chrome 48 | Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android 48 | Chrome Android 48 | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
getConfiguration
|
Chrome 70 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android 70 | Chrome Android 70 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
getDefaultIceServers
|
Chrome No | Edge No | Firefox ? | IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No | Firefox Android ? | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
getIdentityAssertion
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
getLocalStreams
弃用
非标
|
Chrome 27 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android Yes | Chrome Android 27 | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
getReceivers
|
Chrome 59 | Edge ≤18 | Firefox 22 | IE No | Opera 46 | Safari 11 | WebView Android 59 | Chrome Android 59 | Firefox Android 44 | Opera Android 43 | Safari iOS Yes | Samsung Internet Android 6.0 |
getRemoteStreams
弃用
非标
|
Chrome 27 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android Yes | Chrome Android 27 | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
getSenders
|
Chrome 64 | Edge ≤18 | Firefox 22 | IE No | Opera 51 | Safari 11 | WebView Android 64 | Chrome Android 64 | Firefox Android 44 | Opera Android 47 | Safari iOS Yes | Samsung Internet Android 6.0 |
getStats
|
Chrome
58
|
Edge 15 | Firefox Yes | IE No | Opera 45 | Safari 11 |
WebView Android
58
|
Chrome Android
58
|
Firefox Android Yes | Opera Android 43 | Safari iOS Yes |
Samsung Internet Android
7.0
|
getStreamById
弃用
非标
|
Chrome 56 — 62 | Edge 15 — 79 | Firefox 22 — 53 | IE No |
Opera
43
|
Safari ? | WebView Android 56 — 62 | Chrome Android 56 — 62 | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 — 8.0 |
icecandidate
event
|
Chrome 24 | Edge 15 | Firefox 22 | IE No | Opera 43 | Safari 11 | WebView Android Yes | Chrome Android 25 | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
iceConnectionState
|
Chrome 26 | Edge 15 | Firefox 52 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android 26 | Firefox Android Yes |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 7.0 |
iceconnectionstatechange
event
|
Chrome 28 | Edge 15 | Firefox 22 | IE No | Opera 43 | Safari 11 | WebView Android Yes | Chrome Android 28 | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
iceGatheringState
|
Chrome 25 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android 25 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
identityresult
event
弃用
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No | Opera 43 | Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
idpassertionerror
event
弃用
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No | Opera 43 | Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
idpvalidationerror
event
弃用
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No | Opera 43 | Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
localDescription
|
Chrome 24 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android 25 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
negotiationneeded
event
|
Chrome 24 | Edge 15 | Firefox 22 | IE No | Opera 43 | Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
onaddstream
弃用
非标
|
Chrome 24 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari No | WebView Android Yes | Chrome Android Yes | Firefox Android 44 |
Opera Android
43
|
Safari iOS No | Samsung Internet Android 6.0 |
onconnectionstatechange
|
Chrome 72 | Edge 79 | Firefox No | IE No | Opera No | Safari 11 | WebView Android 72 | Chrome Android 72 | Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android 11.0 |
ondatachannel
|
Chrome 25 | Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android 25 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
onicecandidate
|
Chrome 24 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
onicecandidateerror
|
Chrome No | Edge No | Firefox ? | IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No | Firefox Android ? | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
oniceconnectionstatechange
|
Chrome 28 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android 28 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
onicegatheringstatechange
|
Chrome 59 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android 59 | Chrome Android 59 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 7.0 |
onidentityresult
弃用
非标
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
onidpassertionerror
弃用
非标
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
onidpvalidationerror
弃用
非标
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
onnegotiationneeded
|
Chrome 24 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
onpeeridentity
弃用
非标
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
onremovestream
弃用
非标
|
Chrome 24 | Edge 15 | Firefox 22 — 60 | IE No |
Opera
43
|
Safari No | WebView Android Yes | Chrome Android Yes | Firefox Android 44 — 60 |
Opera Android
43
|
Safari iOS No | Samsung Internet Android 6.0 |
onsignalingstatechange
|
Chrome 28 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android 28 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
ontrack
|
Chrome 64 | Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android 64 | Chrome Android 64 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
peerIdentity
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
peeridentity
event
弃用
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No | Opera 43 | Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
pendingLocalDescription
|
Chrome 70 | Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android 70 | Chrome Android 70 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
pendingRemoteDescription
|
Chrome 70 | Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android 70 | Chrome Android 70 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
remoteDescription
|
Chrome 24 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android Yes | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
removeStream
弃用
非标
|
Chrome 24 | Edge 15 | Firefox 22 — 51 | IE No |
Opera
43
|
Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 44 |
Opera Android
43
|
Safari iOS 11 — 12 | Samsung Internet Android 6.0 |
removestream
event
弃用
非标
|
Chrome 24 | Edge 15 | Firefox 22 — 60 | IE No | Opera 43 | Safari No | WebView Android Yes | Chrome Android 25 | Firefox Android 44 — 60 | Opera Android 43 | Safari iOS No | Samsung Internet Android 6.0 |
removeTrack
|
Chrome 64 | Edge ≤18 | Firefox 22 | IE No | Opera 51 | Safari 11 | WebView Android 64 | Chrome Android 64 | Firefox Android 44 | Opera Android 47 | Safari iOS Yes | Samsung Internet Android 6.0 |
restartIce()
方法
|
Chrome 77 | Edge 79 | Firefox 70 | IE No | Opera No | Safari No | WebView Android 77 | Chrome Android 77 | Firefox Android No | Opera Android 55 | Safari iOS No | Samsung Internet Android 12.0 |
sctp
|
Chrome 76 | Edge 79 |
Firefox
No
|
IE No | Opera No | Safari No | WebView Android 76 | Chrome Android 76 |
Firefox Android
No
|
Opera Android 54 | Safari iOS No | Samsung Internet Android 12.0 |
setConfiguration
|
Chrome 48 | Edge ≤18 |
Firefox
No
|
IE No |
Opera
43
|
Safari 11 | WebView Android 48 | Chrome Android 48 |
Firefox Android
No
|
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
setIdentityProvider
|
Chrome No | Edge ≤18 — 79 | Firefox 22 | IE No |
Opera
43
|
Safari ? | WebView Android No | Chrome Android No | Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
setLocalDescription()
|
Chrome
51
|
Edge 15 |
Firefox
22
|
IE No |
Opera
43
|
Safari 11 |
WebView Android
51
|
Chrome Android
51
|
Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes |
Samsung Internet Android
6.0
|
setRemoteDescription()
|
Chrome
51
|
Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 |
WebView Android
51
|
Chrome Android
51
|
Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes |
Samsung Internet Android
5.0
|
signalingState
|
Chrome 26 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android Yes | Chrome Android 26 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 6.0 |
signalingstatechange
event
|
Chrome 28 | Edge 15 | Firefox 22 | IE No | Opera 43 | Safari 11 | WebView Android Yes | Chrome Android 28 | Firefox Android 44 | Opera Android 43 | Safari iOS No | Samsung Internet Android 6.0 |
track
event
|
Chrome 64 | Edge ≤18 | Firefox 22 | IE No | Opera 43 | Safari 11 | WebView Android 64 | Chrome Android 64 | Firefox Android 44 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 6.0 |
完整支持
不支持
兼容性未知
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
见实现注意事项。
要求使用供应商前缀或不同名称。
RTCPeerConnection
canTrickleIceCandidates
connectionState
currentLocalDescription
currentRemoteDescription
getDefaultIceServers()
iceConnectionState
iceGatheringState
localDescription
onaddstream
onconnectionstatechange
ondatachannel
onicecandidate
oniceconnectionstatechange
onicegatheringstatechange
onidentityresult
onidpassertionerror
onidpvalidationerror
onnegotiationneeded
onpeeridentity
onremovestream
onsignalingstatechange
ontrack
peerIdentity
pendingLocalDescription
pendingRemoteDescription
remoteDescription
sctp
signalingState
addIceCandidate()
addStream()
addTrack()
close()
createAnswer()
createDataChannel()
createOffer()
generateCertificate() static function
getConfiguration()
getIdentityAssertion()
getReceivers()
getSenders()
getStats()
getStreamById()
getTransceivers()
removeStream()
removeTrack()
restartIce()
setConfiguration()
setIdentityProvider()
setLocalDescription()
setRemoteDescription()
MediaDevices.getUserMedia()
Navigator.mediaDevices
RTCCertificate
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCDataChannel
RTCDataChannelEvent
RTCDtlsTransport
RTCErrorEvent
RTCIceCandidate
RTCIceTransport
RTCPeerConnectionIceErrorEvent
RTCPeerConnectionIceEvent
RTCRtpReceiver
RTCRtpSender
RTCRtpTransceiver
RTCSctpTransport
RTCSessionDescription
RTCStatsReport
RTCTrackEvent