The WebRTC API's
RTCIceCandidateStats
dictionary provides statistics related to an
RTCIceCandidate
.
RTCIceCandidateStats
is based upon the
RTCStats
dictionary, so it includes those properties in addition to the ones below.
address
可选
ip
and only accepted IP addresses.
candidateType
可选
RTCIceCandidateType
enumerated type, indicating what kind of candidate the object provides statistics for.
deleted
可选
false
. For local candidates, it's value is
true
if the candidate has been deleted or released. For host candidates,
true
means that any network resources (usually a network socket) associated with the candidate have already been released. For
TURN
candidates, the TURN allocation is no longer active for deleted candidates. This property is not present for remote candidates.
networkType
可选
RTCNetworkType
enumerated type which indicates the type of interface used for a local candidate. This property is only present for local candidates.
port
可选
The network port number used by the candidate.
priority
可选
RTCIceCandidate.priority
.
协议
可选
tcp
or
udp
) used to transmit data on the
port
.
relayProtocol
可选
tcp
,
udp
,和
tls
. Only present for local candidates.
transportId
可选
RTCTransportStats
associated with the candidate correspondin to these statistics.
url
可选
url
property is the
URL
的
ICE
server from which the candidate was received. This URL matches the one included in the
RTCPeerConnectionIceEvent
object representing the
icecandidate
event that delivered the candidate to the local peer.
This example features a function,
isUsableNetworkType()
, whose job it is to look at an
RTCIceCandidateStats
对象的
networkType
and determine whether or not the type of network is acceptable for use.
This function is then called for
RTCStats
objects whose type is
local-candidate
, indicating that the object is in fact an
RTCIceCandidateStats
with information about a local ICE candidate.
const isUsableNetworkType = stats => {
switch(stats.networkType) {
case "ethernet":
case "vpn":
return true;
case "bluetooth":
case "cellular":
case "wimax":
case "unknown":
默认:
return false;
}
}
if (rtcStats && rtcStats.type === "local-candidate") {
if (!isUsableNetworkType(rtcStats)) {
abortConnection();
return;
}
}
This code calls a function called
abortConnection()
若
RTCStats
object represents information about a local candidate is which would be using a network connection other than Ethernet or a VPN.
| 规范 | 状态 | 注释 |
|---|---|---|
|
Identifiers for WebRTC's Statistics API
The definition of 'RTCIceCandidateStats' in that specification. |
候选推荐 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCIceCandidateStats
|
Chrome No | Edge No | Firefox 27 | IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No | Firefox Android 27 | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
address
|
Chrome No | Edge No |
Firefox
65
|
IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No |
Firefox Android
65
|
Opera Android ? | Safari iOS ? | Samsung Internet Android No |
candidateType
|
Chrome No | Edge No | Firefox 27 | IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No | Firefox Android 27 | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
componentId
非标
|
Chrome No | Edge No |
Firefox
29
|
IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No |
Firefox Android
29
|
Opera Android ? | Safari iOS ? | Samsung Internet Android No |
deleted
|
Chrome No | Edge No | Firefox No | IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No | Firefox Android No | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
networkType
弃用
非标
|
Chrome No | Edge No | Firefox No | IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No | Firefox Android No | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
port
|
Chrome No | Edge No |
Firefox
27
Alternate Name
|
IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No |
Firefox Android
27
Alternate Name
|
Opera Android ? | Safari iOS ? | Samsung Internet Android No |
priority
|
Chrome No | Edge No | Firefox No | IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No | Firefox Android No | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
协议
|
Chrome No | Edge No |
Firefox
64
|
IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No |
Firefox Android
64
|
Opera Android ? | Safari iOS ? | Samsung Internet Android No |
relayProtocol
|
Chrome No | Edge No |
Firefox
64
|
IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No |
Firefox Android
64
|
Opera Android ? | Safari iOS ? | Samsung Internet Android No |
transportId
|
Chrome No | Edge No |
Firefox
31
Alternate Name
|
IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No |
Firefox Android
31
Alternate Name
|
Opera Android ? | Safari iOS ? | Samsung Internet Android No |
url
|
Chrome No | Edge No | Firefox No | IE No | Opera ? | Safari ? | WebView Android No | Chrome Android No | Firefox Android No | Opera Android ? | Safari iOS ? | Samsung Internet Android No |
完整支持
不支持
兼容性未知
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
见实现注意事项。
使用非标名称。
RTCIceCandidateStats
MediaDevices.getUserMedia()
Navigator.mediaDevices
RTCCertificate
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCDataChannel
RTCDataChannelEvent
RTCDtlsTransport
RTCErrorEvent
RTCIceCandidate
RTCIceTransport
RTCPeerConnection
RTCPeerConnectionIceErrorEvent
RTCPeerConnectionIceEvent
RTCRtpReceiver
RTCRtpSender
RTCRtpTransceiver
RTCSctpTransport
RTCSessionDescription
RTCStatsEvent
RTCStatsReport
RTCTrackEvent