Swift

Overview

Subscribe to a remote stream and assign networkStatsDelegate so you receive statistics callbacks. On iOS, video, audio, and media link stats (including network condition events) are delivered through a single OTSubscriberKitNetworkStatsDelegate—not separate listener objects like on Android.

The callback handling is implemented in the next step.

1. Subscribe and Register the Network Stats Delegate

When a remote stream is created, build an OTSubscriber, set delegates, and subscribe:

Delegate What it delivers
OTSubscriberDelegate Connection lifecycle, subscriber view
OTSubscriberKitNetworkStatsDelegate Video/audio stats, media link stats, network condition events

iOS-specific: Set networkStatsDelegate on the subscriber instance. There is no separate “media link listener” registration—implement mediaLinkStatsUpdated and networkConditionChanged on the same delegate type.

2. Clear State When the Stream Ends

Reset observability state when the stream is destroyed:

In subscriberDidConnect, assign the subscriber view for SwiftUI:

Next: Implement the network stats delegate methods and merge data for the overlay.