The Vonage Video SDK exposes detailed stream-quality metrics through a high-level statistics API—recommended for most use cases—which provides audio, video, network, and sender-side statistics in a unified, session-aware form that remains stable across peer-connection transitions. For advanced debugging, the SDK also offers access to the raw WebRTC stats report, which reflects unprocessed peer-connection data.

Audio and video statistics API

The Vonage Video iOS SDK sends periodic audio and video network statistics for both publishers and subscribers. These include packet counts, bitrates, frame rate data, pause/freeze metrics, codec information, and optional sender-side network estimation.

Statistics are delivered through:

  • OTPublisherKitNetworkStatsDelegate — publisher-side stats

  • OTSubscriberKitNetworkStatsDelegate — subscriber-side stats

To receive them, enable the appropriate delegate on the publisher or subscriber.

Enabling statistics for publishers

Attach a class that adopts OTPublisherKitNetworkStatsDelegate:

class MyViewController: UIViewController, OTPublisherKitDelegate, OTPublisherKitNetworkStatsDelegate {
    var publisher: OTPublisher?

    func setupPublisher() {
        let settings = OTPublisherSettings()
        // Configure settings as needed
        publisher = OTPublisher(delegate: self, settings: settings)
        publisher?.networkStatsDelegate = self
    }
}

Implement the callbacks:

func publisher(_ publisher: OTPublisherKit, videoNetworkStatsUpdated stats: [OTPublisherKitVideoNetworkStats]) {
    let first = stats.first

    // For routed sessions, stats.first is enough.
    // For relayed sessions (one object per subscriber), you would iterate all elements.
    let connectionId = first.connectionId.isEmpty ? "<none>" : first.connectionId
    let subscriberId = first.subscriberId.isEmpty ? "<none>" : first.subscriberId

    print("Publisher Video Stats for connectionId: \(connectionId), subscriberId: \(subscriberId)")
    print("Video bytes sent: \(first.videoBytesSent)")
    print("Video packets sent: \(first.videoPacketsSent)")
    print("Video packets lost: \(first.videoPacketsLost)")
    print("Current average frame rate: \(first.videoFrameRate) fps")

    for layer in first.videoLayers {
        print("Layer: \(layer.width)x\(layer.height)")
        print("  Encoded FPS: \(layer.encodedFrameRate)")
        print("  Bitrate: \(layer.bitrate) bps")
        print("  Total bitrate (incl. RTP overhead): \(layer.totalBitrate) bps")
        print("  Codec: \(layer.codec ?? "<none>")")
        print("  Scalability mode: \(layer.scalabilityMode ?? "<none>")")
        print("  Quality limitation: \(layer.qualityLimitationReason.rawValue)")
    }

    if let transport = first.transport {
        print("Estimated uplink bandwidth: \(transport.connectionEstimatedBandwidth) bps")
    }
}

func publisher(_ publisher: OTPublisherKit, audioNetworkStatsUpdated stats: [OTPublisherKitAudioNetworkStats]) {
    let first = stats.first

    // For routed sessions, stats.first is enough.
    // For relayed sessions (one object per subscriber), you would iterate all elements.
    let connectionId = first.connectionId.isEmpty ? "<none>" : first.connectionId
    let subscriberId = first.subscriberId.isEmpty ? "<none>" : first.subscriberId

    print("Publisher Audio Stats for connectionId: \(connectionId), subscriberId: \(subscriberId)")
    print("Audio bytes sent: \(first.audioBytesSent)")
    print("Audio packets sent: \(first.audioPacketsSent)")
    print("Audio packets lost: \(first.audioPacketsLost)")

    if let transport = first.transport {
        print("Estimated uplink bandwidth: \(transport.connectionEstimatedBandwidth) bps")
    }
}

For a publisher in a routed session (one that uses the Vonage Video Media Router), the stats array includes one object, defining the statistics for the single audio or video media stream that is sent to the Vonage Video Media Router. In a relayed session, the stats array includes an object for each subscriber to the published stream.

Receiving video quality events on the publishers

If you are also interested in video quality events implement this callback:

func publisher(_ publisher: OTPublisherKit, videoQualityChanged stats: OTPublisherKitVideoNetworkStats, reason: OTPublisherVideoEventReason) {
    print("Publisher video quality event: \(reason.rawValue)")
}

