RTCIceServer
dictionary defines how to connect to a single ICE server (such as a
STUN
or
TURN
server). Objects of this type are provided in the
configuration
of an
RTCPeerConnection
, in the
iceServers
数组。
credential
可选
RTCIceServer
represents a TURN server.
credentialType
可选
RTCIceServer
represents a TURN server, this attribute specifies what kind of
credential
is to be used when connecting. This must be one of the values defined by the
RTCIceCredentialType
枚举。默认为
password
.
urls
DOMString
or an array of
DOMString
s, each specifying a URL which can be used to connect to the server.
username
可选
RTCIceServer
is a TURN server, then this is the username to use during the authentication process.
Avoid specifying an unnecessarily large number of URLs in the
urls
property; the startup time for your connection will go up substantially. Every server in the list will be contacted and tried out before one is selected to be used for negotiation.
Older versions of the WebRTC specification included an
url
property instead of
urls
; this was changed in order to let you specify multiple addresses for each server in the list, as shown in the example below.
The following properties have been removed from the specification and should not be used.
url
urls
代替。
Because many older books and examples still use this, we include it to help developers update their code or make sense of older examples.
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);
Once the configuration object has been created, it is passed into the
RTCPeerConnection()
constructor to use it as the configuration for the new peer connection.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCIceServer
|
Chrome Yes | Edge ≤79 | Firefox 22 | IE 不支持 No | Opera ? | Safari ? | WebView Android 不支持 No | Chrome Android Yes | Firefox Android 24 | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
credential
|
Chrome Yes | Edge ≤79 | Firefox 22 | IE 不支持 No | Opera ? | Safari ? | WebView Android 不支持 No | Chrome Android Yes | Firefox Android 24 | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
credentialType
|
Chrome Yes | Edge ≤79 | Firefox 47 | IE 不支持 No | Opera ? | Safari ? | WebView Android 不支持 No | Chrome Android Yes | Firefox Android 47 | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
url
弃用
|
Chrome Yes | Edge ≤79 | Firefox 22 | IE 不支持 No | Opera ? | Safari ? | WebView Android 不支持 No | Chrome Android Yes | Firefox Android 24 | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
urls
|
Chrome Yes | Edge ≤79 | Firefox 37 | IE 不支持 No | Opera ? | Safari ? | WebView Android 不支持 No | Chrome Android Yes | Firefox Android 37 | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
username
|
Chrome Yes | Edge ≤79 | Firefox 23 | IE 不支持 No | Opera ? | Safari ? | WebView Android 不支持 No | Chrome Android Yes | Firefox Android 24 | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
完整支持
不支持
兼容性未知
弃用。不要用于新网站。
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