Call Quality Monitoring
Feature Introduction
During stream publishing and playing, users can monitor the quality of specific published and played streams by registering relevant callbacks.
Usage Steps
Monitor Publish Stream Quality
-
API Prototype
/** * Publish stream quality callback * * This callback is received every 3 seconds after the stream is successfully published. Through this callback, you can obtain quality data such as capture frame rate, bitrate, RTT, and packet loss rate of the published audio and video stream. * Developers can monitor the health status of the published audio and video stream in real time based on the quality parameters of this interface, so as to display the uplink network status on the device UI in real time. * If developers are not sure how to use each parameter of this callback interface, they can focus on the level field of the quality parameter. This is a comprehensive value describing the uplink network calculated by ZegoExpressEngine internally based on quality parameters. The description of the level field is as follows: ZegoStreamQualityLevelExcellent: stream quality is excellent; ZegoStreamQualityLevelGood: stream quality is good; ZegoStreamQualityLevelMedium: stream quality is normal; ZegoStreamQualityLevelBad: stream quality is poor; ZegoStreamQualityLevelDie: stream quality is abnormal. * @param streamID Stream ID of the published stream * @param quality Quality of the published stream, including audio and video frame rate, bitrate, RTT, etc. */ public void onPublisherQualityUpdate(String streamID, ZegoPublishStreamQuality quality){ } -
Usage Example
class MyEventHandler extends IZegoEventHandler { public void onPublisherQualityUpdate(String streamID, ZegoPublishStreamQuality quality) { // Developers can monitor specific quality in this callback and report to the business server for monitoring, or monitor a specific field of the quality object to give user-friendly hints // If developers don't know which field of the quality to monitor, they can focus on the level field, which is the comprehensive value of the quality object Log.v("onPublisherQualityUpdate: streamID=", streamID); } }
Publish Stream Quality Details
Publish stream quality includes the frame rate of audio and video streams in the capture and encoding stages, and the frame rate, bitrate, delay, and packet loss rate of audio and video streams in transmission (sending). The specific definitions are as follows:
public class ZegoPublishStreamQuality {
/** Video capture frame rate, in f/s */
public double videoCaptureFPS;
/** Video encoding frame rate, in f/s */
public double videoEncodeFPS;
/** Video sending frame rate, in f/s */
public double videoSendFPS;
/** Video bitrate, in kbps */
public double videoKBPS;
/** Audio capture frame rate, in f/s */
public double audioCaptureFPS;
/** Audio sending frame rate, in f/s */
public double audioSendFPS;
/** Audio bitrate, in kbps */
public double audioKBPS;
/** Delay from local device to server, in milliseconds */
public int rtt;
/** Packet loss rate, in percentage, 0.0 ~ 1.0 */
public double packetLostRate;
/** Publish stream quality level */
public ZegoStreamQualityLevel level;
/** Whether hardware encoding is enabled */
public boolean isHardwareEncode;
/** Video encoding format */
public ZegoVideoCodecID videoCodecID;
/** Total bytes sent, including audio, video, and SEI */
public double totalSendBytes;
/** Audio bytes sent */
public double audioSendBytes;
/** Video bytes sent */
public double videoSendBytes;
}Publish Stream Capture Quality
Publish stream capture quality is close to the user's subjective feeling during preview. The relevant parameters of audio and video quality in the capture stage during stream publishing are as follows:
- audioCaptureFPS: Audio capture frame rate (fps)
- videoCaptureFPS: Video capture frame rate (fps)
Publish Stream Encoding Quality
The relevant parameters of audio and video quality in the encoding stage during stream publishing are as follows:
videoEncodeFPS: Current target video encoding frame rate of the encoder (fps)
Publish Stream Sending Quality
Publish stream sending quality is the actual stream publishing quality, which is related to the set encoding and actual network quality. The relevant members are as follows:
- audioSendFPS: Actual audio sending frame rate (fps)
- audioKBPS: Actual audio sending bitrate (kbps)
- videoSendFPS: Actual video sending frame rate (fps)
- videoKBPS: Actual video sending bitrate (kbps)
- rtt: Round-trip delay from device to ZEGO Server (ms)
- packetLostRate: Device uplink packet loss rate
Monitor Play Stream Quality
-
API Prototype
/** * Play stream quality callback * * This callback is received every 3 seconds after the stream is successfully played. Through this callback, you can obtain quality data such as frame rate, bitrate, RTT, and packet loss rate of the played audio and video stream, and monitor the health status of the played stream in real time. * Developers can monitor the health status of the played audio and video stream in real time based on the quality parameters of this interface, so as to display the downlink network status on the device UI in real time. * If developers are not sure how to use each parameter of this callback interface, they can focus on the level field of the quality parameter. This is a comprehensive value describing the downlink network calculated by ZegoExpressEngine internally based on quality parameters. The description of the level field is as follows: ZegoStreamQualityLevelExcellent: stream quality is excellent; ZegoStreamQualityLevelGood: stream quality is good; ZegoStreamQualityLevelMedium: stream quality is normal; ZegoStreamQualityLevelBad: stream quality is poor; ZegoStreamQualityLevelDie: stream quality is abnormal. * @param streamID Stream ID of the played stream * @param quality Quality of the played stream, including audio and video frame rate, bitrate, RTT, etc. */ public void onPlayerQualityUpdate(String streamID, ZegoPlayStreamQuality quality){ } -
Usage Example
class MyEventHandler extends IZegoEventHandler { public void onPlayerQualityUpdate(String streamID, ZegoPlayStreamQuality quality) { // Developers can monitor specific quality in this callback and report to the business server for monitoring, or monitor a specific field of the quality object to give user-friendly hints // If developers don't know which field of the quality to monitor, they can focus on the level field, which is the comprehensive value of the quality object Log.v("onPlayerQualityUpdate: streamID=", streamID); } }
Play Stream Quality Details
Play stream quality includes the frame rate, bitrate, delay, and packet loss rate of received audio and video streams, the frame rate of audio and video streams in the decoding stage, and the frame rate, freeze rate, and overall audio and video quality in the rendering stage. The specific definitions are as follows:
public class ZegoPlayStreamQuality {
/** Video receive frame rate, in f/s */
public double videoRecvFPS;
/** Video dejitter frame rate, in f/s */
public double videoDejitterFPS;
/** Video decoding frame rate, in f/s */
public double videoDecodeFPS;
/** Video rendering frame rate, in f/s */
public double videoRenderFPS;
/** Video bitrate, in kbps */
public double videoKBPS;
/** Video freeze rate, in (freeze count/10 seconds) */
/** No data playback for more than 500ms is considered a video freeze */
public double videoBreakRate;
/** Audio receive frame rate, in f/s */
public double audioRecvFPS;
/** Audio dejitter frame rate, in f/s */
public double audioDejitterFPS;
/** Audio decoding frame rate, in f/s */
public double audioDecodeFPS;
/** Audio rendering frame rate, in f/s */
public double audioRenderFPS;
/** Audio bitrate, in kbps */
public double audioKBPS;
/** Audio freeze rate, in (freeze count/10 seconds) */
/** Continuous loss of 3 frames and no audio data rendering within a given freeze threshold is considered an audio freeze */
public double audioBreakRate;
/** Delay from server to local device, in milliseconds */
public int rtt;
/** Packet loss rate, in percentage, 0.0 ~ 1.0 */
public double packetLostRate;
/** End-to-end delay, in milliseconds */
public int peerToPeerDelay;
/** End-to-end packet loss rate, in percentage, 0.0 ~ 1.0 */
public double peerToPeerPacketLostRate;
/** Play stream quality level */
public ZegoStreamQualityLevel level;
/** Delay from receiving data to playback on the local device, in milliseconds */
public int delay;
/** Difference between video timestamp and audio timestamp, used to reflect audio-video synchronization status, in milliseconds. A value less than 0 means the video is ahead of the audio by milliseconds, greater than 0 means the video is behind the audio by milliseconds, and equal to 0 means no difference. When the absolute value is less than 200, audio-video synchronization can be basically considered. When the absolute value is greater than 200 for 10 consecutive seconds, it can be considered abnormal */
public int avTimestampDiff;
/** Whether hardware decoding is enabled */
public boolean isHardwareDecode;
/** Video encoding format */
public ZegoVideoCodecID videoCodecID;
/** Total bytes received, including audio, video, and SEI */
public double totalRecvBytes;
/** Audio bytes received */
public double audioRecvBytes;
/** Video bytes received */
public double videoRecvBytes;
}Play Stream Receive Quality
Play stream receive quality is the actual play stream quality, which is related to the actual publish stream quality and current network quality. The relevant parameters are as follows:
- audioRecvFPS: Actual received audio frame rate (fps)
- audioKBPS: Actual received audio bitrate (kbps)
- audioBreakRate: Actual received audio freeze rate (freeze count/10 seconds)
- videoKBPS: Actual received video bitrate (kbps)
- videoRecvFPS: Actual received video frame rate (fps)
- videoBreakRate: Actual received video freeze rate (freeze count/10 seconds)
- packetLostRate: Device downlink packet loss rate
- rtt: Round-trip delay from device to ZEGO Server (ms)
Play Stream Rendering Quality
Play stream rendering quality is close to the user's subjective feeling when watching audio and video. This quality may be lower than the actual received play stream quality value due to the influence of the decoder. The relevant parameters are as follows:
- audioRenderFPS: Actual audio rendering frame rate
- videoRenderFPS: Actual video rendering frame rate
API Reference List
| Method | Description |
|---|---|
| onPublisherQualityUpdate | Publish stream quality callback |
| onPlayerQualityUpdate | Play stream quality update callback |
