大网数据广告活动
Web 标准与前端开发

RTCIceCandidateStats

· 52CE 我爱测

The **`RTCIceCandidateStats`** dictionary of the WebRTC API is used to report statistics related to an RTCIceCandidate.

WebRTC

The RTCIceCandidateStats dictionary of the WebRTC API is used to report statistics related to an RTCIceCandidate.

The statistics can be obtained by iterating the RTCStatsReport returned by RTCPeerConnection.getStats() until you find a report with the type of local-candidate.

Instance properties

  • RTCIceCandidateStats.address
    • : 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. Corresponds to RTCIceCandidate.address.
  • RTCIceCandidateStats.candidateType
    • : A string matching one of the values in RTCIceCandidate.type, indicating what kind of candidate the object provides statistics for.
  • RTCIceCandidateStats.deleted
    • : A boolean indicating whether or not the candidate has been deleted or released.
  • RTCIceCandidateStats.foundation
    • : A string that uniquely identifies the candidate across multiple transports. Corresponds to RTCIceCandidate.foundation.
  • RTCIceCandidateStats.port
    • : The network port number used by the candidate. Corresponds to RTCIceCandidate.port.
  • RTCIceCandidateStats.priority
    • : The candidate's priority. Corresponds to RTCIceCandidate.priority.
  • RTCIceCandidateStats.protocol
    • : A string specifying the protocol (tcp or udp) used to transmit data on the port. Corresponds to RTCIceCandidate.protocol.
  • RTCIceCandidateStats.relayProtocol
    • : A string specifying the protocol being used by a local ICE candidate to communicate with the TURN server.
  • RTCIceCandidateStats.transportId
    • : A string uniquely identifying the transport object that was inspected in order to obtain the RTCTransportStats associated with the candidate corresponding to these statistics.
  • RTCIceCandidateStats.url
    • : A string specifying the URL of the ICE server from which the described candidate was obtained. This property is only available for local candidates.
  • RTCIceCandidateStats.usernameFragment
    • : A string containing the ICE username fragment ("ice-ufrag"). Corresponds to RTCIceCandidate.usernameFragment.

Common instance properties

The following properties are common to all WebRTC statistics objects.

  • RTCIceCandidateStats.id
    • : A string that uniquely identifies the object that is being monitored to produce this set of statistics.
  • RTCIceCandidateStats.timestamp
    • : A DOMHighResTimeStamp object indicating the time at which the sample was taken for this statistics object.
  • RTCIceCandidateStats.type
    • : A string with the value "local-candidate", indicating the type of statistics that the object contains.

Examples

Given a variable myPeerConnection, which is an instance of RTCPeerConnection, the code below uses await to wait for the statistics report, and then iterates it using RTCStatsReport.forEach(). It then filters the dictionaries for just those reports that have the type of local-candidate and logs the result.

const stats = await myPeerConnection.getStats();

stats.forEach((report) => {
  if (report.type === "local-candidate") {
    // Log the ICE candidate information
    console.log(report);
  }
});

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。