Global

Members

(constant) RTCStatsInsightEvents

Enum for event references of RTCStatsInsight

Properties:
Name Type Description
audio-rtt EnumItem

RTT of sending audio.

video-rtt EnumItem

RTT of sending audio.

audio-jitter EnumItem

Jitter about sending audio.

video-jitter EnumItem

Jitter about sending video.

audio-fractionLost EnumItem

Packet loss rate of receiving audio stream.

video-fractionLost EnumItem

Packet loss rate of receiving video stream.

audio-jitterBufferDelay EnumItem

Local jitter buffer delay about receiving audio.

video-jitterBufferDelay EnumItem

Local jitter buffer delay about receiving video.

rtt EnumItem

Current RTT for ICE transport.

Example
import {
  RTCStatsInsightEvents,
  RTCStatsInsight
} from 'rtcstats-wrapper';

const insight = new RTCStatsInsight(sender);

insight.on(RTCStatsInsightEvents["audio-rtt"].key, event => {
  console.log(event.level);
});

insight.watch()

(constant) RTCStatsReferences

Enum for stats object references

Properties:
Name Type Description
RTCCodecs EnumItem

Reference for stats of the codecs.

RTCInboundRtpVideoStreams EnumItem

Reference for stats represents the incoming RTP video streams. In general, there is one RTCInboundRtpVideoStreams corresponding to one MediaStream that receives video tracks.

RTCInboundRtpAudioStreams EnumItem

Reference for stats represents the incoming RTP audio streams.

RTCOutboundRtpVideoStreams EnumItem

Reference for stats represents the outgoing RTP video streams.

RTCOutboundRtpAudioStreams EnumItem

Reference for stats represents the outgoing RTP audio streams.

RTCRemoteInboundRtpVideoStreams EnumItem

Reference for stats represents the metrics reported in RR or XR corresponding to sending video streams.

RTCRemoteInboundRtpAudioStreams EnumItem

Reference for stats represents the metrics reported in RR or XR corresponding to sending audio streams.

RTCRemoteOutboundRtpVideoStreams EnumItem

Reference for stats represents the metrics reported in SR corresponding to receiving video streams.

RTCRemoteOutboundRtpAudioStreams EnumItem

Reference for stats represents the metrics reported in SR corresponding to receiving audio streams.

RTCVideoSources EnumItem

Reference for stats represents video tracks which are attached to one or more sender.

RTCAudioSources EnumItem

Reference for stats represents audio tracks which are attached to one or more sender.

RTCRtpContributingSources EnumItem

Reference for stats represents CSRCs contributing to an incoming RTP stream.

RTCPeerConnection EnumItem

Reference for stats which have the record of datachannels establishment.

RTCDataChannels EnumItem

Reference for stats of the data channels.

RTCMediaStreams EnumItem

Reference for stats of the media streams.

RTCVideoSenders EnumItem

Reference for stats represents the sender of one video track.

RTCAudioSenders EnumItem

Reference for stats represents the sender of one audio track.

RTCVideoReceivers EnumItem

Reference for stats represents the receiver of one video track.

RTCAudioReceivers EnumItem

Reference for stats represents the receiver of one audio track.

RTCTransports EnumItem

Reference for stats represents ICE and DTLS transport.

RTCIceCandidatePairs EnumItem

Reference for stats represents ICE candidate pairs, includes deleted or unnominate pairs.

RTCLocalIceCandidates EnumItem

Reference for stats represents local ICE candidates.

RTCRemoteIceCandidates EnumItem

Reference for stats represents remote ICE candidates.

RTCCertificates EnumItem

Reference for stats of certificates used by an ICE transports.

RTCStunServerConnections EnumItem

Reference for stats of transports between STUN and TURN servers.

Example
import {
  ChromeRTCStatsReport,
  RTCStatsReferences
} from 'rtcstats-wrapper';

const report = new BaseRTCStatsReport(await pc.getStats());

// get stats of incoming RTP stream
const recvVideoStats = report.get(RTCStatsReferences.RTCInboundRtpVideoStreams.key)

// get each log of inbound-rtp
for (const stats of recvVideoStats) {
  logger.info(JSON.stringify(stats));
}

(constant) StatusLevels

Enum for levels of RTCStatsInsightEvents.

Properties:
Name Type Description
stable EnumItem

The call is stable.

unstable EnumItem

The call is unstable and may communicated in low quality.

critical EnumItem

