logo
On this page

Call quality monitoring


Feature overview

During the publish and play stream process, users can monitor the specific quality of published and played streams by registering relevant callbacks.

Example source code download

Please refer to Download example source code to get the source code.

  • Publish stream: For relevant source code, please view the "/ZegoExpressExample/Topics/PublishStream/ZGPublishStreamViewController.m" file.
  • Play stream: For relevant source code, please view the "/ZegoExpressExample/Topics/PlayStream/ZGPlayStreamViewController.m" file.

Usage steps

Monitor publish stream quality

  • Interface prototype

    /// Publish stream quality callback
    /// @discussion After the stream is successfully published, this callback will be received every 3 seconds. Through this callback, you can obtain quality data such as capture frame rate, bitrate, RTT, packet loss rate of the published audio and video stream, and monitor the health status of the published stream in real time.
    /// @param quality Publish stream quality, including audio and video frame rate, bitrate, RTT and other values
    /// @param streamID Stream ID
    - (void)onPublisherQualityUpdate:(ZegoPublishStreamQuality *)quality streamID:(NSString *)streamID;
  • Usage example

    Declare compliance with the ZegoEventHandler protocol in the class that needs to receive callbacks, and pass the class as the "eventHandler" parameter when calling the method to create the engine object. Then you can receive quality information callbacks by implementing this method.

    - (void)onPublisherQualityUpdate:(ZegoPublishStreamQuality *)quality streamID:(NSString *)streamID {
        NSLog(@"Video Capture FPS: %f", quality.videoCaptureFPS);
        NSLog(@"Video Encode FPS: %f", quality.videoEncodeFPS);
        NSLog(@"Video Send FPS: %f", quality.videoSendFPS);
        NSLog(@"Video KBPS: %f", quality.videoKBPS);
        NSLog(@"Audio Capture FPS: %f", quality.audioCaptureFPS);
        NSLog(@"Audio Send FPS: %f", quality.audioSendFPS);
        NSLog(@"Audio KBPS: %f", quality.audioKBPS);
        NSLog(@"RTT: %d", quality.rtt);
        NSLog(@"Packet Lost Rate: %f", quality.packetLostRate);
        NSLog(@"Quality Level: %d", (int)quality.level);
        NSLog(@"is Hardware Encode: %d", quality.isHardwareEncode);
    }

Publish stream quality details

Publish stream quality includes the frame rate of the audio and video stream during the capture and encoding stages, the frame rate, bitrate, delay, and packet loss rate of the transmitted (sent) audio and video stream. The specific definitions are as follows:

/// Audio and video parameters and network quality, etc.
@interface ZegoPublishStreamQuality : NSObject

/// Video capture frame rate, in f/s
@property (nonatomic, assign) double videoCaptureFPS;

/// Video encoding frame rate, in f/s
@property (nonatomic, assign) double videoEncodeFPS;

/// Video sending frame rate, in f/s
@property (nonatomic, assign) double videoSendFPS;

/// Video bitrate, in kbps
@property (nonatomic, assign) double videoKBPS;

/// Audio capture frame rate, in f/s
@property (nonatomic, assign) double audioCaptureFPS;

/// Audio sending frame rate, in f/s
@property (nonatomic, assign) double audioSendFPS;

/// Audio bitrate, in kbps
@property (nonatomic, assign) double audioKBPS;

/// Delay from the local end to the server, in milliseconds
@property (nonatomic, assign) int rtt;

/// Packet loss rate, in percentage, 0.0 ~ 1.0
@property (nonatomic, assign) double packetLostRate;

/// Publish stream quality level
@property (nonatomic, assign) ZegoStreamQualityLevel level;

/// Whether hardware encoding is enabled
@property (nonatomic, assign) BOOL isHardwareEncode;

/// Video encoding format
@property (nonatomic, assign) ZegoVideoCodecID videoCodecID;

/// Total bytes sent, including audio, video and SEI, etc.
@property (nonatomic, assign) double totalSendBytes;

/// Total audio bytes sent
@property (nonatomic, assign) double audioSendBytes;

/// Total video bytes sent
@property (nonatomic, assign) double videoSendBytes;

@end

Publish stream capture quality

The publish stream capture quality is close to the user's subjective feeling during preview. The relevant parameters of the audio and video quality of the SDK during the capture stage when publishing the stream are as follows:

  • audioCaptureFPS: Audio capture frame rate (fps)
  • videoCaptureFPS: Video capture frame rate (fps)

Publish stream encoding quality

The relevant parameters of the audio and video quality of the SDK during the encoding stage when publishing the stream are as follows:

videoEncodeFPS: The target video encoding frame rate of the current encoder (fps)

Publish stream sending quality

The publish stream sending quality is the actual quality of publishing the stream, which is related to the 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 the device to ZEGO Server (ms)
  • packetLostRate: Device uplink packet loss rate

Monitor play stream quality

  • Interface prototype

    /// Play stream quality callback
    /// @discussion After the stream is successfully played, this callback will be received every 3 seconds. Through this callback, you can obtain quality data such as frame rate, bitrate, RTT, packet loss rate of the played audio and video stream, and monitor the health status of the played stream in real time.
    /// @param quality Play stream quality
    /// @param streamID Stream ID
    - (void)onPlayerQualityUpdate:(ZegoPlayStreamQuality *)quality streamID:(NSString *)streamID;
  • Usage example

    Declare compliance with the ZegoEventHandler protocol in the class that needs to receive callbacks, and pass the class as the "eventHandler" parameter when calling the method to create the engine object. Then you can receive quality information callbacks by implementing this method.

    - (void)onPlayerQualityUpdate:(ZegoPlayStreamQuality *)quality streamID:(NSString *)streamID {
        NSLog(@"Video Received FPS: %f", quality.videoRecvFPS);
        NSLog(@"Video Decode FPS: %f", quality.videoDecodeFPS);
        NSLog(@"Video Render FPS: %f", quality.videoRenderFPS);
        NSLog(@"Video KBPS: %f", quality.videoKBPS);
        NSLog(@"Audio Received FPS: %f", quality.audioRecvFPS);
        NSLog(@"Audio Decode FPS: %f", quality.audioDecodeFPS);
        NSLog(@"Audio Render FPS: %f", quality.audioRenderFPS);
        NSLog(@"Audio KBPS: %f", quality.audioKBPS);
        NSLog(@"RTT: %d", quality.rtt);
        NSLog(@"Packet Lost Rate: %f", quality.packetLostRate);
        NSLog(@"Quality Level: %d", (int)quality.level);
        NSLog(@"Delay: %d", quality.delay);
        NSLog(@"is Hardware Decode: %d", quality.isHardwareDecode);
    }

Play stream quality details

Play stream quality includes the frame rate and bitrate of the received audio and video stream, delay and packet loss rate, the frame rate of the audio and video stream during the decoding stage, and the frame rate, freeze rate, and overall audio and video quality during the rendering stage. The specific definitions are as follows:

@interface ZegoPlayStreamQuality : NSObject

/// Video receiving frame rate, in f/s
@property (nonatomic, assign) double videoRecvFPS;

/// Video dejitter frame rate, in f/s
@property (nonatomic, assign) double videoDejitterFPS;

/// Video decoding frame rate, in f/s
@property (nonatomic, assign) double videoDecodeFPS;

/// Video rendering frame rate, in f/s
@property (nonatomic, assign) double videoRenderFPS;

/// Video bitrate, in kbps
@property (nonatomic, assign) double videoKBPS;

/// Video freeze rate, in (freeze counts/10 seconds)
/// No data to play for more than 500ms is considered a video freeze
@property (nonatomic, assign) double videoBreakRate;

/// Audio receiving frame rate, in f/s
@property (nonatomic, assign) double audioRecvFPS;

/// Audio dejitter frame rate, in f/s
@property (nonatomic, assign) double audioDejitterFPS;

/// Audio decoding frame rate, in f/s
@property (nonatomic, assign) double audioDecodeFPS;

/// Audio rendering frame rate, in f/s
@property (nonatomic, assign) double audioRenderFPS;

/// Audio bitrate, in kbps
@property (nonatomic, assign) double audioKBPS;

/// Audio freeze rate, in (freeze counts/10 seconds)
/// Losing 3 consecutive frames and no audio data rendering within a given freeze threshold is considered an audio freeze
@property (nonatomic, assign) double audioBreakRate;

/// Delay from the server to the local end, in milliseconds
@property (nonatomic, assign) int rtt;

/// Packet loss rate, in percentage, 0.0 ~ 1.0
@property (nonatomic, assign) double packetLostRate;

/// End-to-end delay, in milliseconds
@property (nonatomic, assign) int peerToPeerDelay;

/// End-to-end packet loss rate, in percentage, 0.0 ~ 1.0
@property (nonatomic, assign) double peerToPeerPacketLostRate;

/// Play stream quality level
@property (nonatomic, assign) ZegoStreamQualityLevel level;

/// Delay from receiving data to playing at the local end, in milliseconds
@property (nonatomic, assign) int delay;

/// The difference between the video timestamp and the audio timestamp, used to reflect the audio-video synchronization status, in milliseconds. A value less than 0 indicates the number of milliseconds the video is ahead of the audio, a value greater than 0 indicates the number of milliseconds the video lags behind the audio, and a value equal to 0 indicates no difference. When the absolute value is less than 200, it can be basically considered as audio-video synchronization. When the absolute value is continuously greater than 200 for 10 seconds, it can be considered abnormal
@property (nonatomic, assign) int avTimestampDiff;

/// Whether hardware decoding is enabled
@property (nonatomic, assign) BOOL isHardwareDecode;

/// Video encoding format
@property (nonatomic, assign) ZegoVideoCodecID videoCodecID;

/// Total bytes received, including audio, video and SEI, etc.
@property (nonatomic, assign) double totalRecvBytes;

/// Total audio bytes received
@property (nonatomic, assign) double audioRecvBytes;

/// Total video bytes received
@property (nonatomic, assign) double videoRecvBytes;

@end

Play stream receiving quality

The play stream receiving quality is the actual quality of playing the stream, which is related to the actual publish stream quality and the 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 counts/10 seconds)
  • videoKBPS: Actual received video frame rate (fps)
  • videoRecvFPS: Actual received video bitrate (kbps)
  • videoBreakRate: Actual received video freeze rate (freeze counts/10 seconds)
  • packetLostRate: Device downlink packet loss rate
  • rtt: Round-trip delay from the device to ZEGO Server (ms)

Play stream rendering quality

The 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

MethodDescription
onPublisherQualityUpdatePublish stream quality callback
onPlayerQualityUpdatePlay stream quality update callback

Previous

Using Token Authentication

Next

Network Speed Test