WebRTC Device API dictionary RTCConfiguration 's iceTransportPolicy property is a string indicating the transport selection policy the ICE agent should use during negotiation of connections. Its value must come from the RTCIceTransportPolicy enumerated type.

If this property isn't included in the RTCConfiguration , the default value, all , is used.

句法

let rtcConfiguration = {
  iceTransportPolicy: policy
};
rtcConfiguration.iceTransportPolicy = policy;
let policy = rtcConfiguration.iceTransportPolicy;
					

A DOMString which indicates what ICE candidate policy the ICE agent should use during the negotiation process, per the JSEP standard . The permitted values are:

all
The ICE agent is permitted to use any kind of candidate, including both local and relay candidates. The agent—or the browser itself—may still perform some form of IP filtering on the incoming candidates for reasons including privacy and security, as well as to simply limit the number of candidates. This is the default.
relay

The ICE agent only considers media relay candidates when evaluating candidates. This includes, for example, those candidates relayed by a STUN or TURN 服务器。

This can be used to prevent the remote endpoint from receiving the user's IP addresses, which may be important in some security situations. For example, in a video calling application, the app may want to prevent unknown callers from learning the callee's IP addresses until the callee has agreed to receive the call.

范例

In this example, a new connection is configured to only accept relay candidates.

let config = {
  iceServers: [
    {
      urls: [ "stun:stun.example.com" ]
    },
  ],
  iceTransportPolicy: "relay"
};
let pc = new RTCPeerConnection(config);
					

规范

规范 状态 注释
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCCandidate.iceTransportPolicy' in that specification.
候选推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

No compatibility data found. Please contribute data for "api.RTCCandidate.iceTransportPolicy" (depth: 1) to the MDN 兼容性数据存储库 .

元数据

  • 最后修改: