RTCStatsReport

Draft: This page is not complete.

This page is currently incomplete and under active construction. Please be aware that it's not going to answer all of your questions just yet.

The RTCStatsReport interface provides a statistics report obtained by calling one of the RTCPeerConnection.getStats(), RTCRtpReceiver.getStats(), and RTCRtpSender.getStats() methods.

This statistics report contains a mapping of statistic category string names to objects containing the corresponding statistics data.

Calling getStats() on an RTCPeerConnection lets you specify whether you wish to obtain statistics for outbound, inbound, or all streams on the connection. The RTCRtpReceiver and RTCRtpSender versions of getStats() specifically only return statistics available to the incoming or outgoing stream on which you call them.

The statistics objects

For each category of statistic information, there is a dictionary whose properties provide the relevant information.

Properties common to all statistic categories

All WebRTC statistics objects are fundamentally based on the RTCStats dictionary, which provides the most fundamental information: the timestamp, the statistic type string, and an ID uniquely identifying the source of the data:

id

A DOMString 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 DOMString indicating the type of statistics the object contains, taken from the enum type RTCStatsType.

The statistic categories

The type gives the name of the statistic category represented by the object, and is how you locate the specific type of data you need. The statistic category names are members of the enumerated type RTCStatsType, as follows:

candidate-pair

An RTCIceCandidatePairStats object providing statistics related to an RTCIceTransport. Candidate pairs other than the currently active pair for the transport are deleted when the RTCPeerConnection changes its RTCPeerConnection.iceGatheringState to new 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 an RTCIceTransport.

codec

An RTCCodecStats object containing statistics about a codec currently being used by RTP streams to send or receive data for the RTCPeerConnection.

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 each RTCDataChannel 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 from RTCIceTransport.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's RTCPeerConnection.

receiver

Provides statistics about a specific RTCRtpReceiver. The statistics object is an RTCAudioReceiverStats object if kind is audio; if kind is video, the object is an RTCVideoReceiverStats object.

remote-candidate

The report is an RTCIceCandidateStats object containing statistics about the remote candidate's RTCIceTransport. 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 your outbound-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 the RTCPeerConnection. If kind is "audio", this object is of type RTCAudioSenderStats; if kind is "video", this is an RTCVideoSenderStats object.

stream

An object of type RTCMediaStreamStats, providing statistics and information about a MediaStream which is part of the RTCPeerConnection.

track

The object is one of the types based on RTCMediaHandlerStats: for audio tracks, the type is RTCSenderAudioTrackAttachmentStats and for video tracks, the type is RTCSenderVideoTrackAttachmentStats. The data within provides statistics related to a particular MediaStreamTrack's attachment to an RTCRtpSender; also included are the media level metrics that go along with the track.

transport

An object that contains statistics related to a transport for an RTCPeerConnection. The object is of type RTCTransportStats.

Using RTCStatsReport

... coming soon-ish ...

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
RTCStatsReport
58
79
27
No
45
11
58
58
27
43
11
7.0
entries
58
79
48
No
45
11
58
58
48
43
11
7.0
forEach
58
79
27
No
45
11
58
58
27
43
11
7.0
get
58
79
27
No
45
11
58
58
27
43
11
7.0
has
58
79
27
No
45
11
58
58
27
43
11
7.0
keys
58
79
48
No
45
11
58
58
48
43
11
7.0
size
59
79
48
No
46
11
59
59
48
43
11
7.0
values
58
79
48
No
45
11
58
58
48
43
11
7.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport