RTCIceCandidateStats - Web APIs 编辑

The WebRTC API's RTCIceCandidateStats dictionary provides statistics related to an RTCIceCandidate.

Properties

RTCIceCandidateStats is based upon the RTCStats dictionary, so it includes those properties in addition to the ones below.

address Optional
A string containing the address of the candidate. This value may be an IPv4 address, an IPv6 address, or a fully-qualified domain name. This property was previously named ip and only accepted IP addresses.
candidateType Optional
A string matching one of the values in the RTCIceCandidateType enumerated type, indicating what kind of candidate the object provides statistics for.
deleted Optional
A Boolean value indicating whether or not the candidate has been released or deleted; the default value is 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 Optional
A string from the RTCNetworkType enumerated type which indicates the type of interface used for a local candidate. This property is only present for local candidates.
port Optional
The network port number used by the candidate.
priority Optional
The candidate's priority, corresponding to RTCIceCandidate.priority.
protocol Optional
A string specifying the protocol (tcp or udp) used to transmit data on the port.
relayProtocol Optional
A string identifying the protocol used by the endpoint for communicating with the TURN server; valid values are tcp, udp, and tls. Only present for local candidates.
transportId Optional
A string uniquely identifiying the transport object that was inspected in order to obtain the RTCTransportStats associated with the candidate correspondin to these statistics.
url Optional
For local candidates, the url property is the URL of the 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.

Example

This example features a function, isUsableNetworkType(), whose job it is to look at an RTCIceCandidateStats object's 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":
    default:
      return false;
  }
}

if (rtcStats && rtcStats.type === "local-candidate") {
  if (!isUsableNetworkType(rtcStats)) {
    abortConnection();
    return;
  }
}

This code calls a function called abortConnection() if the RTCStats object represents information about a local candidate is which would be using a network connection other than Ethernet or a VPN.

Specifications

SpecificationStatusComment
Identifiers for WebRTC's Statistics API
The definition of 'RTCIceCandidateStats' in that specification.
Candidate RecommendationInitial specification.

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:82 次

字数:6723

最后编辑:8 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文