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 |
瀏覽器相容性
載入中…