Enabling statistics for subscribers

Attach a class that adopts OTSubscriberKitNetworkStatsDelegate:

class MyViewController: UIViewController, OTSubscriberKitDelegate, OTSubscriberKitNetworkStatsDelegate {
    var subscriber: OTSubscriber?

    func setupSubscriber(stream: OTStream, session: OTSession) {
        subscriber = OTSubscriber(stream: stream, delegate: self)
        subscriber?.networkStatsDelegate = self
        try? session.subscribe(subscriber!)
    }
}

Implement the callbacks:

func subscriber(_ subscriber: OTSubscriberKit, videoNetworkStatsUpdated stats: OTSubscriberKitVideoNetworkStats) {
    print("Video bytes received: \(stats.videoBytesReceived)")
}

func subscriber(_ subscriber: OTSubscriberKit, audioNetworkStatsUpdated stats: OTSubscriberKitAudioNetworkStats) {
    print("Audio packets received: \(stats.audioPacketsReceived)")
}

Receiving video quality events on the subscribers

Additionally handle subscriber video quality changed events:

func subscriber(_ subscriber: OTSubscriberKit, videoQualityChanged stats: OTSubscriberKitVideoNetworkStats, reason: OTSubscriberVideoEventReason) {
    print("Subscriber video quality event: \(reason.rawValue)")
}

Statistics data structures

This section outlines the structs and properties provided by the iOS audio and video statistics API. While all Video SDK platforms expose the same set statistics, there may be minor differences in how each platform structures or names individual fields. These variations reflect platform-specific SDK design conventions rather than differences in the underlying metrics.

For a platform-independent explanation of the available statistics and what they represent, refer to client observability overview.

OTTransportStats

Represents shared transport-level estimation.

  • connectionEstimatedBandwidth – Estimated available uplink connection bandwidth (bps).

OTPublisherKitVideoNetworkStats

Provides statistics about a publisher’s video track. It includes:

  • connectionId – In a relayed session, the connection ID of the client subscribing to the stream. Undefined in a routed session.
  • subscriberId – In a relayed session, the subscribed ID of the client subscribing to the stream. Undefined in a routed session.
  • videoPacketsLost – Estimated video packets lost.
  • videoPacketsSent – Video packets sent.
  • videoBytesSent – Video bytes sent.
  • timestamp – Unix timestamp in milliseconds when stats were gathered.
  • startTime – The timestamp, in milliseconds since the Unix epoch, from which the cumulative totals started accumulating.
  • videoLayers – The array of video layer statistics (see OTPublisherKitVideoLayerStats).
  • transport – Transport statistics.

OTPublisherKitAudioNetworkStats

Provides statistics about a publisher’s audio track. It includes:

  • connectionId – In a relayed session, the connection ID of the client subscribing to the stream. Undefined in a routed session.
  • subscriberId – In a relayed session, the subscribed ID of the client subscribing to the stream. Undefined in a routed session.
  • audioPacketsLost – Estimated packets lost.
  • audioPacketsSent – Audio packets sent.
  • audioBytesSent – Audio bytes sent.
  • timestamp – Unix timestamp in milliseconds.
  • startTime – The timestamp, in milliseconds since the Unix epoch, from which the cumulative totals started accumulating.
  • transport – Transport statistics.

OTPublisherKitVideoLayerStats

Represents one simulcast layer or SVC layer.

  • width – Encoded frame width.
  • height – Encoded frame height.
  • encodedFrameRate – Encoded frames per second.
  • bitrate – Layer bitrate (bps).
  • totalBitrate – Layer bitrate including RTP overhead (bps).
  • scalabilityMode – SVC/scalability descriptor (e.g., "L3T3").
  • qualityLimitationReason – Reason for quality limitation (bandwidth, CPU, codec, resolution, or layer change).
  • codec – The codec used by this video layer.

OTSenderStats

Sender-side estimation metrics (mirrored on both audio and video).

  • connectionMaxAllocatedBitrate – Maximum bitrate estimated for the sender connection.
  • connectionEstimatedBandwidth – Current bandwidth estimation (bps).

OTSubscriberKitVideoNetworkStats

