startStats method

Future<bool> startStats(
  1. String callId,
  2. String peerId, {
  3. CallQualityCallback? onCallQualityChange,
})

Starts reporting WebRTC statistics.

callId The ID of the call. peerId The ID of the peer. onCallQualityChange Callback for call quality updates. Returns a Future that completes with true if stats reporting started successfully, false otherwise.

Implementation

Future<bool> startStats(
  String callId,
  String peerId, {
  CallQualityCallback? onCallQualityChange,
}) async {
  if (_debug == false) {
    GlobalLogger().d(
      'Peer :: Stats manager will not start. Debug mode not enabled on config',
    );
    return false;
  }

  if (peerConnection == null) {
    GlobalLogger().d('Peer connection null');
    return false;
  }

  _statsManager = WebRTCStatsReporter(
    _socket,
    peerConnection!,
    callId,
    peerId,
    _txClient.isDebug(),
    onCallQualityChange: onCallQualityChange,
  );
  await _statsManager?.startStatsReporting();

  return true;
}