Highly affected on call quality.

unknown EnumItem

This level is for unmonitored metrics.

Example
import {
  StatusLevels,
  RTCStatsInsightEvents,
  RTCStatsInsight
} from 'rtcstats-wrapper';

const insight = new RTCStatsInsight(sender);

insight.on(RTCStatsInsightEvents["audio-rtt"].key, event => {
  if (event.level === StatusLevels.stable.key) {
    console.log("Now back to stable!");
  }
});

insight.watch()

Methods

standardizeReport(report) → {RTCStatsReport}

A function that ditects the browser and returns an instance of this library's standardized RTCStatsReport.

Parameters:
Name Type Description
report RTCStatsReport

original stats report from (pc|sender|receiver).getStats().

Returns:
Type:
RTCStatsReport

A standardized RTCStatsReport. See example to get how to use.

Example
import {
  standardizeReport,
  RTCStatsReferences
} from 'rtcstats-wrapper';

const report = standardizeReport(await pc.getStats());
const receiverStats = report.get(RTCStatsReferences.RTCVideoReceivers.key);
const framesDecoded = receiverStats[0].framesDecoded;

Type Definitions

EnumItem

Represents an Item of an Enum.

Properties:
Name Type Description
key String

The Enum key.

value Number

The Enum value.

See:

MomentaryReport

Properties:
Name Type Description
send.video.jitter Number

A jitter in seconds given in RR.

send.video.rtt Number

An rtt in seconds given in RR.

send.video.averageEncodeTime Number

Estimated average encode time in milliseconds.

send.video.qpValue Number

Estimated QP(quantize parameter) value.

send.video.bitrate Number

Estimated bit/sec about sending video.

send.audio.jitter Number

A jitter in seconds given in RR.

send.audio.rtt Number

An rtt in seconds given in RR.

send.audio.bitrate Number

Estimated bit/sec about sending audio.

receive.video.jitterBufferDelay Number

Estimated delay from jitter buffer, measured in seconds.

receive.video.fractionLost Number

Estimated Rate of packet loss.

receive.video.qpValue Number

Estimated QP(quantize parameter) value.

receive.video.bitrate Number

Estimated bit/sec about receiving video.

receive.audio.audioLevel Number

The audio level of the receiving track.

receive.audio.jitterBufferDelay Number

Estimated delay from jitter buffer, measured in seconds.

receive.audio.fractionLost Number

Estimated Rate of packet loss.

receive.audio.bitrate Number

Estimated bit/sec about receiving audio.

candidatePair.rtt Number

An round-trip time in seconds computed from STUN connectivity checks.

candidatePair.downstreamBitrate Number

Estimated bit/sec about receiving data.

candidatePair.upstreamBitrate Number

Estimated bit/sec about sending data.

Example
{
  send: {
    video: {
      jitter: 0.008,
      rtt: 0.002,
      averageEncodeTime: 0.0026,
      qpValue: 5.5,
      bitrate: 550092.0485312309
    },
    audio: {
      jitter: 0.0078,
      rtt: 0.001,
      bitrate: 37708.31230270733
    }
  },
  receive: {
    video: {
      jitterBufferDelay: 0.12,
      fractionLost: 0,
      qpValue: 19.8,
      bitrate: 814766.8777838446
    },
    audio: {
      audioLevel: 0.0096,
      jitterBufferDelay: 0.11183673469387359,
      fractionLost: 0,
      bitrate: 37136.608229785656
    }
  },
  candidatePair: {
    rtt: 0.002,
    upstreamBitrate: 606239.8302281727,
    downstreamBitrate: 872903.5454809506
  }
}

Thresholds

A set of thresholds for emitting each events used in the constructor of RTCStatsInsight. Use the event name for the thresholds object's key and use this object for the value. Please see example for usage.

Properties:
Name Type Description
unstable Number

When the value used in thresholds object's key goes greater than this value, the unstable level event is fired.

critical Number

When the value used in thresholds object's key goes greater than this value, the critical level event is fired.

Type:
  • Object
Example
const thresholds = {
    "audio-rtt": {
      unstable: 0.1
    },
    "audio-fractionLost": {
      unstable: 0.03,
      critical: 0.08,
    }
  }
}

const insight = new RTCStatsInsight(pc, { thresholds });
insight.on(RTCStatsInsightEvents["audio-fractionLost"].key, events => {
  // fired when `fractionLost` of receiving audio goes up to 0.03
  // ...
}