RTCPeerConnection()

这篇翻译不完整。请帮忙从英语翻译这篇文章

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

RTCPeerConnection()构造函数,返回一个新建的  RTCPeerConnection实例,它代表了本地端机器与远端机器的一条连接。

语法

pc = new RTCPeerConnection([configuration]);

参数

configuration 可选
一个RTCConfiguration dictionary 提供了一条新建连接的可选参数。

RTCConfiguration dictionary

bundlePolicy Optional
Specifies how to handle negotiation of candidates when the remote peer is not compatible with the SDP BUNDLE standard. This must be one of the values from the enum RTCBundlePolicy. If this value isn't included in the dictionary, "balanced" is assumed.
certificates Optional
An Array of objects of type RTCCertificate which are used by the connection for authentication. If this property isn't specified, a set of certificates is generated automatically for each RTCPeerConnection instance. Although only one certificate is used by a given connection, providing certificates for multiple algorithms may improve the odds of successfully connecting in some circumstances. See Using certificates below for additional information.
This configuration option cannot be changed after it is first specified; once the certificates have been set, this property is ignored in future calls to RTCPeerConnection.setConfiguration().
iceCandidatePoolSize Optional
An unsigned 16-bit integer value which specifies the size of the prefetched ICE candidate pool. The default value is 0 (meaning no candidate prefetching will occur). You may find in some cases that connections can be established more quickly by allowing the ICE agent to start fetching ICE candidates before you start trying to connect, so that they're already available for inspection when RTCPeerConnection.setLocalDescription() is called.
Changing the size of the ICE candidate pool may trigger the beginning of ICE gathering.
iceServers Optional
An array of RTCIceServer objects, each describing one server which may be used by the ICE agent; these are typically STUN and/or TURN servers. If this isn't specified, the ICE agent may choose to use its own ICE servers; otherwise, the connection attempt will be made with no STUN or TURN server available, which limits the connection to local peers.
iceTransportPolicy Optional
The current ICE transport policy; this must be one of the values from the RTCIceTransportPolicy enum. If this isn't specified, "all" is assumed.
peerIdentity Optional
A DOMString which specifies the target peer identity for the RTCPeerConnection. If this value is set (it defaults to null), the RTCPeerConnection will not connect to a remote peer unless it can successfully authenticate with the given name.
rtcpMuxPolicy Optional
The RTCP mux policy to use when gathering ICE candidates, in order to support non-multiplexed RTCP. The value must be one of those from the RTCRtcpMuxPolicy enum. The default is "require".

返回值

一个新生成的 RTCPeerConnection 对象, 如果指定了配置信息,它按照指定配置进行配置,否则,它将按照基本配置进行配置。

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
RTCPeerConnection()
Working Draft Initial definition.

浏览器支持性

特性 Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) 22 (22) ? ? ?
iceCandidatePoolSize 59 ? ? ? ? ?
特性 Android Webview Chrome for Android Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 (Yes) (Yes) 24.0 (24) ? ? ? ?
iceCandiatePoolSize 未实现 59 ? ? ? ? ? ?

引申阅读

文档标签和贡献者

 此页面的贡献者: ztacesa
 最后编辑者: ztacesa,