RTCIceCandidateStats: deleted 属性
RTCIceCandidateStats 字典的 deleted 属性指示该候选者是否已被删除或释放。
值
一个布尔值,指示该候选者是否已被删除或释放。如果此值为 true,则 RTCIceCandidateStats 对象描述的候选者不再被考虑。确切的含义取决于候选者的类型
- 本地候选者
-
值为
true表示根据 RFC 5245, Section 8.3 的描述,该候选者已被删除。 - 主机候选者
-
值为
true表示该候选者的网络资源已释放。这通常意味着任何关联的套接字已关闭并释放。 - 远程 (TURN) 候选者
-
值为
true表示该候选者的 TURN 分配已不再激活。
最终结果是相同的;如果此值为 true,则该候选者不再被考虑。
示例
在此示例中,使用 setInterval() 设置一个定期运行的函数来显示候选者的最新统计信息。输出仅包含尚未被删除的候选者。
js
setInterval(() => {
myPeerConnection.getStats(null).then((stats) => {
let statsOutput = "";
stats.forEach((report) => {
if (
(stats.type === "local-candidate" ||
stats.type === "remote.candidate") &&
!stats.deleted
) {
statsOutput +=
`<h2>Report: ${report.type}</h3>\n<strong>ID:</strong> ${report.id}<br>\n` +
`<strong>Timestamp:</strong> ${report.timestamp}<br>\n`;
// Now the statistics for this report; we intentionally drop the ones we
// sorted to the top above
Object.keys(report).forEach((statName) => {
if (
statName !== "id" &&
statName !== "timestamp" &&
statName !== "type"
) {
statsOutput += `<strong>${statName}:</strong> ${report[statName]}<br>\n`;
}
});
}
});
document.querySelector(".stats-box").innerHTML = statsOutput;
});
}, 1000);
规范
此特性似乎未在任何规范中定义。浏览器兼容性
加载中…