IRtcEngineEventHandler

The SDK uses the IRtcEngineEventHandler interface to send event notifications to your app. Your app can get those notifications through methods that inherit this interface.

All methods in this interface have default (empty) implementation. You can choose to inherit events related to your app scenario.

Attention:
  • In the callbacks, avoid implementing time-consuming tasks or calling APIs that may cause thread blocking (such as sendMessage). Otherwise, the SDK may not work properly.
  • The SDK no longer catches exceptions in the code logic that developers implement themselves in IRtcEngineEventHandler class. You need to handle this exception yourself, otherwise the app may crash when the exception occurs.

FOnActiveSpeaker

Occurs when the most active remote speaker is detected.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnActiveSpeaker, int64, userId);

After a successful call of EnableAudioVolumeIndication, the SDK continuously detects which remote user has the loudest volume. During the current period, the remote user whose volume is detected as the loudest for the most times, is the most active user.

When the number of users is no less than two and an active remote speaker exists, the SDK triggers this callback and reports the uid of the most active remote speaker.
  • If the most active remote speaker is always the same user, the SDK triggers the FOnActiveSpeaker callback only once.
  • If the most active remote speaker changes to another user, the SDK triggers this callback again and reports the uid of the new active remote speaker.

Parameters

userId
The user ID of the most active speaker.

FOnAudioDeviceStateChanged

Occurs when the audio device state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnAudioDeviceStateChanged, FString, deviceId, int, deviceType, int, deviceState);

This callback notifies the application that the system's audio device state is changed. For example, a headset is unplugged from the device.

Note: This method is for Windows and macOS only.

Parameters

deviceId
The device ID.
deviceType
The device type. See EENUMCUSTOM_MEDIA_DEVICE_TYPE.
deviceState
The device state. See MEDIA_DEVICE_STATE_TYPE.

FOnAudioDeviceVolumeChanged

Reports the volume change of the audio device or app.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnAudioDeviceVolumeChanged, FENUMWRAP_MEDIA_DEVICE_TYPE, deviceType, int, volume, bool, muted);

Occurs when the volume on the playback device, audio capture device, or the volume of the app changes.

Note: This callback is for Windows and macOS only.

Parameters

deviceType
The device type. See EENUMCUSTOM_MEDIA_DEVICE_TYPE.
volume
The volume value. The range is [0, 255].
muted
Whether the audio device is muted:
  • true: The audio device is muted.
  • false: The audio device is not muted.

FOnAudioEffectFinished

Occurs when the playback of the local music file finishes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAudioEffectFinished, int, soundId);

This callback occurs when the local audio effect file finishes playing.

Parameters

soundId
The ID of the audio effect. The ID of each audio effect file is unique.

FOnAudioMixingFinished

Occurs when the playback of the local music file finishes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnAudioMixingFinished);
Deprecated:
Use FOnAudioMixingStateChanged instead.

After you call StartAudioMixing to play a local music file, this callback occurs when the playback finishes. If the call of StartAudioMixing fails, the error code WARN_AUDIO_MIXING_OPEN_ERROR is returned.

FOnAudioMixingStateChanged

Occurs when the playback state of the music file changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnAudioMixingStateChanged, FENUMWRAP_AUDIO_MIXING_STATE_TYPE, state, FENUMWRAP_AUDIO_MIXING_REASON_TYPE, reason);

This callback occurs when the playback state of the music file changes, and reports the current state and error code.

Parameters

state
The playback state of the music file. See EENUMCUSTOM_AUDIO_MIXING_STATE_TYPE.
reason
Error code. See EENUMCUSTOM_AUDIO_MIXING_REASON_TYPE.

FOnAudioPublishStateChanged

Occurs when the audio publishing state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnAudioPublishStateChanged, FString, channel, ESTREAM_PUBLISH_STATE, oldState, ESTREAM_PUBLISH_STATE, newState, int, elapseSinceLastState);

Parameters

channel
The channel name.
oldState
The previous publishing state. See ESTREAM_PUBLISH_STATE.
newState
The current publishing stat. See ESTREAM_PUBLISH_STATE.
elapseSinceLastState
The time elapsed (ms) from the previous state to the current state.

FOnAudioQuality

Reports the statistics of the audio stream sent by each remote user.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnAudioQuality, int64, uid, int, quality, int, delay, int, lost);
Deprecated:
Use FOnRemoteAudioStats instead.

The SDK triggers this callback once every two seconds to report the audio quality of each remote user who is sending an audio stream. If a channel has multiple users sending audio streams, the SDK triggers this callback as many times.

Parameters

uid
The user ID of the remote user sending the audio stream.
quality
Audio quality of the user.
  • QUALITY_UNKNOWN(0): The quality is unknown.
  • QUALITY_EXCELLENT(1): The quality is excellent.
  • QUALITY_GOOD(2): The network quality seems excellent, but the bitrate can be slightly lower than excellent.
  • QUALITY_POOR(3): Users can feel the communication is slightly impaired.
  • QUALITY_BAD(4): Users cannot communicate smoothly.
  • QUALITY_VBAD(5): The quality is so bad that users can barely communicate.
  • QUALITY_DOWN(6): The network is down, and users cannot communicate at all.
delay
The network delay (ms) from the sender to the receiver, including the delay caused by audio sampling pre-processing, network transmission, and network jitter buffering.
lost
The packet loss rate (%) of the audio packet sent from the remote user to the receiver.

FOnAudioRoutingChanged

Occurs when the local audio route changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAudioRoutingChanged, int, routing);
Note:

This method is for Android, iOS and macOS only.

Parameters

routing
The current audio routing.
  • ROUTE_DEFAULT(-1): The default audio route.
  • ROUTE_HEADSET(0): The audio route is a headset with a microphone.
  • ROUTE_EARPIECE(1): The audio route is an earpiece.
  • ROUTE_HEADSETNOMIC(2): The audio route is a headset without a microphone.
  • ROUTE_SPEAKERPHONE(3): The audio route is the speaker that comes with the device.
  • ROUTE_LOUDSPEAKER(4): (For future use) The audio route is an external speaker.
  • (5): The audio route is a Bluetooth device using the HFP protocol.
  • (10): The audio route is a Bluetooth device using the A2DP protocol..

FOnAudioSubscribeStateChanged

Occurs when the audio subscribing state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnAudioSubscribeStateChanged, FString, channel, int64, uid, ESTREAM_SUBSCRIBE_STATE, oldState, ESTREAM_SUBSCRIBE_STATE, newState, int, elapseSinceLastState);

Parameters

channel
The channel name.
uid
The user ID of the remote user.
oldState
The previous subscribing status. See ESTREAM_SUBSCRIBE_STATE.
newState
The current subscribing status. See ESTREAM_SUBSCRIBE_STATE.
elapseSinceLastState
The time elapsed (ms) from the previous state to the current state.

FOnAudioVolumeIndication

Reports the volume information of users.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnAudioVolumeIndication, const TArray<FAudioVolumeInfo>&, speakers, int, totalVolume);

By default, this callback is disabled. You can enable it by calling EnableAudioVolumeIndication. Once this callback is enabled and users send streams in the channel, the SDK triggers the FOnAudioVolumeIndication callback according to the time interval set in EnableAudioVolumeIndication. The SDK triggers two independent FOnAudioVolumeIndication callbacks simultaneously, which separately report the volume information of the local user who sends a stream and the remote users (up to three) whose instantaneous volume is the highest.

Attention:

