RTCIceCandidate: component 属性
RTCIceCandidate 接口上只读的 component 属性是一个字符串,用于指示该候选是 RTP 候选还是 RTCP 候选。
如果一个候选代表了 RTP 和 RTCP 的联合多路复用,它将被报告为 RTP 候选。
值
一个字符串,其值是以下之一:
rtp-
标识正在用于 实时传输协议 (RTP) 或用于与 RTP 控制协议 (RTCP) 多路复用的 RTP 的 ICE 传输。RTP 在 RFC 3550 中定义。此值对应于
candidatea-line 中的 component ID 字段,值为 1。 rtcp-
标识用于 RTCP 的 ICE 传输,RTCP 在 RFC 3550, section 6 中定义。此值对应于 component ID 2。
用法说明
考虑以下 SDP 属性行 (a-line)
a=candidate:4234997325 1 udp 2043278322 192.0.2.172 44323 typ host
这是一行 ICE 候选 a-line,其 foundation 为 4234997325。a-line 中的下一个字段 "1" 是 component ID。值为 "1" 表示 RTP,它在 component 属性中记录为 "rtp"。如果该值而是 "2",则 a-line 将描述一个 RTCP 候选,此时 component 将为 "rtcp"。
示例
此代码片段检查候选的 component 类型,并根据值将候选分派给不同的处理程序。
js
if (candidate.component === "rtp") {
handleRTPCandidate(candidate);
} else if (candidate.component === "rtcp") {
handleRTCPCandidate(candidate);
} else {
handleUnknownCandidate(candidate);
}
规范
| 规范 |
|---|
| WebRTC:浏览器中的实时通信 # dom-rtcicecandidate-component |
浏览器兼容性
加载中…