Provides statistics about a subscriber’s video track. It includes:

  • videoPacketsLost – Estimated video packets lost.
  • videoPacketsReceived – Video packets received.
  • videoBytesReceived – Video bytes received.
  • timestamp – Unix timestamp in milliseconds when stats were gathered.
  • senderStats – Sender-side metrics (optional).
  • width – Decoded frame width in pixels.
  • height – Decoded frame height in pixels.
  • decodedFrameRate – Decoded frames per second.
  • bitrate – Video bitrate (bps).
  • totalBitrate – Bitrate including RTP overhead (bps).
  • pauseCount – Number of pauses (>5s since last frame). Includes intentional disables and audio-fallback cases.
  • totalPausesDuration – Total pause duration (ms).
  • freezeCount – Freeze count (WebRTC-defined freeze event).
  • totalFreezesDuration – Total freeze duration (ms).
  • codec – Current decoder codec.

OTSubscriberKitAudioNetworkStats

Provides statistics about a subscriber’s audio track. It includes:

  • audioPacketsLost – Estimated packets lost.
  • audioPacketsReceived – Packets received.
  • audioBytesReceived – Bytes received.
  • timestamp – Unix timestamp in milliseconds.
  • senderStats – Sender-side metrics (optional).

Sender-side statistics

See the sender-side statistics overview.

Enabling sender-side statistics

Sender-side statistics are received on the subscribers. To receive sender-side statistics, enable them for the stream’s publisher by setting the senderStatsTrack property to true for the OTPublisherKitSettings object used to create the publisher.

let settings = OTPublisherKitSettings()
settings.senderStatsTrack = true

let publisher = OTPublisher(delegate: self, settings: settings)

If senderStatsTrack is not enabled, no sender statistics channel will be published for this publisher. The default value is NO.

Subscribing to sender-side statistics

If the stream’s publisher has enabled sender-side statistics, subscribers start receiving them automatically once a listener is registered for video or audio stats, as described above.

Implement the delegate method for video stats:

func subscriber(_ subscriber: OTSubscriberKit, videoNetworkStatsUpdated stats: OTSubscriberKitVideoNetworkStats) {
    if let sender = stats.senderStats {
        print("Connection max allocated bitrate: \(sender.connectionMaxAllocatedBitrate)")
        print("Connection current estimated bandwidth: \(sender.connectionEstimatedBandwidth)")
    } else {
        print("Sender-side stats not available yet.")
    }
}

Receiving statistics events

Sender-side statistics are delivered via the OTSubscriberKitNetworkStatsDelegate callbacks for video and audio, as shown above. The OTSenderStats, included as the senderStats member in both OTSubscriberKitVideoNetworkStats and OTSubscriberKitAudioNetworkStats, provides two properties:

  • connectionMaxAllocatedBitrate — The maximum bitrate that can be estimated for the connection
  • connectionEstimatedBandwidth — The current estimated bandwidth for the connection

These two metrics are calculated per audio-video bundle, so the same values appear in both video and audio statistics. Because they reflect the transport rather than individual tracks, the metrics are shared across both audio and video.

RTC stats report

To get low level stream statistics, use the getRtcStatsReport() method on OTPublisherKit. This provides RTC stats reports for the media stream asynchronously.

Before calling this method, set the rtcStatsReportDelegate property on your publisher and implement the delegate method publisher(_:rtcStatsReport:) from OTPublisherKitRtcStatsReportDelegate. When the stats are available, this method is called with an array of OTPublisherRtcStats objects. Each object contains a jsonArrayOfReports property, which is a JSON array of RTC stats reports similar to the format used by WebRTC in web browsers.

Example

class MyViewController: UIViewController, OTPublisherKitRtcStatsReportDelegate {
    var publisher: OTPublisher?

    func setupPublisher() {
        // Create and configure the publisher
        publisher = OTPublisher(delegate: self, settings: OTPublisherKitSettings())
        publisher?.rtcStatsReportDelegate = self
    }

    func fetchRtcStats() {
        publisher?.getRtcStatsReport()
    }

    // Delegate method called when stats are ready
    func publisher(_ publisher: OTPublisherKit, rtcStatsReport stats: [OTPublisherRtcStats]) {
        for stat in stats {
            print("RTC Stats JSON: \(stat.jsonArrayOfReports)")
        }
    }
}

See these Mozilla docs). Also see this W3C documentation.

Sample

The Vonage Video iOS SDK Client Observability Sample App demonstrates client observability features in a mobile app built with the iOS client SDK.