RTCStatsReport
草案: 本页尚未完工.
该页面目前尚不完整,正在建设中。 请注意,它还不能解答您所有的问题。RTCStatsReport
接口提供了通过调用 RTCPeerConnection.getStats()
(en-US), RTCRtpReceiver.getStats()
(en-US),和 RTCRtpSender.getStats()
(en-US) 这三个方法之一所获得的统计报告。该统计报告包含统计类别字符串名称到包含相应统计数据的对象的映射。
在 RTCPeerConnection
上调用 getStats()
可以指定是希望获取连接上的出站,入站还是所有流的统计信息。 getStats()
的 RTCRtpReceiver
(en-US) 和 RTCRtpSender
(en-US) 版本仅返回可用于调用它们的传入或传出流的统计信息。
统计对象
对于每种统计信息类别,都有一个字典,字典的属性提供相关信息。
所有统计类别共有的属性
所有 WebRTC 统计对象都基于 RTCStats
字典,该字典提供了最基本的信息:时间戳,统计类型字符串和唯一标识数据源的ID:
id
-
A string which uniquely identifies the object which was inspected to produce this object based on
RTCStats
. timestamp
-
A
DOMHighResTimeStamp
object indicating the time at which the sample was taken for this statistics object. type
-
A string indicating the type of statistics the object contains, taken from the enum type
RTCStatsType
.
统计类别
type
(en-US) 给出了对象所代表的统计类别的名称,以及如何查找所需的特定数据类型。统计类别名称是枚举类 RTCStatsType
(en-US) 的成员,如下所示:
candidate-pair
-
An
RTCIceCandidatePairStats
object providing statistics related to anRTCIceTransport
. Candidate pairs other than the currently active pair for the transport are deleted when theRTCPeerConnection
changes itsRTCPeerConnection.iceGatheringState
tonew
during an ICE restart. The active candidate pair is deleted after the transport switches to another candidate pair; this change cannot be detected otherwise. certificate
-
An
RTCCertificateStats
object providing statistics related to a certificate being used by anRTCIceTransport
. codec
-
An
RTCCodecStats
object containing statistics about a codec currently being used by RTP streams to send or receive data for theRTCPeerConnection
. csrc
-
An
RTCContributingSourceStats
object which contains statistics related to a contributing source (CSRC) that contributed to an inbound RTP stream. data-channel
-
An
RTCDataChannelStats
object which contains statistics about eachRTCDataChannel
on the connection. inbound-rtp
-
An
RTCInboundRtpStreamStats
object providing statistics about inbound data being received from remote peers. Since this only provides statistics related to inbound data, without considering the local peer's state, any values that require knowledge of both, such as round-trip time, is not included. This report isn't available if there are no connected peers. local-candidate
-
An
RTCIceCandidateStats
object giving statistics about an ICE local candidate; these candidates are found in the output fromRTCIceTransport.getLocalCandidates()
. outbound-rtp
-
The report is an
RTCOutboundRtpStreamStats
object providing statistics based on the local peer's outgoing data being sent to its peers. This information considers only the outbound RTP stream, so any data which requires information about the state of the remote peers (such as round-trip time) is unavailable, since those values can't be computed without knowing about the other peers' states. peer-connection
-
A
RTCPeerConnectionStats
object provides statistics related to the overall peer connection'sRTCPeerConnection
. receiver
-
Provides statistics about a specific
RTCRtpReceiver
. The statistics object is anRTCAudioReceiverStats
object ifkind
isaudio
; ifkind
isvideo
, the object is anRTCVideoReceiverStats
object. remote-candidate
-
The report is an
RTCIceCandidateStats
object containing statistics about the remote candidate'sRTCIceTransport
. This may include information such as the type of network, the protocol, the URL, the type of relay being used, and so forth. remote-inbound-rtp
-
The report is an
RTCRemoteInboundRtpStreamStats
object providing statistics about your outbound RTP data stream, but from the perspective of the remote peer. That is, this information is about youroutbound-rtp
stream, but as seen by the remote device that's handling the stream. You can use this information to do things like determine how well the remote peer is receiving data. remote-outbound-rtp
-
The report is an
RTCRemoteOutboundRtpStreamStats
object that contains statistics about your inbound RTP (inbound-rtp
) stream, but from the perspective of the remote peer. sender
-
An object containing statistics about the
RTCRtpSender
for a stream on theRTCPeerConnection
. Ifkind
is"audio"
, this object is of typeRTCAudioSenderStats
; ifkind
is"video"
, this is anRTCVideoSenderStats
object. stream
Deprecated-
An object of type
RTCMediaStreamStats
, providing statistics and information about aMediaStream
which is part of theRTCPeerConnection
. track
Deprecated-
The object is one of the types based on
RTCMediaHandlerStats
: for audio tracks, the type isRTCSenderAudioTrackAttachmentStats
and for video tracks, the type isRTCSenderVideoTrackAttachmentStats
. The data within provides statistics related to a particularMediaStreamTrack
's attachment to anRTCRtpSender
; also included are the media level metrics that go along with the track.
Note: All "track" stats have been made obsolete. The relevant metrics have been moved to "media-source", "sender", "outbound-rtp", "receiver" and "inbound-rtp" stats.
transport
-
An object that contains statistics related to a transport for an
RTCPeerConnection
. The object is of typeRTCTransportStats
.
使用 RTCStatsReport
... 即将到来 ...
规范
标准 | 状态 | 说明 |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers RTCStatsReport |
Candidate Recommendation | 初始规范 |
浏览器兼容性
BCD tables only load in the browser