RTCPeerConnection.remoteDescription

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

只读属性 RTCPeerConnection.remoteDescription 返回一个 RTCSessionDescription ,它描述了和远程对端之间的会话 (包括配置和媒体信息) ,如果还没有被设置过的话,它会是 null.

这个值通常是通过信令服务器接收的对端的会话描述(作为提议或应答),调用RTCPeerConnection.setRemoteDescription()之后生效。

语法

 var sessionDescription = peerConnection.remoteDescription;

从更基础的层面上看,如果该属性不为null,则返回值为RTCPeerConnection.pendingRemoteDescription的值,否则,返回RTCPeerConnection.currentRemoteDescription的值。有关此算法的详细信息及其使用原因,请参阅待定的和当前描述

示例

此示例查看remoteDescription并显示包含RTCSessionDescription对象的 type 和sdp字段的警告。

js
var pc = new RTCPeerConnection();var sd = pc.remoteDescription;
if (sd) {
  alert("Remote session: type='" +
        sd.type + "'; sdp description='" +
        sd.sdp + "'");
}
else {
  alert("No remote session yet.");
}

规范

Specification
WebRTC: Real-Time Communication in Browsers
# dom-peerconnection-remotedescription

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
remoteDescription

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见