Once this callback is enabled, if the local user calls the MuteLocalAudioStream method to mute, the SDK continues to report the volume indication of the local user.

If a remote user whose volume is one of the three highest in the channel stops publishing the audio stream for 20 seconds, the callback excludes this user's information; if all remote users stop publishing audio streams for 20 seconds, the SDK stops triggering the callback for remote users.

Parameters

speakers
The volume information of the users. See FAudioVolumeInfo. An empty speakers array in the callback indicates that no remote user is in the channel or is sending a stream.
totalVolume
The volume of the speaker. The value range is [0,255].
  • In the callback for the local user, totalVolume is the volume of the local user who sends a stream.
  • In the callback for remote users, totalVolume is the sum of the volume of all remote users (up to three) whose instantaneous volume is the highest. If the user calls StartAudioMixing, then totalVolume is the volume after audio mixing.

FOnCameraExposureAreaChanged

Occurs when the camera exposure area changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnCameraExposureAreaChanged, int, x, int, y, int, width, int, height);

The SDK triggers this callback when the local user changes the camera exposure position by calling SetCameraExposurePosition.

Attention: This callback is for Android and iOS only.

Parameters

x
The x coordinate of the changed camera exposure area.
y
The y coordinate of the changed camera exposure area.
width
The width of the changed camera exposure area.
height
The height of the changed exposure area.

FOnCameraFocusAreaChanged

Occurs when the camera focus area changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnCameraFocusAreaChanged, int, x, int, y, int, width, int, height);
Attention: This callback is for Android and iOS only.

Parameters

x
The x-coordinate of the changed camera focus area.
y
The y-coordinate of the changed camera focus area.
width
The width of the changed camera focus area.
height
The height of the changed camera focus area.

FOnCameraReady

Occurs when the camera turns on and is ready to capture the video.

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnCameraReady);
Deprecated:

Use LOCAL_VIDEO_STREAM_STATE_CAPTURING(1) in FOnLocalVideoStateChanged instead.

This callback indicates that the camera has been successfully turned on and you can start to capture video.

FOnChannelMediaRelayEvent

Reports events during the media stream relay.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnChannelMediaRelayEvent, int, code);
Deprecated:
This callback is deprecated.

Parameters

code
The event code of channel media relay:
  • RELAY_EVENT_NETWORK_DISCONNECTED(0): The user disconnects from the server due to a poor network connection.
  • RELAY_EVENT_NETWORK_CONNECTED(1): The user is connected to the server.
  • RELAY_EVENT_PACKET_JOINED_SRC_CHANNEL(2): The user joins the source channel.
  • RELAY_EVENT_PACKET_JOINED_DEST_CHANNEL(3): The user joins the target channell.
  • RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL(4): The SDK starts relaying the media stream to the target channel.
  • RELAY_EVENT_PACKET_RECEIVED_VIDEO_FROM_SRC(5): The server receives the video stream from the source channel.
  • RELAY_EVENT_PACKET_RECEIVED_AUDIO_FROM_SRC(6): The server receives the audio stream from the source channel.
  • RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL(7): The target channel is updated.
  • RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE(9): The target channel does not change, which means that the target channel fails to be updated.
  • RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_IS_NULL(10): The target channel name is NULL.
  • RELAY_EVENT_VIDEO_PROFILE_UPDATE(11): The video profile is sent to the server.
  • RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS(12): The SDK successfully pauses relaying the media stream to target channels.
  • RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_FAILED(13): The SDK fails to pause relaying the media stream to target channels.
  • RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS(14): The SDK successfully resumes relaying the media stream to target channels.
  • RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_FAILED(15): The SDK fails to resume relaying the media stream to target channels.

FOnChannelMediaRelayStateChanged

Occurs when the state of the media stream relay changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnChannelMediaRelayStateChanged, int, state, int, code);

The SDK returns the state of the current media relay with any error message.

Parameters

state
The state code:
  • RELAY_STATE_IDLE(0): The SDK is initializing.
  • RELAY_STATE_CONNECTING(1): The SDK tries to relay the media stream to the destination channel.
  • RELAY_STATE_RUNNING(2): The SDK successfully relays the media stream to the destination channel.
  • RELAY_STATE_FAILURE(3): An error occurs. See code for the error code.
code
The error code of the channel media relay.
  • RELAY_OK(0): Everything is normal.
  • RELAY_ERROR_SERVER_ERROR_RESPONSE(1): An error occurs in the server response.
  • RELAY_ERROR_SERVER_NO_RESPONSE(2): No server response. This error may be caused by poor network connections. If this error occurs when initiating a channel media relay, you can try again later; if this error occurs during channel media relay, you can call LeaveChannel to leave the channel. This error can also occur if the channel media relay service is not enabled in the project. You can contact technical support to enable the service.
  • RELAY_ERROR_NO_RESOURCE_AVAILABLE(3): The SDK fails to access the service, probably due to limited resources of the server.
  • RELAY_ERROR_FAILED_JOIN_SRC4: The server fails to send the relay request.
  • RELAY_ERROR_FAILED_JOIN_DEST5: The server fails to accept the relay request.
  • RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC6: The server fails to receive the media stream.
  • RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST7: The server fails to send the media stream.
  • RELAY_ERROR_SERVER_CONNECTION_LOST(8): The SDK disconnects from the server due to poor network connections. You can call LeaveChannel to leave the channel.
  • RELAY_ERROR_INTERNAL_ERROR(9): An internal error occurs in the server.
  • RELAY_ERROR_SRC_TOKEN_EXPIRED(10): The token of the source channel has expired.
  • RELAY_ERROR_DEST_TOKEN_EXPIRED(11): The token of the destination channel has expired.

FOnClientRoleChanged

Occurs when the user role or the audience latency level changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnClientRoleChanged, ECLIENT_ROLE_TYPE, oldRole, ECLIENT_ROLE_TYPE, newRole, FClientRoleOptions, roleoption);

Trigger timing

This callback will be triggered in any of the following situations:
  • Calling SetClientRole to set the user role or audience latency level after joining a channel.
  • Calling SetClientRole to set the user role to AUDIENCE before joining a channel.

Restrictions

This callback will not be triggered when you call setClientRole [1/2] or SetClientRole and set the user role to BROADCASTER before joining a channel.

Parameters

oldRole
Role that the user switches from: ECLIENT_ROLE_TYPE.
newRole
Role that the user switches to: ECLIENT_ROLE_TYPE.
newRoleOptions

Properties of the role that the user switches to. See FClientRoleOptions.

FOnClientRoleChangeFailed

Occurs when switching a user role fails.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnClientRoleChangeFailed, ECLIENT_ROLE_CHANGE_FAILED_REASON, reason, ECLIENT_ROLE_TYPE, currentRole);

This callback informs you about the reason for failing to switching and your current user role.

Trigger timing

The SDK triggers this callback when the local user calls SetClientRole after joining a channel to switch the user role but the switching fails.

Restrictions

None.

Parameters

reason
The reason for a user role switch failure. See ECLIENT_ROLE_CHANGE_FAILED_REASON.
currentRole
Current user role. See ECLIENT_ROLE_TYPE.

FOnConnectionInterrupted

