RTCDtlsTransport
interface provides access to information about the Datagram Transport Layer Security (
DTLS
) transport over which a
RTCPeerConnection
's
RTP
and
RTCP
packets are sent and received by its
RTCRtpSender
and
RTCRtpReceiver
对象。
A DTLS transport is also used to provide information about SCTP packets transmitted and received by an connection's data channels .
Features of the DTLS transport include the addition of security to the underlying transport; the
RTCDtlsTransport
interface can be used to obtain information about the underlying transport and the security added to it by the DTLS layer.
<div id="interfaceDiagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 11.666666666666666%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 70" preserveAspectRatio="xMinYMin meet"><a xlink:href="../API/RTCDtlsTransport" target="_top"><rect x="1" y="1" width="160" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="81" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">RTCDtlsTransport</text></a></svg></div>
a:hover text { fill: #0095DD; pointer-events: all;}
iceTransport
只读
RTCDtlsTransport
property
iceTransport
contains a reference to the underlying
RTCIceTransport
.
state
只读
state
只读特性在
RTCDtlsTransport
interface provides information which describes a Datagram Transport Layer Security (
DTLS
) transport state.
This interface has no methods.
RTCDtlsTransport
objects are created when an app calls either
setLocalDescription()
or
setRemoteDescription()
. The number of DTLS transports created and how they're used depends on the bundling mode used when creating the
RTCPeerConnection
.
Whether bundling is used depends on what the other endpoint is able to negotiate. All browsers support bundling, so when both endpoints are browsers, you can rest assured that bundling will be used.
Some non-browser legacy endpoints, however, may not support bundle. To be able to negotiate with such endpoints (or to exclude them entirely), the
RTCConfiguration
property
bundlePolicy
may be provided when creating the connection. The
bundlePolicy
lets you control
how to negotiate with these legacy endpoints. The default policy is
"balanced"
, which provides a balance between performance and compatibility.
For example, to create the connection using the highest level of bundling:
const rtcConfig = {
bundlePolicy: "max-bundle"
};
const pc = new RTCPeerConnection(rtcConfig);
捆绑
lets you use one
RTCDtlsTransport
to carry the data for multiple higher-level transports, such as multiple
RTCRtpTransceiver
。
When the connection is created without using BUNDLE, each RTP or RTCP component of each
RTCRtpTransceiver
has its own
RTCDtlsTransport
; that is, every
RTCRtpSender
and
RTCRtpReceiver
, has its own transport, and all
RTCDataChannel
objects share a transport dedicated to SCTP.
When the connection is using BUNDLE, each
RTCDtlsTransport
object represents a group of
RTCRtpTransceiver
objects. If the connection was created using
max-compat
mode, each transport is responsible for handling all of the communications for a given type of media (audio, video, or data channel). Thus, a connection that has any number of audio and video channels will always have exactly one DTLS transport for audio and one for video communications.
Because transports are established early in the negotiation process, it's likely that it won't be known until after they're created whether or not the remote peer supports bundling or not. For this reason, you'll sometimes see separate transports created at first, one for each track, then see them get bundled up once it's known that bundling is possible. If your code accesses
RTCRtpSender
s and/or
RTCRtpReceiver
s directly, you may encounter situations where they're initially separate, then half or more of them get closed and the senders and receivers updated to refer to the appropriate remaining
RTCDtlsTransport
对象。
RTCDataChannel
s use
SCTP
to communicate. All of a peer connection's data channels share a single
RTCSctpTransport
, found in the connection's
sctp
特性。
You can, in turn, identify the
RTCDtlsTransport
used to securely encapsulate the data channels' SCTP communications by looking at the
RTCSctpTransport
对象的
transport
特性。
This example presents a function,
tallySenders()
, which iterates over an
RTCPeerConnection
's
RTCRtpSender
s, tallying up how many of them are in various states. The function returns an object containing properties whose values indicate how many of the senders are in each state.
let pc = new RTCPeerConnection({ bundlePolicy: "max-bundle" });
/* ... */
function tallySenders(pc) {
let results = {
transportMissing: 0,
connectionPending: 0,
connected: 0,
closed: 0,
failed: 0,
unknown: 0
};
let senderList = pc.getSenders();
senderList.forEach(sender => {
let transport = sender.transport;
if (!transport) {
results.transportMissing++;
} else {
switch(transport.state) {
case "new":
case "connecting":
results.connectionPending++;
break;
case "connected":
results.connected++;
break;
case "closed":
results.closed++;
break;
case "failed":
results.failed++;
break;
默认:
results.unknown++;
break;
}
}
});
return results;
}
Note that in this code, the
new
and
connecting
states are being treated as a single
connectionPending
status in the returned object.
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCDtlsTransport' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCDtlsTransport
|
Chrome 72 | Edge 12 |
Firefox
No
|
IE No | Opera 60 | Safari No | WebView Android 72 | Chrome Android 72 |
Firefox Android
No
|
Opera Android 50 | Safari iOS No | Samsung Internet Android 11.0 |
getRemoteCertificates
|
Chrome 72 | Edge 12 |
Firefox
No
|
IE No | Opera 60 | Safari No | WebView Android 72 | Chrome Android 72 |
Firefox Android
No
|
Opera Android 50 | Safari iOS No | Samsung Internet Android 11.0 |
iceTransport
|
Chrome 72 |
Edge
15
Alternate Name
|
Firefox
No
|
IE No | Opera 60 | Safari No | WebView Android 72 | Chrome Android 72 |
Firefox Android
No
|
Opera Android 50 | Safari iOS No | Samsung Internet Android 11.0 |
onerror
|
Chrome 72 | Edge 12 |
Firefox
No
|
IE No | Opera 60 | Safari No | WebView Android 72 | Chrome Android 72 |
Firefox Android
No
|
Opera Android 50 | Safari iOS No | Samsung Internet Android 11.0 |
onstatechange
|
Chrome 72 |
Edge
12
Alternate Name
|
Firefox
No
|
IE No | Opera 60 | Safari No | WebView Android 72 | Chrome Android 72 |
Firefox Android
No
|
Opera Android 50 | Safari iOS No | Samsung Internet Android 11.0 |
state
|
Chrome 72 | Edge 12 |
Firefox
No
|
IE No | Opera 60 | Safari No | WebView Android 72 | Chrome Android 72 |
Firefox Android
No
|
Opera Android 50 | Safari iOS No | Samsung Internet Android 11.0 |
statechange
event
|
Chrome 72 |
Edge
12
Alternate Name
|
Firefox
No
|
IE No | Opera 60 | Safari No | WebView Android 72 | Chrome Android 72 |
Firefox Android
No
|
Opera Android 50 | Safari iOS No | Samsung Internet Android 11.0 |
完整支持
不支持
见实现注意事项。
使用非标名称。
RTCPeerConnection
RTCSessionDescription
RTCIceCandidate
RTCPeerConnectionIceEvent
RTCPeerConnectionIceErrorEvent
RTCCertificate
RTCRtpSender
RTCRtpReceiver
RTCRtpTransceiver
RTCDtlsTransport
RTCIceTransport
RTCTrackEvent
RTCSctpTransport
RTCDataChannel
RTCDataChannelEvent
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCStatsReport
RTCErrorEvent
RTCDTMFSender
:
tonechange
RTCDataChannel
:
bufferedamountlow
RTCDataChannel
:
close
RTCDataChannel
:
closing
RTCDataChannel
:
error
RTCDataChannel
:
message
RTCDataChannel
:
open
RTCDtlsTransport
:
error
RTCDtlsTransport
:
statechange
RTCIceTransport
:
error
RTCIceTransport
:
gatheringstatechange
RTCIceTransport
:
selectedcandidatepairchange
RTCIceTransport
:
statechange
RTCPeerConnection
:
connectionstatechange
RTCPeerConnection
:
datachannel
RTCPeerConnection
:
icecandidate
RTCPeerConnection
:
icecandidateerror
RTCPeerConnection
:
iceconnectionstatechange
RTCPeerConnection
:
icegatheringstatechange
RTCPeerConnection
:
negotiationneeded
RTCPeerConnection
:
signalingstatechange
RTCPeerConnection
:
track
RTCSctpTransport
:
error