RTCPeerConnection.setRemoteDescription() - Web API 接口参考 编辑
这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
RTCPeerConnection.setRemoteDescription()
方法改变与连接相关的描述,该描述主要是描述有些关于连接的属性,例如对端使用的解码器。 连接受此更改影响,并且必须能够支持旧的和新的描述。 方法带三个参数,RTCSessionDescription
对象用于设置,然后是更改成功的回调方法,一个是更改失败的回调方法。
方法是异步的,不用等待设置完成,成功会调用成功回调方法,失败则会调用错误回调方法。
连接的offer通常来自于负责匹配的服务器所发送的数据。执行者应调用此方法设置远程描述,然后生成发送到对端计算机的answer。
语法
aPromise = pc.setRemoteDescription(sessionDescription);
pc.setRemoteDescription(sessionDescription, successCallback, errorCallback);
这个方法没有返回值。
参数
- sessionDescription
- Is a
DOMString
is the description of the parameters to be applied to the remote session. - successCallback
- Is a
Function
without parameter which will be called when the description has been successfully set. At this point, one can send the offer to a remote server that can forward it to a remote client - errorCallback
- Is a
RTCPeerConnectionErrorCallback
which will be called if the description can't be set. It takes the following parameter:- errorInformation which is a
DOMString
describing the reason why the description has not been set.
- errorInformation which is a
Example
var pc = new PeerConnection();
pc.setRemoteDescription( new RTCSessionDescription( offer ), function() {
pc.createAnswer( function( answer ) {
pc.setLocalDescription( answer, function() {
// send the answer to the remote connection
})
})
});
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers RTCPeerConnection.setRemoteDescription() | Candidate Recommendation | Initial specification. |
Browser compatibility
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | (Yes) [1] | (Yes) [1] | 未实现 | (Yes) | ? |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | ? | ? | ? | 未实现 | ? | ? |
[1] Though this property is not prefixed, the interface it belongs to is.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论