diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/rtcpeerconnection/setremotedescription/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/rtcpeerconnection/setremotedescription/index.html')
-rw-r--r-- | files/zh-cn/web/api/rtcpeerconnection/setremotedescription/index.html | 127 |
1 files changed, 127 insertions, 0 deletions
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 +--- +<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p> + +<p><code><strong>RTCPeerConnection.setRemoteDescription()</strong></code> 方法改变与连接相关的描述,该描述主要是描述有些关于连接的属性,例如对端使用的解码器。 连接受此更改影响,并且必须能够支持旧的和新的描述。 方法带三个参数,{{domxref("RTCSessionDescription")}} 对象用于设置,然后是更改成功的回调方法,一个是更改失败的回调方法。</p> + +<p>方法是异步的,不用等待设置完成,成功会调用成功回调方法,失败则会调用错误回调方法。</p> + +<p>连接的offer通常来自于负责匹配的服务器所发送的数据。执行者应调用此方法设置远程描述,然后生成发送到对端计算机的answer。</p> + +<h2 id="Syntax" name="Syntax">语法</h2> + +<pre>aPromise = pc.setRemoteDescription(<em>sessionDescription</em>); + +<code><em>pc</em>.setRemoteDescription(<em>sessionDescription</em>, <em>successCallback</em>, <em>errorCallback</em>); +</code></pre> + +<p><em>这个方法没有返回值。</em></p> + +<h3 id="Example" name="Example">参数</h3> + +<dl> + <dt><em>sessionDescription</em></dt> + <dd>Is a {{domxref("DOMString")}} is the description of the parameters to be applied to the remote session.</dd> + <dt><em>successCallback</em></dt> + <dd>Is a <code>Function</code> 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</dd> + <dt><em>errorCallback</em></dt> + <dd>Is a <code>RTCPeerConnectionErrorCallback</code> which will be called if the description can't be set. It takes the following parameter: + <ul> + <li><em>errorInformation </em>which is a {{domxref("DOMString")}} describing the reason why the description has not been set.</li> + </ul> + </dd> +</dl> + +<h2 id="Example" name="Example">Example</h2> + +<pre class="brush: js">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 + }) + }) +}); +</pre> + +<h2 id="Specifications" name="Specifications">Specifications</h2> + +<table class="standard-table" style="height: 49px; width: 1000px;"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-setRemoteDescription-void-RTCSessionDescription-description-VoidFunction-successCallback-RTCPeerConnectionErrorCallback-failureCallback', 'RTCPeerConnection.setRemoteDescription()') }}</td> + <td>{{ Spec2('WebRTC 1.0') }}</td> + <td>Initial specification.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{ CompatVersionUnknown() }} [1]</td> + <td>{{ CompatVersionUnknown }} [1]</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<p>[1] Though this property is not prefixed, the interface it belongs to is.</p> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/Web/Guide/API/WebRTC">WebRTC</a></li> +</ul> |