RTC Call Stats

Sometimes you need a way to capture certain metrics related to a call. This may be helpful if you want to tailor the experience to your users or debug issues. Typical metrics of interest are audio/video bitrate, round trip time, total consumed bandwidth and packet loss. 100ms SDK provides this data via dedicated delegate callbacks found in HMSUpdateListener. These will be called with a fixed interval of one second after a room has been joined. You can get stats on a per track basis (on(remoteAudioStats:track:peer)) or as an overall summary (on(rtcStats:))

Here is the full list of callbacks:

import { HMSUpdateListenerActions } from '@100mslive/react-native-hms'; // hms instance aquired from build method hmsInstance?.addEventListener( HMSUpdateListenerActions.ON_LOCAL_AUDIO_STATS, onChangeLocalAudioStats, ); hmsInstance?.addEventListener( HMSUpdateListenerActions.ON_LOCAL_VIDEO_STATS, onChangeLocalVideoStats, ); hmsInstance?.addEventListener( HMSUpdateListenerActions.ON_RTC_STATS, onChangeRtcStats, ); hmsInstance?.addEventListener( HMSUpdateListenerActions.ON_REMOTE_AUDIO_STATS, onChangeRemoteAudioStats, ); hmsInstance?.addEventListener( HMSUpdateListenerActions.ON_REMOTE_VIDEO_STATS, onChangeRemoteVideoStats, );

Enable RTC call stats

hmsInstance?.enableRTCStats();

Disable RTC call stats

hmsInstance?.disableRTCStats();

HMSRTCStatsReport

This class will contain the combined stats for the room.

class HMSRTCStats { // Total bytes sent in the current session. var bytesSent: UInt64 // Total bytes received in the current session. var bytesReceived: UInt64 // Total packets received in the current session. var packetsReceived: UInt64 // Total packets lost in the current session. var packetsLost: UInt64 // Total outgoing bitrate observed since previous report. var bitrateSent: Double // Total incoming bitrate observed since previous report in Kb/s. var bitrateReceived: Double // Average round trip time observed since previous report in Kb/s. var roundTripTime: Double } class HMSRTCStatsReport { // Combined audio + video values var combined: HMSRTCStats // Summary of all audio tracks var audio: HMSRTCStats // Summary of all video tracks var video: HMSRTCStats }

HMSLocalAudioStats

This class contains stats related to local audio track.

class HMSLocalAudioStats { // Round trip time observed since previous report. var roundTripTime: Double // Total bytes sent by this track in the current session. var bytesSent: UInt64 // Outgoing bitrate of this track observed since previous report in Kb/s. var bitrate: Double }

HMSLocalVideoStats

This class contains stats related to local video track.

class HMSLocalVideoStats { // Round trip time observed since previous report. var roundTripTime: Double // Total bytes sent by this track in the current session. var bytesSent: UInt64 // Outgoing bitrate of this track observed since previous report in Kb/s. var bitrate: Double // Resolution of video frames being sent. var resolution: HMSVideoResolution // Frame rate of video frames being sent (FPS). var frameRate: Double }

HMSRemoteAudioStats

This class contains stats related to remote audio track.

class HMSRemoteAudioStats { // Packet Jitter measured in seconds for this track. Calculated as defined in section 6.4.1. of RFC3550. var jitter: Double // Total bytes received by this track in the current session. var bytesReceived: UInt64 // Incoming bitrate of this track observed since previous report in Kb/s. var bitrate: Double // Total packets received by this track in the current session. var packetsReceived: UInt64 // Total packets lost by this track in the current session. var packetsLost: UInt64 }

HMSRemoteVideoStats

This class contains stats related to remote video track.

class HMSRemoteVideoStats { // Packet Jitter measured in seconds for this track. Calculated as defined in section 6.4.1. of RFC3550. var jitter: Double // Total bytes received by this track in the current session. var bytesReceived: UInt64 // Incoming bitrate of this track observed since previous report in Kb/s. var bitrate: Double // Total packets received by this track in the current session. var packetsReceived: UInt64 // Total packets lost by this track in the current session. var packetsLost: UInt64 // Resolution of video frames being received. var resolution: HMSVideoResolution // Frame rate of video frames being received (FPS). var frameRate: Double }