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:
/// This callback provides stats for a local audio track. optional func on(localAudioStats: HMSLocalAudioStats, track: HMSLocalAudioTrack, peer: HMSPeer) /// This callback provides stats for a local video track. In case of simulcast enabled room /// the localVideoStats param will contain an entry for each simulcast layer. optional func on(localVideoStats: [HMSLocalVideoStats], track: HMSLocalVideoTrack, peer: HMSPeer) /// This callback provides stats for a remote audio track. optional func on(remoteAudioStats: HMSRemoteAudioStats, track: HMSRemoteAudioTrack, peer: HMSPeer) /// This callback provides stats for a remote video track. optional func on(remoteVideoStats: HMSRemoteVideoStats, track: HMSRemoteVideoTrack, peer: HMSPeer) /// This callback provides combined stats for the session. optional func on(rtcStats: HMSRTCStatsReport)
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 seconds. 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 // Simulcast layer id in case of simulcast enabled room. See HMSSimulcastLayer enum for possible values var simulcastLayerId: NSNumber? }
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 }