Agora Java API Reference for Android

Classes | Public Member Functions | List of all members
io.agora.rtc2.IRtcEngineEventHandler Class Referenceabstract

## Classes
class | AgoraFacePositionInfo
| The information of the detected human face. More...
class | AudioVolumeInfo
| The volume information of users. More...
class | ClientRole
class | DownlinkNetworkInfo
class | ErrorCode
class | LastmileProbeResult
| Results of the uplink and downlink last-mile network tests. More...
class | LocalAudioStats
| Local audio statistics. More...
class | LocalVideoStats
| The statistics of the local video stream. More...
class | MultipathStats
| Aggregates statistics of each network path in multipath transmission. More...
class | PathStats
| Statistical information about a specific network path. More...
class | Quality
class | RemoteAudioStats
| Audio statistics of the remote user. More...
class | RemoteVideoStats
| Statistics of the remote video stream. More...
class | RtcStats
| Statistics of a call session. More...
class | UplinkNetworkInfo
| The uplink network information. More...
class | UserOfflineReason
class | VideoLayout
| Layout information of a specific sub-video stream within the mixed stream. More...
class | VideoLayoutInfo
| Detailed layout information of a mixed video stream. More...
class | VideoProfile
class | VideoRenderingTracingInfo
| Indicators during video frame rendering progress. More...
class | WarnCode

## Public Member Functions
void | onError (int err)
| Reports an error during SDK runtime. More...
void | onJoinChannelSuccess (String channel, int uid, int elapsed)
| Occurs when a user joins a channel. More...
void | onRejoinChannelSuccess (String channel, int uid, int elapsed)
| Occurs when a user rejoins the channel. More...
void | onLeaveChannel (RtcStats stats)
| Occurs when a user leaves a channel. More...
void | onClientRoleChanged (int oldRole, int newRole, ClientRoleOptions newRoleOptions)
| Occurs when the user role or the audience latency level changes. More...
void | onClientRoleChangeFailed (int reason, int currentRole)
| Occurs when switching a user role fails. More...
void | onLocalUserRegistered (int uid, String userAccount)
| Occurs when the local user registers a user account. More...
void | onUserInfoUpdated (int uid, UserInfo userInfo)
| Occurs when the SDK gets the user ID and user account of the remote user. More...
void | onUserStateChanged (int uid, int state)
void | onUserJoined (int uid, int elapsed)
| Occurs when a remote user (in the communication profile)/ host (in the live streaming profile) joins the channel. More...
void | onUserOffline (int uid, int reason)
| Occurs when a remote user (in the communication profile)/ host (in the live streaming profile) leaves the channel. More...
void | onConnectionStateChanged (int state, int reason)
| Occurs when the network connection state changes. More...
void | onConnectionInterrupted ()
| Occurs when the connection between the SDK and the server is interrupted. More...
void | onConnectionLost ()
| Occurs when the SDK cannot reconnect to Agora's edge server 10 seconds after its connection to the server is interrupted. More...
void | onConnectionBanned ()
| Occurs when the connection is banned by the Agora server.
void | onTokenPrivilegeWillExpire (String token)
| Occurs when the token expires in 30 seconds. More...
void | onRequestToken ()
| Occurs when the token expires. More...
void | onLicenseValidationFailure (int error)
void | onAudioVolumeIndication (AudioVolumeInfo[] speakers, int totalVolume)
| Reports the volume information of users. More...
void | onActiveSpeaker (int uid)
| Occurs when the most active remote speaker is detected. More...
void | onVideoStopped ()
| Occurs when the video stops playing. More...
void | onFirstLocalVideoFrame (Constants.VideoSourceType source, int width, int height, int elapsed)
| Occurs when the first local video frame is displayed on the local video view. More...
void | onFirstLocalVideoFramePublished (Constants.VideoSourceType source, int elapsed)
| Occurs when the first video frame is published. More...
void | onFirstRemoteVideoDecoded (int uid, int width, int height, int elapsed)
| Occurs when the first remote video frame is received and decoded. More...
void | onFirstRemoteVideoFrame (int uid, int width, int height, int elapsed)
| Occurs when the renderer receives the first frame of the remote video. More...
void | onUserMuteAudio (int uid, boolean muted)
| Occurs when a remote user (in the communication profile) or a host (in the live streaming profile) stops/resumes sending the audio stream. More...
void | onUserMuteVideo (int uid, boolean muted)
| Occurs when a remote user stops or resumes publishing the video stream. More...
void | onUserEnableVideo (int uid, boolean enabled)
| Occurs when a remote user enables or disables the video module. More...
void | onUserEnableLocalVideo (int uid, boolean enabled)
| Occurs when a specific remote user enables/disables the local video capturing function. More...
void | onVideoSizeChanged (Constants.VideoSourceType source, int uid, int width, int height, int rotation)
| Occurs when the video size or rotation of a specified user changes. More...
void | onRemoteAudioStateChanged (int uid, int state, int reason, int elapsed)
| Occurs when the remote audio state changes. More...
void | onAudioPublishStateChanged (String channel, int oldState, int newState, int elapseSinceLastState)
| Occurs when the audio publishing state changes. More...
void | onVideoPublishStateChanged (Constants.VideoSourceType source, String channel, int oldState, int newState, int elapseSinceLastState)
| Occurs when the video publishing state changes. More...
void | onAudioSubscribeStateChanged (String channel, int uid, int oldState, int newState, int elapseSinceLastState)
| Occurs when the audio subscribing state changes. More...
void | onVideoSubscribeStateChanged (String channel, int uid, int oldState, int newState, int elapseSinceLastState)
| Occurs when the video subscribing state changes. More...
void | onRemoteVideoStateChanged (int uid, int state, int reason, int elapsed)
| Occurs when the remote video stream state changes. More...
void | onChannelMediaRelayStateChanged (int state, int code)
| Occurs when the state of the media stream relay changes. More...
void | onFirstLocalAudioFramePublished (int elapsed)
| Occurs when the first audio frame is published. More...
void | onFirstRemoteAudioFrame (int uid, int elapsed)
| Occurs when the SDK receives the first audio frame from a specific remote user. More...
void | onFirstRemoteAudioDecoded (int uid, int elapsed)
| Occurs when the SDK decodes the first remote audio frame for playback. More...
void | onRemoteSubscribeFallbackToAudioOnly (int uid, boolean isFallbackOrRecover)
| Occurs when the remote media stream falls back to the audio-only stream due to poor network conditions or switches back to the video stream after the network conditions improve. More...
void | onAudioRouteChanged (int routing)
| Occurs when the local audio route changes. More...
void | onCameraReady ()
| Occurs when the camera turns on and is ready to capture the video. More...
void | onCameraFocusAreaChanged (Rect rect)
| Occurs when the camera focus area changes. More...
void | onCameraExposureAreaChanged (Rect rect)
| Occurs when the camera exposure area changes. More...
void | onSnapshotTaken (int uid, String filePath, int width, int height, int errCode)
| Reports the result of taking a video snapshot. More...
void | onFacePositionChanged (int imageWidth, int imageHeight, AgoraFacePositionInfo[] faceRectArr)
| Reports the face detection result of the local user. More...
void | onAudioQuality (int uid, int quality, short delay, short lost)
| Reports the statistics of the audio stream sent by each remote user. More...
void | onRtcStats (RtcStats stats)
| Reports the statistics about the current call. More...
void | onLastmileQuality (int quality)
| Reports the last-mile network quality of the local user. More...
void | onLastmileProbeResult (LastmileProbeResult result)
| Reports the last mile network probe result. More...
void | onNetworkQuality (int uid, int txQuality, int rxQuality)
| Reports the last mile network quality of each user in the channel. More...
void | onLocalAudioStats (LocalAudioStats stats)
| Reports the statistics of the local audio stream. More...
void | onLocalVideoStats (Constants.VideoSourceType source, LocalVideoStats stats)
| Reports the statistics of the local video stream. More...
void | onRemoteAudioStats (RemoteAudioStats stats)
| Reports the transport-layer statistics of each remote audio stream. More...
void | onRemoteVideoStats (RemoteVideoStats stats)
| Reports the statistics of the video stream sent by each remote users. More...
void | onLocalVideoStat (int sentBitrate, int sentFrameRate)
void | onRemoteVideoStat (int uid, int delay, int receivedBitrate, int receivedFrameRate)
void | onRemoteAudioTransportStats (int uid, int delay, int lost, int rxKBitRate)
| Reports the transport-layer statistics of each remote audio stream. More...
void | onRemoteVideoTransportStats (int uid, int delay, int lost, int rxKBitRate)
| Reports the transport-layer statistics of each remote video stream. More...
void | onAudioMixingStateChanged (int state, int reason)
| Occurs when the playback state of the music file changes. More...
void | onAudioMixingPositionChanged (long position)
| Reports the playback progress of a music file. More...
void | onAudioMixingFinished ()
| Occurs when the playback of the local music file finishes. More...
void | onAudioEffectFinished (int soundId)
| Occurs when the playback of the local music file finishes. More...
void | onRhythmPlayerStateChanged (int state, int reason)
| Occurs when the state of virtual metronome changes. More...
void | onLocalAudioStateChanged (int state, int reason)
| Occurs when the local audio stream state changes. More...
void | onLocalVideoStateChanged (Constants.VideoSourceType source, int state, int reason)
| Occurs when the local video stream state changes. More...
void | onLocalVideoEvent (Constants.VideoSourceType source, int event)
| Occurs when the local video event occurs. More...
void | onRtmpStreamingStateChanged (String url, int state, int reason)
| Occurs when the state of Media Push changes. More...
void | onRtmpStreamingEvent (String url, int event)
| Reports events during the Media Push. More...
void | onTranscodingUpdated ()
| Occurs when the publisher's transcoding is updated. More...
void | onStreamMessage (int uid, int streamId, byte[] data)
| Occurs when the local user receives the data stream from the remote user. More...
void | onStreamMessageError (int uid, int streamId, int error, int missed, int cached)
| Occurs when the local user does not receive the data stream from the remote user. More...
void | onRdtMessage (int uid, int type, byte[] data)
| Occurs when the local user receives data via Reliable Data Transmission (RDT) from a remote user. More...
void | onRdtStateChanged (int uid, int state)
| Occurs when the RDT tunnel state changed. More...
void | onMediaControlMessage (int uid, byte[] data)
| Occurs when the local user receives media control message sent by a remote user. More...
void | onMediaEngineLoadSuccess ()
void | onMediaEngineStartCallSuccess ()
void | onNetworkTypeChanged (int type)
| Occurs when the local network type changes. More...
void | onIntraRequestReceived ()
void | onUplinkNetworkInfoUpdated (UplinkNetworkInfo info)
| Occurs when the uplink network information changes. More...
void | onEncryptionError (int errorType)
| Reports the built-in encryption errors. More...
void | onPermissionError (int permission)
| Occurs when the SDK cannot get the device permission. More...
void | onPermissionGranted (int permission)
void | onUploadLogResult (String requestId, boolean success, int reason)
void | onContentInspectResult (int result)
void | onProxyConnected (String channel, int uid, int proxyType, String localProxyIp, int elapsed)
| Reports the proxy connection state. More...
void | onVideoRenderingTracingResult (int uid, Constants.MEDIA_TRACE_EVENT currentEvent, VideoRenderingTracingInfo tracingInfo)
| Video frame rendering event callback. More...
void | onLocalVideoTranscoderError (LocalTranscoderConfiguration.TranscodingVideoStream stream, int error)
| Occurs when there's an error during the local video mixing. More...
void | onTranscodedStreamLayoutInfo (int uid, VideoLayoutInfo info)
| Occurs when the local user receives a mixed video stream carrying layout information. More...
void | onAudioMetadataReceived (int uid, byte[] data)
| Occurs when the SDK receives audio metadata. More...
void | onMultipathStats (MultipathStats stats)
| Reports the multipath transmission statistics. More...
void | onRenewTokenResult (String token, Constants.RenewTokenErrorCode code)
| Callback for `renewToken` call result. More...