Occurs when the connection between the SDK and the server is interrupted.

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnConnectionInterrupted);
Deprecated:
Use FOnConnectionStateChanged instead.
The SDK triggers this callback when it loses connection with the server for more than four seconds after the connection is established. After triggering this callback, the SDK tries to reconnect to the server. You can use this callback to implement pop-up reminders. The differences between this callback and FOnConnectionLost are as follow:
  • The SDK triggers the FOnConnectionInterrupted callback when it loses connection with the server for more than four seconds after it successfully joins the channel.
  • The SDK triggers the FOnConnectionLost callback when it loses connection with the server for more than 10 seconds, whether or not it joins the channel.
If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora's edge server, the SDK stops rejoining the channel.

FOnConnectionLost

Occurs when the SDK cannot reconnect to Agora's edge server 10 seconds after its connection to the server is interrupted.

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnConnectionLost);

The SDK triggers this callback when it cannot connect to the server 10 seconds after calling the JoinChannel method, regardless of whether it is in the channel. If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora's edge server, the SDK stops rejoining the channel.

FOnConnectionStateChanged

Occurs when the network connection state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnConnectionStateChanged, ECONNECTION_STATE_TYPE, state, ECONNECTION_CHANGED_REASON_TYPE, reason);

When the network connection state changes, the SDK triggers this callback and reports the current connection state and the reason for the change.

Parameters

state

The current connection state. See ECONNECTION_STATE_TYPE.

reason

The reason for a connection state change. See ECONNECTION_CHANGED_REASON_TYPE.

FOnEncryptionError

Reports the built-in encryption errors.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEncryptionError, EENCRYPTION_ERROR_TYPE, errorType);

When encryption is enabled by calling EnableEncryption, the SDK triggers this callback if an error occurs in encryption or decryption on the sender or the receiver side.

Parameters

errorType
Details about the error type. See EENCRYPTION_ERROR_TYPE.

FOnError

Reports an error during SDK runtime.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnError, int, err, FString, msg);

This callback indicates that an error (concerning network or media) occurs during SDK runtime. In most cases, the SDK cannot fix the issue and resume running. The SDK requires the app to take action or informs the user about the issue.

Parameters

msg
The error message.
err
Error code.
  • ERR_OK(0): No error.
  • ERR_FAILED(1): General error with no classified reason. Try calling the method again.
  • ERR_INVALID_ARGUMENT(2): An invalid parameter is used. For example, the specified channel name includes illegal characters. Reset the parameter.
  • ERR_NOT_READY(3): The SDK is not ready. Possible reasons include the following:
    • The initialization of IRtcEngine fails. Reinitialize the IRtcEngine.
    • No user has joined the channel when the method is called. Please check your code logic.
    • The user has not left the channel when the Rate or Complain method is called. Please check your code logic.
    • The audio module is disabled. The program is not complete.
  • ERR_NOT_SUPPORTED(4): IRtcEngine does not support the request. Possible reasons include the following:
    • The built-in encryption mode is incorrect, or the SDK fails to load the external encryption library. Check the encryption mode setting, or reload the external encryption library.
  • ERR_REFUSED(5): The request is rejected. Possible reasons include the following:
    • The initialization of IRtcEngine fails. Reinitialize the IRtcEngine.
    • The channel name is set as the empty string "" when joining the channel. Reset the channel name.
    • When the JoinChannelEx method is called to join multiple channels, the specified channel name is already in use. Reset the channel name.
  • ERR_BUFFER_TOO_SMALL(6): The buffer size is insufficient to store the returned data.
  • ERR_NOT_INITIALIZED(7): A method is called before the initialization of IRtcEngine. Ensure that the IRtcEngine object is initialized before using this method.
  • ERR_INVALID_STATE(8): Invalid state.
  • ERR_NO_PERMISSION(9): Permission to access is not granted. Check whether your app has access to the audio and video device.
  • ERR_TIMEDOUT(10): A timeout occurs. Some API calls require the SDK to return the execution result. This error occurs if the SDK takes too long (more than 10 seconds) to return the result.
  • ERR_JOIN_CHANNEL_REJECTED(17): The request to join the channel is rejected. Possible reasons include the following:
    • The user is already in the channel. Agora recommends that you use the FOnConnectionStateChanged callback to determine whether the user exists in the channel. Do not call this method to join the channel unless you receive the CONNECTION_STATE_DISCONNECTED(1) state.
    • After calling StartEchoTest for the call test, the user tries to join the channel without calling StopEchoTest to end the current test. To join a channel, the call test must be ended by calling StopEchoTest.
  • ERR_LEAVE_CHANNEL_REJECTED(18): Fails to leave the channel. Possible reasons include the following:
    • The user has left the channel before calling the LeaveChannel method. Stop calling this method to clear this error.
    • The user calls the LeaveChannel method to leave the channel before joining the channel. In this case, no extra operation is needed.
  • ERR_ALREADY_IN_USE(19): Resources are already in use.
  • ERR_ABORTED(20): The request is abandoned by the SDK, possibly because the request has been sent too frequently.
  • ERR_RESOURCE_LIMITED(22): The SDK fails to allocate resources because your app uses too many system resources or system resources are insufficient.
  • ERR_INVALID_APP_ID(101): The App ID is invalid. Rejoin the channel with a valid App ID.
  • ERR_INVALID_CHANNEL_NAME(102): The channel name is invalid. A possible reason is that the parameter's data type is incorrect. Rejoin the channel with a valid channel name.
  • ERR_NO_SERVER_RESOURCES(103): Fails to get server resources in the specified region. Try another region when initializing IRtcEngine.
  • ERR_TOKEN_EXPIRED(109): The current token has expired. Generate a new token on the server and call RenewToken to pass the token.
    Deprecated:
    This enumerator is deprecated. Use CONNECTION_CHANGED_TOKEN_EXPIRED(9) in the FOnConnectionStateChanged callback instead.
  • ERR_INVALID_TOKEN(110): Invalid token Possible reasons are as follows:
    • App Certificate is enabled in Agora Console, but the code still uses App ID for authentication. Once App Certificate is enabled for a project, you must use token-based authentication.
    • The uid used to generate the token is not the same as the uid used to join the channel.
    Deprecated:
    This enumerator is deprecated. Use CONNECTION_CHANGED_INVALID_TOKEN(8) in the FOnConnectionStateChanged callback instead.
  • ERR_CONNECTION_INTERRUPTED(111): The network connection is interrupted. The SDK triggers this callback when it loses connection with the server for more than four seconds after the connection is established.
  • ERR_CONNECTION_LOST(112): The network connection is lost. Occurs when the SDK cannot reconnect to Agora's edge server 10 seconds after its connection to the server is interrupted.
  • ERR_NOT_IN_CHANNEL(113): The user is not in the channel when calling the SendStreamMessage method.
  • ERR_SIZE_TOO_LARGE(114): The data size exceeds 1 KB when calling the SendStreamMessage method.
  • ERR_BITRATE_LIMIT(115): The data bitrate exceeds 6 KB/s when calling the SendStreamMessage method.
  • ERR_TOO_MANY_DATA_STREAMS(116): More than five data streams are created when calling the CreateDataStream method.
  • ERR_STREAM_MESSAGE_TIMEOUT(117): The data stream transmission times out.
  • ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED(119): Switching roles fails; try rejoining the channel.
  • ERR_DECRYPTION_FAILED(120): Decryption fails. The user might have entered an incorrect password to join the channel. Check the entered password, or tell the user to try rejoining the channel.
  • ERR_INVALID_USER_ID(121): The user ID is invalid.
  • ERR_CLIENT_IS_BANNED_BY_SERVER(123): The user is banned by the server.
  • ERR_ENCRYPTED_STREAM_NOT_ALLOWED_PUBLISH(130): The SDK does not support pushing encrypted streams to CDN.
  • ERR_INVALID_USER_ACCOUNT(134): The user account is invalid, possibly because it contains invalid parameters.
  • ERR_LOAD_MEDIA_ENGINE(1001): The SDK fails to load the media engine.
  • ERR_ADM_GENERAL_ERROR(1005): A general error occurs (no specified reason). Check whether the audio device is already in use by another app, or try rejoining the channel.
  • ERR_ADM_INIT_PLAYOUT(1008): An error occurs when initializing the playback device. Check whether the playback device is already in use by another app, or try rejoining the channel.
  • ERR_ADM_START_PLAYOUT(1009): An error occurs when starting the playback device. Check the playback device.
  • ERR_ADM_STOP_PLAYOUT(1010): An error occurs when stopping the playback device.
  • ERR_ADM_INIT_RECORDING(1011): An error occurs when initializing the recording device. Check the recording device, or try rejoining the channel.
  • ERR_ADM_START_RECORDING(1012): An error occurs when starting the recording device. Check the recording device.
  • ERR_ADM_STOP_RECORDING(1013): An error occurs when stopping the recording device.
  • ERR_VDM_CAMERA_NOT_AUTHORIZED(1501): Permission to access the camera is not granted. Check whether permission to access the camera permission is granted.

FOnExtensionError

Occurs when the extension runs incorrectly.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnExtensionError, FString, provider, FString, extension, int, error, FString, message);

In case of extension enabling failure or runtime errors, the extension triggers this callback and reports the error code along with the reasons.

Parameters

provider
The name of the extension provider.
extension
The name of the extension.
error
Error code. For details, see the extension documentation provided by the extension provider.
message
Reason. For details, see the extension documentation provided by the extension provider.

FOnExtensionEvent

The event callback of the extension.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnExtensionEvent, FString, provider, FString, extension, FString, key, FString, value);

To listen for events while the extension is running, you need to register this callback.

Parameters

provider
The name of the extension provider.
extension
The name of the extension.
key
The key of the extension.
value
The value of the extension key.

FOnExtensionStarted

Occurs when the extension is enabled.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnExtensionStarted, FString, provider, FString, extension);

The extension triggers this callback after it is successfully enabled.

Parameters

provider
The name of the extension provider.
extension
The name of the extension.

FOnExtensionStopped

Occurs when the extension is disabled.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnExtensionStopped, FString, provider, FString, extension);

The extension triggers this callback after it is successfully destroyed.

Parameters

provider
The name of the extension provider.
extension
The name of the extension.

FOnFacePositionChanged

Reports the face detection result of the local user.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnFacePositionChanged, int, imageWidth, int, imageHeight, FRectangle, vecRectangle, TArray<int>, vecDistance, int, numFaces);
Once you enable face detection by calling EnableFaceDetection(true), you can get the following information on the local user in real-time:
  • The width and height of the local video.
  • The position of the human face in the local view.
  • The distance between the human face and the screen.

This value is based on the fitting calculation of the local video size and the position of the human face.

Attention:
  • This callback is for Android and iOS only.
  • When it is detected that the face in front of the camera disappears, the callback will be triggered immediately. When no human face is detected, the frequency of this callback to be triggered wil be decreased to reduce power consumption on the local device.
  • The SDK stops triggering this callback when a human face is in close proximity to the screen.
  • On Android, the value of distance reported in this callback may be slightly different from the actual distance. Therefore, Agora does not recommend using it for accurate calculation.

Parameters

imageWidth
The width (px) of the video image captured by the local camera.
imageHeight
The height (px) of the video image captured by the local camera.
vecRectangle
An array of numFaces, representing the detected face information:
  • x: The x-coordinate (px) of the human face in the local view. Taking the top left corner of the view as the origin, the x-coordinate represents the horizontal position of the human face relative to the origin.
  • y: The y-coordinate (px) of the human face in the local view. Taking the top left corner of the view as the origin, the y-coordinate represents the vertical position of the human face relative to the origin.
  • width: The width (px) of the human face in the captured view.
  • height: The height (px) of the human face in the captured view.
vecDistance
An array of numFaces, representing the distance (cm) between a face and the device screen.
numFaces
The number of faces detected. If the value is 0, it means that no human face is detected.

FOnFirstLocalAudioFramePublished

Occurs when the first audio frame is published.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnFirstLocalAudioFramePublished, int, elapsed);
The SDK triggers this callback under one of the following circumstances:
  • The local client enables the audio module and calls JoinChannel successfully.
  • The local client calls MuteLocalAudioStream(true) and MuteLocalAudioStream(false) in sequence.
  • The local client calls DisableAudio and EnableAudio in sequence.
  • The local client calls PushAudioFrame to successfully push the audio frame to the SDK.

Parameters

elapsed
Time elapsed (ms) from the local user calling JoinChannel until the SDK triggers this callback.

FOnFirstLocalVideoFrame

Occurs when the first local video frame is displayed on the local video view.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnFirstLocalVideoFrame, EVIDEO_SOURCE_TYPE, source, int, width, int, height, int, elapsed);

The SDK triggers this callback when the first local video frame is displayed on the local video view.

Parameters

source
The type of the video source. See EVIDEO_SOURCE_TYPE.
width
The width (px) of the first local video frame.
height
The height (px) of the first local video frame.
elapsed
The time elapsed (ms) from the local user calling JoinChannel to join the channel to when the SDK triggers this callback. If StartPreview is called before joining the channel, this parameter indicates the time elapsed from calling StartPreview to when this event occurred.

FOnFirstLocalVideoFramePublished

Occurs when the first video frame is published.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnFirstLocalVideoFramePublished, EVIDEO_SOURCE_TYPE, source, int, elapsed);
The SDK triggers this callback under one of the following circumstances:
  • The local client enables the video module and calls JoinChannel to join the channel successfully.
  • The local client calls MuteLocalVideoStream(true) and MuteLocalVideoStream(false) in sequence.
  • The local client calls DisableVideo and EnableVideo in sequence.
  • The local client calls PushVideoFrame to successfully push the video frame to the SDK.

Parameters

source
The type of the video source. See EVIDEO_SOURCE_TYPE.
elapsed
Time elapsed (ms) from the local user calling JoinChannel until this callback is triggered.

FOnFirstRemoteAudioFrame

Occurs when the SDK receives the first audio frame from a specific remote user.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnFirstRemoteAudioFrame, int64, uid, int, elapsed);
Deprecated:
Use FOnRemoteAudioStateChanged instead.

Parameters

uid
The user ID of the remote user.
elapsed
The time elapsed (ms) from the local user calling JoinChannel until the SDK triggers this callback.

FOnFirstRemoteAudioDecoded

Occurs when the SDK decodes the first remote audio frame for playback.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnFirstRemoteAudioDecoded, int64, uid, int, elapsed);
Deprecated:
Use FOnRemoteAudioStateChanged instead.
The SDK triggers this callback under one of the following circumstances:
  • The remote user joins the channel and sends the audio stream for the first time.
  • The remote user's audio is offline and then goes online to re-send audio. It means the local user cannot receive audio in 15 seconds. Reasons for such an interruption include:
    • The remote user leaves channel.
    • The remote user drops offline.
    • The remote user calls MuteLocalAudioStream to stop sending the audio stream.
    • The remote user calls DisableAudio to disable audio.

Parameters

