This topic describes the callback and listener interfaces of the Windows SDK.
Table of contents
AliRtcEventListener(AliRtcEngine callback)
| API | Description | Supported in the above version |
| onRemoteUserOnLineNotify | Remote user launch callback. | 1.1 |
| onRemoteUserOffLineNotify | Remote user offline callback. | 1.1 |
| onRemoteTrackAvailableNotify | Callback when the audio and video streams of remote users change. | 1.1 |
| onSubscribeChangedNotify | The callback for the subscription result. | 1.1 |
| onFirstRemoteVideoFrameDrawn | The callback when the first frame of the remote video stream is rendered. | 1.1 |
| onOccurWarning | Warning callback. | 1.1 |
| onOccurError | Error callback. | 1.1 |
| onBye | Callback when the server is kicked out or the channel is closed. | 1.1 |
| onExternalDeviceStateChange | The callback for the status change of the external device. | 1.11 |
| onFirstPacketReceived | The callback for successful data reception of the first packet. | 1.13 |
| onFirstPacketSent | The callback for successful data sending of the first frame. | 1.11 |
| onLeaveChannelResult | Leave the channel result callback. | 1.15 |
| onConnectionLost | The network disconnect callback. | 1.15 |
| onTryToReconnect | Attempt network reconnection callback. | 1.15 |
| onConnectionRecovery | Callback for successful network reconnection. | 1.15 |
| onNetworkQualityChanged | Callback when the network quality changes. | 1.15 |
| onUpdateRoleNotify | Callback when the user role changes. | 1.16 |
| onRTCStats | Real-time data callback (triggered once in 2 seconds). | 1.17 |
| onPerformanceLow | The callback for insufficient performance of the current device. | 1.16.2 |
| onPerformanceRecovery | The callback for performance recovery of the current device. | 1.17.19 |
| onLastmileDetectResultWithQuality | The network quality probe callback. | 1.16.2 |
| onAudioSampleCallback | The callback for the subscribed audio data. | 1.16.2 |
| onCaptureVideoSample | The callback for the locally collected video data of the subscription. | 1.16.2 |
| onRemoteVideoSample | The callback of the subscribed remote video data. | 1.16.2 |
| onJoinChannelResult | Add channel result callback. | 1.17 |
| onPublishChangedNotify | The callback for the stream ingest result. | 1.17 |
| onRTCLocalVideoStats | The callback for local video statistics. | 1.17 |
| onRTCRemoteVideoStats | Remote video statistics callback. | 1.17 |
| onMediaRecordEvent | Recording event callback. | 1.17.9 |
| onAudioVolumeCallback | User volume size callback. | 1.17.9 |
| onMediaExtensionMsgReceived | Receive custom data callbacks. | 1.17.1 |
API operation details
onRemoteUserOnLineNotify: remote user online callback.
void onRemoteUserOnLineNotify(const AliRtc::String& uid)Parameter Type Description uid const AliRtc::String& The ID of the remote user. onRemoteUserOffLineNotify: remote user offline callback.
void onRemoteUserOffLineNotify(const AliRtc::String& uid)Parameter Type Description uid const AliRtc::String& The ID of the remote user. onRemoteTrackAvailableNotify: callback when the audio and video streams of remote users change.
Note This callback is also triggered if a remote user stops publishing.void onRemoteTrackAvailableNotify(const AliRtc::String& uid, AliRtcAudioTrack audioTrack, AliRtcVideoTrack videoTrack)Parameter Type Description uid const AliRtc::String& The ID of the remote user. audioTrack AliRtcAudioTrack The audio stream after the remote user changes. videoTrack AliRtcVideoTrack The video stream after the remote user changes. onSubscribeChangedNotify: the callback for subscription results.
void onSubscribeChangedNotify(const AliRtc::String& uid, AliRtcAudioTrack audioTrack, AliRtcVideoTrack videoTrack)Parameter Type Description uid const AliRtc::String& The ID of the remote user. audioTrack AliRtcAudioTrack Subscribe to a successful audio stream. videoTrack AliRtcVideoTrack Subscribe to a successful video stream. onFirstRemoteVideoFrameDrawn: the callback for the completion of rendering of the first frame of the remote video stream.
void onFirstRemoteVideoFrameDrawn(const AliRtc::String& uid, AliRtcVideoTrack videoTrack)Parameter Type Description uid const AliRtc::String& The ID of the remote user. videoTrack AliRtcVideoTrack The type of stream to render. onOccurWarning: a warning callback. Currently, the warning callback can be ignored and will not affect normal use.
void onOccurWarning(int warn)Parameter Type Description warn int The type of the warning. onOccurError: the error callback.
If the parameter error is 16908812 or 33620229, you need to call destroy to destroy the instance, recreate the SDK instance, and then call joinChannel to join the channel.
void onOccurError(int error)Parameter Type Description error int The type of the error that occurred. onBye: callback when the server is kicked out or the channel is closed.
void onBye(int code)Parameter Type Description code int The type of the message. Valid values: - 1: kicked out by the server.
- 2: The channel is closed.
- 3: The same user ID is logged on to another end and kicked out by the server.
- onExternalDeviceStateChange: The status of the external device changes.
virtual void onExternalDeviceStateChange(const AliRtc::String &deviceName, AliRtcExternalDeviceState state) {};Parameter Type Description deviceName AliRtc::String The external device name. state AliRtcExternalDeviceState The status of the external device. - onFirstPacketReceived: the callback function that sends the first packet.
virtual void onFirstPacketReceived(const AliRtc::String &uid, AliRtcAudioTrack audioTrack, AliRtcVideoTrack videoTrack) {};Parameter Type Description audioTrack AliRtcAudioTrack The ID of the audio. videoTrack AliRtcVideoTrack The ID of the video. onFirstPacketSent: The callback for the first frame data being sent successfully.
void onFirstPacketSent(AliRtcAudioTrack audioTrack, AliRtcVideoTrack videoTrack)Parameter Type Description audioTrack AliRtcAudioTrack The first audio packet is sent. videoTrack AliRtcVideoTrack The first packet of the video is sent. onLeaveChannelResult: Leave the channel result callback.
void onLeaveChannelResult(int result)Parameter Type Description result int 0 is returned if successful and error code information is returned if failed. onConnectionLost: network disconnection callback.
void onConnectionLost()onTryToReconnect: Attempt the network reconnection callback.
void onTryToReconnect()onConnectionRecovery: The callback for successful network reconnection.
void onConnectionRecovery()onNetworkQualityChanged: callback when the network quality changes.
void onNetworkQualityChanged(const AliRtc::String &uid,AliRtcNetworkQuality upQuality,AliRtcNetworkQuality downQuality)Parameter Type Description uid AliRtc::String The ID of the user whose network quality has changed. If the user ID is empty, it means local, and others means remote. upQuality AliRtcNetworkQuality Upstream network quality. downQuality AliRtcNetworkQuality The downstream network quality. onUpdateRoleNotify: callback when the user role changes.
void onUpdateRoleNotify(const AliRtcClientRole old_role, const AliRtcClientRole new_role) {};Parameter Type Description old_role AliRtcClientRole The role before the switch. new_role AliRtcClientRole The role after the switch. onRTCStats: real-time data callback (triggered once in 2 seconds). The SDK triggers this statistics callback every two seconds.
Note The name of a 1.17 or later method is changed from onAliRTCStats to onRTCStats.virtual void onRTCStats(const AliRtcStats& stats)Parameter Type Description stats const AliRtcStats& Session statistics. onPerformanceLow: the callback for insufficient performance of the current device.
virtual void onPerformanceLow()onPerformanceRecovery : the callback for performance recovery of the current device.
virtual void onPerformanceRecovery()onLastmileDetectResultWithQuality: network quality detection callback.
virtual void onLastmileDetectResultWithQuality(AliRtcNetworkQuality networkQuality)Parameter Type Description networkQuality AliRtcNetworkQuality Network quality. onAudioSampleCallback: the callback of the subscribed audio data.
virtual void onAudioSampleCallback(AliRtcAudioSource type, AliRtcAudioDataSample *audioSample)Parameter Type Description type AliRtcAudioSource The type of the audio data source. audioSample AliRtcAudioDataSample * The audio data. onAudioVolumeCallback : user volume callback. In the AliRtcUserVolumeInfo, user_id is 0 to indicate the local stream ingest volume, 1 to indicate the remote mixing volume, and others to indicate the volume of the user.
virtual void onAudioVolumeCallback(AliRtcAudioSource type, const AliRtcUserVolumeInfo* userVolumeInfo, int userVolumeNumber) {};Parameter Type Description type AliRtcAudioSource The type of the audio data source. userVolumeInfo const AliRtcUserVolumeInfo* An array of user volume information. userVolumeNumber int The number of user volume information. - onMediaExtensionMsgReceived: Receive custom data callback. When a user sends custom data in a room, you can use this callback to receive data.
virtual void onMediaExtensionMsgReceived(const AliRtc::String &uid, unsigned char* message, int size) {};Parameter Type Description uid const AliRtc::String & User uid. message unsigned char* The received custom data. size int The length of the received data. onCaptureVideoSample : the callback for subscribed locally collected video data.
virtual void onCaptureVideoSample(AliRtcVideoSource videoSource, AliRtcVideoDataSample *videoSample)Parameter Type Description videoSource AliRtcVideoSource The type of the video data. videoSample AliRtcVideoDataSample * Video data. onRemoteVideoSample : the callback for subscribed remote video data.
virtual void onRemoteVideoSample(const AliRtc::String &uid, AliRtcVideoSource videoSource, AliRtcVideoDataSample *videoSample)Parameter Type Description uid const AliRtc::String & The ID of the user. videoSource AliRtcVideoSource The type of the video source. videoSample AliRtcVideoDataSample * Video data. onJoinChannelResult: Add channel result callback.
virtual void onJoinChannelResult(int result) {};Parameter Type Description result int The result of adding a channel. 0 is returned if it is successful and an error code is returned if it fails. onPublishChangedNotify: callback for stream ingest results.
virtual void onPublishChangedNotify(int result, bool isPublished) {};Parameter Parameter Description result int The result is returned. 0 is returned if it is successful. An error code is returned if it fails. isPublished int Indicates whether the stream is being ingested. Valid values: true | false. onRTCLocalVideoStats: local video statistics callback.
virtual void onRTCLocalVideoStats(const AliRtcLocalVideoStats& local_video_stats) {};Parameter Type Description local_video_stats AliRtcLocalVideoStats The statistics on local videos. onRTCRemoteVideoStats: remote video statistics callback.
vvirtual void onRTCRemoteVideoStats(const AliRtcRemoteVideoStats& remote_video_stats) {};Parameter Type Description remote_video_stats AliRtcRemoteVideoStats The statistics on remote videos. onMediaRecordEvent: the callback for recording events.
virtual void onMediaRecordEvent(int event, const AliRtc::String &filePath) {};Parameter Parameter Description event int Record events. Valid values: - 0: The recording starts.
- 1: The recording ends.
- 2: Failed to open the file.
- 3: Failed to write the file.
filePath const AliRtc::String & Recording file path