Handle Video Stats
In this step you will handle subscriber video and media link callbacks to diagnose stuttering and surface network health in your app.
| What you'll monitor | How it can be used |
|---|---|
videoPacketsLost / videoBytesReceived | Confirm the receive path is struggling (symptom: stutter, freezes) |
transport (local downlink bandwidth) | Suggest “Your connection looks weak” when your downlink looks constrained |
remotePublisherTransport (remote uplink) | Suggest “The other participant’s network may be unstable” when their send path looks constrained |
networkDegradationSource | Choose between local vs remote messaging—or log both bandwidth values for support |
1. Handle Subscriber Video Stats
Implement SubscriberKit.VideoStatsListener to receive periodic video receive metrics:
Callbacks may arrive on a background thread. Post UI updates to the main thread (as above) if you drive Compose or Views from these listeners.
2. Handle Media Link Stats
Implement SubscriberKit.MediaLinkStatsListener.onMediaLinkStats & SubscriberKit.MediaLinkStatsListener.onNetworkConditionChanged for transport bandwidth and degradation source. Network condition scores are also present on transport and remotePublisherTransport in each periodic sample—see Network condition.
Video stats and media link stats are delivered on separate callbacks. The sample keeps a MediaLinkSnapshot and merges it when building or updating ObservabilityStats:
Extend MediaLinkSnapshot and ObservabilityStats with the new fields (or map condition integers to labels in the overlay in the next step).
3. React to degradation on network condition events
When video stutters, onNetworkConditionChanged fires on a significant change. Use it with networkDegradationSource to choose user-facing copy:
reason in onNetworkConditionChanged describes why the event fired (for example a shift in bandwidth or packet loss). Combine it with networkCondition and networkConditionReason on transport for analytics.
Define ObservabilityStats, MediaLinkSnapshot, and fromVideoStats() in your project. The sample ObservabilityStats.kt is a starting point.
Client Observability
Learn how to use client observability to monitor real-time quality metrics for a video call with Vonage Video SDK.