## Detailed Description

Callback methods.

The SDK uses the IRtcEngineEventHandler interface class to send callback event notifications to the application, and the application inherits the methods of this interface class to retrieve these event notifications. All methods in this interface class have their (empty) default implementations, and the application can inherit only some of the required events instead of all of them. In the callback methods, the application should avoid time-consuming tasks or call blocking APIs (such as SendMessage), otherwise, the SDK may not work properly.

## Member Function Documentation

## ◆ onError()

void io.agora.rtc2.IRtcEngineEventHandler.onError | ( | int | err | ) |

Reports an error during SDK runtime.

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

  err | Error code.

## ◆ onJoinChannelSuccess()

void io.agora.rtc2.IRtcEngineEventHandler.onJoinChannelSuccess | ( | String | channel,
|  | int | uid,
|  | int | elapsed
| ) |  |

Occurs when a user joins a channel.

This callback notifies the application that a user joins a specified channel. Call timing: The SDK triggers this callback when you call `joinChannel(String token, String channelId, String optionalInfo, int uid)`, `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` , `joinChannelWithUserAccount(String token, String channelName, String userAccount)`, `joinChannelWithUserAccount(String token, String channelName, String userAccount, ChannelMediaOptions options)` , `joinChannelEx` or `joinChannelWithUserAccountEx` to join a 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(String token, String channelId, int uid, ChannelMediaOptions options)` until the SDK triggers this callback.

## ◆ onRejoinChannelSuccess()

void io.agora.rtc2.IRtcEngineEventHandler.onRejoinChannelSuccess | ( | String | channel,
|  | int | uid,
|  | int | elapsed
| ) |  |

Occurs when a user rejoins the channel.

Call timing: 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(String token, String channelId, int uid, ChannelMediaOptions options)` until the SDK triggers this callback.

## ◆ onLeaveChannel()

void io.agora.rtc2.IRtcEngineEventHandler.onLeaveChannel | ( | RtcStats | stats | ) |

Occurs when a user leaves a channel.

You can obtain information such as the total duration of a call, and the data traffic that the SDK transmits and receives. Call timing: The SDK triggers this callback after you call `leaveChannel()`, `leaveChannel(LeaveChannelOptions options)` , `leaveChannelEx(RtcConnection connection)`, or `leaveChannelEx(RtcConnection connection, LeaveChannelOptions options)` to leave a channel.

Parameters

  stats | Call statistics. See `RtcStats`.

## ◆ onClientRoleChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onClientRoleChanged | ( | int | oldRole,
|  | int | newRole,
|  | ClientRoleOptions | newRoleOptions
| ) |  |

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

Call timing: This callback will be triggered in any of the following situations:

- Calling `setClientRole(int role)` or `setClientRole(int role, ClientRoleOptions options)` to set the user role or audience latency level after joining a channel
- Calling `setClientRole(int role)` or `setClientRole(int role, ClientRoleOptions options)` and set the user role to `AUDIENCE` before joining a channel.

Note
  This callback will not be triggered when you call `setClientRole(int role)` or `setClientRole(int role, ClientRoleOptions options)` and set the user role to `BROADCASTER` before joining a channel.

Parameters

  oldRole | Role that the user switches from: CLIENT_ROLE_BROADCASTER (1): Host. CLIENT_ROLE_AUDIENCE (2): Audience.
  newRole | Role that the user switches to: CLIENT_ROLE_BROADCASTER (1): Host. CLIENT_ROLE_AUDIENCE (2): Audience.
  newRoleOptions | Since v4.1.0 Properties of the role that the user switches to. See `ClientRoleOptions`.

## ◆ onClientRoleChangeFailed()

void io.agora.rtc2.IRtcEngineEventHandler.onClientRoleChangeFailed | ( | int | reason,
|  | int | currentRole
| ) |  |

Occurs when switching a user role fails.

This callback informs you about the reason for failing to switching and your current user role. Call timing: The SDK triggers this callback when the local user calls `setClientRole(int role)` or `setClientRole(int role, ClientRoleOptions options)` after joining a channel to switch the user role but the switching fails.

Parameters

  reason | The reason for a user role switch failure. CLIENT_ROLE_CHANGE_FAILED_TOO_MANY_BROADCASTERS (1): The number of hosts in the channel is already at the upper limit.Note: This enumerator is reported only when the support for 128 users is enabled. The maximum number of hosts is based on the actual number of hosts configured when you enable the 128-user feature. CLIENT_ROLE_CHANGE_FAILED_NOT_AUTHORIZED (2): The request is rejected by the Agora server. Agora recommends you prompt the user to try to switch their user role again. CLIENT_ROLE_CHANGE_FAILED_REQUEST_TIME_OUT (3): The request is timed out. Agora recommends you prompt the user to check the network connection and try to switch their user role again. Deprecated: This enumerator is deprecated since v4.4.0 and is not recommended for use. CLIENT_ROLE_CHANGE_FAILED_CONNECTION_FAILED (4): The SDK connection fails. You can troubleshoot the failure through the `reason` reported by `onConnectionStateChanged`. Deprecated: This enumerator is deprecated since v4.4.0 and is not recommended for use.
  currentRole | Current user role. CLIENT_ROLE_BROADCASTER (1): Host. A host can both send and receive streams. CLIENT_ROLE_AUDIENCE (2): Audience. An audience member can only receive streams.

## ◆ onLocalUserRegistered()

void io.agora.rtc2.IRtcEngineEventHandler.onLocalUserRegistered | ( | int | uid,
|  | String | userAccount
| ) |  |

Occurs when the local user registers a user account.

Since
  v2.8.0.

After the local user successfully calls `registerLocalUserAccount` to register the user account or calls `joinChannelWithUserAccount(String token, String channelName, String userAccount, ChannelMediaOptions options)` 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.

## ◆ onUserInfoUpdated()

void io.agora.rtc2.IRtcEngineEventHandler.onUserInfoUpdated | ( | int | uid,
|  | UserInfo | userInfo
| ) |  |

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

Since
  v2.8.0.

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.
  userInfo | The UserInfo object that contains the user ID and user account of the remote user. See `UserInfo` for details.

## ◆ onUserStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onUserStateChanged | ( | int | uid,
|  | int | state
| ) |  |

Occurs when the remote user state is updated.

Parameters

  uid | The ID of the remote user.
  state | State of the remote user: Just & #REMOTE_USER_STATE `USER_STATE_MUTE_AUDIO(1 << 0)`: The remote user has muted the audio. `USER_STATE_MUTE_VIDEO(1 << 1)`: The remote user has muted the video. `USER_STATE_ENABLE_VIDEO(1 << 4)`: The remote user has enabled the video, which includes video capturing and encoding. `USER_STATE_ENABLE_LOCAL_VIDEO(1 << 8)`: The remote user has enabled the local video capturing.

## ◆ onUserJoined()

void io.agora.rtc2.IRtcEngineEventHandler.onUserJoined | ( | int | uid,
|  | int | elapsed
| ) |  |

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

