Swift

Handle Video Stats

In this step you implement OTSubscriberKitNetworkStatsDelegate to diagnose stuttering and surface network health in your app.

What you'll monitor How it is delivered How it can be used
videoPacketsLost / videoBytesReceived Periodic — videoNetworkStatsUpdated Confirm the receive path is struggling (stutter, freezes)
transport (local downlink bandwidth) Periodic — mediaLinkStatsUpdated Suggest “Your connection looks weak”
remotePublisherTransport (remote uplink) Periodic — mediaLinkStatsUpdated Suggest “The other participant’s network may be unstable”
networkDegradationSource Periodic and on change Pick local vs remote messaging
Significant network change EventnetworkConditionChanged Banners, toasts, support logs

iOS-specific: Periodic stats and network condition events are methods on the same OTSubscriberKitNetworkStatsDelegate—not a separate listener type.

Adopt the delegate in an extension:

1. Handle Subscriber Video Stats

Callbacks may arrive off the main queue. Update @Published overlay state on the main queue.

3. Handle Network Condition Events

Implement subscriber(_:networkConditionChanged:reason:) for significant changes—see Network condition:

Shared merge helper:

4. React to Degradation on Network Condition Events

Define ObservabilityStats, MediaLinkSnapshot, and helpers in your project (mirror the Android sample’s model). If remotePublisherTransport stays nil, confirm the remote publisher used settings.senderStatsTrack = true.

Next: Pass merged stats into SwiftUI and render the overlay.