getShareStats method

List? getShareStats()

Retrieves real-time screen-share statistics for the participant.

  • This method returns metrics related to the participant’s screen-share 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 screen-share stream statistics objects, or null if stats are unavailable. Each object may include:

    • jitter: Represents distortion in the screen-share stream.

    • bitrate: The bitrate at which the screen-share stream is being transmitted.

    • totalPackets: The total number of packets transmitted for the screen-share 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 screen-share 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 screen-share stats for a participant
final shareStats = widget.participant.getShareStats();

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

Implementation

List<dynamic>? getShareStats() => _getShareStats();