RTCPeerConnection.remoteDescription

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

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

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

语法

 var sessionDescription = peerConnection.remoteDescription;

从更基础的层面上看,如果该属性不为null,则返回值为RTCPeerConnection.pendingRemoteDescription的值,否则,返回RTCPeerConnection.currentRemoteDescription的值。有关此算法的详细信息及其使用原因,请参阅Pending and current descriptions in WebRTC connectivity

示例

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

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.");
}

规范

标准 状态 说明
WebRTC 1.0: Real-time Communication Between Browsers
RTCPeerConnection.remoteDescription
Candidate Recommendation 初始化规范

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
remoteDescriptionChrome Full support 24Edge Full support 15Firefox Full support 22IE No support NoOpera Full support 43
Notes
Full support 43
Notes
Notes Promise-based version and unprefixed.
No support 38 — 43
Notes
Notes Promise-based version.
Safari Full support 11WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 44Opera Android Full support 43
Notes
Full support 43
Notes
Notes Promise-based version and unprefixed.
No support 41 — 43
Notes
Notes Promise-based version.
Safari iOS Full support YesSamsung Internet Android Full support 6.0

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.

相关链接