> ## Documentation Index
> Fetch the complete documentation index at: https://www.vobiz.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Call quality metrics in the Vobiz Flutter SDK

> Measure call quality in the Vobiz Flutter SDK: poll round-trip time, jitter, and packet loss with getCallStats, and react to MOS-based good, fair, and poor levels from CallQualityEvent.

The SDK measures the audio of the connected call in two ways: an on-demand snapshot, and a stream of quality samples with a mean opinion score (MOS) and a level you can show to the user.

## Snapshot

```dart Signature theme={null}
Future<CallStats?> getCallStats()
```

Returns the connected call's statistics, or `null` when there is no call.

| `CallStats` field | Type | Description |
| - | - | - |
| `rttMs` | `double?` | Round-trip time, in milliseconds. |
| `jitterMs` | `double?` | Jitter of the incoming audio, in milliseconds. |
| `packetLossPercent` | `double?` | Share of incoming audio packets lost since the previous poll. |

Fields are `null` until WebRTC has reported them. Poll about once per second to draw a latency chart:

```dart theme={null}
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:vobiz_webrtc/vobiz_webrtc.dart';

Timer pollLatency(VobizClient client) {
  return Timer.periodic(const Duration(seconds: 1), (_) async {
    final stats = await client.getCallStats();
    if (stats == null) return;
    debugPrint('RTT ${stats.rttMs} ms, jitter ${stats.jitterMs} ms, '
        'loss ${stats.packetLossPercent}%');
  });
}
```

Cancel the timer when the call ends.

## Quality events

Once the call's audio connects, the SDK emits a `CallQualityEvent` on `callMediaEvents` every 2 seconds.

| `CallQualityEvent` member | Type | Description |
| - | - | - |
| `sample` | `CallQualitySample` | The measurement. |
| `level` | `CallQualityLevel` | The sample's level. |
| `levelChanged` | `bool` | `true` when the level moved, for example from good to poor. Show or clear a warning on these. |

| `CallQualitySample` field | Type | Description |
| - | - | - |
| `mos` | `double` | Estimated mean opinion score, from 1 (bad) to about 4.5 (excellent), using the E-model. |
| `level` | `CallQualityLevel` | The level for this MOS. |
| `rttMs` | `double?` | Round-trip time, in milliseconds. |
| `jitterMs` | `double?` | Jitter, in milliseconds. |
| `packetLossPercent` | `double?` | Packet loss over the last interval. |
| `codec` | `String?` | The audio codec in use. |

| `CallQualityLevel` | MOS | What the user hears |
| - | - | - |
| `good` | 3.6 or higher | Clear audio. |
| `fair` | 3.1 to 3.6 | Noticeable impairment, still usable. |
| `poor` | Below 3.1 | Choppy or delayed audio. Suggest a better network. |

A level change is reported only after two samples in a row agree, so a single bad sample doesn't flash a warning.

```dart theme={null}
void warnOnPoorQuality(VobizClient client) {
  client.callMediaEvents.listen((event) {
    if (event is CallQualityEvent && event.levelChanged) {
      if (event.level == CallQualityLevel.poor) {
        debugPrint('Poor network: MOS ${event.sample.mos.toStringAsFixed(1)}');
      } else {
        debugPrint('Call quality is ${event.level.name} again');
      }
    }
  });
}
```

## Signalling quality

`client.signalingQuality` tells you whether the signalling connection itself is usable (`good`, `degraded`, or `unavailable`). See [Network events](https://www.vobiz.ai/docs/integrations/flutter-sdk/events.md#network-events).

## After the call

Vobiz also records quality per call leg. The [call detail record](https://www.vobiz.ai/docs/cdr.md) of each call has `mos`, `jitter`, `packet_loss`, and the negotiated `codec`, which you can compare with what the app measured.

## Next steps

* [Network and reconnection](https://www.vobiz.ai/docs/integrations/flutter-sdk/network.md)
* [Events and states](https://www.vobiz.ai/docs/integrations/flutter-sdk/events.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.