getVideoStats method

List? getVideoStats()

Retrieves real-time video statistics for the participant.

  • This method returns metrics related to the participant’s video stream, such as jitter, packet loss, bitrate, and round-trip time (RTT). Returns the most recent sample and starts fetching the next one, so call it periodically — from a timer, for example. The first call after the participant joins returns null.

Returns

  • A List<dynamic>? containing video stream statistics objects, or null if stats are unavailable. Each object may include:

    • jitter: Represents distortion in the video stream.

    • bitrate: The bitrate at which the video stream is being transmitted.

    • totalPackets: The total number of packets transmitted for the video stream.

    • packetsLost: The total number of packets lost during transmission.

    • rtt: The round-trip time (RTT) in milliseconds, representing the time taken for the stream to travel from the server to the client.

    • codec: The codec used for encoding the video stream.

    • network: The network type used to transmit the stream.

    • size: An object containing the stream’s width, height, and frameRate.

Notes

  • Each value is the last sample taken, not an average over the room.

  • If the reported rtt is consistently greater than 300 ms, it is recommended to use a server region closer to the participant for improved performance.

Example

// Fetch audio and video stats for a participant
final audioStats = widget.participant.getAudioStats();
final videoStats = widget.participant.getVideoStats();

if (videoStats != null && videoStats.isNotEmpty) {
  final stats = videoStats.first;
  print('Video Bitrate: ${stats['bitrate']}');
  print('Packet Loss: ${stats['packetsLost']}');
  print('RTT: ${stats['rtt']} ms');
}

Implementation

List<dynamic>? getVideoStats() => _getVideoStats();