uid
The user ID of the remote user.
elapsed
The time elapsed (ms) from the local user calling JoinChannel until the SDK triggers this callback.

FOnFirstRemoteVideoDecoded

Occurs when the first remote video frame is received and decoded.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnFirstRemoteVideoDecoded, int64, uid, int, width, int, height, int, elapsed);
The SDK triggers this callback under one of the following circumstances:
  • The remote user joins the channel and sends the video stream.
  • The remote user stops sending the video stream and re-sends it after 15 seconds. Reasons for such an interruption include:
    • The remote user leaves the channel.
    • The remote user drops offline.
    • The remote user calls DisableVideo to disable video.

Parameters

uid
The user ID of the remote user sending the video stream.
width
The width (px) of the video stream.
height
The height (px) of the video stream.
elapsed
The time elapsed (ms) from the local user calling JoinChannel until the SDK triggers this callback.

FOnFirstRemoteVideoFrame

Occurs when the renderer receives the first frame of the remote video.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnFirstRemoteVideoFrame, int64, userId, int, width, int, height, int, elapsed);
Attention: This callback is only triggered when the video frame is rendered by the SDK; it will not be triggered if the user employs custom video rendering.You need to implement this independently using methods outside the SDK.

Parameters

userId
The user ID of the remote user sending the video stream.
width
The width (px) of the video stream.
height
The height (px) of the video stream.
elapsed
The time elapsed (ms) from the local user calling JoinChannel until the SDK triggers this callback.

FOnJoinChannelSuccess

Occurs when a user joins a channel.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnJoinChannelSuccess, FString, channel, int64, uid, int, elapsed);

This callback notifies the application that a user joins a specified channel.

Parameters

channel
The channel name.
uid
The ID of the user who joins the channel.
elapsed
The time elapsed (ms) from the local user calling JoinChannel until the SDK triggers this callback.

FOnLastmileProbeResult

Reports the last mile network probe result.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnLastmileProbeResult, const FLastmileProbeResult&, result);

The SDK triggers this callback within 30 seconds after the app calls StartLastmileProbeTest.

Parameters

result
The uplink and downlink last-mile network probe test result. See FLastmileProbeResult.

FOnLastmileQuality

Reports the last-mile network quality of the local user.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnLastmileQuality, int, quality);

This callback reports the last-mile network conditions of the local user before the user joins the channel. Last mile refers to the connection between the local device and Agora's edge server.

Before the user joins the channel, this callback is triggered by the SDK onceStartLastmileProbeTest is called and reports the last-mile network conditions of the local user.

Parameters

quality
The last-mile network quality.
  • QUALITY_UNKNOWN(0): The quality is unknown.
  • QUALITY_EXCELLENT(1): The quality is excellent.
  • QUALITY_GOOD(2): The network quality seems excellent, but the bitrate can be slightly lower than excellent.
  • QUALITY_POOR(3): Users can feel the communication is slightly impaired.
  • QUALITY_BAD(4): Users cannot communicate smoothly.
  • QUALITY_VBAD(5): The quality is so bad that users can barely communicate.
  • QUALITY_DOWN(6): The network is down, and users cannot communicate at all.

FOnLeaveChannel

Occurs when a user leaves a channel.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnLeaveChannel, const FRtcStats&, stats);

You can obtain information such as the total duration of a call, and the data traffic that the SDK transmits and receives.

Trigger timing

The SDK triggers this callback after you call LeaveChannel or LeaveChannelEx to leave a channel.

Restrictions

None.

Parameters

stats
Call statistics. See FRtcStats.

FOnLocalAudioStateChanged

Occurs when the local audio stream state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnLocalAudioStateChanged, ELOCAL_AUDIO_STREAM_STATE, state, ELOCAL_AUDIO_STREAM_ERROR, error);

When the state of the local audio stream changes (including the state of the audio capture and encoding), the SDK triggers this callback to report the current state. This callback indicates the state of the local audio stream, and allows you to troubleshoot issues when audio exceptions occur.

Attention: When the state is LOCAL_AUDIO_STREAM_STATE_FAILED (3), you can view the error information in the error parameter.

Parameters

state
The state of the local audio. See ELOCAL_AUDIO_STREAM_STATE.
reason
Reasons for local audio state changes. See ELOCAL_AUDIO_STREAM_REASON.

FOnLocalAudioStats

Reports the statistics of the local audio stream.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnLocalAudioStats, const FLocalAudioStats&, stats);

The SDK triggers this callback once every two seconds.

Parameters

stats
Local audio statistics. See FLocalAudioStats.

FOnLocalUserRegistered

Occurs when the local user registers a user account.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnLocalUserRegistered, int64, uid, FString, userAccount);

After the local user successfully calls RegisterLocalUserAccount to register the user account or calls JoinChannelWithUserAccount to join a channel, the SDK triggers the callback and informs the local user's UID and User Account.

Parameters

uid
The ID of the local user.
userAccount
The user account of the local user.

FOnLocalVideoStateChanged

Occurs when the local video stream state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnLocalVideoStateChanged, EVIDEO_SOURCE_TYPE, source, ELOCAL_VIDEO_STREAM_STATE, state, ELOCAL_VIDEO_STREAM_ERROR, error);

When the status of the local video changes, the SDK triggers this callback to report the current local video state and the reason for the state change.

Applicable scenarios

You can use this callback to stay updated on the state changes of the local video stream, and take corresponding measures based on the reasons for the state changes, to better manage and debug issues related to the video stream.

Trigger timing

  • The SDK triggeres this callback under the following circumstances, with the state as LOCAL_VIDEO_STREAM_STATE_FAILED, and the reason as LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE:
    • The app switches to the background, and the system revokes the camera resource.
    • For Android 9 and later versions, after an app is in the background for a period, the system automatically revokes camera permissions.
    • For Android 6 and later versions, if the camera is held by a third-party app for a certain duration and then released, the SDK triggers this callback and reports the FOnLocalVideoStateChanged(LOCAL_VIDEO_STREAM_STATE_CAPTURING,LOCAL_VIDEO_STREAM_REASON_OK) callback.
    • The camera starts normally, but does not output video frames for four consecutive seconds.
  • When the camera outputs captured video frames, if the SDK detects 15 consecutive duplicate video frames, it triggers this callback, with the state as LOCAL_VIDEO_STREAM_STATE_CAPTURING and the reason as LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE.
    Note: Note that the video frame duplication detection is only available for video frames with a resolution greater than 200 Ă— 200, a frame rate greater than or equal to 10 fps, and a bitrate less than 20 Kbps.

Restrictions

For some device models, the SDK does not trigger this callback when the state of the local video changes while the local video capturing device is in use, so you have to make your own timeout judgment.

Parameters

source
The type of the video source. See EVIDEO_SOURCE_TYPE.
state

The state of the local video, see ELOCAL_VIDEO_STREAM_STATE.

reason

The reasons for changes in local video state. See ELOCAL_VIDEO_STREAM_REASON.

FOnLocalVideoStats

Reports the statistics of the local video stream.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnLocalVideoStats, EVIDEO_SOURCE_TYPE, source, const FLocalVideoStats&, stats);

The SDK triggers this callback once every two seconds to report the statistics of the local video stream.

Parameters

source
The type of the video source. See EVIDEO_SOURCE_TYPE.
stats
The statistics of the local video stream. See FLocalVideoStats.

FOnLocalVideoTranscoderError