- 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 co-hosts to 32, with a maximum of 17 video hosts. Call timing: 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(String token, String channelId, String optionalInfo, int uid)` or `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` until this callback is triggered.

## ◆ onUserOffline()

void io.agora.rtc2.IRtcEngineEventHandler.onUserOffline | ( | int | uid,
|  | int | reason
| ) |  |

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

There are generally two reasons for users to become offline:

- Leave the channel: When a user/host leaves the channel, the user/host sends a goodbye message.
- 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 is recommended to use the Agora RTM SDK for reliable offline detection. Call timing: This callback is triggered when a remote user (in the communication profile) or host (in the live streaming profile) leaves a channel.

Parameters

  uid | The ID of the user who leaves the channel or goes offline.
  reason | Reasons why a remote user (in the communication profile) or host (in the live streaming profile) goes offline: USER_OFFLINE_QUIT (0): The user has quit the call. When the user leaves the channel, the user sends a goodbye message. USER_OFFLINE_DROPPED (1): The SDK timed out and the user dropped offline because it has not received any data package within a certain period of time. A poor network connection may lead to false detection. It is recommended to use the Agora RTM SDK for reliable offline detection. USER_OFFLINE_BECOME_AUDIENCE (2): The user switches the user role from a broadcaster to an audience.

## ◆ onConnectionStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onConnectionStateChanged | ( | int | state,
|  | int | reason
| ) |  |

Occurs when the network connection state changes.

Since
  v2.3.2.

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. CONNECTION_STATE_DISCONNECTED (1): The SDK is disconnected from Agora's edge server. CONNECTION_STATE_CONNECTING (2): The SDK is connecting to Agora's edge server. CONNECTION_STATE_CONNECTED (3): The SDK is connected to Agora's edge server. CONNECTION_STATE_RECONNECTING (4): The SDK tries to reconnect to the Agora edge server. CONNECTION_STATE_FAILED (5): The SDK fails to connect to Agora's edge server.
  reason | - CONNECTION_CHANGED_CONNECTING (0): The SDK is connecting to Agora's edge server. CONNECTION_CHANGED_JOIN_SUCCESS (1): The SDK has joined the channel successfully. CONNECTION_CHANGED_INTERRUPTED (2): The connection between the SDK and Agora's edge server is interrupted. CONNECTION_CHANGED_BANNED_BY_SERVER (3): The connection is banned by the Agora server. For example, when a user is kicked out of the channel, this code will be returned. CONNECTION_CHANGED_JOIN_FAILED (4): The SDK fails to join the channel. When the SDK fails to join the channel for more than 20 minutes, this code will be returned and the SDK stops reconnecting to the channel. You need to prompt the user to try to switch to another network and rejoin the channel. CONNECTION_CHANGED_LEAVE_CHANNEL (5): The SDK has left the channel. CONNECTION_CHANGED_INVALID_APP_ID (6): Invalid App ID. You need to rejoin the channel with a valid APP ID and make sure the App ID you are using is consistent with the one generated in the Agora Console. CONNECTION_CHANGED_INVALID_CHANNEL_NAME (7): Invalid channel name. Rejoin the channel with a valid channel name. A valid channel name is a string of up to 64 bytes in length. Supported characters (89 characters in total): All lowercase English letters: a to z. All uppercase English letters: A to Z. All numeric characters: 0 to 9. "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", "," CONNECTION_CHANGED_INVALID_TOKEN (8): Invalid token. Possible reasons are as follows: The App Certificate for the project is enabled in Agora Console, but you do not pass in a token when joining a channel. The uid specified when calling `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` to join the channel is inconsistent with the uid passed in when generating the token. The generated token and the token used to join the channel are not consistent. Ensure the following: When your project enables App Certificate, you need to pass in a token to join a channel. The user ID specified when generating the token is consistent with the user ID used when joining the channel. The generated token is the same as the token passed in to join the channel. CONNECTION_CHANGED_TOKEN_EXPIRED (9): The token currently being used has expired. You need to generate a new token on your server and rejoin the channel with the new token. CONNECTION_CHANGED_REJECTED_BY_SERVER (10): The user is banned by the server. CONNECTION_CHANGED_SETTING_PROXY_SERVER (11): The SDK tries to reconnect after setting a proxy server. CONNECTION_CHANGED_RENEW_TOKEN (12): The connection state changed because the token is renewed. CONNECTION_CHANGED_CLIENT_IP_ADDRESS_CHANGED (13): Client IP address changed. If you receive this code multiple times, You need to prompt the user to switch networks and try joining the channel again. CONNECTION_CHANGED_KEEP_ALIVE_TIMEOUT (14): Timeout for the keep-alive of the connection between the SDK and the Agora edge server. The SDK tries to reconnect to the server automatically. CONNECTION_CHANGED_REJOIN_SUCCESS (15): The SDK has rejoined the channel successfully. CONNECTION_CHANGED_LOST (16): The connection between the SDK and the server is lost. CONNECTION_CHANGED_ECHO_TEST (17): The connection state changes due to the echo test. CONNECTION_CHANGED_CLIENT_IP_ADDRESS_CHANGED_BY_USER (18): The local IP address was changed by the user. CONNECTION_CHANGED_SAME_UID_LOGIN (19): The user joined the same channel from different devices with the same UID. CAUTION: Joining the same RTC channel with the same UID is an undefined behavior. Agora does not guarantee that `reason` 19 is always triggered under the same circumstance. CONNECTION_CHANGED_TOO_MANY_BROADCASTERS (20): The number of hosts in the channel has reached the upper limit.

## ◆ onConnectionInterrupted()

void io.agora.rtc2.IRtcEngineEventHandler.onConnectionInterrupted | ( |  | ) |

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

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 `onConnectionLost` are as follow:

- The SDK triggers the `onConnectionInterrupted` callback when it loses connection with the server for more than four seconds after it successfully joins the channel.
- The SDK triggers the `onConnectionLost` 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.

## ◆ onConnectionLost()

void io.agora.rtc2.IRtcEngineEventHandler.onConnectionLost | ( |  | ) |

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

The SDK triggers this callback when it cannot connect to the server 10 seconds after calling the `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` 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.

## ◆ onTokenPrivilegeWillExpire()

void io.agora.rtc2.IRtcEngineEventHandler.onTokenPrivilegeWillExpire | ( | String | token | ) |

Occurs when the token expires in 30 seconds.

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(LeaveChannelOptions options)` to leave the current channel and then pass in the new token when you call `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` to join a channel.
- In scenarios involving mutiple channels: Call `updateChannelMediaOptionsEx` to pass in the new token. Call timing: The SDK triggers this callback 30 seconds before the token expires, reminding the app to update the token.

Parameters

  token | The token that is about to expire.

## ◆ onRequestToken()

void io.agora.rtc2.IRtcEngineEventHandler.onRequestToken | ( |  | ) |

Occurs when the token expires.

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(LeaveChannelOptions options)` to leave the current channel and then pass in the new token when you call `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` to join a channel.
- In scenarios involving mutiple channels: Call `updateChannelMediaOptionsEx` to pass in the new token.

## ◆ onLicenseValidationFailure()

void io.agora.rtc2.IRtcEngineEventHandler.onLicenseValidationFailure | ( | int | error | ) |

Occurs when connection license verification fails You can know the reason accordding to error code

Parameters

  error | license verify fail reason: `LICENSE_ERR_INVALID(1)`: Invalid license. `LICENSE_ERR_EXPIRE(2)`: License expired. `LICENSE_ERR_MINUTES_EXCEED(3)`: Exceed license minutes limit. `LICENSE_ERR_LIMITED_PERIOD(4)`: License use in limited period. `LICENSE_ERR_DIFF_DEVICES(5)`: Same license used in different devices at the same time. `LICENSE_ERR_INTERNAL(99)`: SDK internal error.

## ◆ onAudioVolumeIndication()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioVolumeIndication | ( | AudioVolumeInfo[] | speakers,
|  | int | totalVolume
| ) |  |

Reports the volume information of users.

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 `onAudioVolumeIndication` callback according to the time interval set in `enableAudioVolumeIndication`. The SDK triggers two independent `onAudioVolumeIndication` 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.

Note
  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 `AudioVolumeInfo`. 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(String filePath, boolean loopback, int cycle, int startPos)` , then `totalVolume` is the volume after audio mixing.

## ◆ onActiveSpeaker()

void io.agora.rtc2.IRtcEngineEventHandler.onActiveSpeaker | ( | int | uid | ) |

Occurs when the most active remote speaker is detected.

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 `onActiveSpeaker` 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

  uid | The user ID of the most active speaker.

## ◆ onVideoStopped()

void io.agora.rtc2.IRtcEngineEventHandler.onVideoStopped | ( |  | ) |

Occurs when the video stops playing.

Deprecated:
  Use onLocalVideoStateChanged 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.

## ◆ onFirstLocalVideoFrame()

void io.agora.rtc2.IRtcEngineEventHandler.onFirstLocalVideoFrame | ( | Constants.VideoSourceType | source,
|  | int | width,
|  | int | height,
|  | int | elapsed
| ) |  |

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

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 `VideoSourceType`.
  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(String token, String channelId, String optionalInfo, int uid)` or `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` to join the channel to when the SDK triggers this callback. If `startPreview()` / `startPreview(Constants.VideoSourceType sourceType)` is called before joining the channel, this parameter indicates the time elapsed from calling `startPreview()` or `startPreview(Constants.VideoSourceType sourceType)` to when this event occurred.

## ◆ onFirstLocalVideoFramePublished()

void io.agora.rtc2.IRtcEngineEventHandler.onFirstLocalVideoFramePublished | ( | Constants.VideoSourceType | source,
|  | int | elapsed
| ) |  |

Occurs when the first video frame is published.

The SDK triggers this callback under one of the following circumstances:

- The local client enables the video module and calls `joinChannel(String token, String channelId, String optionalInfo, int uid)` or `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` 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 `pushExternalVideoFrameById(AgoraVideoFrame frame, int videoTrackId)` to successfully push the video frame to the SDK.

Parameters

  source | The type of the video source. See `VideoSourceType`.
  elapsed | Time elapsed (ms) from the local user calling `joinChannel(String token, String channelId, String optionalInfo, int uid)` or `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` until this callback is triggered.

## ◆ onFirstRemoteVideoDecoded()

void io.agora.rtc2.IRtcEngineEventHandler.onFirstRemoteVideoDecoded | ( | int | uid,
|  | int | width,
|  | int | height,
|  | int | elapsed
| ) |  |

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

Deprecated:
  This callback is deprecated. Use `REMOTE_VIDEO_STATE_STARTING(1)` or `REMOTE_VIDEO_STATE_DECODING(2)` in the onRemoteVideoStateChanged callback instead.

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(String token, String channelId, String optionalInfo, int uid)` or `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` until the SDK triggers this callback.

