From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../setremotedescription/index.html | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 files/zh-cn/web/api/rtcpeerconnection/setremotedescription/index.html (limited to 'files/zh-cn/web/api/rtcpeerconnection/setremotedescription/index.html') diff --git a/files/zh-cn/web/api/rtcpeerconnection/setremotedescription/index.html b/files/zh-cn/web/api/rtcpeerconnection/setremotedescription/index.html new file mode 100644 index 0000000000..9e8db040bc --- /dev/null +++ b/files/zh-cn/web/api/rtcpeerconnection/setremotedescription/index.html @@ -0,0 +1,127 @@ +--- +title: RTCPeerConnection.setRemoteDescription() +slug: Web/API/RTCPeerConnection/setRemoteDescription +translation_of: Web/API/RTCPeerConnection/setRemoteDescription +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.setRemoteDescription() 方法改变与连接相关的描述,该描述主要是描述有些关于连接的属性,例如对端使用的解码器。 连接受此更改影响,并且必须能够支持旧的和新的描述。 方法带三个参数,{{domxref("RTCSessionDescription")}} 对象用于设置,然后是更改成功的回调方法,一个是更改失败的回调方法。

+ +

方法是异步的,不用等待设置完成,成功会调用成功回调方法,失败则会调用错误回调方法。

+ +

连接的offer通常来自于负责匹配的服务器所发送的数据。执行者应调用此方法设置远程描述,然后生成发送到对端计算机的answer。

+ +

语法

+ +
aPromise = pc.setRemoteDescription(sessionDescription);
+
+pc.setRemoteDescription(sessionDescription, successCallback, errorCallback);
+
+ +

这个方法没有返回值。

+ +

参数

+ +
+
sessionDescription
+
Is a {{domxref("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 {{domxref("DOMString")}} describing the reason why the description has not been set.
  • +
+
+
+ +

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

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-setRemoteDescription-void-RTCSessionDescription-description-VoidFunction-successCallback-RTCPeerConnectionErrorCallback-failureCallback', 'RTCPeerConnection.setRemoteDescription()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

Browser compatibility

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatVersionUnknown() }} [1]{{ CompatVersionUnknown }} [1]{{ CompatNo() }}{{ CompatVersionUnknown() }}{{ CompatUnknown() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatNo() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
+
+ +

[1] Though this property is not prefixed, the interface it belongs to is.

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf