After reading this topic, you can learn more about the callback and listener interfaces of iOS SDK and Mac SDK.
Table of contents
The AliRtcEngineDelegate callback is shown as follows.
| 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 |
| onNetworkQualityChanged | Callback when the network quality changes. | 1.4 |
| 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 |
| onFirstPacketSentWithAudioTrack | The callback for successful data sending of the first frame. | 1.11 |
| onFirstRemoteVideoFrameDrawn | The callback when the first frame of the remote video stream is rendered. | 1.1 |
| onFirstPacketReceivedWithAudioTrack | The callback for successful data reception of the first packet. |
|
| onVideoDetectCallback | RTC collects video data callback (iOS only). | 1.14 |
| onUserAudioMuted | User muteAudio notification callback (iOS only). | 1.14 |
| onUserVideoMuted | User muteVideo notification callback (iOS only). | 1.14 |
| onUserAudioInterruptedBegin | User audio is interrupted notification callback (iOS only). | 1.14 |
| onUserAudioInterruptedEnded | User audio interrupt end notification callback (iOS only). | 1.14 |
| onConnectionLost | The network disconnect callback. | 1.14 |
| onTryToReconnect | Attempt network reconnection callback. | 1.14 |
| onConnectionRecovery | Callback for successful network reconnection. | 1.14 |
| onLeaveChannelResult | Leave the channel result callback. | 1.15 |
| onUserWillResignActive | The remote user application retreats to the background callback (iOS only). | 1.15 |
| onUserWillBecomeActive | The remote user application returns a foreground callback (iOS only). | 1.15 |
| onPerformanceLow | The callback for insufficient performance of the current device. | 1.16 |
| onPerformanceRecovery | The callback for performance recovery of the current device. | 1.16 |
| onUpdateRoleNotifyWithOldRole | Callback when the user role changes. | 1.16 |
| onFirstLocalVideoFrameDrawn | The local preview render gets the first frame callback (iOS only). | 1.16.2 |
| onAudioPlayingStateChanged | Accompanying playback callback (iOS only). | 1.16.2 |
| onLastmileDetectResultWithQuality | The network quality probe callback. | 1.16.2 |
| onAudioDeviceRecordLevel | Audio capture device test callback (Mac only). | 1.16.2 |
| onAudioDevicePlayoutLevel | Audio playback device test callback (Mac only). | 1.16.2 |
| onAudioDevicePlayoutEnd | The audio playback device test ends (Mac only). | 1.16.2 |
| onVideoSampleCallback | Subscribed video data callback (Mac only). | 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 |
| onVideoTexture | The Texture callback for the subscribed video. | 1.16.2 |
| onJoinChannelResult | Add channel result callback. |
|
| onPublishResult | The callback for the status change of the published stream. | 1.17 |
| onMediaRecordEvent | Recording event callback. | 1.17 |
| onRtcStats | Real-time data callback (triggered once in 2 seconds). | 1.17 |
| onRtcLocalVideoStats | The callback for local video statistics. | 1.17 |
| onRtcRemoteVideoStats | Remote video statistics callback. | 1.17 |
| onAudioSampleCallback | The callback for the subscribed audio data. | 1.17 |
| onAudioVolumeCallback | User volume size callback. | 1.17.9 |
| onMediaExtensionMsgReceived | Receive custom data callbacks. | 1.17.1 |
| onAudioEffectFinished | The callback for the end of sound playback. | 1.17.30 |
| onVideoTextureCreated | Texture callback for the subscribed video. | 1.17 |
| onVideoTextureDestory | Callback for the destruction of the Texture of the subscribed video. | 1.17 |
| onVideoPixelBuffer | The callback for subscribing to the video collection data. | 1.17 |
| onSubscribeResult | Callbacks for subscribing to media streams from remote users. | 1.17.39 |
| onUnsubscribeResult | Callback for unsubscribing a remote user media stream. | 1.17.39 |
API operation details
onRemoteUserOnLineNotify: remote user online callback.
- (void)onRemoteUserOnLineNotify:(NSString *)uid;Parameter Type Description uid NSString * The ID of the remote user. onRemoteUserOffLineNotify: remote user offline callback.
- (void)onRemoteUserOffLineNotify:(NSString *)uid;Parameter Type Description uid NSString * The ID of the remote user. onRemoteTrackAvailableNotify: callback when the audio and video streams of remote users change.
- (void)onRemoteTrackAvailableNotify:(NSString *)uid audioTrack:(AliRtcAudioTrack)audioTrack videoTrack:(AliRtcVideoTrack)videoTrack;Parameter Type Description uid NSString * 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:(NSString *)uid audioTrack:(AliRtcAudioTrack)audioTrack videoTrack:(AliRtcVideoTrack)videoTrack;Parameter Type Description uid NSString * The ID of the remote user. audioTrack AliRtcAudioTrack Subscribe to a successful audio stream. videoTrack AliRtcVideoTrack Subscribe to a successful video stream. onNetworkQualityChanged: Callback when the network quality changes. We recommend that you prompt users on the interface when the network quality is poor.
- (void)onNetworkQualityChanged:(NSString *)uid upNetworkQuality:(AliRtcNetworkQuality)upQuality downNetworkQuality:(AliRtcNetworkQuality)downQuality;Parameter Type Description uid NSString * 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. 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.
onFirstPacketSentWithAudioTrack: The callback for the first frame data being sent successfully.
- (void)onFirstPacketSentWithAudioTrack:(AliRtcAudioTrack)audioTrack videoTrack:(AliRtcVideoTrack)videoTrack;Parameter Type Description audioTrack AliRtcAudioTrack The type of audio stream that was sent successfully. videoTrack AliRtcVideoTrack The type of the successfully sent video stream. onFirstRemoteVideoFrameDrawn: the callback for the completion of rendering of the first frame of the remote video stream.
- (void)onFirstRemoteVideoFrameDrawn:(NSString *)uid videoTrack:(AliRtcVideoTrack)videoTrack;Parameter Type Description uid NSString * The ID of the remote user. videoTrack AliRtcVideoTrack The type of stream to render. onFirstPacketReceivedWithAudioTrack: The first data packet is received.
- iOS code, as follows:
- (void)onFirstPacketReceivedWithUid:(NSString *)uid audioTrack:(AliRtcAudioTrack)audioTrack videoTrack:(AliRtcVideoTrack)videoTrack; - Mac code, as follows:
- (void)onFirstPacketReceivedWithAudioTrack:(AliRtcAudioTrack)audioTrack videoTrack:(AliRtcVideoTrack)videoTrack;
Parameter Type Description audioTrack AliRtcAudioTrack The type of audio stream that was sent successfully. videoTrack AliRtcVideoTrack The type of the successfully sent video stream. - iOS code, as follows:
onVideoDetectCallback (available for iOS only):RTC collects video data callbacks.
Note The return value of the callback is of the long type. The face data detected in the App layer Face Recognition module returns the pointer of the structure stored in this face data to the SDK. After the SDK receives this pointer, it passes the receipt to the App again in the onVideoTexture callback.- (long)onVideoDetectCallback:(AliRtcVideoSource)type videoFrame:(AliRtcVideoDataSample *)videoFrame;Parameter Type Description type AliRtcVideoSource The type of the video stream. videoFrame AliRtcVideoDataSample * The video data frame. onUserAudioMuted (iOS only): Users cancel audio notifications.
- (void)onUserAudioMuted:(NSString *)uid audioMuted:(BOOL)isMute;Parameter Type Description uid NSString * The ID of the user. isMute BOOL YES indicates mute, and NO indicates unmute. onUserVideoMuted (iOS only): Users cancel video notifications.
- (void)onUserVideoMuted:(NSString *)uid videoMuted:(BOOL)isMute;Parameter Type Description uid NSString * The ID of the user. isMute BOOL YES indicates ingest black frames, and NO indicates normal ingest. onUserAudioInterruptedBegin (only available for iOS): User audio is interrupted notification (general user calls and other audio preemption scenarios).
- (void)onUserAudioInterruptedBegin:(NSString *)uid;Parameter Type Description uid NSString * The ID of the user whose audio was interrupted. onUserAudioInterruptedEnded (available for iOS only): User audio interruption end notification (corresponding onUserAudioInterruptedBegin).
- (void)onUserAudioInterruptedEnded:(NSString *)uid;Parameter Type Description uid NSString * The ID of the user whose audio interruption ended. onConnectionLost: network disconnection callback. The Mac environment supports this callback since version 1.15.
- (void)onConnectionLost;onTryToReconnect: Attempt the network reconnection callback. The Mac environment supports this callback since version 1.15.
- (void)onTryToReconnect;onConnectionRecovery: The callback for successful network reconnection. The Mac environment supports this callback since version 1.15.
- (void)onConnectionRecovery;onLeaveChannelResult: Leave the channel result callback. This callback is returned after you call the leaveChannel operation. If you call destroy directly after you call the leaveChannel operation, no callback is received.
- (void)onLeaveChannelResult:(int)result;Parameter Type Description result int 0 is returned for success and an error code is returned for failure. onUserWillResignActive: The remote user application is retreated to the background.
(void)onUserWillResignActive:(NSString *)uidParameter Type Description uid NSString * The ID of the user. onUserWillBecomeActive: The remote user application returns to the foreground.
(void)onUserWillBecomeActive:(NSString *)uidParameter Type Description uid NSString * The ID of the user. onPerformanceLow: the callback for insufficient performance of the current device.
- (void)onPerformanceLow;onPerformanceRecovery: the callback for performance recovery of the current device.
- (void)onPerformanceRecovery;onUpdateRoleNotifyWithOldRole: callback when the user role changes (this callback is triggered when the setClientRole method is called to switch the role successfully).
- (void)onUpdateRoleNotifyWithOldRole:(AliRtcClientRole)oldRole newRole:(AliRtcClientRole)newRole;Parameter Type Description oldRole AliRtcClientRole The type of the role before the change. newRole AliRtcClientRole The role type after the change. onFirstLocalVideoFrameDrawn: local preview rendering gets the first frame callback.
- (void)onFirstLocalVideoFrameDrawn;onAudioPlayingStateChanged: Accompaniment playback callback.
/** * @brief The playback status of the accompaniment. * @param playState The current playback status. * @param errorCode The error code is returned. */ - (void)onAudioPlayingStateChanged:(AliRtcAudioPlayingStateCode)playState errorCode:(AliRtcAudioPlayingErrorCode)errorCode;Parameter Type Description playStatus AliRtcAudioPlayingStateCode The current playback status. errorCode int The error code returned. onLastmileDetectResultWithQuality: network quality detection callback.
- (void)onLastmileDetectResultWithQuality:(AliRtcNetworkQuality)networkQuality;Parameter Type Description networkQuality AliRtcNetworkQuality Network quality. onAudioDeviceRecordLevel: the audio capture device test callback.
- (void)onAudioDeviceRecordLevel:(int)level;Parameter Type Description level int The audio collection device volume value. onAudioDevicePlayoutLevel: the audio playback device test callback.
- (void)onAudioDevicePlayoutLevel:(int) level;Parameter Type Description level int The volume value of the audio playback device. onAudioDevicePlayoutEnd: The audio playback device test ends (the audio file is played).
- (void)onAudioDevicePlayoutEnd;onVideoSampleCallback: the callback of the subscribed video data.
- (void)onVideoSampleCallback:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource videoSample:(AliRtcVideoDataSample *)videoSample;Parameter Type Description uid NSString * The ID of the user. type AliRtcVideoSource The type of the video stream. videoSample AliRtcVideoDataSample * The frame rate of the video. onCaptureVideoSample: the callback for subscribed locally collected video data.
- (void)onCaptureVideoSample:(AliRtcVideoSource)videoSource videoSample:(AliRtcVideoDataSample *)videoSample;Parameter Type Description videoSource AliRtcVideoSource The video source. videoSample AliRtcVideoDataSample * The frame rate of the video. onRemoteVideoSample: the callback for subscribed remote video data.
- (void)onRemoteVideoSample:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource videoSample:(AliRtcVideoDataSample *)videoSample;Parameter Type Description uid NSString * The ID of the user. videoSource AliRtcVideoSource The type of the video stream. videoSample AliRtcVideoDataSample * The frame rate of the video. onVideoTexture: the video texture (texture) callback for the subscription.
- (int)onVideoTexture:(NSString *)uid videoTextureType:(AliRtcVideoTextureType)videoTextureType textureId:(int)textureId width:(int)width height:(int)height rotate:(int)rotate extraData:(long)extraData ;Parameter Type Description uid NSString * The ID of the user. videoTextureType AliRtcVideoTextureType The type of the texture. textureId int The ID of the texture. width int The width of the video. height int The height of the video. rotate int The video direction. extraData long The pointer to the face data structure of the long data type is returned in the onVideoDetectCallback callback. onJoinChannelResult: Add channel result callback (this callback is equivalent to calling the block operation of the joinChannel interface. When you are processing events after adding a channel, select one of them).
- iOS code, as follows:
(void)onJoinChannelResult:(int)result authInfo:(AliRtcAuthInfo *)authInfo; - Mac code, as follows:
- (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. - iOS code, as follows:
onPublishResult: The status of the publish stream changes. This callback is equivalent to calling the block operation of the publish operation. When you are processing events after publishing, select one of them.
- (void)onPublishResult:(int)result isPublished:(BOOL)isPublished;Parameter Type Description result int The result of the current push-pull stream. isPublished BOOL Indicates whether the stream is being ingested. Valid values: - YES: Yes.
- NO: No.
onMediaRecordEvent: the callback for recording events.
- (void)onMediaRecordEvent:(int)event filePath:(NSString *)filePath;Parameter Type 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 NSString * The path of the recording file. onRtcStats: real-time data callback (triggered once in 2 seconds).
- (void)onRtcStats:(AliRtcStats)stats;Parameter Type Description stats AliRtcStats Data callback. onRtcLocalVideoStats: local video statistics callback, which is triggered once in 2 seconds.
- (void)onRtcLocalVideoStats:(AliRtcLocalVideoStats *)localVideoStats;Parameter Type Description localVideoStats AliRtcLocalVideoStats * The statistics on local videos. onRtcRemoteVideoStats: remote video statistics callback, which is triggered once in 2 seconds.
- (void)onRtcRemoteVideoStats:(AliRtcRemoteVideoStats *)remoteVideoStats;Parameter Type Description remoteVideoStats AliRtcLocalVideoStats * The statistics on remote videos. onAudioSampleCallback: the callback of the subscribed audio data.
- (void)onAudioSampleCallback:(AliRtcAudioSource)audioSource audioSample:(AliRtcAudioDataSample *)audioSample;Parameter Type Description audioSource AliRtcAudioSource The type of the bare audio data source. audioSample AliRtcAudioDataSample * The bare audio data. onAudioVolumeCallback: user volume callback. Voice status and uid.
- (void)onAudioVolumeCallback:(AliRtcAudioSource)audioSource userAudioinfo:(NSArray <AliRtcUserVolumeInfo *> *)array;Parameter Type Description audioSource AliRtcAudioSource The type of the audio data. array NSArray <AliRtcUserVolumeInfo*> * Callback user volume information array, including user UID, voice status, and volume. - onMediaExtensionMsgReceived: Receive custom data callback. When a user sends custom data in a room, you can use this callback to receive data.
- (void)onMediaExtensionMsgReceived:(NSString *)uid message:(NSData *)data;Parameter Type Description uid NSString The UID of the Alibaba Cloud account. data NSData The received custom data. - onAudioEffectFinished: the callback for the end of sound playback.
- (void)onAudioEffectFinished:(int)soundId;Parameter Type Description soundId int The ID assigned by the user to the sound effect file. - onVideoTextureCreated: the Texture callback for the subscription video.
- (void)onVideoTextureCreated:(NSString *)uid videoTextureType:(AliRtcVideoTextureType)videoTextureType context:(void *)context;Parameter Type Description uid NSString * The ID of the user. videoTextureType AliRtcVideoTextureType The type of the texture. context void * OpenGL context. - onVideoTextureDestory: the callback for the texture of the subscribed video to be destroyed.
- (void)onVideoTextureDestory:(NSString *)uid videoTextureType:(AliRtcVideoTextureType)videoTextureType;Parameter Type Description uid NSString * The ID of the user. videoTextureType AliRtcVideoTextureType The type of the texture. - onVideoPixelBuffer: Subscribe to the callback for video collection data.
- (void)onVideoPixelBuffer:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource pixelBuffer:(CVPixelBufferRef)pixelBuffer;Parameter Type Description uid NSString * The ID of the user. videoSource AliRtcVideoSource The type of the bare video data source. pixelBuffer CVPixelBufferRef The video texture buffer. - onSubscribeResult: the callback for subscribing to the media stream of the remote user.
- (void)onSubscribeResult:(NSString *)uid result:(int)result audioTrack:(AliRtcAudioTrack)audioTrack videoTrack:(AliRtcVideoTrack)videoTrack;Parameter Type Description uid NSString * The ID of the remote user. result int The subscription result. 0 indicates that the subscription is successful. An error code is returned if the subscription fails. audioTrack AliRtcAudioTrack Subscribe to a successful audio stream. videoTrack AliRtcAudioTrack Subscribe to a successful video stream. - onUnsubscribeResult: the callback for unsubscribing a media stream from a remote user.
- (void)onUnsubscribeResult:(NSString *)uid result:(int)result;Parameter Type Description uid NSString * The ID of the remote user. result int The subscription result. 0 indicates that the subscription is canceled. An error code is returned if the subscription fails.