RTCPeerConnection.currentLocalDescription

翻译不完整。 请帮助我们翻译这篇文章!

只读属性 RTCPeerConnection.currentLocalDescription 返回一个 RTCSessionDescription 对象,该对象描述了 自上次 RTCPeerConnection 完成协商与连接到远程端后,最近一次成功协商的连接的本地端。原文(describing the local end of the connection as it was most recently successfully negotiated since the last time the RTCPeerConnection finished negotiating and connecting to a remote peer)。也包括自RTCSessionDescription所代表的offer或anwser首次实例化以来,ICE代理可能已经生成的任何ICE候选人的列表。

若想改变 currentLocalDescription ,则调用 RTCPeerConnection.setLocalDescription() 。这将会触发引发该值被设置的一系列事件。 如果希望详细了解策略与机制,查阅 Pending and current descriptions in WebRTC connectivity

RTCPeerConnection.localDescription 不同, 这个值代表了当前连接的本地端的事实当前状态; localDescription 也许指明了一个当前正在切换中的连接的description。

语法

sessionDescription = RTCPeerConnection.currentLocalDescription;

返回值

连接本地端的当前description描述,如果成功设置了一个。否则返回null。

例子

本例子查看 currentLocalDescription 并且显示了包含 RTCSessionDescription 对象的 type 与 sdp 字段的alert。

var pc = new RTCPeerConnection();
…
var sd = pc.currentLocalDescription;
if (sd) {
  alert("Local session: type='" +         
        sd.type + "'; sdp description='" +
        sd.sdp + "'");
}
else {
  alert("No local session yet.");
}

参数类别

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
RTCPeerConnection.currentLocalDescription
Candidate Recommendation Initial specification.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
currentLocalDescriptionChrome Full support 70Edge Full support ≤18Firefox Full support 22IE No support NoOpera Full support 43
Notes
Full support 43
Notes
Notes Promise-based version.
No support 37 — 43
Safari Full support 11WebView Android Full support 70Chrome Android Full support 70Firefox Android Full support 44Opera Android Full support 43
Notes
Full support 43
Notes
Notes Promise-based version.
No support 37 — 43
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.

The addition of currentLocalDescription and pendingLocalDescription to the WebRTC spec is relatively recent. In browsers which don't support them, just use localDescription.

参阅