RTCConfiguration
dictionary is used to provide configuration options for an
RTCPeerConnection
. It may be passed into the constructor when instantiating a connection, or used with the
RTCPeerConnection.getConfiguration()
and
RTCPeerConnection.setConfiguration()
methods, which allow inspecting and changing the configuration while a connection is established.
The options include ICE server and transport settings and identity information.
bundlePolicy
可选
RTCBundlePolicy
. If this value isn't included in the dictionary,
"balanced"
is assumed.
certificates
可选
数组
of objects of type
RTCCertificate
which are used by the connection for authentication. If this property isn't specified, a set of certificates is generated automatically for each
RTCPeerConnection
instance. Although only one certificate is used by a given connection, providing certificates for multiple algorithms may improve the odds of successfully connecting in some circumstances. See
Using certificates
了解进一步信息。
This configuration option cannot be changed after it is first specified; once the certificates have been set, this property is ignored in future calls to
RTCPeerConnection.setConfiguration()
.
iceCandidatePoolSize
可选
RTCPeerConnection.setLocalDescription()
被调用。
Changing the size of the ICE candidate pool may trigger the beginning of ICE gathering.
iceServers
可选
RTCIceServer
objects, each describing one server which may be used by the ICE agent; these are typically STUN and/or TURN servers. If this isn't specified, the connection attempt will be made with no STUN or TURN server available, which limits the connection to local peers.
iceTransportPolicy
可选
RTCIceTransportPolicy
enumeration. If the policy isn't specified,
all
is assumed by default, allowing all candidates to be considered. A value of
relay
limits the candidates to those relayed through another server, such as a STUN or TURN server.
peerIdentity
可选
DOMString
which specifies the target peer identity for the
RTCPeerConnection
. If this value is set (it defaults to
null
),
RTCPeerConnection
will not connect to a remote peer unless it can successfully authenticate with the given name.
rtcpMuxPolicy
可选
RTCRtcpMuxPolicy
enum
。默认为
"require"
.
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.
|
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. |
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. |
The configuration below establishes two ICE servers. The first one,
stun:stun.services.mozilla.com
, requires authentication, so the username and password are provided. The second server has two URLs:
stun:stun.example.com
and
stun:stun-1.example.com
.
var configuration = { iceServers: [{
urls: "stun:stun.services.mozilla.com",
username: "louis@mozilla.com",
credential: "webrtcdemo"
}, {
urls: ["stun:stun.example.com", "stun:stun-1.example.com"]
}]
};
var pc = new RTCPeerConnection(configuration);
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCConfiguration' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCConfiguration
|
Chrome 23 | Edge ≤79 | Firefox ? | IE 不支持 No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android 57 | Firefox Android ? | Opera Android Yes | Safari iOS ? | Samsung Internet Android 7.0 |
bundlePolicy
|
Chrome 23 | Edge ≤79 | Firefox ? | IE 不支持 No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android 57 | Firefox Android ? | Opera Android Yes | Safari iOS ? | Samsung Internet Android 7.0 |
certificates
|
Chrome 23 | Edge ≤79 | Firefox ? | IE 不支持 No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android 57 | Firefox Android ? | Opera Android Yes | Safari iOS ? | Samsung Internet Android 7.0 |
iceCandidatePoolSize
|
Chrome 23 | Edge ≤79 | Firefox ? | IE 不支持 No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android 57 | Firefox Android ? | Opera Android Yes | Safari iOS ? | Samsung Internet Android 7.0 |
iceServers
|
Chrome 23 | Edge ≤79 | Firefox ? | IE 不支持 No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android 57 | Firefox Android ? | Opera Android Yes | Safari iOS ? | Samsung Internet Android 7.0 |
iceTransportPolicy
|
Chrome 23 | Edge ≤79 | Firefox ? | IE 不支持 No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android 57 | Firefox Android ? | Opera Android Yes | Safari iOS ? | Samsung Internet Android 7.0 |
peerIdentity
|
Chrome 23 | Edge ≤79 | Firefox ? | IE 不支持 No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android 57 | Firefox Android ? | Opera Android Yes | Safari iOS ? | Samsung Internet Android 7.0 |
rtcpMuxPolicy
|
Chrome
57
注意事项
|
Edge
≤79
注意事项
|
Firefox ? | IE 不支持 No |
Opera
44
注意事项
|
Safari ? | WebView Android Yes | Chrome Android 57 | Firefox Android ? | Opera Android Yes | Safari iOS ? | Samsung Internet Android 7.0 |
完整支持
不支持
兼容性未知
见实现注意事项。
RTCPeerConnection
RTCSessionDescription
RTCIceCandidate
RTCPeerConnectionIceEvent
RTCPeerConnectionIceErrorEvent
RTCCertificate
RTCRtpSender
RTCRtpReceiver
RTCRtpTransceiver
RTCDtlsTransport
RTCIceTransport
RTCTrackEvent
RTCSctpTransport
RTCDataChannel
RTCDataChannelEvent
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCStatsReport
RTCErrorEvent
RTCDTMFSender
:
tonechange
RTCDataChannel
:
bufferedamountlow
RTCDataChannel
:
close
RTCDataChannel
:
closing
RTCDataChannel
:
error
RTCDataChannel
:
message
RTCDataChannel
:
open
RTCDtlsTransport
:
error
RTCDtlsTransport
:
statechange
RTCIceTransport
:
error
RTCIceTransport
:
gatheringstatechange
RTCIceTransport
:
selectedcandidatepairchange
RTCIceTransport
:
statechange
RTCPeerConnection
:
connectionstatechange
RTCPeerConnection
:
datachannel
RTCPeerConnection
:
icecandidate
RTCPeerConnection
:
icecandidateerror
RTCPeerConnection
:
iceconnectionstatechange
RTCPeerConnection
:
icegatheringstatechange
RTCPeerConnection
:
negotiationneeded
RTCPeerConnection
:
signalingstatechange
RTCPeerConnection
:
track
RTCSctpTransport
:
error