RTCPeerConnection: remoteDescription 屬性
RTCPeerConnection 介面的只讀屬性 remoteDescription 返回一個 RTCSessionDescription 物件,該物件描述了連線的遠端端的會話(包括配置和媒體資訊)。如果尚未設定,則此屬性為 null。
返回的值通常反映了透過信令伺服器接收到的遠端描述(作為 offer 或 answer),然後透過您的程式碼響應式地呼叫 RTCPeerConnection.setRemoteDescription() 來生效。
值
更根本地說,返回值是 RTCPeerConnection.pendingRemoteDescription 的值(如果該屬性不為 null);否則,將返回 RTCPeerConnection.currentRemoteDescription 的值。有關此演算法及其使用原因的詳細資訊,請參閱 WebRTC 連線頁面中的 掛起和當前描述。
示例
此示例檢視 remoteDescription 並顯示一個包含 RTCSessionDescription 物件的 type 和 sdp 欄位的警報。
js
const pc = new RTCPeerConnection();
// …
const sd = pc.remoteDescription;
if (sd) {
alert(`Remote session: type='${sd.type}'; sdp description='${sd.sdp}'`);
} else {
alert("No remote session yet.");
}
規範
| 規範 |
|---|
| WebRTC:瀏覽器中的即時通訊 # dom-peerconnection-remotedescription |
瀏覽器相容性
載入中…