## ◆ onFirstRemoteVideoFrame()

void io.agora.rtc2.IRtcEngineEventHandler.onFirstRemoteVideoFrame | ( | int | uid,
|  | int | width,
|  | int | height,
|  | int | elapsed
| ) |  |

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

Note
  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

  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(String token, String channelId, String optionalInfo, int uid)` or `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` until the SDK triggers this callback.

## ◆ onUserMuteAudio()

void io.agora.rtc2.IRtcEngineEventHandler.onUserMuteAudio | ( | int | uid,
|  | boolean | muted
| ) |  |

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

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

Note
  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 32.

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.

## ◆ onUserMuteVideo()

void io.agora.rtc2.IRtcEngineEventHandler.onUserMuteVideo | ( | int | uid,
|  | boolean | muted
| ) |  |

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

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.

Note
  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 32.

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.

## ◆ onUserEnableVideo()

void io.agora.rtc2.IRtcEngineEventHandler.onUserEnableVideo | ( | int | uid,
|  | boolean | enabled
| ) |  |

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

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.

## ◆ onUserEnableLocalVideo()

void io.agora.rtc2.IRtcEngineEventHandler.onUserEnableLocalVideo | ( | int | uid,
|  | boolean | enabled
| ) |  |

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

Deprecated:
  This callback is deprecated and replaced by the onRemoteVideoStateChanged callback with the following parameters:
  - `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.

## ◆ onVideoSizeChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onVideoSizeChanged | ( | Constants.VideoSourceType | source,
|  | int | uid,
|  | int | width,
|  | int | height,
|  | int | rotation
| ) |  |

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

Parameters

  source | The type of the video source. See `VideoSourceType`.
  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).

## ◆ onRemoteAudioStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onRemoteAudioStateChanged | ( | int | uid,
|  | int | state,
|  | int | reason,
|  | int | elapsed
| ) |  |

Occurs when the remote audio state changes.

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.

Note
  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 32.

Parameters

  uid | The ID of the remote user whose audio state changes.
  state | Remote audio states. REMOTE_AUDIO_STATE_STOPPED (0): The remote audo is in the initial state. The SDK reports this state in the case of `REMOTE_AUDIO_REASON_LOCAL_MUTED`, `REMOTE_AUDIO_REASON_REMOTE_MUTED`, or `REMOTE_AUDIO_REASON_REMOTE_OFFLINE`. REMOTE_AUDIO_STATE_STARTING (1): The first remote audio packet is received. REMOTE_AUDIO_STATE_DECODING (2): The remote audio stream is decoded and plays normally. The SDK reports this state in the case of `REMOTE_VIDEO_STATE_REASON_NETWORK_RECOVERY`, `REMOTE_AUDIO_REASON_LOCAL_UNMUTED` or `REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED`. REMOTE_AUDIO_STATE_FROZEN (3): The remote audio is frozen. The SDK reports this state in the case of `REMOTE_AUDIO_REASON_NETWORK_CONGESTION`. REMOTE_AUDIO_STATE_FAILED (4): The remote audio fails to start. The SDK reports this state in the case of `REMOTE_VIDEO_STATE_REASON_INTERNAL`.
  reason | The reason of the remote audio state change. REMOTE_AUDIO_REASON_INTERNAL (0): The SDK reports this reason when the audio state changes. REMOTE_AUDIO_REASON_NETWORK_CONGESTION (1): Network congestion. REMOTE_AUDIO_REASON_NETWORK_RECOVERY (2): Network recovery. REMOTE_AUDIO_REASON_LOCAL_MUTED (3): The local user stops receiving the remote audio stream or disables the audio module. REMOTE_AUDIO_REASON_LOCAL_UNMUTED (4): The local user resumes receiving the remote audio stream or enables the audio module. REMOTE_AUDIO_REASON_REMOTE_MUTED (5): The remote user stops sending the audio stream or disables the audio module. REMOTE_AUDIO_REASON_REMOTE_UNMUTED (6): The remote user resumes sending the audio stream or enables the audio module. REMOTE_AUDIO_REASON_REMOTE_OFFLINE (7): The remote user leaves the channel.
  elapsed | Time elapsed (ms) from the local user calling the `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` method until the SDK triggers this callback.

## ◆ onAudioPublishStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioPublishStateChanged | ( | String | channel,
|  | int | oldState,
|  | int | newState,
|  | int | elapseSinceLastState
| ) |  |

Occurs when the audio publishing state changes.

Parameters

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

## ◆ onVideoPublishStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onVideoPublishStateChanged | ( | Constants.VideoSourceType | source,
|  | String | channel,
|  | int | oldState,
|  | int | newState,
|  | int | elapseSinceLastState
| ) |  |

Occurs when the video publishing state changes.

Parameters

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

## ◆ onAudioSubscribeStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioSubscribeStateChanged | ( | String | channel,
|  | int | uid,
|  | int | oldState,
|  | int | newState,
|  | int | elapseSinceLastState
| ) |  |

Occurs when the audio subscribing state changes.

Parameters

  channel | The channel name.
  uid | The user ID of the remote user.
  oldState | The previous subscription status. SUB_STATE_IDLE (0): The initial subscribing state after joining the channel. SUB_STATE_NO_SUBSCRIBED (1): Fails to subscribe to the remote stream. Possible reasons: The remote user: Calls `muteLocalAudioStream` (`true`) to stop sending the local audio stream. Calls `disableAudio` to disable the local audio module. Calls `enableLocalAudio` `false`) to disable the local audio capture. The role of the remote user is audience. The local user calls the following methods to stop receiving the remote audio streams: Sets `autoSubscribeAudio` to `false` when calling `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` or `updateChannelMediaOptions`, which means not to automatically subscribe to any audio streams. Sets `muted` to `true` when calling `muteRemoteAudioStream` or `muteAllRemoteAudioStreams`, which means stopping receiving the remote video streams. SUB_STATE_SUBSCRIBING (2): Subscribing. SUB_STATE_SUBSCRIBED (3): The remote stream is received, and the subscription is successful.
  newState | The current subscribing status. SUB_STATE_IDLE (0): The initial subscribing state after joining the channel. SUB_STATE_NO_SUBSCRIBED (1): Fails to subscribe to the remote stream. Possible reasons: The remote user: Calls `muteLocalAudioStream` (`true`) to stop sending the local audio stream. Calls `disableAudio` to disable the local audio module. Calls `enableLocalAudio` `false`) to disable the local audio capture. The role of the remote user is audience. The local user calls the following methods to stop receiving the remote audio streams: Sets `autoSubscribeAudio` to `false` when calling `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` or `updateChannelMediaOptions`, which means not to automatically subscribe to any audio streams. Sets `muted` to `true` when calling `muteRemoteAudioStream` or `muteAllRemoteAudioStreams`, which means stopping receiving the remote video streams. SUB_STATE_SUBSCRIBING (2): Subscribing. SUB_STATE_SUBSCRIBED (3): The remote stream is received, and the subscription is successful.
  elapseSinceLastState | The time elapsed (ms) from the previous state to the current state.

## ◆ onVideoSubscribeStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onVideoSubscribeStateChanged | ( | String | channel,
|  | int | uid,
|  | int | oldState,
|  | int | newState,
|  | int | elapseSinceLastState
| ) |  |

Occurs when the video subscribing state changes.

Parameters

  channel | The channel name.
  uid | The user ID of the remote user.
  oldState | The previous subscription status. SUB_STATE_IDLE (0): The initial subscribing state after joining the channel. SUB_STATE_NO_SUBSCRIBED (1): Fails to subscribe to the remote stream. Possible reasons: The remote user: Calls `muteLocalVideoStream` (`true`) to stop sending the local video streams. Calls `disableVideo` to disable the local video module. Calls `enableLocalVideo` (`false`) to disable the local video capture. The role of the remote user is audience. The local user calls the following methods to stop receiving the remote media stream: Sets `autoSubscribeVideo` to `false` when calling `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` or `updateChannelMediaOptions`, which means not to automatically subscribe to any video streams. Sets `muted` to `true` when calling `muteRemoteVideoStream` or `muteAllRemoteVideoStreams`, which means stopping receiving the remote video streams. SUB_STATE_SUBSCRIBING (2): Subscribing. SUB_STATE_SUBSCRIBED (3): The remote stream is received, and the subscription is successful.
  newState | The current subscribing status. SUB_STATE_IDLE (0): The initial subscribing state after joining the channel. SUB_STATE_NO_SUBSCRIBED (1): Fails to subscribe to the remote stream. Possible reasons: The remote user: Calls `muteLocalVideoStream` (`true`) to stop sending the local video streams. Calls `disableVideo` to disable the local video module. Calls `enableLocalVideo` (`false`) to disable the local video capture. The role of the remote user is audience. The local user calls the following methods to stop receiving the remote media stream: Sets `autoSubscribeVideo` to `false` when calling `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` or `updateChannelMediaOptions`, which means not to automatically subscribe to any video streams. Sets `muted` to `true` when calling `muteRemoteVideoStream` or `muteAllRemoteVideoStreams`, which means stopping receiving the remote video streams. SUB_STATE_SUBSCRIBING (2): Subscribing. SUB_STATE_SUBSCRIBED (3): The remote stream is received, and the subscription is successful.
  elapseSinceLastState | The time elapsed (ms) from the previous state to the current state.