Occurs when there's an error during the local video mixing.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnLocalVideoTranscoderError, const FTranscodingVideoStream&, stream, EVIDEO_TRANSCODER_ERROR, error);

Details

When you fail to call StartLocalVideoTranscoder or UpdateLocalTranscoderConfiguration, the SDK triggers this callback to report the reason.

Parameters

stream
The video streams that cannot be mixed during video mixing. See FTranscodingVideoStream.
error
The reason for local video mixing error. See EVIDEO_TRANSCODER_ERROR.

FOnNetworkQuality

Reports the last mile network quality of each user in the channel.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnNetworkQuality, int64, uid, int, txQuality, int, rxQuality);

This callback reports the last mile network conditions of each user in the channel. Last mile refers to the connection between the local device and Agora's edge server.

The SDK triggers this callback once every two seconds. If a channel includes multiple users, the SDK triggers this callback as many times.

This callback provides feedback on network quality through sending and receiving broadcast packets within the channel. Excessive broadcast packets can lead to broadcast storms. To prevent broadcast storms from causing a large amount of data transmission within the channel, this callback supports feedback on the network quality of up to 4 remote hosts simultaneously by default.

Note: txQuality is UNKNOWN when the user is not sending a stream; rxQuality is UNKNOWN when the user is not receiving a stream.

Parameters

uid

The user ID. The network quality of the user with this user ID is reported. If the uid is 0, the local network quality is reported.

txQuality
Uplink network quality rating of the user in terms of the transmission bit rate, packet loss rate, average RTT (Round-Trip Time) and jitter of the uplink network. This parameter is a quality rating helping you understand how well the current uplink network conditions can support the selected video encoder configuration. For example, a 1000 Kbps uplink network may be adequate for video frames with a resolution of 640 Ă— 480 and a frame rate of 15 fps in the LIVE_BROADCASTING profile, but might be inadequate for resolutions higher than 1280 Ă— 720.
  • QUALITY_UNKNOWN(0): The quality is unknown.
  • QUALITY_EXCELLENT(1): The quality is excellent.
  • QUALITY_GOOD(2): The network quality seems excellent, but the bitrate can be slightly lower than excellent.
  • QUALITY_POOR(3): Users can feel the communication is slightly impaired.
  • QUALITY_BAD(4): Users cannot communicate smoothly.
  • QUALITY_VBAD(5): The quality is so bad that users can barely communicate.
  • QUALITY_DOWN(6): The network is down, and users cannot communicate at all.
rxQuality
Downlink network quality rating of the user in terms of packet loss rate, average RTT, and jitter of the downlink network.
  • QUALITY_UNKNOWN(0): The quality is unknown.
  • QUALITY_EXCELLENT(1): The quality is excellent.
  • QUALITY_GOOD(2): The network quality seems excellent, but the bitrate can be slightly lower than excellent.
  • QUALITY_POOR(3): Users can feel the communication is slightly impaired.
  • QUALITY_BAD(4): Users cannot communicate smoothly.
  • QUALITY_VBAD(5): The quality is so bad that users can barely communicate.
  • QUALITY_DOWN(6): The network is down, and users cannot communicate at all.

FOnNetworkTypeChanged

Occurs when the local network type changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnNetworkTypeChanged, FENUMWRAP_NETWORK_TYPE, type);

This callback occurs when the connection state of the local user changes. You can get the connection state and reason for the state change in this callback. When the network connection is interrupted, this callback indicates whether the interruption is caused by a network type change or poor network conditions.

Parameters

type

The type of the local network connection. See EENUMCUSTOM_NETWORK_TYPE.

FOnPermissionError

Occurs when the SDK cannot get the device permission.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPermissionError, EPERMISSION_TYPE, permissionType);

When the SDK fails to get the device permission, the SDK triggers this callback to report which device permission cannot be got.

Parameters

permissionType
The type of the device permission. See EPERMISSION_TYPE.

FOnProxyConnected

Reports the proxy connection state.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnProxyConnected, FString, channel, int64, uid, EPROXY_TYPE, proxyType, FString, localProxyIp, int, elapsed);

You can use this callback to listen for the state of the SDK connecting to a proxy. For example, when a user calls SetCloudProxy and joins a channel successfully, the SDK triggers this callback to report the user ID, the proxy type connected, and the time elapsed fromthe user calling JoinChannel until this callback is triggered.

Parameters

channel
The channel name.
uid
The user ID.
proxyType
The proxy type connected. See EPROXY_TYPE.
localProxyIp
Reserved for future use.
elapsed
The time elapsed (ms) from the user calling JoinChannel until this callback is triggered.

FOnRejoinChannelSuccess

Occurs when a user rejoins the channel.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnRejoinChannelSuccess, FString, channel, int64, uid, int, elapsed);

When a user loses connection with the server because of network problems, the SDK automatically tries to reconnect and triggers this callback upon reconnection.

Parameters

channel
The channel name.
uid
The ID of the user who rejoins the channel.
elapsed
Time elapsed (ms) from the local user calling JoinChannel until the SDK triggers this callback.

FOnRemoteAudioStateChanged

Occurs when the remote audio state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnRemoteAudioStateChanged, int64, uid, EREMOTE_AUDIO_STATE, state, EREMOTE_AUDIO_STATE_REASON, reason, int, elapsed);

When the audio state of a remote user (in a voice/video call channel) or host (in a live streaming channel) changes, the SDK triggers this callback to report the current state of the remote audio stream.

Attention: This callback does not work properly when the number of users (in the communication profile) or hosts (in the live streaming channel) in a channel exceeds 17.

Parameters

uid
The ID of the remote user whose audio state changes.
state
The state of the remote audio. See EREMOTE_AUDIO_STATE.
reason
The reason of the remote audio state change. See EREMOTE_AUDIO_STATE_REASON.
elapsed
Time elapsed (ms) from the local user calling the JoinChannel method until the SDK triggers this callback.

FOnRemoteAudioStats

Reports the transport-layer statistics of each remote audio stream.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnRemoteAudioStats, const FRemoteAudioStats&, stats);

The SDK triggers this callback once every two seconds for each remote user who is sending audio streams. If a channel includes multiple remote users, the SDK triggers this callback as many times.

Parameters

stats
The statistics of the received remote audio streams. See FRemoteAudioStats.

FOnRemoteAudioTransportStats

Reports the transport-layer statistics of each remote audio stream.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnRemoteAudioTransportStats, int64, uid, int, delay, int, lost, int, rxKBitRate);
Deprecated:
Use FOnRemoteAudioStats instead.

This callback reports the transport-layer statistics, such as the packet loss rate and network time delay after the local user receives an audio packet from a remote user. During a call, when the user receives the audio packet sent by the remote user, the callback is triggered every 2 seconds.

Parameters

uid
The ID of the remote user sending the audio streams.
delay
The network delay (ms) from the remote user to the receiver.
lost
The packet loss rate (%) of the audio packet sent from the remote user to the receiver.
rxKBitrate
The bitrate of the received audio (Kbps).

FOnRemoteVideoStateChanged

Occurs when the remote video stream state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnRemoteVideoStateChanged, int64, uid, EREMOTE_VIDEO_STATE, state, EREMOTE_VIDEO_STATE_REASON, reason, int, elapsed);
Attention: This callback does not work properly when the number of users (in the communication profile) or hosts (in the live streaming channel) in a channel exceeds 17.

Parameters

uid
The ID of the remote user whose video state changes.
state

The state of the remote video. See EREMOTE_VIDEO_STATE.

