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 AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic support
Experimental
Chrome Full support 56Edge Full support 15Firefox Full support 22IE ? Opera Full support 43
Notes
Full support 43
Notes
Notes Promise based version and unprefixed.
No support 38 — 43
Notes
Notes Promise based version.
Safari ? WebView Android Full support 56Chrome Android Full support 56Edge Mobile Full support YesFirefox Android Full support 44Opera Android Full support 43
Notes
Full support 43
Notes
Notes Promise based version and unprefixed.
No support 38 — 43
Notes
Notes Promise based version.
Safari iOS ? Samsung Internet Android Full support 6.0

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.

相关链接

文档标签和贡献者

此页面的贡献者: Tsui
最后编辑者: Tsui,