## ◆ onRemoteVideoStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onRemoteVideoStateChanged | ( | int | uid,
|  | int | state,
|  | int | reason,
|  | int | elapsed
| ) |  |

Occurs when the remote video stream state changes.

Note
  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 32.

Parameters

  uid | The ID of the remote user whose video state changes.
  state | The state of the remote video: REMOTE_VIDEO_STATE_STOPPED (0): The remote video is in the initial state. This state is reported in the case of `REMOTE_VIDEO_STATE_REASON_LOCAL_MUTED` (3), `REMOTE_VIDEO_STATE_REASON_REMOTE_MUTED` (5), or `REMOTE_VIDEO_STATE_REASON_REMOTE_OFFLINE` (7). REMOTE_VIDEO_STATE_STARTING (1): The first remote video packet is received. REMOTE_VIDEO_STATE_DECODING (2): The remote video stream is decoded and plays normally. This state is reported in the case of `REMOTE_VIDEO_STATE_REASON_NETWORK_RECOVERY` (2), `REMOTE_VIDEO_STATE_REASON_LOCAL_UNMUTED` (4), `REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED` (6), or `REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK_RECOVERY` (9). REMOTE_VIDEO_STATE_FROZEN (3): The remote video is frozen. This state is reported in the case of `REMOTE_VIDEO_STATE_REASON_NETWORK_CONGESTION` (1) or `REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK` (8). REMOTE_VIDEO_STATE_FAILED (4): The remote video fails to start. The SDK reports this state in the case of `REMOTE_VIDEO_STATE_REASON_INTERNAL` (0).
  reason | The reason for the remote video state change: REMOTE_VIDEO_STATE_REASON_INTERNAL (0): Internal reasons. REMOTE_VIDEO_STATE_REASON_NETWORK_CONGESTION (1): Network congestion. REMOTE_VIDEO_STATE_REASON_NETWORK_RECOVERY (2): Network recovery. REMOTE_VIDEO_STATE_REASON_LOCAL_MUTED (3): The local user stops receiving the remote video stream or disables the video module. REMOTE_VIDEO_STATE_REASON_LOCAL_UNMUTED (4): The local user resumes receiving the remote video stream or enables the video module. REMOTE_VIDEO_STATE_REASON_REMOTE_MUTED (5): The remote user stops sending the video stream or disables the video module. REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED (6): The remote user resumes sending the video stream or enables the video module. REMOTE_VIDEO_STATE_REASON_REMOTE_OFFLINE (7): The remote user leaves the channel. REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK (8): The remote media stream falls back to the audio-only stream due to poor network conditions. REMOTE_VIDEO_STATE_REASON_AUDIO_FALLBACK_RECOVERY (9): The remote media stream switches back to the video stream after the network conditions improve. REMOTE_VIDEO_STATE_REASON_CODEC_NOT_SUPPORT (13): The local video decoder does not support decoding the remote video stream.
  elapsed | Time elapsed (ms) from the local user calling the `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` method until the SDK triggers this callback.

## ◆ onChannelMediaRelayStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onChannelMediaRelayStateChanged | ( | int | state,
|  | int | code
| ) |  |

Occurs when the state of the media stream relay changes.

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(LeaveChannelOptions options)` 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_SRC 4: The server fails to send the relay request. RELAY_ERROR_FAILED_JOIN_DEST 5: The server fails to accept the relay request. RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC 6: The server fails to receive the media stream. RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST 7: 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(LeaveChannelOptions options)` 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.

## ◆ onFirstLocalAudioFramePublished()

void io.agora.rtc2.IRtcEngineEventHandler.onFirstLocalAudioFramePublished | ( | int | elapsed | ) |

Occurs when the first audio frame is published.

The SDK triggers this callback under one of the following circumstances:

- The local client enables the audio module and calls `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` 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 `pushExternalAudioFrame` to successfully push the audio frame to the SDK.

Parameters

  elapsed | Time elapsed (ms) from the local user calling `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` until the SDK triggers this callback.

## ◆ onFirstRemoteAudioFrame()

void io.agora.rtc2.IRtcEngineEventHandler.onFirstRemoteAudioFrame | ( | int | uid,
|  | int | elapsed
| ) |  |

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

Parameters

  uid | The user ID of the remote user.
  elapsed | The time elapsed (ms) from the local user calling `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` until the SDK triggers this callback.

## ◆ onFirstRemoteAudioDecoded()

void io.agora.rtc2.IRtcEngineEventHandler.onFirstRemoteAudioDecoded | ( | int | uid,
|  | int | elapsed
| ) |  |

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

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(String token, String channelId, int uid, ChannelMediaOptions options)` until the SDK triggers this callback.

## ◆ onRemoteSubscribeFallbackToAudioOnly()

void io.agora.rtc2.IRtcEngineEventHandler.onRemoteSubscribeFallbackToAudioOnly | ( | int | uid,
|  | boolean | isFallbackOrRecover
| ) |  |

Occurs when the remote media stream falls back to the audio-only stream due to poor network conditions or switches back to the video stream after the network conditions improve.

If you call `setRemoteSubscribeFallbackOption(int option)` and set `option` to `STREAM_FALLBACK_OPTION_AUDIO_ONLY`, the SDK triggers this callback in the following situations:

- The downstream network condition is poor, and the subscribed video stream is downgraded to audio-only stream.
- The downstream network condition has improved, and the subscribed stream has been restored to video stream.

Note
  Once the remote media stream switches to the low-quality video stream due to weak network conditions, you can monitor the stream switch between a high-quality and low-quality stream in the `onRemoteVideoStats` callback.

Parameters

  uid | The user ID of the remote user.
  isFallbackOrRecover | - `true`: The subscribed media stream falls back to audio-only due to poor network conditions. `false`: The subscribed media stream switches back to the video stream after the network conditions improve.

## ◆ onAudioRouteChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioRouteChanged | ( | int | routing | ) |

Occurs when the local audio route changes.

Parameters

  routing | The current audio routing. AUDIO_ROUTE_DEFAULT (-1): The default audio route. AUDIO_ROUTE_HEADSET (0): The audio route is a headset with a microphone. AUDIO_ROUTE_EARPIECE (1): The audio route is an earpiece. AUDIO_ROUTE_HEADSETNOMIC (2): The audio route is a headset without a microphone. AUDIO_ROUTE_SPEAKERPHONE (3): The audio route is the speaker that comes with the device. AUDIO_ROUTE_LOUDSPEAKER (4): (For future use) The audio route is an external speaker. AUDIO_ROUTE_BLUETOOTH_DEVICE_HFP (5): The audio route is a Bluetooth device using the HFP protocol. AUDIO_ROUTE_BLUETOOTH_DEVICE_A2DP (10): The audio route is a Bluetooth device using the A2DP protocol.

## ◆ onCameraReady()

void io.agora.rtc2.IRtcEngineEventHandler.onCameraReady | ( |  | ) |

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

Deprecated:
  Use onLocalVideoStateChanged instead.

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

## ◆ onCameraFocusAreaChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onCameraFocusAreaChanged | ( | Rect | rect | ) |

Occurs when the camera focus area changes.

The SDK triggers this callback when the local user changes the camera focus position by calling `setCameraFocusPositionInPreview`.

Parameters

  rect | The focus rectangle in the local preview. See `Rect`.

## ◆ onCameraExposureAreaChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onCameraExposureAreaChanged | ( | Rect | rect | ) |

Occurs when the camera exposure area changes.

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

Parameters

  rect | The focus rectangle in the local preview. See `Rect`.

## ◆ onSnapshotTaken()

void io.agora.rtc2.IRtcEngineEventHandler.onSnapshotTaken | ( | int | uid,
|  | String | filePath,
|  | int | width,
|  | int | height,
|  | int | errCode
| ) |  |

Reports the result of taking a video snapshot.

After a successful `takeSnapshot(int uid, String filePath)` 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(int uid, String filePath)` method call succeeds. The possible reasons are: local capture stops, remote end stops publishing, or video data processing is blocked. -3: Calling the `takeSnapshot(int uid, String filePath)` method too frequently.

## ◆ onFacePositionChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onFacePositionChanged | ( | int | imageWidth,
|  | int | imageHeight,
|  | AgoraFacePositionInfo[] | faceRectArr
| ) |  |

Reports the face detection result of the local user.

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.

Note
  - 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.
  faceRectArr | Information of the detected face. See `AgoraFacePositionInfo`. The number of `AgoraFacePositionInfo` array reported in this callback is based on the faces detected. The length of the array can be 0, which means that no human face is detected in front of the camera.

## ◆ onAudioQuality()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioQuality | ( | int | uid,
|  | int | quality,
|  | short | delay,
|  | short | lost
| ) |  |

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

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. QUALITY_DETECTING (8): The last-mile probe test is in progress.
  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.

## ◆ onRtcStats()

void io.agora.rtc2.IRtcEngineEventHandler.onRtcStats | ( | RtcStats | stats | ) |

Reports the statistics about the current call.

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

Parameters

  stats | Statistics of the RTC engine. See `RtcStats`.

## ◆ onLastmileQuality()

void io.agora.rtc2.IRtcEngineEventHandler.onLastmileQuality | ( | int | quality | ) |

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

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 once `startLastmileProbeTest` 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. QUALITY_DETECTING (8): The last-mile probe test is in progress.

## ◆ onLastmileProbeResult()

void io.agora.rtc2.IRtcEngineEventHandler.onLastmileProbeResult | ( | LastmileProbeResult | result | ) |

Reports the last mile network probe 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 `LastmileProbeResult`.

## ◆ onNetworkQuality()

void io.agora.rtc2.IRtcEngineEventHandler.onNetworkQuality | ( | int | uid,
|  | int | txQuality,
|  | int | rxQuality
| ) |  |

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

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. QUALITY_DETECTING (8): The last-mile probe test is in progress.
  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. QUALITY_DETECTING (8): The last-mile probe test is in progress.

## ◆ onLocalAudioStats()

void io.agora.rtc2.IRtcEngineEventHandler.onLocalAudioStats | ( | LocalAudioStats | stats | ) |

Reports the statistics of the local audio stream.

The SDK triggers this callback once every two seconds.

Parameters

  stats | Local audio statistics. See `LocalAudioStats`.

## ◆ onLocalVideoStats()

void io.agora.rtc2.IRtcEngineEventHandler.onLocalVideoStats | ( | Constants.VideoSourceType | source,
|  | LocalVideoStats | stats
| ) |  |

Reports the statistics of the local video stream.

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 `VideoSourceType`.
  stats | The statistics of the local video stream. See `LocalVideoStats`.

## ◆ onRemoteAudioStats()

void io.agora.rtc2.IRtcEngineEventHandler.onRemoteAudioStats | ( | RemoteAudioStats | stats | ) |

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

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 `RemoteAudioStats`.

## ◆ onRemoteVideoStats()

void io.agora.rtc2.IRtcEngineEventHandler.onRemoteVideoStats | ( | RemoteVideoStats | stats | ) |

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

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 `RemoteVideoStats`.

## ◆ onLocalVideoStat()

void io.agora.rtc2.IRtcEngineEventHandler.onLocalVideoStat | ( | int | sentBitrate,
|  | int | sentFrameRate
| ) |  |

Deprecated:
  The statistics of the uploading local video streams once every two seconds.

Parameters

  sentBitrate | Data sending bitrate (kbit/s) since last count.
  sentFrameRate | Data sending frame rate (fps) since last count.

## ◆ onRemoteVideoStat()

void io.agora.rtc2.IRtcEngineEventHandler.onRemoteVideoStat | ( | int | uid,
|  | int | delay,
|  | int | receivedBitrate,
|  | int | receivedFrameRate
| ) |  |

Deprecated:
  The statistics of receiving remote video streams once every two seconds.

Parameters

  uid | User ID of the user whose video streams are received.
  delay | Time delay (ms).
  receivedBitrate | Data receiving bitrate (kbit/s).
  receivedFrameRate | Data receiving frame rate (fps).

## ◆ onRemoteAudioTransportStats()

void io.agora.rtc2.IRtcEngineEventHandler.onRemoteAudioTransportStats | ( | int | uid,
|  | int | delay,
|  | int | lost,
|  | int | rxKBitRate
| ) |  |

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

Deprecated:
  Use onRemoteAudioStats 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).

## ◆ onRemoteVideoTransportStats()

void io.agora.rtc2.IRtcEngineEventHandler.onRemoteVideoTransportStats | ( | int | uid,
|  | int | delay,
|  | int | lost,
|  | int | rxKBitRate
| ) |  |

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

Deprecated:
  Use onRemoteVideoStats 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).

## ◆ onAudioMixingStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioMixingStateChanged | ( | int | state,
|  | int | reason
| ) |  |

Occurs when the playback state of the music file changes.

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. AUDIO_MIXING_STATE_PLAYING (710): The music file is playing. AUDIO_MIXING_STATE_PAUSED (711): The music file pauses playing. AUDIO_MIXING_STATE_STOPPED (713): The music file stops playing. AUDIO_MIXING_STATE_FAILED (714): An exception occurs when playing the audio mixing file. The SDK returns the specific reason in the `reasonCode` parameter.
  reason | Error code. AUDIO_MIXING_REASON_OK (0): No error. AUDIO_MIXING_REASON_CAN_NOT_OPEN (701): The SDK cannot open the music file. AUDIO_MIXING_REASON_TOO_FREQUENT_CALL (702): The SDK opens the music file too frequently. AUDIO_MIXING_REASON_INTERRUPTED_EOF (703): The music file playback is interrupted. AUDIO_MIXING_REASON_ONE_LOOP_COMPLETED (721): The music file completes a loop playback. AUDIO_MIXING_REASON_ALL_LOOPS_COMPLETED (723): The music file completes all loop playback. AUDIO_MIXING_REASON_STOPPED_BY_USER (724): The music file pauses playing by calling `stopAudioMixing`.

## ◆ onAudioMixingPositionChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioMixingPositionChanged | ( | long | position | ) |

Reports the playback progress of a music file.

After you called the `startAudioMixing(String filePath, boolean loopback, int cycle, int startPos)` method to play a music file, the SDK triggers this callback every two seconds to report the playback progress.

Parameters

  position | The playback progress (ms).

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ onAudioMixingFinished()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioMixingFinished | ( |  | ) |

Occurs when the playback of the local music file finishes.

Deprecated:
  Use onAudioMixingStateChanged instead.

After you call `startAudioMixing(String filePath, boolean loopback, int cycle, int startPos)` to play a local music file, this callback occurs when the playback finishes. If the call of `startAudioMixing(String filePath, boolean loopback, int cycle, int startPos)` fails, the error code `WARN_AUDIO_MIXING_OPEN_ERROR` is returned.

## ◆ onAudioEffectFinished()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioEffectFinished | ( | int | soundId | ) |

Occurs when the playback of the local music file finishes.

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

Parameters

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

## ◆ onRhythmPlayerStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onRhythmPlayerStateChanged | ( | int | state,
|  | int | reason
| ) |  |

Occurs when the state of virtual metronome changes.

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.

Parameters

  state | The current virtual metronome state. RHYTHM_PLAYER_STATE_IDLE (810): The virtual metronome is not enabled or is already disabled. RHYTHM_PLAYER_STATE_OPENING (811): Opening the beat files. RHYTHM_PLAYER_STATE_DECODING (812): Decoding the beat files. RHYTHM_PLAYER_STATE_PLAYING (813): The beat files are playing. RHYTHM_PLAYER_STATE_FAILED (814): Failed to start virtual metronome. You can use the reported `errorCode` to troubleshoot the cause of the error, or you can try to start the virtual metronome again.
  reason | Error codes and error messages for virtual metronome errors. RHYTHM_PLAYER_REASON_OK (0): The beat files are played normally without errors. RHYTHM_PLAYER_REASON_FAILED (1): General error with no clear cause. RHYTHM_PLAYER_REASON_CAN_NOT_OPEN (801): There is an error when opening the beat files. RHYTHM_PLAYER_REASON_CAN_NOT_PLAY (802): There is an error when playing beat files. RHYTHM_PLAYER_REASON_FILE_OVER_DURATION_LIMIT (803): The duration of the beat audio file exceeds the limit. The maximum duration is 1.2 seconds.

## ◆ onLocalAudioStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onLocalAudioStateChanged | ( | int | state,
|  | int | reason
| ) |  |

Occurs when the local audio stream state changes.

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.

Note
  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. LOCAL_AUDIO_STREAM_STATE_STOPPED (0): The local video is in the initial state. LOCAL_AUDIO_STREAM_STATE_RECORDING (1): The local video capturing device starts successfully. LOCAL_AUDIO_STREAM_STATE_ENCODING (2): The first video frame is successfully encoded. LOCAL_AUDIO_STREAM_STATE_FAILED (3): Fails to start the local video.
  reason | Reasons for local audio state changes. LOCAL_AUDIO_STREAM_REASON_OK (0): The local video is normal. LOCAL_AUDIO_STREAM_REASON_FAILURE (1): No specified reason for the local audio failure. Remind your users to try to rejoin the channel. LOCAL_AUDIO_STREAM_REASON_DEVICE_NO_PERMISSION (2): No permission to use the local video capturing device. Remind your users to grant permission. LOCAL_AUDIO_STREAM_REASON_DEVICE_BUSY (3): The microphone is in use. Remind your users to check whether another application occupies the microphone. Local audio capture automatically resumes after the microphone is idle for about five seconds. You can also try to rejoin the channel after the microphone is idle. LOCAL_AUDIO_STREAM_REASON_CAPTURE_FAILURE (4): The local video capture failed. LOCAL_AUDIO_STREAM_REASON_ENCODE_FAILURE (5): The local video encoding fails. LOCAL_AUDIO_STREAM_REASON_INTERRUPTED (8): The local audio capture is interrupted by system calls, smart assistants, or alarm clocks. Prompt your users to end the phone call, smart assistants, or alarm clock if the local audio capture is required.

## ◆ onLocalVideoStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onLocalVideoStateChanged | ( | Constants.VideoSourceType | source,
|  | int | state,
|  | int | reason
| ) |  |

