RTCPeerConnection()
constructor returns a newly-created
RTCPeerConnection
, which represents a connection between the local device and a remote peer.
pc = new RTCPeerConnection([configuration]);
configuration
可选
RTCConfiguration
dictionary
providing options to configure the new connection.
bundlePolicy
可选
RTCBundlePolicy
. If this value isn't included in the dictionary,
"balanced"
is assumed.
certificates
可选
数组
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
可选
RTCPeerConnection.setLocalDescription()
被调用。
Changing the size of the ICE candidate pool may trigger the beginning of ICE gathering.
iceServers
可选
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 connection attempt will be made with no STUN or TURN server available, which limits the connection to local peers.
iceTransportPolicy
可选
RTCIceTransportPolicy
enum. If this isn't specified,
"all"
is assumed.
peerIdentity
可选
DOMString
which specifies the target peer identity for the
RTCPeerConnection
. If this value is set (it defaults to
null
),
RTCPeerConnection
will not connect to a remote peer unless it can successfully authenticate with the given name.
rtcpMuxPolicy
可选
RTCRtcpMuxPolicy
enum
。默认为
"require"
.
A newly-created
RTCPeerConnection
object, configured as described by
configuration
, if specified; otherwise, configured to appropriate basic defaults.
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection()' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCPeerConnection()
构造函数
|
Chrome
23
|
Edge ≤18 | Firefox 22 | IE No |
Opera
43
|
Safari ? |
WebView Android
Yes
|
Chrome Android
Yes
|
Firefox Android 44 |
Opera Android
43
|
Safari iOS ? | Samsung Internet Android 6.0 |
完整支持
不支持
兼容性未知
见实现注意事项。
RTCPeerConnection
RTCPeerConnection
RTCPeerConnection()
canTrickleIceCandidates
connectionState
currentLocalDescription
currentRemoteDescription
getDefaultIceServers()
iceConnectionState
iceGatheringState
localDescription
onaddstream
onconnectionstatechange
ondatachannel
onicecandidate
oniceconnectionstatechange
onicegatheringstatechange
onidentityresult
onidpassertionerror
onidpvalidationerror
onnegotiationneeded
onpeeridentity
onremovestream
onsignalingstatechange
ontrack
peerIdentity
pendingLocalDescription
pendingRemoteDescription
remoteDescription
sctp
signalingState
addIceCandidate()
addStream()
addTrack()
close()
createAnswer()
createDataChannel()
createOffer()
generateCertificate()
getConfiguration()
getIdentityAssertion()
getReceivers()
getSenders()
getStats()
getStreamById()
getTransceivers()
removeStream()
removeTrack()
restartIce()
setConfiguration()
setIdentityProvider()
setLocalDescription()
setRemoteDescription()
MediaDevices.getUserMedia()
Navigator.mediaDevices
RTCCertificate
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCDataChannel
RTCDataChannelEvent
RTCDtlsTransport
RTCErrorEvent
RTCIceCandidate
RTCIceTransport
RTCPeerConnectionIceErrorEvent
RTCPeerConnectionIceEvent
RTCRtpReceiver
RTCRtpSender
RTCRtpTransceiver
RTCSctpTransport
RTCSessionDescription
RTCStatsReport
RTCTrackEvent