RTCIceCandidate:foundation 属性
Baseline 2024Newly available
Since May 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
RTCIceCandidate
接口的 foundation
只读属性是一个用于在多个传输中标识唯一候选者的字符串。
因此,foundation
属性可用于关联出现在多个 RTCIceTransport
对象上的候选者。
值
在所有可用的 RTCIceTransport
对象上标识唯一候选者的字符串。
备注:
如果候选者 port
(端口)的值为 null
,并且用户代理支持 port
,将这个候选者传递给 addIceCandidate()
时将失败,并抛出 OperationError
异常。
使用说明
考虑描述 ICE 候选者的 SDP 属性行(a-line)如下:
a=candidate:4234997325 1 udp 2043278322 192.0.2.172 44323 typ host
字段 "4234997325"
为 foundation 属性。
示例
下面的代码片段使用两个候选者的 foundation
来确定它们是否实际上是同一个候选者
js
if (candidate1.foundation === candidate2.foundation) {
/* 即使是在不同的 transport(传输器), 这也是相同的候选者 */
}
规范
Specification |
---|
WebRTC: Real-Time Communication in Browsers # dom-rtcicecandidate-foundation |