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 GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
remoteDescription |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.