RTCStatsReport

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

* Some parts of this feature may have varying levels of support.

RTCStatsReport 接口提供了通过调用 RTCPeerConnection.getStats()RTCRtpReceiver.getStats()RTCRtpSender.getStats() 这三个方法之一所获得的统计报告。

该统计报告包含统计类别字符串名称到包含相应统计数据的对象的映射。

RTCPeerConnection 上调用 getStats() 可以让你指定是否希望获取连接上的出站、入站或是所有流的统计信息。getStats()RTCRtpReceiverRTCRtpSender 版本仅返回你调用它们的传入或传出流的统计信息。

统计对象

对于每种统计信息类别,都有一个字典,字典的属性提供相关信息。

所有统计类别共有的属性

所有 WebRTC 统计对象都基于 RTCStats 字典,该字典提供了最基本的信息:时间戳、统计类型字符串和唯一标识数据源的 ID。

统计类别

type 值给出了对象所代表的统计类别的名称。以及如何查找你需要的特定数据的类型。

规范

Specification
WebRTC: Real-Time Communication in Browsers
# rtcstatsreport-object

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
RTCStatsReport
[Symbol.iterator]
entries
forEach
get
has
keys
size
candidate-pair stats
availableOutgoingBitrate in 'candidate-pair' stats
bytesDiscardedOnSend in 'candidate-pair' stats
Experimental
bytesReceived in 'candidate-pair' stats
bytesSent in 'candidate-pair' stats
consentRequestsSent in 'candidate-pair' stats
Experimental
currentRoundTripTime in 'candidate-pair' stats
id in 'candidate-pair' stats
lastPacketReceivedTimestamp in 'candidate-pair' stats
lastPacketSentTimestamp in 'candidate-pair' stats
localCandidateId in 'candidate-pair' stats
nominated in 'candidate-pair' stats
packetsDiscardedOnSend in 'candidate-pair' stats
Experimental
packetsReceived in 'candidate-pair' stats
Experimental
packetsSent in 'candidate-pair' stats
Experimental
priority in 'candidate-pair' stats
DeprecatedNon-standard
remoteCandidateId in 'candidate-pair' stats
requestsReceived in 'candidate-pair' stats
requestsSent in 'candidate-pair' stats
responsesReceived in 'candidate-pair' stats
responsesSent in 'candidate-pair' stats
state in 'candidate-pair' stats
timestamp in 'candidate-pair' stats
totalRoundTripTime in 'candidate-pair' stats
transportId in 'candidate-pair' stats
type in 'candidate-pair' stats
certificate stats
base64Certificate in 'certificate' stats
fingerprint in 'certificate' stats
fingerprintAlgorithm in 'certificate' stats
id in 'certificate' stats
timestamp in 'certificate' stats
type in 'certificate' stats
codec stats
channels in 'codec' stats
clockRate in 'codec' stats
id in 'codec' stats
mimeType in 'codec' stats
payloadType in 'codec' stats
sdpFmtpLine in 'codec' stats
timestamp in 'codec' stats
transportId in 'codec' stats
type in 'codec' stats
data-channel stats
bytesReceived in 'data-channel' stats
bytesSent in 'data-channel' stats
dataChannelIdentifier in 'data-channel' stats
id in 'data-channel' stats
label in 'data-channel' stats
messagesReceived in 'data-channel' stats
messagesSent in 'data-channel' stats
protocol in 'data-channel' stats
state in 'data-channel' stats
timestamp in 'data-channel' stats
type in 'data-channel' stats
inbound-rtp stats
audioLevel in 'inbound-rtp' stats
bytesReceived in 'inbound-rtp' stats
codecId in 'inbound-rtp' stats
concealedSamples in 'inbound-rtp' stats
concealmentEvents in 'inbound-rtp' stats
fecPacketsDiscarded in 'inbound-rtp' stats
fecPacketsReceived in 'inbound-rtp' stats
frameHeight in 'inbound-rtp' stats
frameWidth in 'inbound-rtp' stats
framesDecoded in 'inbound-rtp' stats
framesPerSecond in 'inbound-rtp' stats
framesReceived in 'inbound-rtp' stats
headerBytesReceived in 'inbound-rtp' stats
id in 'inbound-rtp' stats
insertedSamplesForDeceleration in 'inbound-rtp' stats
jitter in 'inbound-rtp' stats
jitterBufferDelay in 'inbound-rtp' stats
jitterBufferEmittedCount in 'inbound-rtp' stats
jitterBufferMinimumDelay in 'inbound-rtp' stats
Experimental
jitterBufferTargetDelay in 'inbound-rtp' stats
Experimental
keyFramesDecoded in 'inbound-rtp' stats
Experimental
kind in 'inbound-rtp' stats
lastPacketReceivedTimestamp in 'inbound-rtp' stats
mid in 'inbound-rtp' stats
nackCount in 'inbound-rtp' stats
packetsDiscarded in 'inbound-rtp' stats
packetsLost in 'inbound-rtp' stats
packetsReceived in 'inbound-rtp' stats
playoutId in 'inbound-rtp' stats
Experimental
qpSum in 'inbound-rtp' stats
type_inbound-rtp.remoteId
removedSamplesForAcceleration in 'inbound-rtp' stats
silentConcealedSamples in 'inbound-rtp' stats
ssrc in 'inbound-rtp' stats
timestamp in 'inbound-rtp' stats
totalAudioEnergy in 'inbound-rtp' stats
totalDecodeTime in 'inbound-rtp' stats
totalInterFrameDelay in 'inbound-rtp' stats
totalProcessingDelay in 'inbound-rtp' stats
totalSamplesDuration in 'inbound-rtp' stats
totalSamplesReceived in 'inbound-rtp' stats
totalSquaredInterFrameDelay in 'inbound-rtp' stats
trackIdentifier in 'inbound-rtp' stats
transportId in 'inbound-rtp' stats
type in 'inbound-rtp' stats
local-candidate stats
address in 'local-candidate' stats
candidateType in 'local-candidate' stats
foundation in 'local-candidate' stats
Experimental
id in 'local-candidate' stats
port in 'local-candidate' stats
priority in 'local-candidate' stats
protocol in 'local-candidate' stats
timestamp in 'local-candidate' stats
transportId in 'local-candidate' stats
type in 'local-candidate' stats
usernameFragment in 'local-candidate' stats
Experimental
media-playout stats
id in 'media-playout' stats
Experimental
kind in 'media-playout' stats
Experimental
synthesizedSamplesDuration in 'media-playout' stats
Experimental
synthesizedSamplesEvents in 'media-playout' stats
Experimental
timestamp in 'media-playout' stats
Experimental
totalPlayoutDelay in 'media-playout' stats
Experimental
totalSamplesCount in 'media-playout' stats
Experimental
totalSamplesDuration in 'media-playout' stats
Experimental
type in 'media-playout' stats
Experimental
media-source stats
audioLevel in 'media-source' stats
Experimental
frames in 'media-source' stats for video
framesPerSecond in 'media-source' stats for video
height in 'media-source' stats for video
id in 'media-source' stats
kind in 'media-source' stats
timestamp in 'media-source' stats
totalAudioEnergy in 'media-source' stats
Experimental
totalSamplesDuration in 'media-source' stats
Experimental
trackIdentifier in 'media-source' stats
type in 'media-source' stats
width in 'media-source' stats for video
outbound-rtp stats
active in 'outbound-rtp' stats
Experimental
bytesSent in 'outbound-rtp' stats
codecId in 'outbound-rtp' stats
frameHeight in 'outbound-rtp' stats
frameWidth in 'outbound-rtp' stats
framesEncoded in 'outbound-rtp' stats
framesPerSecond in 'outbound-rtp' stats
framesSent in 'outbound-rtp' stats
headerBytesSent in 'outbound-rtp' stats
id in 'outbound-rtp' stats
keyFramesEncoded in 'outbound-rtp' stats
Experimental
kind in 'outbound-rtp' stats
mediaSourceId in 'outbound-rtp' stats
mid in 'outbound-rtp' stats
nackCount in 'outbound-rtp' stats
packetsSent in 'outbound-rtp' stats
qpSum in 'outbound-rtp' stats
qualityLimitationDurations in 'outbound-rtp' stats
Experimental
qualityLimitationReason in 'outbound-rtp' stats
Experimental
remoteId in 'outbound-rtp' stats
retransmittedBytesSent in 'outbound-rtp' stats
retransmittedPacketsSent in 'outbound-rtp' stats
rid in 'outbound-rtp' stats
scalabilityMode in 'outbound-rtp' stats
Experimental
ssrc in 'outbound-rtp' stats
targetBitrate in 'outbound-rtp' stats
timestamp in 'outbound-rtp' stats
totalEncodeTime in 'outbound-rtp' stats
totalEncodedBytesTarget in 'outbound-rtp' stats
Experimental
totalPacketSendDelay in 'outbound-rtp' stats
transportId in 'outbound-rtp' stats
type in 'outbound-rtp' stats
peer-connection stats
dataChannelsClosed in 'peer-connection' stats
dataChannelsOpened in 'peer-connection' stats
id in 'peer-connection' stats
timestamp in 'peer-connection' stats
type in 'peer-connection' stats
remote-candidate stats
address in 'remote-candidate' stats
candidateType in 'remote-candidate' stats
foundation in 'remote-candidate' stats
Experimental
id in 'remote-candidate' stats
port in 'remote-candidate' stats
priority in 'remote-candidate' stats
protocol in 'remote-candidate' stats
timestamp in 'remote-candidate' stats
transportId in 'remote-candidate' stats
type in 'remote-candidate' stats
usernameFragment in 'remote-candidate' stats
Experimental
remote-inbound-rtp stats
codecId in 'remote-inbound-rtp' stats
fractionLost in 'remote-inbound-rtp' stats
id in 'remote-inbound-rtp' stats
jitter in 'remote-inbound-rtp' stats
kind in 'remote-inbound-rtp' stats
localId in 'remote-inbound-rtp' stats
packetsLost in 'remote-inbound-rtp' stats
packetsReceived in 'remote-inbound-rtp' stats
Experimental
roundTripTime in 'remote-inbound-rtp' stats
roundTripTimeMeasurements in 'remote-inbound-rtp' stats
ssrc in 'remote-inbound-rtp' stats
timestamp in 'remote-inbound-rtp' stats
totalRoundTripTime in 'remote-inbound-rtp' stats
transportId in 'remote-inbound-rtp' stats
type in 'remote-inbound-rtp' stats
remote-outbound-rtp stats
bytesSent in 'remote-outbound-rtp' stats
codecId in 'remote-outbound-rtp' stats
id in 'remote-outbound-rtp' stats
kind in 'remote-outbound-rtp' stats
localId in 'remote-outbound-rtp' stats
packetsSent in 'remote-outbound-rtp' stats
remoteTimestamp in 'remote-outbound-rtp' stats
reportsSent in 'remote-outbound-rtp' stats
Experimental
roundTripTimeMeasurements in 'remote-outbound-rtp' stats
Experimental
ssrc in 'remote-outbound-rtp' stats
timestamp in 'remote-outbound-rtp' stats
totalRoundTripTime in 'remote-outbound-rtp' stats
Experimental
transportId in 'remote-outbound-rtp' stats
type in 'remote-outbound-rtp' stats
transport stats
bytesReceived in 'transport' stats
bytesSent in 'transport' stats
dtlsCipher in 'transport' stats
dtlsRole in 'transport' stats
Experimental
dtlsState in 'transport' stats
iceLocalUsernameFragment in 'transport' stats
Experimental
iceRole in 'transport' stats
Experimental
iceState in 'transport' stats
Experimental
id in 'transport' stats
localCertificateId in 'transport' stats
packetsReceived in 'transport' stats
Experimental
packetsSent in 'transport' stats
Experimental
remoteCertificateId in 'transport' stats
selectedCandidatePairChanges in 'transport' stats
selectedCandidatePairId in 'transport' stats
srtpCipher in 'transport' stats
timestamp in 'transport' stats
tlsVersion in 'transport' stats
type in 'transport' stats
values

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
Uses a non-standard name.
Requires a vendor prefix or different name for use.
Has more compatibility info.

参见