reason

The reason for the remote video state change. See EREMOTE_VIDEO_STATE_REASON.

elapsed
Time elapsed (ms) from the local user calling the JoinChannel method until the SDK triggers this callback.

FOnRemoteVideoStats

Reports the statistics of the video stream sent by each remote users.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnRemoteVideoStats, const FRemoteVideoStats&, stats);

Reports the statistics of the video stream from the remote users. The SDK triggers this callback once every two seconds for each remote user. If a channel has multiple users/hosts sending video streams, the SDK triggers this callback as many times.

Parameters

stats
Statistics of the remote video stream. See FRemoteVideoStats.

FOnRemoteVideoTransportStats

Reports the transport-layer statistics of each remote video stream.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnRemoteVideoTransportStats, int64, uid, int, delay, int, lost, int, rxKBitRate);
Deprecated:
This callback is deprecated. Use FOnRemoteVideoStats instead.

This callback reports the transport-layer statistics, such as the packet loss rate and network time delay after the local user receives a video packet from a remote user.

During a call, when the user receives the video packet sent by the remote user/host, the callback is triggered every 2 seconds.

Parameters

uid
The ID of the remote user sending the video packets.
delay
The network delay (ms) from the sender to the receiver.
lost
The packet loss rate (%) of the video packet sent from the remote user.
rxKBitRate
The bitrate of the received video (Kbps).

FOnRequestToken

Occurs when the token expires.

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnRequestToken);

The SDK triggers this callback if the token expires.

When receiving this callback, you need to generate a new token on your token server and you can renew your token through one of the following ways:
  • In scenarios involving one channel:
    • Call RenewToken to pass in the new token.
    • Call LeaveChannel to leave the current channel and then pass in the new token when you call JoinChannel to join a channel.
  • In scenarios involving mutiple channels: Call UpdateChannelMediaOptionsEx to pass in the new token.

Restrictions

None.

FOnRhythmPlayerStateChanged

Occurs when the state of virtual metronome changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnRhythmPlayerStateChanged, FENUMWRAP_RHYTHM_PLAYER_STATE_TYPE, state, FENUMWRAP_RHYTHM_PLAYER_ERROR_TYPE, errorCode);

When the state of the virtual metronome changes, the SDK triggers this callback to report the current state of the virtual metronome. This callback indicates the state of the local audio stream and enables you to troubleshoot issues when audio exceptions occur.

Attention: This callback is for Android and iOS only.

Parameters

state
For the current virtual metronome status, see EENUMCUSTOM_RHYTHM_PLAYER_STATE_TYPE.
errorCode
For the error codes and error messages related to virtual metronome errors, see EENUMCUSTOM_RHYTHM_PLAYER_REASON.

FOnRtcStats

Reports the statistics about the current call.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnRtcStats, const FRtcStats&, stats);

Trigger timing

The SDK triggers this callback once every two seconds after the user joins the channel.

Restrictions

None.

Parameters

stats

Statistics of the RTC engine. See FRtcStats.

FOnRtmpStreamingEvent

Reports events during the Media Push.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnRtmpStreamingEvent, FString, url, ERTMP_STREAMING_EVENT, eventCode);

Parameters

url
The URL for Media Push.
eventCode
The event code of Media Push. See ERTMP_STREAMING_EVENT.

FOnRtmpStreamingStateChanged

Occurs when the state of Media Push changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnRtmpStreamingStateChanged, FString, url, ERTMP_STREAM_PUBLISH_STATE, state, ERTMP_STREAM_PUBLISH_REASON, errCode);

When the state of Media Push changes, the SDK triggers this callback and reports the URL address and the current state of the Media Push. This callback indicates the state of the Media Push. When exceptions occur, you can troubleshoot issues by referring to the detailed error descriptions in the error code parameter.

Parameters

url

The URL address where the state of the Media Push changes.

state
The current state of the Media Push. See ERTMP_STREAM_PUBLISH_STATE.
reason
Reasons for the changes in the Media Push status. See ERTMP_STREAM_PUBLISH_REASON.

FOnSnapshotTaken

Reports the result of taking a video snapshot.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnSnapshotTaken, int64, uid, FString, filePath, int, width, int, height, int, errCode);

After a successful TakeSnapshot method call, the SDK triggers this callback to report whether the snapshot is successfully taken as well as the details for the snapshot taken.

Parameters

uid
The user ID. One uid of 0 indicates the local user.
filePath
The local path of the snapshot.
width
The width (px) of the snapshot.
height
The height (px) of the snapshot.
errCode
The message that confirms success or gives the reason why the snapshot is not successfully taken:
  • 0: Success.
  • < 0: Failure:
    • -1: The SDK fails to write data to a file or encode a JPEG image.
    • -2: The SDK does not find the video stream of the specified user within one second after the TakeSnapshot method call succeeds. The possible reasons are: local capture stops, remote end stops publishing, or video data processing is blocked.
    • -3: Calling the TakeSnapshot method too frequently.

FOnStreamMessage

Occurs when the local user receives the data stream from the remote user.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnStreamMessage, int64, userId, int, streamId, FString, data, int64, length, int, sentTs);

The SDK triggers this callback when the local user receives the stream message that the remote user sends by calling the SendStreamMessage method.

Parameters

userId
The ID of the remote user sending the message.
streamId
The stream ID of the received message.
data
The data received.
length
The data length (byte).
sentTs
The time when the data stream is sent.

FOnStreamMessageError

Occurs when the local user does not receive the data stream from the remote user.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnStreamMessageError, int64, userId, int, streamId, int, code, int, missed, int, cached);

The SDK triggers this callback when the local user fails to receive the stream message that the remote user sends by calling the SendStreamMessage method.

Parameters

userId
The ID of the remote user sending the message.
streamId
The stream ID of the received message.
code
The error code. See .
missed
The number of lost messages.
cached
Number of incoming cached messages when the data stream is interrupted.

FOnTokenPrivilegeWillExpire

Occurs when the token expires in 30 seconds.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTokenPrivilegeWillExpire, FString, token);
When receiving this callback, you need to generate a new token on your token server and you can renew your token through one of the following ways:
  • In scenarios involving one channel:
    • Call RenewToken to pass in the new token.
    • Call LeaveChannel to leave the current channel and then pass in the new token when you call JoinChannel to join a channel.
  • In scenarios involving mutiple channels: Call UpdateChannelMediaOptionsEx to pass in the new token.

Trigger timing

The SDK triggers this callback 30 seconds before the token expires, reminding the app to update the token.

Restrictions

None.

Parameters

token
The token that is about to expire.

FOnTranscodingUpdated

Occurs when the publisher's transcoding is updated.

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnTranscodingUpdated);

When the FLiveTranscoding class in the StartRtmpStreamWithTranscoding method updates, the SDK triggers the FOnTranscodingUpdated callback to report the update information.

Attention: If you call the StartRtmpStreamWithTranscoding method to set the FLiveTranscoding class for the first time, the SDK does not trigger this callback.

FOnUplinkNetworkInfoUpdated

Occurs when the uplink network information changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnUplinkNetworkInfoUpdated, const FUplinkNetworkInfo&, info);

The SDK triggers this callback when the uplink network information changes.

Attention: This callback only applies to scenarios where you push externally encoded video data in H.264 format to the SDK.

Parameters

info
The uplink network information. See FUplinkNetworkInfo.

FOnUserEnableLocalVideo

