Kotlin

Overview

We'll now subscribe and register the listeners, so that we can receive the callbacks with the actual statistics to see. The calback handling itself will be done in the next step

1. Subscribe and Register Relevant Listeners

When a remote stream arrives, build a Subscriber and attach both stats listeners before or after subscribe (the sample sets them before session.subscribe):

Listener What it delivers
VideoStatsListener Receive-side video metrics (bytes, packets, loss, timestamp)
MediaLinkStatsListener transport, remotePublisherTransport, networkDegradationSource — see Subscriber Media Link Statistics

2. Clear observability state when the stream is dropped:

When the remote participant unpublishes or disconnects, release the subscriber and reset stored stats so the overlay does not show stale values:

Also unsubscribe or destroy the subscriber if your app supports rejoining the same session with a new stream.

3. Optional: subscriber lifecycle callbacks

In SubscriberListener, log onConnected / onDisconnected to confirm the subscription is active before you expect stats in Logcat or the overlay.