Skip to main content
Version: 5.3

Media statistics

WebPlanetKit provides an API to get recent media statistics. This page describe how to use the API and what type of information is provided for each media stream type.

Overview of media statistics

You can use the getCurrentStats() method to get some of the statistics from WebRTC statistics.

Tip

For more information on WebRTC statistics, see RTCStatsReport of the Mozilla documentation.

The getCurrentStats() method returns a WebPlanetKitStatistics object, which represents the statistics at the time of the API call. A WebPlanetKitStatistics object consists of OutboundRtpStats (outbound-rtp statistics) and InboundRtpStats (inbound-rtp statistics).

  • The outbound-rtp statistics include the audio and video statistics of the local user.
  • The inbound-rtp statistics include the audio and video statistics of one or more peers.

Detailed description of media statistics

The following statistical information is provided for each media stream type.

Tip

Outbound audio streams

For outbound audio streams (outbound-rtp audio), the following information is provided. You can find more detailed description in the links of each property.

PropertyDescription
kindThe media type of this stream
ssrcThe identifier of this stream
packetsSentThe total number of packets sent on this stream
bytesSentThe total number of bytes sent on this stream

Outbound video streams

For outbound video streams (outbound-rtp video), the following information is provided. You can find more detailed description in the links of each property.

PropertyDescription
kindThe media type of this stream
ssrcThe identifier of this stream
ridThe video resolution level in a group call
contentTypeIf this stream is for screen share, the value of this property will be screenshare. Otherwise, this property will not exist.
packetsSentThe total number of packets sent on this stream
bytesSentThe total number of bytes sent on this stream
firCountThe total number of Full Intra Request (FIR) packets on this stream
pliCountThe total number of Picture Loss Indication (PLI) packets on this stream
nackCountThe total number of Negative Acknowledgement (NACK) packets on this stream
frameWidthThe width of the video frame
frameHeightThe height of the video frame
framesSentThe total number of frames sent on this stream
framesPerSecondThe number of encoded frames during the last second
targetBitrateThe target bitrate for this stream

Inbound audio streams

For inbound audio streams (inbound-rtp audio), the following information is provided. You can find more detailed description in the links of each property.

PropertyDescription
kindThe media type of this stream
ssrcThe identifier of this stream
packetsReceivedThe total number of packets received on this stream
bytesReceivedThe total number of bytes received on this stream
packetsLostThe total number of packets lost on this stream
jitterThe variation in the delay of received packets

Inbound video streams

For inbound video streams (inbound-rtp video), the following information is provided. You can find more detailed description in the links of each property.

PropertyDescription
kindThe media type of this stream
ssrcThe identifier of this stream
packetsReceivedThe total number of packets received on this stream
bytesReceivedThe total number of bytes received on this stream
packetsLostThe total number of packets lost on this stream
jitterThe variation in the delay of received packets
firCountThe total number of FIR packets on this stream
pliCountThe total number of PLI packets on this stream
nackCountThe total number of NACK packets on this stream
frameWidthThe width of the video frame
frameHeightThe height of the video frame
framesReceivedThe total number of frames received on this stream
framesDecodedThe total number of frames decoded on this stream
framesDroppedThe total number of frames dropped on this stream
framesPerSecondThe number of decoded frames in the last second

Media statistics by call type

This section describes what type of statistics are provided for each call type.

1-to-1 call

OutboundRtpStats contains one audio stream statistic for the local user's audio transmission and one video stream statistic for the local user's video transmission. If the local user is doing screen share, OutboundRtpStats contains another video stream statistic for the local user's screen share.

InboundRtpStats contains one audio stream statistic and multiple video stream statistics for the peer.

Group call

OutboundRtpStats contains an audio stream statistic for the local user's audio transmission and three video stream statistics (one for each resolution level). If the local user is doing screen share, OutboundRtpStats contains another video stream statistic for the local user's screen share.

InboundRtpStats contains an audio stream statistic for the room and multiple video stream statistics for each peer.

Statistics for screen share

The statistics for screen share are included in OutboundRtpStats or InboundRtpStats as a video stream statistic.

Statistic of the local user's screen share

The statistic for the local user's screen share is included in OutboundRtpStats. Among video stream statistics, only the screen share statistic has contentType property and its value is screenshare.

Therefore, to obtain the statistics for the local user's screen share, get an object among OutboundRtpStats whose kind property is video and whose contentType property is screenshare.

planetKit.getCurrentStats().then((stats) => {
const outboundRtpStats = stats['outbound-rtp'];

outboundRtpStats.forEach((outboundRtpStat) => {
if (outboundRtpStat.kind === 'video' && outboundRtpStat.contentType === 'screenshare') {
// This outboundRtpStat is the statistics for the local user's screen share
}
});
})

Statistic of a peer's screen share

The statistics for one or more peers' screen share are included in InboundRtpStats.

In a 1-to-1 call, you can distinguish the statistics because the peer is specified, but in a group call, you must distinguish the statistics by ssrc.

In group calls, each peer has their own state information as PeerInfo, which includes properties such as vSsrc for video stream identifier and dSsrc for screen share identifier.

To obtain the statistics for a peer's screen share, get an object among InboundRtpStats whose kind property is video and whose ssrc property matches the peer's dSsrc value.

The following example code is the sample code for group calls.

planetKit.getCurrentStats().then((stats) => {
const inboundRtpStats = stats['inbound-rtp'];

const samplePeerInfo = planetKit.getPeerInfo('testPeerId');
inboundRtpStats.forEach((inboundRtpStat) => {
if (inboundRtpStat.kind === 'video' && inboundRtpStat.ssrc === samplePeerInfo.dSsrc) {
// This inboundRtpStat is the statistics for a peer's screen share
}
});
})

APIs related to media statistics are as follows: