RTCConfiguration dictionary's bundlePolicy property is a string value indicating which SDP bundling policy, if any, to use for the underlying RTP streams used by an RTCPeerConnection .

The configuration object is used as an input to the RTCPeerConnection() 构造函数。

句法

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

A DOMString identifying the SDP bundling policy to use for the RTP streams used by the RTCPeerConnection . This string, which must be a member of the RTCBundlePolicy enumeration, has the following possible values:

balanced
The ICE agent begins by creating one RTCDtlsTransport to handle each type of content added: one for audio, one for video, and one for the RTC data channel, if applicable. If the remote peer isn't BUNDLE-aware, the ICE agent chooses one audio track and one video track and those two tracks are each assigned to the corresponding RTCDtlsTransport . All other tracks are ignored by the connection. This is the default, and most compatible, policy.
max-compat
The ICE agent intially creates one RTCDtlsTransport for each media track and a separate one for the RTCDataChannel , if one is created. If the remote endpoint can't handle bundling, each media track is negotiated on its own separate transport. This introduces bundling but will fall back to not bundling if the remote peer can't handle it.
max-bundle
The ICE agent starts by creating a single RTCDtlsTransport to handle all of the connection's media. If the remote peer isn't bundle-compatible, only one media track is negotiated and the rest are ignored. This maximizes bundling at the risk of losing tracks if the remote peer can't do bundling.

If any other value is specified, no configuration is specified when creating the RTCPeerConnection , or if the bundlePolicy property isn't included in the RTCConfiguration object specified when creating the connection, balanced is assumed.

描述

bundlePolicy configuration option for an RTCPeerConnection specifies how the ICE agent should handle negotiation if the remote peer isn't compatible with the SDP BUNDLE standard . If the remote peer is bundle compatible, the policy is moot and all media tracks and the data channel are bundled onto a single RTCDtlsTransport at the completion of the negotiation process. Any other transports that were used during negotiation are then closed.

In technical terms, an SDP BUNDLE lets all of the media tracks (identified in the SDP from the m= lines) stream between two peers across a single 5-tuple , that is, from a single IP and port on one peer to a single IP and port on another peer, all using the same RTCDtlsTransport .

The goal of bundling is to optimize performance by reducing the overhead of having multiple transports in play. The fewer RTP transports or bundles of RTP streams you have, the better the network performance will be.

All current major browsers are BUNDLE compatible.

范例

The following example creates a new RTCPeerConnection with a configuration setting the connection's bundlePolicy to max-compat to maximize compatibility while attempting to optimize network use. It also specifies stun:stun.example.com 作为 STUN server for ICE to use during negotiation.

let config = {
  iceServers: [
    {
      urls: [ "stun:stun.example.com" ]
    },
  ],
  bundlePolicy: "max-compat"
};
let pc = new RTCPeerConnection(config);
					

规范

规范 状态 注释
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCConfiguration.bundlePolicy' 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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
bundlePolicy Chrome 23 Edge ≤79 Firefox ? IE 不支持 No Opera Yes Safari ? WebView Android Yes Chrome Android 57 Firefox Android ? Opera Android Yes Safari iOS ? Samsung Internet Android 7.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: