blob: 96c84962482c12f343c5d1bd7a8fbff56a5a1034 (
plain)
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
|
---
title: RTCPeerConnection.getDefaultIceServers()
slug: Web/API/RTCPeerConnection/getDefaultIceServers
translation_of: Web/API/RTCPeerConnection/getDefaultIceServers
---
<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p>
<p>{{domxref("RTCPeerConnection")}} 接口的方法 <code><strong>getDefaultIceServers()</strong></code> 返回一个基于 {{domxref("RTCIceServer")}} 字典的对象数组。如果在 {{domxref("RTCPeerConnection")}} 的 {{domxref("RTCConfiguration")}} 中没有设置,该数组指向浏览器缺省使用的ICE servers,前提是浏览器确实存在缺省的ICE servers。然而,浏览器完全不必提供任何的缺省ICE Servers。</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox"> var <em>defaultIceServers</em> = <em>RTCPeerConnection</em>.getDefaultIceServers();</pre>
<h3 id="返回值">返回值</h3>
<p>一个 ICE servers 的数组,以基于 {{domxref("RTCIceServer")}} 的对象组成,当没有在 {{domxref("RTCPeerConnection")}} 的设置中进行设置时,浏览器将使用它们。如果浏览器没有提供缺省值,将返回一个空数组,该属性的值永远不是 <code>null</code>。</p>
<h2 id="例子">例子</h2>
<pre class="brush: js">var pc = new RTCPeerConnection();
var iceServers = pc.getDefaultIceServers();
if (iceServers.length === 0) {
// Deal with the lack of default ICE servers, possibly by using our own defaults
}</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://w3c.github.io/webrtc-extensions/#dom-rtcpeerconnection-getdefaulticeservers">WebRTC Extensions</a></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("api.RTCPeerConnection.getDefaultIceServers")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="/en-US/docs/Web/Guide/API/WebRTC">WebRTC</a></li>
<li>{{domxref("RTCConfiguration")}}</li>
</ul>
|