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 Android 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:
PublisherKit.NetworkStatsListener— publisher-side statsSubscriberKit.NetworkStatsListener— subscriber-side stats
To receive them, enable the appropriate listener on the publisher or subscriber.
Enabling statistics for publishers
Attach a listener for publisher stats:
publisher.setNetworkStatsListener(new PublisherKit.NetworkStatsListener() {
@Override
public void onVideoStats(PublisherKit publisher, PublisherKit.PublisherVideoStats[] statsArray) {
if (statsArray != null && statsArray.length > 0) {
// For routed sessions, first element is sufficient.
// For relayed sessions, iterate all statsArray elements to get per-subscriber info.
PublisherKit.PublisherVideoStats stats = statsArray[0];
String connectionId = (stats.connectionId != null && !stats.connectionId.isEmpty())
? stats.connectionId
: "<none>";
String subscriberId = (stats.subscriberId != null && !stats.subscriberId.isEmpty())
? stats.subscriberId
: "<none>";
Log.d("VideoStats", "Publisher Video Stats for connectionId: " + connectionId
+ ", subscriberId: " + subscriberId);
Log.d("VideoStats", "Video bytes sent: " + stats.videoBytesSent);
Log.d("VideoStats", "Video packets sent: " + stats.videoPacketsSent);
Log.d("VideoStats", "Video packets lost: " + stats.videoPacketsLost);
Log.d("VideoStats", "Stats timestamp: " + stats.timeStamp + " ms");
if (stats.videoLayers != null) {
for (PublisherKit.VideoLayerStats layer : stats.videoLayers) {
Log.d("VideoStats", "Layer: " + layer.width + "x" + layer.height);
Log.d("VideoStats", " Encoded FPS: " + layer.encodedFrameRate);
Log.d("VideoStats", " Bitrate: " + layer.bitrate + " bps");
Log.d("VideoStats", " Total bitrate (incl. RTP overhead): " + layer.totalBitrate + " bps");
Log.d("VideoStats", " Codec: " + (layer.codec != null ? layer.codec : "unknown"));
Log.d("VideoStats", " Scalability mode: " + (layer.scalabilityMode != null ? layer.scalabilityMode : "none"));
Log.d("VideoStats", " Quality limitation: " + layer.qualityLimitationReason);
}
}
if (stats.transport != null) {
Log.d("VideoStats", "Estimated uplink bandwidth: " + stats.transport.getConnectionEstimatedBandwidth() + " bps");
}
}
}
@Override
public void onAudioStats(PublisherKit publisher, PublisherKit.PublisherAudioStats[] statsArray) {
if (statsArray != null && statsArray.length > 0) {
// For routed sessions, first element is sufficient.
// For relayed sessions, iterate all statsArray elements to get per-subscriber info.
PublisherKit.PublisherAudioStats stats = statsArray[0];
String connectionId = (stats.connectionId != null && !stats.connectionId.isEmpty())
? stats.connectionId
: "<none>";
String subscriberId = (stats.subscriberId != null && !stats.subscriberId.isEmpty())
? stats.subscriberId
: "<none>";
Log.d("AudioStats", "Publisher Audio Stats for connectionId: " + connectionId
+ ", subscriberId: " + subscriberId);
Log.d("AudioStats", "Audio bytes sent: " + stats.audioBytesSent);
Log.d("AudioStats", "Audio packets sent: " + stats.audioPacketsSent);
Log.d("AudioStats", "Audio packets lost: " + stats.audioPacketsLost);
Log.d("AudioStats", "Stats timestamp: " + stats.timeStamp + " ms");
if (stats.transport != null) {
Log.d("AudioStats", "Estimated uplink bandwidth: " + stats.transport.getConnectionEstimatedBandwidth() + " 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
For video quality events, implement:
@Override
public void onPublisherVideoQualityChanged(PublisherKit.PublisherVideoStats stats, String reason) {
Log.d("Stats", "Publisher video quality event: " + reason);
}
Enabling statistics for subscribers
Attach a listener implementing SubscriberKit.SubscriberKitNetworkStatsListener:
Subscriber subscriber = new Subscriber(stream);
subscriber.setNetworkStatsListener(new SubscriberKit.SubscriberKitNetworkStatsListener() {
@Override
public void onSubscriberVideoStatsUpdated(SubscriberKit.SubscriberVideoStats stats) {
Log.d("Stats", "Video bytes received: " + stats.videoBytesReceived);
}
@Override
public void onSubscriberAudioStatsUpdated(SubscriberKit.SubscriberAudioStats stats) {
Log.d("Stats", "Audio packets received: " + stats.audioPacketsReceived);
}
});
Receiving video quality events on the subscribers
For video quality events, implement:
@Override
public void onSubscriberVideoQualityChanged(SubscriberKit.SubscriberVideoStats stats, String reason) {
Log.d("Stats", "Subscriber video quality event: " + reason);
}
Statistics data structures
This section outlines the structs and properties provided by the Android 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.
TransportStats
Represents shared transport-level estimation.
connectionEstimatedBandwidth– Estimated available uplink connection bandwidth (bps).
PublisherKit.PublisherVideoStats
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 (seeOTPublisherKitVideoLayerStats).transport– Transport statistics.
PublisherKit.PublisherAudioStats
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.
PublisherKit.VideoLayerStats
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.
SubscriberKit.SenderStats
Sender-side estimation metrics (mirrored on both audio and video).
connectionMaxAllocatedBitrate– Maximum bitrate estimated for the sender connection.connectionEstimatedBandwidth– Current bandwidth estimation (bps).
SubscriberKit.SubscriberVideoStats
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.
SubscriberKit.SubscriberAudioStats
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 senderStatisticsTrack property to true when building the publisher:
Publisher publisher = new Publisher.Builder(context)
.senderStatsTrack(true) // Enable sender-side stats
.build();
If senderStatsTrack is not enabled, no sender statistics channel will be published for this publisher. The default value is false.
Subscribing to sender-side statistics
Subscribers automatically receive sender statistics only if the publisher has enabled them and if the subscriber registers a listener for network statistics events.
Receiving statistics events
Sender-side statistics are delivered via the SubscriberKit.VideoStatsListener and SubscriberKit.AudioStatsListener callbacks for video and audio. The SubscriberKit.SubscriberVideoStats and SubscriberKit.SubscriberAudioStats classes each include these properties:
connectionMaxAllocatedBitrate— The maximum bitrate that can be estimated for the connectionconnectionEstimatedBandwidth— The current estimated bitrate 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.
The stats object includes an optional senderStats field that provides the sender-side statistics. For example, when using SubscriberKit.setVideoStatsListener(), the stats parameter is a SubscriberKit.SubscriberVideoStats object:
subscriber.setVideoStatsListener((subscriber, stats) -> {
if (stats.senderStats != null) {
Log.d(TAG, "Connection max allocated bitrate: " + stats.senderStats.connectionMaxAllocatedBitrate);
Log.d(TAG, "Connection current estimated bandwidth: " + stats.senderStats.connectionEstimatedBandwidth);
} else {
Log.d(TAG, "Sender stats not available yet.");
}
});
The same applies to audio stats using SubscriberKit.AudioStatsListener.
RTC stats report
To get low-level peer connection statistics for a publisher, use the PublisherKit.getRtcStatsReport() method. This provides RTC stats reports for the media stream. This is an asynchronous operation. Call the PublisherKit.setRtcStatsReportListener(PublisherKit.PublisherRtcStatsReportListener listener) method, and then implement the PublisherKit.PublisherRtcStatsReportListener.onRtcStatsReport(PublisherKit publisher, PublisherKit.PublisherRtcStats[] stats) method prior to calling PublisherKit.getRtcStatsReport().
When the stats are available, the implementation of the PublisherKit.PublisherRtcStatsReportListener.onRtcStatsReport(PublisherKit publisher, PublisherKit.PublisherRtcStats[] stats) method is called.
An array of PublisherRtcStats objects is passed into that method. The PublisherRtcStats object includes a jsonArrayOfReports property. This is a JSON array of RTC stats reports, which are similar to the format of the RtcStatsReport object implemented in web browsers (see these Mozilla docs).
To get low-level peer connection statistics for a subscriber, use the SubscriberKit.getRtcStatsReport() method. This provides an RTC stats report for the media stream.
This is an asynchronous operation. Call the SubscriberKit.setRtcStatsReportListener(SubscriberKit.SubscriberRtcStatsReportListener listener) method, and then implement the SubscriberKit.SubscriberRtcStatsReportListener.onRtcStatsReport(SubscriberKit subscriber, java.lang.String jsonArrayOfReports) method prior to calling SubscriberKit.getRtcStatsReport().
When the stats are available, the implementation of the SubscriberKit.SubscriberRtcStatsReportListener.onRtcStatsReport(SubscriberKit subscriber, java.lang.String jsonArrayOfReports) method is called. The jsonArrayOfReports parameter is a JSON array of RTC stats reports, which are similar to the format of the RtcStatsReport object implemented in web browsers (see these Mozilla docs).
Also see this W3C documentation.