Occurs when the local video stream state changes.

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. Call 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`:

- 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 `onLocalVideoStateChanged` (`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.
- Normally, if there is an error in video capturing, the issue can be troubleshooted through the `reason` parameter in this callback. However, on some devices, when there is an issue with capturing (such as freezing), the Android system will not throw any error callbacks, so the SDK cannot report the reason for the change in local video status. In this case, you can determine if there is no video frame being captured by checking the following: this callback reports the `state` as `LOCAL_VIDEO_STREAM_STATE_CAPTURING` or `LOCAL_VIDEO_STREAM_STATE_ENCODING`, and the `captureFrameRate` in the `onLocalVideoStats` callback is 0.

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.
  - Normally, if there is an error in video capturing, the issue can be troubleshooted through the `reason` parameter in this callback. However, on some devices, when there is an issue with capturing (such as freezing), the Android system will not throw any error callbacks, so the SDK cannot report the reason for the change in local video status. In this case, you can determine if there is no video frame being captured by checking the following: this callback reports the `state` as `LOCAL_VIDEO_STREAM_STATE_CAPTURING` or `LOCAL_VIDEO_STREAM_STATE_ENCODING`, and the `captureFrameRate` in the `onLocalVideoStats` callback is 0.

Parameters

  source | The type of the video source. See `VideoSourceType`.
  state | - LOCAL_VIDEO_STREAM_STATE_STOPPED (0): The local video is in the initial state. LOCAL_VIDEO_STREAM_STATE_CAPTURING (1): The local video capturing device starts successfully. LOCAL_VIDEO_STREAM_STATE_ENCODING (2): The first video frame is successfully encoded. LOCAL_VIDEO_STREAM_STATE_FAILED (3): Fails to start the local video.
  reason | - LOCAL_VIDEO_STREAM_REASON_OK (0): The local video is normal. LOCAL_VIDEO_STREAM_REASON_FAILURE (1): No specified reason for the local video failure. LOCAL_VIDEO_STREAM_REASON_DEVICE_BUSY (3): The local video capturing device is in use. Prompt the user to check if the camera is being used by another app, or try to rejoin the channel. LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE (4): The local video capture failed. Prompt the user to check whether the video capture device is working properly, whether the camera is used by another app, or try to rejoin the channel. LOCAL_VIDEO_STREAM_REASON_CODEC_NOT_SUPPORT (5): The local video encoding fails. LOCAL_VIDEO_STREAM_REASON_DEVICE_NOT_FOUND (8): Fails to find a local video capture device. Remind the user to check whether the camera is connected to the device properly or the camera is working properly, and then to rejoin the channel. LOCAL_VIDEO_STREAM_REASON_DEVICE_INTERRUPT (14): Video capture is interrupted. Possible reasons include the following: The camera is being used by another app. Prompt the user to check if the camera is being used by another app. The device is locked, or the current app has been switched to the background. You can use foreground services to notify the operating system and ensure that the app can still collect video when it switches to the background. LOCAL_VIDEO_STREAM_REASON_DEVICE_FATAL_ERROR (15): The video capture device encounters an error. Prompt the user to close and restart the camera to restore functionality. If this operation does not solve the problem, check if the camera has a hardware failure. LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_FAILURE (21): The current window being captured has no data.

## ◆ onLocalVideoEvent()

void io.agora.rtc2.IRtcEngineEventHandler.onLocalVideoEvent | ( | Constants.VideoSourceType | source,
|  | int | event
| ) |  |

Occurs when the local video event occurs.

This callback is triggered when a video event occurs. You can use this callback to get the reason for such an event.

Parameters

  source | The type of the video source. See `VideoSourceType`.
  event | The local video event type. LOCAL_VIDEO_EVENT_TYPE_SCREEN_CAPTURE_WINDOW_HIDDEN (1): The screen capture window is hidden. LOCAL_VIDEO_EVENT_TYPE_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_HIDDEN (2): The screen capture window is recovered from hidden. LOCAL_VIDEO_EVENT_TYPE_SCREEN_CAPTURE_STOPPED_BY_USER (3): The screen capture is stopped by user. LOCAL_VIDEO_EVENT_TYPE_SCREEN_CAPTURE_SYSTEM_INTERNAL_ERROR (4): An internal error occurs during the screen capture.

## ◆ onRtmpStreamingStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onRtmpStreamingStateChanged | ( | String | url,
|  | int | state,
|  | int | reason
| ) |  |

Occurs when the state of Media Push changes.

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: RTMP_STREAM_PUBLISH_STATE_IDLE (0): The Media Push has not started or has ended. RTMP_STREAM_PUBLISH_STATE_CONNECTING (1): The streaming server and CDN server are being connected. RTMP_STREAM_PUBLISH_STATE_RUNNING (2): The Media Push publishes. The SDK successfully publishes the RTMP or RTMPS streaming and returns this state. RTMP_STREAM_PUBLISH_STATE_RECOVERING (3): The Media Push is recovering. When exceptions occur to the CDN, or the Media Push is interrupted, the SDK tries to resume the Media Push and returns this state. If the SDK successfully resumes the streaming, RTMP_STREAM_PUBLISH_STATE_RUNNING (2) returns. If the streaming does not resume within 60 seconds or server errors occur, RTMP_STREAM_PUBLISH_STATE_FAILURE (4) returns. You can also reconnect to the server by calling the `startRtmpStreamWithTranscoding` / `startRtmpStreamWithoutTranscoding` and `stopRtmpStream` methods. RTMP_STREAM_PUBLISH_STATE_FAILURE (4): The Media push fails. See the errCode parameter for the detailed error information.You can also try to publish streams again. RTMP_STREAM_PUBLISH_STATE_DISCONNECTING (5): The SDK is disconnecting from the Agora Media Push server and CDN server. When you call `stopRtmpStream` to stop the Media Push normally, the SDK reports the Media Push state as `RTMP_STREAM_PUBLISH_STATE_DISCONNECTING` and `RTMP_STREAM_PUBLISH_STATE_IDLE` in sequence.
  reason | Reasons for the changes in the Media Push status: RTMP_STREAM_PUBLISH_REASON_OK (0): The Media Push publishes successfully. RTMP_STREAM_PUBLISH_REASON_INVALID_ARGUMENT (1): Invalid argument used. Check the parameter setting. RTMP_STREAM_PUBLISH_REASON_ENCRYPTED_STREAM_NOT_ALLOWED (2): The Media Push is encrypted and cannot be published. RTMP_STREAM_PUBLISH_REASON_CONNECTION_TIMEOUT (3): Timeout for the Media Push. You can try to push the stream again. RTMP_STREAM_PUBLISH_REASON_INTERNAL_SERVER_ERROR (4): An error occurs in Agora streaming server. You can try to publish media streams again. RTMP_STREAM_PUBLISH_REASON_RTMP_SERVER_ERROR (5): An error occurs in the CDN server. RTMP_STREAM_PUBLISH_REASON_TOO_OFTEN (6): A reserved parameter. RTMP_STREAM_PUBLISH_REASON_REACH_LIMIT (7): The host publishes more than 10 URLs. You can stop publishing sreams to unnecessary URLs. RTMP_STREAM_PUBLISH_REASON_NOT_AUTHORIZED (8): The host manipulates other hosts' URLs. For example, the host updates or stops other hosts' streams. Check your app logic. RTMP_STREAM_PUBLISH_REASON_STREAM_NOT_FOUND (9): Agora's server fails to find the media stream of Media Push. RTMP_STREAM_PUBLISH_REASON_FORMAT_NOT_SUPPORTED (10): The format of the media push URL is not supported. Check whether the URL format is correct. RTMP_STREAM_PUBLISH_REASON_NOT_BROADCASTER (11): The user role is not host, so the user cannot use the Media Push function. Check your application code logic. RTMP_STREAM_PUBLISH_REASON_TRANSCODING_NO_MIX_STREAM (13): The `updateRtmpTranscoding` method is called to update the transcoding configuration in a scenario where there is Media Push without transcoding. Check your application code logic. RTMP_STREAM_PUBLISH_REASON_NET_DOWN (14): Errors occurred in the host's network. RTMP_STREAM_PUBLISH_REASON_INVALID_PRIVILEGE (16): Your project does not have permission to use Media Push service. RTMP_STREAM_UNPUBLISH_REASON_OK (100): The Media Push has been stopped normally. After you call `stopRtmpStream` to stop the Media Push, the SDK returns this value.

## ◆ onRtmpStreamingEvent()

void io.agora.rtc2.IRtcEngineEventHandler.onRtmpStreamingEvent | ( | String | url,
|  | int | event
| ) |  |

Reports events during the Media Push.

Since
  v3.1.0.

Parameters

  url | The URL for Media Push.
  event | The event code of Media Push. RTMP_STREAMING_EVENT_FAILED_LOAD_IMAGE (1): An error occurs when you add a background image or a watermark image in the Media Push. RTMP_STREAMING_EVENT_URL_ALREADY_IN_USE (2): The streaming URL is already being used for Media Push. If you want to start new streaming, use a new streaming URL. RTMP_STREAMING_EVENT_ADVANCED_FEATURE_NOT_SUPPORT (3): The feature is not supported. RTMP_STREAMING_EVENT_REQUEST_TOO_OFTEN (4): Reserved.

## ◆ onTranscodingUpdated()

void io.agora.rtc2.IRtcEngineEventHandler.onTranscodingUpdated | ( |  | ) |

Occurs when the publisher's transcoding is updated.

When the `LiveTranscoding` class in the `startRtmpStreamWithTranscoding` method updates, the SDK triggers the `onTranscodingUpdated` callback to report the update information.

Note
  If you call the `startRtmpStreamWithTranscoding` method to set the `LiveTranscoding` class for the first time, the SDK does not trigger this callback.

## ◆ onStreamMessage()

void io.agora.rtc2.IRtcEngineEventHandler.onStreamMessage | ( | int | uid,
|  | int | streamId,
|  | byte[] | data
| ) |  |

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

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

Note
  If you need a more comprehensive solution for low-latency, high-concurrency, and scalable real-time messaging and status synchronization, it is recommended to use `Signaling`.

Parameters

  uid | The ID of the remote user sending the message.
  streamId | The stream ID of the received message.
  data | The data received.

