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

RTCIceCandidateStats: priority property

· 52CE 我爱测

The **`priority`** property of the RTCIceCandidateStats dictionary is a positive integer value indicating the priority (or desirability) of the described candidate.

WebRTC

The priority property of the RTCIceCandidateStats dictionary is a positive integer value indicating the priority (or desirability) of the described candidate.

Value

A positive integer indicating the priority of the RTCIceCandidate described by the RTCIceCandidateStats object. The value may be anywhere from 1 to 2,147,483,647.

Description

During ICE negotiation while setting up a WebRTC peer connection, the priority values reported to the remote peer by a user agent are used to determine which candidates are considered "more desirable". The higher the value, the more desirable the candidate is.

Determining priority

The ICE specification describes how user agents and other software using WebRTC should calculate the priority. The priority of a candidate is calculated using the following variables as inputs:

  • The preferability of the candidate type (local, server reflexive, peer reflexive, or relayed)
  • The preferability of the candidate's specific IP address (for multihomed agents)
  • The candidate's component ID (1 for RTP, 2 for RTCP)

The candidate's priority is computed using the formula (p<sub>type</sub> is the priority of the candidate's type and p<sub>local</sub> is the priority of the IP address):

<math display="block"> <semantics><mrow><mi mathvariant="italic">priority</mi><mo>=</mo><msup><mn>2</mn><mn>24</mn></msup><mo>×</mo><msub><mi>p</mi><mrow><mi>type</mi></mrow></msub><mo>+</mo><msup><mn>2</mn><mn>8</mn></msup><mo>×</mo><msub><mi>p</mi><mrow><mi>local</mi></mrow></msub><mo>+</mo><mo stretchy="false">(</mo><mn>256</mn><mo>-</mo><mi mathvariant="italic">componentID</mi><mo stretchy="false">)</mo></mrow><annotation encoding="TeX">\mathit{priority} = 2^{24} \times p_{type} + 2^{8} \times p_{local} + \left(\right. 256 - \mathit{componentID} \left.\right)</annotation></semantics> </math>

This is equivalent to mapping the priorities of the candidate type, the local IP, and the component ID into various bit ranges within the 32-bit priority value.

Specifications

Browser compatibility

See also

  • : Recommended Formula section in the ICE specification

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

资料来源与适用范围

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

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

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