1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
---
title: RTCPeerConnection.remoteDescription
slug: Web/API/RTCPeerConnection/remoteDescription
tags:
- RTCPeerConnection
- WebRTC
- remoteDescription
- 中文
translation_of: Web/API/RTCPeerConnection/remoteDescription
---
<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p>
<p>只读属性 <code><strong>RTCPeerConnection.remoteDescription</strong></code> 返回一个 {{domxref("RTCSessionDescription")}} ,它描述了和远程对端之间的会话(包括配置和媒体信息) ,如果还没有被设置过的话,它会是 <code>null</code>.</p>
<p>这个值通常是通过信令服务器接收的对端的会话描述(作为提议或应答),调用{{domxref("RTCPeerConnection.setRemoteDescription()")}}之后生效。</p>
<h2 id="语法">语法</h2>
<pre> var <em>sessionDescription</em> = <em>peerConnection</em>.remoteDescription;</pre>
<p>从更基础的层面上看,如果该属性不为<code>null</code>,则返回值为{{domxref("RTCPeerConnection.pendingRemoteDescription")}}的值,否则,返回{{domxref("RTCPeerConnection.currentRemoteDescription")}}的值。有关此算法的详细信息及其使用原因,请参阅{{SectionOnPage("/en-US/docs/Web/API/WebRTC_API/Connectivity", "Pending and current descriptions")}}。</p>
<h2 id="示例">示例</h2>
<p>此示例查看<code>remoteDescription</code>并显示包含{{domxref("RTCSessionDescription")}}对象的<font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">type</span></font>和<code>sdp</code>字段的警告。</p>
<pre class="brush:js">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.");
}
</pre>
<h2 id="Specifications" name="Specifications">规范</h2>
<table class="standard-table" style="height: 49px; width: 1000px;">
<thead>
<tr>
<th scope="col">标准</th>
<th scope="col">状态</th>
<th scope="col">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-remoteDescription', 'RTCPeerConnection.remoteDescription') }}</td>
<td>{{ Spec2('WebRTC 1.0') }}</td>
<td>初始化规范</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.RTCPeerConnection.remoteDescription")}}</p>
<h2 id="相关链接">相关链接</h2>
<ul>
<li>{{domxref("RTCPeerConnection.setRemoteDescription()")}}, {{domxref("RTCPeerConnection.pendingRemoteDescription")}}, {{domxref("RTCPeerConnection.currentRemoteDescription")}}</li>
<li>{{domxref("RTCPeerConnection.setLocalDescription()")}}, {{domxref("RTCPeerConnection.pendingLocalDescription")}}, {{domxref("RTCPeerConnection.currentLocalDescription")}}, {{domxref("RTCPeerConnection.localDescription")}}</li>
<li><a href="/en-US/docs/Web/Guide/API/WebRTC">WebRTC</a></li>
</ul>
|