## ◆ onStreamMessageError()

void io.agora.rtc2.IRtcEngineEventHandler.onStreamMessageError | ( | int | uid,
|  | int | streamId,
|  | int | error,
|  | int | missed,
|  | int | cached
| ) |  |

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

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.

Note
  If you need a more comprehensive solution for low-latency, high-concurrency, and scalable real-time messaging and status synchronization, it is recommended to use `Signaling`.

Parameters

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

## ◆ onRdtMessage()

void io.agora.rtc2.IRtcEngineEventHandler.onRdtMessage | ( | int | uid,
|  | int | type,
|  | byte[] | data
| ) |  |

Occurs when the local user receives data via Reliable Data Transmission (RDT) from a remote user.

@technical preview

Parameters

  uid | ID of the user who sends the data.
  type | The RDT stream type
  data | The data received.

## ◆ onRdtStateChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onRdtStateChanged | ( | int | uid,
|  | int | state
| ) |  |

Occurs when the RDT tunnel state changed.

@technical preview

Parameters

  uid | ID of the user who sends the data.
  state | The RDT tunnel state

## ◆ onMediaControlMessage()

void io.agora.rtc2.IRtcEngineEventHandler.onMediaControlMessage | ( | int | uid,
|  | byte[] | data
| ) |  |

Occurs when the local user receives media control message sent by a remote user.

@technical preview

Parameters

  uid | ID of the user who sends the data.
  data | The data received.

## ◆ onMediaEngineLoadSuccess()

void io.agora.rtc2.IRtcEngineEventHandler.onMediaEngineLoadSuccess | ( |  | ) |

Occurs when the media engine is loaded.

## ◆ onMediaEngineStartCallSuccess()

void io.agora.rtc2.IRtcEngineEventHandler.onMediaEngineStartCallSuccess | ( |  | ) |

Occurs when the media engine starts.

## ◆ onNetworkTypeChanged()

void io.agora.rtc2.IRtcEngineEventHandler.onNetworkTypeChanged | ( | int | type | ) |

Occurs when the local network type changes.

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 | Network types: NETWORK_TYPE_UNKNOWN (-1): The network type is unknown. NETWORK_TYPE_DISCONNECTED (0): The SDK disconnects from the network. NETWORK_TYPE_LAN (1): The network type is LAN. NETWORK_TYPE_WIFI (2): The network type is Wi-Fi (including hotspots). NETWORK_TYPE_MOBILE_2G (3) : The network type is mobile 2G. NETWORK_TYPE_MOBILE_3G (4): The network type is mobile 3G. NETWORK_TYPE_MOBILE_4G (5): The network type is mobile 4G. NETWORK_TYPE_MOBILE_5G (6): The network type is mobile 5G.

## ◆ onIntraRequestReceived()

void io.agora.rtc2.IRtcEngineEventHandler.onIntraRequestReceived | ( |  | ) |

Occurs when intra request from remote user is received.

This callback is triggered once remote user needs one Key frame.

## ◆ onUplinkNetworkInfoUpdated()

void io.agora.rtc2.IRtcEngineEventHandler.onUplinkNetworkInfoUpdated | ( | UplinkNetworkInfo | info | ) |

Occurs when the uplink network information changes.

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

Note
  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 `UplinkNetworkInfo`.

## ◆ onEncryptionError()

void io.agora.rtc2.IRtcEngineEventHandler.onEncryptionError | ( | int | errorType | ) |

Reports the built-in encryption errors.

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 | Error types. ENCRYPTION_ERROR_INTERNAL_FAILURE (0): Internal reasons. ENCRYPTION_ERROR_DECRYPTION_FAILURE (1): Media stream decryption error. Ensure that the receiver and the sender use the same encryption mode and key. ENCRYPTION_ERROR_ENCRYPTION_FAILURE (2): Media stream encryption error. ENCRYPTION_ERROR_DATASTREAM_DECRYPTION_FAILURE (3): Data stream decryption error. Ensure that the receiver and the sender use the same encryption mode and key. ENCRYPTION_ERROR_DATASTREAM_ENCRYPTION_FAILURE (4): Data stream encryption error.

## ◆ onPermissionError()

void io.agora.rtc2.IRtcEngineEventHandler.onPermissionError | ( | int | permission | ) |

Occurs when the SDK cannot get the device permission.

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

Parameters

  permission | The type of the device permission. RECORD_AUDIO (0): Permission for the audio capture device. CAMERA (1): Permission for the camera. SCREEN_CAPTURE (2): Permission for screen sharing.

## ◆ onPermissionGranted()

void io.agora.rtc2.IRtcEngineEventHandler.onPermissionGranted | ( | int | permission | ) |

Reports the permission granted.

Parameters

  permission | of Constants.RECORD_AUDIO, Constants.CAMERA and {}

## ◆ onUploadLogResult()

void io.agora.rtc2.IRtcEngineEventHandler.onUploadLogResult | ( | String | requestId,
|  | boolean | success,
|  | int | reason
| ) |  |

Reports the user log upload result

Parameters

  requestId | RequestId of the upload
  success | Is upload success
  reason | Reason of the upload, 0: OK, 1 Network Error, 2 Server Error.

## ◆ onProxyConnected()

void io.agora.rtc2.IRtcEngineEventHandler.onProxyConnected | ( | String | channel,
|  | int | uid,
|  | int | proxyType,
|  | String | localProxyIp,
|  | int | elapsed
| ) |  |

Reports the proxy connection state.

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(String token, String channelId, int uid, ChannelMediaOptions options)` until this callback is triggered.

Parameters

  channel | The channel name.
  uid | The user ID.
  proxyType | The proxy type connected. PROXY_TYPE_NONE_PROXY (0): Reserved for future use. PROXY_TYPE_UDP_CLOUD_PROXY (1): The cloud proxy for the UDP protocol, that is, the Force UDP cloud proxy mode. In this mode, the SDK always transmits data over UDP. PROXY_TYPE_TCP_CLOUD_PROXY (2): The cloud proxy for the TCP (encryption) protocol, that is, the Force TCP cloud proxy mode. In this mode, the SDK always transmits data over TCP/TLS 443. PROXY_TYPE_LOCAL_PROXY (3): Reserved for future use. PROXY_TYPE_TCP_AUTO_FALLBACK (4): Automatic mode. In this mode, the SDK attempts a direct connection to SD-RTN™ and automatically switches to TCP/TLS 443 if the attempt fails.
  localProxyIp | Reserved for future use.
  elapsed | The time elapsed (ms) from the user calling `joinChannel(String token, String channelId, int uid, ChannelMediaOptions options)` until this callback is triggered.

## ◆ onVideoRenderingTracingResult()

void io.agora.rtc2.IRtcEngineEventHandler.onVideoRenderingTracingResult | ( | int | uid,
|  | Constants.MEDIA_TRACE_EVENT | currentEvent,
|  | VideoRenderingTracingInfo | tracingInfo
| ) |  |

Video frame rendering event callback.

After calling the `startMediaRenderingTracing` method or joining a channel, the SDK triggers this callback to report the events of video frame rendering and the indicators during the rendering process. Developers can optimize the indicators to improve the efficiency of the first video frame rendering.

Parameters

  uid | The user ID.
  currentEvent | The current video frame rendering event. See `MEDIA_TRACE_EVENT`.
  tracingInfo | The indicators during the video frame rendering process. Developers need to reduce the value of indicators as much as possible in order to improve the efficiency of the first video frame rendering. See `VideoRenderingTracingInfo`.

## ◆ onLocalVideoTranscoderError()

void io.agora.rtc2.IRtcEngineEventHandler.onLocalVideoTranscoderError | ( | LocalTranscoderConfiguration.TranscodingVideoStream | stream,
|  | int | error
| ) |  |

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

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 `TranscodingVideoStream`.
  error | The reason for local video mixing error.

## ◆ onTranscodedStreamLayoutInfo()

void io.agora.rtc2.IRtcEngineEventHandler.onTranscodedStreamLayoutInfo | ( | int | uid,
|  | VideoLayoutInfo | info
| ) |  |

Occurs when the local user receives a mixed video stream carrying layout information.

When the local user receives a mixed video stream sent by the video mixing server for the first time, or when there is a change in the layout information of the mixed stream, the SDK triggers this callback, reporting the layout information of each sub-video stream within the mixed video stream.

Parameters

  uid | User ID who published this mixed video stream.
  info | Layout information of a specific sub-video stream within the mixed stream. See . `VideoLayoutInfo`

## ◆ onAudioMetadataReceived()

void io.agora.rtc2.IRtcEngineEventHandler.onAudioMetadataReceived | ( | int | uid,
|  | byte[] | data
| ) |  |

Occurs when the SDK receives audio metadata.

Since
  v4.3.1

Parameters

  metadata | The pointer of metadata
  length | Size of metadata @technical preview

## ◆ onMultipathStats()

void io.agora.rtc2.IRtcEngineEventHandler.onMultipathStats | ( | MultipathStats | stats | ) |

Reports the multipath transmission statistics.

Postcondition
  This callback is triggered after you set `enableMultipath` to `true` to enable multipath transmission.

Since
  4.6.0

Parameters

  stats | The multipath statistics. See `MultipathStats`.

## ◆ onRenewTokenResult()

void io.agora.rtc2.IRtcEngineEventHandler.onRenewTokenResult | ( | String | token,
|  | Constants.RenewTokenErrorCode | code
| ) |  |

Callback for `renewToken` call result.

Since
  v4.6.0

This callback is triggered after the user calls the `renewToken` method to update the token, and is used to notify the app of the result.

Parameters

  token | Token used for authentication.
  code | Error code. See `RenewTokenErrorCode`.