Occurs when a specific remote user enables/disables the local video capturing function.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnUserEnableLocalVideo, int64, uid, bool, enabled);
Deprecated:
This callback is deprecated, use the following enumerations in the FOnRemoteVideoStateChanged callback:
  • REMOTE_VIDEO_STATE_STOPPED(0) and REMOTE_VIDEO_STATE_REASON_REMOTE_MUTED(5).
  • REMOTE_VIDEO_STATE_DECODING(2) and REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED(6).

The SDK triggers this callback when the remote user resumes or stops capturing the video stream by calling the EnableLocalVideo method.

Parameters

uid
The user ID of the remote user.
enabled
Whether the specified remote user enables/disables local video capturing:
  • true: The video module is enabled. Other users in the channel can see the video of this remote user.
  • false: The video module is disabled. Other users in the channel can no longer receive the video stream from this remote user, while this remote user can still receive the video streams from other users.

FOnUserEnableVideo

Occurs when a remote user enables or disables the video module.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnUserEnableVideo, int64, uid, bool, enabled);

Once the video module is disabled, the user can only use a voice call. The user cannot send or receive any video.

The SDK triggers this callback when a remote user enables or disables the video module by calling the EnableVideo or DisableVideo method.

Parameters

uid
The user ID of the remote user.
enabled
  • true: The video module is enabled.
  • false: The video module is disabled.

FOnUserInfoUpdated

Occurs when the SDK gets the user ID and user account of the remote user.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnUserInfoUpdated, int64, uid, const FUserInfo&, info);

After a remote user joins the channel, the SDK gets the UID and user account of the remote user, caches them in a mapping table object, and triggers this callback on the local client.

Parameters

uid
The user ID of the remote user.
info
The UserInfo object that contains the user ID and user account of the remote user. See FUserInfo for details.

FOnUserJoined

Occurs when a remote user (in the communication profile)/ host (in the live streaming profile) joins the channel.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnUserJoined, int64, uid, int, elapsed);
  • In a communication channel, this callback indicates that a remote user joins the channel. The SDK also triggers this callback to report the existing users in the channel when a user joins the channel.
  • In a live-broadcast channel, this callback indicates that a host joins the channel. The SDK also triggers this callback to report the existing hosts in the channel when a host joins the channel. Agora recommends limiting the number of hosts to 17.
The SDK triggers this callback under one of the following circumstances:
  • A remote user/host joins the channel.
  • A remote user switches the user role to the host after joining the channel.
  • A remote user/host rejoins the channel after a network interruption.

Parameters

uid
The ID of the user or host who joins the channel.
elapsed
Time delay (ms) from the local user calling JoinChannel until this callback is triggered.

FOnUserMuteAudio

Occurs when a remote user (in the communication profile) or a host (in the live streaming profile) stops/resumes sending the audio stream.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnUserMuteAudio, int64, uid, bool, muted);

The SDK triggers this callback when the remote user stops or resumes sending the audio stream by calling the MuteLocalAudioStream method.

Attention: This callback does not work properly when the number of users (in the communication profile) or hosts (in the live streaming channel) in a channel exceeds 17.

Parameters

uid
The user ID.
muted
Whether the remote user's audio stream is muted:
  • true: User's audio stream is muted.
  • false: User's audio stream is unmuted.

FOnUserMuteVideo

Occurs when a remote user stops or resumes publishing the video stream.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnUserMuteVideo, int64, userId, bool, muted);

When a remote user calls MuteLocalVideoStream to stop or resume publishing the video stream, the SDK triggers this callback to report to the local user the state of the streams published by the remote user.

Attention: This callback can be inaccurate when the number of users (in the communication profile) or hosts (in the live streaming profile) in a channel exceeds 17.

Parameters

uid
The user ID of the remote user.
muted
Whether the remote user stops publishing the video stream:
  • true: The remote user stops publishing the video stream.
  • false: The remote user resumes publishing the video stream.

FOnUserOffline

Occurs when a remote user (in the communication profile)/ host (in the live streaming profile) leaves the channel.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnUserOffline, int64, uid, EUSER_OFFLINE_REASON_TYPE, reason);
There are two reasons for users to become offline:
  • Leave the channel: When a user/host leaves the channel, the user/host sends a goodbye message. When this message is received, the SDK determines that the user/host leaves the channel.
  • Drop offline: When no data packet of the user or host is received for a certain period of time (20 seconds for the communication profile, and more for the live broadcast profile), the SDK assumes that the user/host drops offline. A poor network connection may lead to false detections. It's recommended to use the Agora RTM SDK for reliable offline detection.

Parameters

uid
The ID of the user who leaves the channel or goes offline.
reason

Reasons why the user goes offline: EUSER_OFFLINE_REASON_TYPE.

FOnVideoDeviceStateChanged

Occurs when the video device state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnVideoDeviceStateChanged, FString, deviceId, int, deviceType, int, deviceState);

This callback reports the change of system video devices, such as being unplugged or removed. On a Windows device with an external camera for video capturing, the video disables once the external camera is unplugged.

Note: This callback is for Windows and macOS only.

Parameters

deviceId
The device ID.
deviceType
Media device types. See EENUMCUSTOM_MEDIA_DEVICE_TYPE.
deviceState
Media device states. See MEDIA_DEVICE_STATE_TYPE.

FOnVideoPublishStateChanged

Occurs when the video publishing state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnVideoPublishStateChanged, EVIDEO_SOURCE_TYPE, source, FString, channel, ESTREAM_PUBLISH_STATE, oldState, ESTREAM_PUBLISH_STATE, newState, int, elapseSinceLastState);

Parameters

channel
The channel name.
source
The type of the video source. See EVIDEO_SOURCE_TYPE.
oldState
The previous publishing state. See ESTREAM_PUBLISH_STATE.
newState
The current publishing stat. See ESTREAM_PUBLISH_STATE.
elapseSinceLastState
The time elapsed (ms) from the previous state to the current state.

FOnVideoSizeChanged

Occurs when the video size or rotation of a specified user changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnVideoSizeChanged, EVIDEO_SOURCE_TYPE, sourceType, int64, uid, int, width, int, height, int, rotation);

Parameters

sourceType
The type of the video source. See EVIDEO_SOURCE_TYPE.
uid
The ID of the user whose video size or rotation changes. (The uid for the local user is 0. The video is the local user's video preview).
width
The width (pixels) of the video stream.
height
The height (pixels) of the video stream.
rotation
The rotation information. The value range is [0,360).
Note: On the iOS platform, the parameter value is always 0.

FOnVideoStopped

Occurs when the video stops playing.

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnVideoStopped);
Deprecated:
Use LOCAL_VIDEO_STREAM_STATE_STOPPED(0) in the FOnLocalVideoStateChanged callback instead.

The application can use this callback to change the configuration of the view (for example, displaying other pictures in the view) after the video stops playing.

FOnVideoSubscribeStateChanged

Occurs when the video subscribing state changes.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnVideoSubscribeStateChanged, FString, channel, int64, uid, ESTREAM_SUBSCRIBE_STATE, oldState, ESTREAM_SUBSCRIBE_STATE, newState, int, elapseSinceLastState);

Parameters

channel
The channel name.
uid
The user ID of the remote user.
oldState
The previous subscribing status. See ESTREAM_SUBSCRIBE_STATE.
newState
The current subscribing status. See ESTREAM_SUBSCRIBE_STATE.
elapseSinceLastState
The time elapsed (ms) from the previous state to the current state.