Classes

class  AudioVolumeInfo
 
class  ClientRole
 
class  ErrorCode
 
class  LastmileProbeResult
 
class  LocalAudioStats
 
class  LocalVideoStats
 
class  Quality
 
class  RemoteAudioStats
 
class  RemoteVideoStats
 
class  RtcStats
 
class  UserOfflineReason
 
class  VideoProfile
 
class  WarnCode
 

Public Member Functions

void onWarning (int warn)
 
void onError (int err)
 
void onJoinChannelSuccess (String channel, int uid, int elapsed)
 
void onRejoinChannelSuccess (String channel, int uid, int elapsed)
 
void onLeaveChannel (RtcStats stats)
 
void onClientRoleChanged (int oldRole, int newRole)
 
void onLocalUserRegistered (int uid, String userAccount)
 
void onUserInfoUpdated (int uid, UserInfo userInfo)
 
void onUserJoined (int uid, int elapsed)
 
void onUserOffline (int uid, int reason)
 
void onConnectionStateChanged (int state, int reason)
 
void onConnectionInterrupted ()
 
void onConnectionLost ()
 
void onConnectionBanned ()
 
void onApiCallExecuted (int error, String api, String result)
 
void onTokenPrivilegeWillExpire (String token)
 
void onRequestToken ()
 
void onMicrophoneEnabled (boolean enabled)
 
void onAudioVolumeIndication (AudioVolumeInfo[] speakers, int totalVolume)
 
void onActiveSpeaker (int uid)
 
void onFirstLocalAudioFrame (int elapsed)
 
void onFirstRemoteAudioFrame (int uid, int elapsed)
 
void onVideoStopped ()
 
void onFirstLocalVideoFrame (int width, int height, int elapsed)
 
void onFirstRemoteVideoDecoded (int uid, int width, int height, int elapsed)
 
void onFirstRemoteVideoFrame (int uid, int width, int height, int elapsed)
 
void onUserMuteAudio (int uid, boolean muted)
 
void onUserMuteVideo (int uid, boolean muted)
 
void onUserEnableVideo (int uid, boolean enabled)
 
void onUserEnableLocalVideo (int uid, boolean enabled)
 
void onVideoSizeChanged (int uid, int width, int height, int rotation)
 
void onRemoteAudioStateChanged (int uid, int state, int reason, int elapsed)
 
void onRemoteVideoStateChanged (int uid, int state, int reason, int elapsed)
 
void onChannelMediaRelayStateChanged (int state, int code)
 
void onChannelMediaRelayEvent (int code)
 
void onLocalPublishFallbackToAudioOnly (boolean isFallbackOrRecover)
 
void onRemoteSubscribeFallbackToAudioOnly (int uid, boolean isFallbackOrRecover)
 
void onAudioRouteChanged (int routing)
 
void onCameraReady ()
 
void onCameraFocusAreaChanged (Rect rect)
 
void onCameraExposureAreaChanged (Rect rect)
 
void onAudioQuality (int uid, int quality, short delay, short lost)
 
void onRtcStats (RtcStats stats)
 
void onLastmileQuality (int quality)
 
void onLastmileProbeResult (LastmileProbeResult result)
 
void onNetworkQuality (int uid, int txQuality, int rxQuality)
 
void onLocalVideoStats (LocalVideoStats stats)
 
void onRemoteVideoStats (RemoteVideoStats stats)
 
void onLocalAudioStats (LocalAudioStats stats)
 
void onRemoteAudioStats (RemoteAudioStats stats)
 
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)
 
void onRemoteVideoTransportStats (int uid, int delay, int lost, int rxKBitRate)
 
void onAudioMixingStateChanged (int state, int errorCode)
 
void onAudioMixingFinished ()
 
void onAudioEffectFinished (int soundId)
 
void onFirstRemoteAudioDecoded (int uid, int elapsed)
 
void onLocalAudioStateChanged (int state, int error)
 
void onLocalVideoStateChanged (int localVideoState, int error)
 
void onRtmpStreamingStateChanged (String url, int state, int errCode)
 
void onStreamPublished (String url, int error)
 
void onStreamUnpublished (String url)
 
void onTranscodingUpdated ()
 
void onStreamInjectedStatus (String url, int uid, int status)
 
void onStreamMessage (int uid, int streamId, byte[] data)
 
void onStreamMessageError (int uid, int streamId, int error, int missed, int cached)
 
void onMediaEngineLoadSuccess ()
 
void onMediaEngineStartCallSuccess ()
 
void onNetworkTypeChanged (int type)
 

Detailed Description

Callbacks.

The SDK uses the IRtcEngineEventHandler interface class to send callbacks to the application, and the application inherits the methods of this interface class to retrieve these callbacks. 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 callbacks, the application should avoid time-consuming tasks or call blocking APIs (such as SendMessage), otherwise, the SDK may not work properly.

Member Function Documentation

◆ onWarning()

void io.agora.rtc.IRtcEngineEventHandler.onWarning ( int  warn)

Reports a warning during SDK runtime.

In most cases, the app can ignore the warning reported by the SDK because the SDK can usually fix the issue and resume running.

For instance, the SDK may report a WARN_LOOKUP_CHANNEL_TIMEOUT warning upon disconnection with the server and tries to reconnect. For detailed warning codes, see Warning Codes.

Parameters
warnWarning code

◆ onError()

void io.agora.rtc.IRtcEngineEventHandler.onError ( int  err)

Reports an error 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.

For example, the SDK reports an ERR_START_CALL error when failing to initialize a call. The app informs the user that the call initialization failed and invokes the leaveChannel method to leave the channel. For detailed error codes, see Error Codes.

Parameters
errError code

◆ onJoinChannelSuccess()

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

Occurs when the local user joins a specified channel.

The channel name assignment is based on channelName specified in the joinChannel method.

If the uid is not specified when joinChannel is called, the server automatically assigns a uid.

Parameters
channelChannel name.
uidUser ID.
elapsedTime elapsed (ms) from the user calling joinChannel until this callback is triggered.

◆ onRejoinChannelSuccess()

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

Occurs when a user rejoins the channel after being disconnected due to network problems.

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
channelChannel name.
uidUser ID.
elapsedTime elapsed (ms) from starting to reconnect until this callback is triggered.

◆ onLeaveChannel()

void io.agora.rtc.IRtcEngineEventHandler.onLeaveChannel ( RtcStats  stats)

Occurs when a user leaves the channel.

When the app calls the leaveChannel method, the SDK uses this callback to notify the app when the user leaves the channel.

With this callback, the application retrieves the channel information, such as the call duration and statistics.

Parameters
statsStatistics of the call: RtcStats

◆ onClientRoleChanged()

void io.agora.rtc.IRtcEngineEventHandler.onClientRoleChanged ( int  oldRole,
int  newRole 
)

Occurs when the user role switches in a live broadcast. For example, from a host to an audience or vice versa.

The SDK triggers this callback when the local user switches the user role by calling the setClientRole method after joining the channel.

Parameters
oldRoleRole that the user switches from.
newRoleRole that the user switches to.

◆ onLocalUserRegistered()

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

Occurs when the local user registers a user account.

Since
v2.8.0.

This callback is triggered when the local user successfully registers a user account by calling the registerLocalUserAccount method, or joins a channel by calling the joinChannelWithUserAccount method. This callback reports the user ID and user account of the local user.

Parameters
uidThe ID of the local user.
userAccountThe user account of the local user.

◆ onUserInfoUpdated()

void io.agora.rtc.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 (UserInfo), and triggers this callback on the local client.

Parameters
uidThe ID of the remote user.
userInfoThe UserInfo object that contains the user ID and user account of the remote user.

◆ onUserJoined()

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

Occurs when a remote user (Communication)/host (Live Broadcast) joins the channel.

  • Communication profile: This callback notifies the app when another user joins the channel. If other users are already in the channel, the SDK also reports to the app on the existing users.
  • Live Broadcast profile: This callback notifies the app when the host joins the channel. If other hosts are already in the channel, the SDK also reports to the app on the existing hosts. We recommend having at most 17 hosts in a channel

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

  • A remote user/host joins the channel by calling the joinChannel method.
  • A remote user switches the user role to the host by calling the setClientRole method after joining the channel.
  • A remote user/host rejoins the channel after a network interruption.
  • The host injects an online media stream into the channel by calling the addInjectStreamUrl method.
Parameters
uidID of the user or host who joins the channel.
elapsedTime delay (ms) from the local user calling joinChannel/setClientRole until this callback is triggered.
Note
In the Live Broadcast profile:
  • The host receives the onUserJoined callback when another host joins the channel.
  • The audience in the channel receives the onUserJoined callback when a new host joins the channel.
  • When a web application joins the channel, the onUserJoined callback is triggered as long as the web application publishes streams.

◆ onUserOffline()

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

Occurs when a remote user (Communication)/host (Live Broadcast) leaves the channel.

There are two reasons for users to become offline:

  • Leave the channel: When the user/host leaves the channel, the user/host sends a goodbye message. When this message is received, the SDK determines that the user/host leaves the channel.
  • Drop offline: When no data packet of the user or host is received for a certain period of time (20 seconds for the communication profile, and more for the live broadcast profile), the SDK assumes that the user/host drops offline. A poor network connection may lead to false detections, so we recommend using the signaling system for reliable offline detection.
Parameters
uidID of the user or host who leaves the channel or goes offline.
reasonReason why the user goes offline:
  • USER_OFFLINE_QUIT(0): The user left the current channel.
  • USER_OFFLINE_DROPPED(1): The SDK timed out and the user dropped offline because no data packet was received within a certain period of time. If a user quits the call and the message is not passed to the SDK (due to an unreliable channel), the SDK assumes the user dropped offline.
  • USER_OFFLINE_BECOME_AUDIENCE(2): (Live broadcast only.) The client role switched from the host to the audience.

◆ onConnectionStateChanged()

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

Occurs when the network connection state changes.

Since
v2.3.2.

The Agora SDK returns this callback to report on the current network connection state when it changes, and the reason to such change.

Parameters
stateThe current network connection state:
reasonThe reason causing the change of the connection state:

◆ onConnectionInterrupted()

void io.agora.rtc.IRtcEngineEventHandler.onConnectionInterrupted ( )

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

Deprecated:
From v2.3.2. Use onConnectionStateChanged instead.

The SDK triggers this callback when it loses connection to 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. This callback is different from onConnectionLost:

  • The SDK triggers the onConnectionInterrupted callback when the SDK loses connection with the server for more than four seconds after it joins the channel.
  • The SDK triggers the onConnectionLost callback when it loses connection with the server for more than 10 seconds, regardless of whether it joins the channel or not.

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.rtc.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 joinChannel(), regardless of whether it is in the channel or not.

This callback is different from onConnectionInterrupted:

  • The SDK triggers the onConnectionInterrupted callback when the SDK loses connection with the server for more than four seconds after it joins the channel.
  • The SDK triggers the onConnectionLost callback when the SDK loses connection with the server for more than 10 seconds, regardless of whether it joins the channel or not.

If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora's edge server, the SDK stops rejoining the channel.

◆ onConnectionBanned()

void io.agora.rtc.IRtcEngineEventHandler.onConnectionBanned ( )

Occurs when your connection is banned by the Agora Server.

Deprecated:
From v2.3.2. Use onConnectionStateChanged instead.

◆ onApiCallExecuted()

void io.agora.rtc.IRtcEngineEventHandler.onApiCallExecuted ( int  error,
String  api,
String  result 
)

Occurs when an API method is executed.

Parameters
errorError Code that the SDK returns when the method call fails. If the SDK returns 0, then the method call was successful.
apiThe method executed by the SDK.
resultThe result of the method call.

◆ onTokenPrivilegeWillExpire()

void io.agora.rtc.IRtcEngineEventHandler.onTokenPrivilegeWillExpire ( String  token)

Occurs when the token expires in 30 seconds.

The user becomes offline if the token used in joinChannel expires. This callback is triggered 30 seconds before the token expires to remind the app to get a new token. Upon receiving this callback, you need to generate a new token on the server and call renewToken to pass the new token to the SDK.

Parameters
tokenThe token that expires in 30 seconds.

◆ onRequestToken()

void io.agora.rtc.IRtcEngineEventHandler.onRequestToken ( )

Occurs when the token expires.

After a token is specified by calling joinChannel, if the SDK losses connection with the Agora server due to network issues, the token may expire after a certain period of time and a new token may be required to reconnect to the server. This callback notifies the app to generate a new token. Call renewToken to renew the token.

◆ onMicrophoneEnabled()

void io.agora.rtc.IRtcEngineEventHandler.onMicrophoneEnabled ( boolean  enabled)

Occurs when the microphone is enabled/disabled.

Deprecated:
This callback is deprecated. Use LOCAL_AUDIO_STREAM_STATE_STOPPED(0) or LOCAL_AUDIO_STREAM_STATE_RECORDING(1) in the onLocalAudioStateChanged callback instead.

The SDK triggers this callback when the local user resumes or stops capturing the local audio stream by calling the enableLocalAudio method.

Parameters
enabledWhether the microphone is enabled/disabled:
  • true: Enabled.
  • false: Disabled.

◆ onAudioVolumeIndication()

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

Reports which users are speaking and the speakers' volume, and whether the local user is speaking.

This callback reports the IDs and volumes of the loudest speakers at the moment in the channel, and whether the local user is speaking.

By default, this callback is diabled. You can enable it by calling the enableAudioVolumeIndication method. Once enabled, this callback is triggered at the set interval, regardless of whether a user speaks or not.

The SDK triggers two independent onAudioVolumeIndication callbacks at one time, which seperately report the volume information of the local user and all the remote speakers. For more information, see the detailed parameter descriptions.

Note
  • To enable the voice activity detection of the local user, ensure that you set report_vad(true) in the enableAudioVolumeIndication method.
  • Calling the muteLocalAudioStream method affects the SDK's behavior.
    • If the local user calls the muteLocalAudioStream method, the SDK stops triggering the local user's callback.
    • 20 seconds after a remote speaker calls the muteLocalAudioStream method, the remote speakers' callback does not include information of this remote user; 20 seconds after all remote users call the the muteLocalAudioStream method, the SDK stops triggering the remote speakers' callback.
Parameters
speakersAn array containing the user ID and volume information for each speaker: AudioVolumeInfo.
  • In the local user’s callback, this array contains the following members:
    • uid = 0,
    • volume = totalVolume, which reports the sum of the voice volume and audio-mixing volume of the local user, and
    • vad, which reports the voice activity status of the local user.
  • In the remote speakers' callbaßck, this array contains the following members:

    • uid of each remote speaker,
    • volume, which reports the sum of the voice volume and audio-mixing volume of each remote speaker, and
    • vad = 0.

    An empty speakers array in the callback indicates that no remote user is speaking at the moment.

totalVolumeTotal volume after audio mixing. The value ranges between 0 (lowest volume) and 255 (highest volume).
  • In the local user’s callback, totalVolume is the sum of the voice volume and audio-mixing volume of the local user.
  • In the remote speakers' callback, totalVolume is the sum of the voice volume and audio-mixing volume of all remote speakers.

◆ onActiveSpeaker()

void io.agora.rtc.IRtcEngineEventHandler.onActiveSpeaker ( int  uid)

Reports which user is the loudest speaker.

This callback reports the speaker with the highest accumulative volume during a certain period. If the user enables the audio volume indication by calling enableAudioVolumeIndication, this callback returns the uid of the active speaker whose voice is detected by the audio volume detection module of the SDK.

Parameters
uidUser ID of the active speaker. A uid of 0 represents the local user.
Note
  • To receive this callback, you need to call enableAudioVolumeIndication.
  • This callback returns the user ID of the user with the highest voice volume during a period of time, instead of at the moment.

◆ onFirstLocalAudioFrame()

void io.agora.rtc.IRtcEngineEventHandler.onFirstLocalAudioFrame ( int  elapsed)

Occurs when the first local audio frame is sent.

Parameters
elapsedTime elapsed (ms) from the local user calling the joinChannel until this callback is triggered.

◆ onFirstRemoteAudioFrame()

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

Occurs when the first remote audio frame is received.

Parameters
uidUser ID of the remote user.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until this callback is triggered.

◆ onVideoStopped()

void io.agora.rtc.IRtcEngineEventHandler.onVideoStopped ( )

Occurs when the video stops playing.

Deprecated:
From v2.4.1. Use LOCAL_VIDEO_STREAM_STATE_STOPPED(0) in the onLocalVideoStateChanged callback instead. The application can use this callback to change the configuration of the view (for example, displaying other pictures in the view) after the video stops playing.

◆ onFirstLocalVideoFrame()

void io.agora.rtc.IRtcEngineEventHandler.onFirstLocalVideoFrame ( int  width,
int  height,
int  elapsed 
)

Occurs when the first local video frame is rendered.

This callback is triggered after the first local video frame is rendered on the local video window.

Parameters
widthWidth (pixels) of the first local video frame.
heightHeight (pixels) of the first local video frame.
elapsedTime elapsed (ms) from the local user calling joinChannel until this callback is triggered. If startPreview is called before joinChannel, elapsed is the time elapsed (ms) from the local user calling startPreview until this callback is triggered.

◆ onFirstRemoteVideoDecoded()

void io.agora.rtc.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.

This callback is triggered in either of the following scenarios:

  • 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. Possible reasons include:
    • The remote user leaves channel.
    • The remote user drops offline.
    • The remote user calls the muteLocalVideoStream method.
    • The remote user calls the disableVideo method.
Parameters
uidUser ID of the remote user sending the video streams.
widthWidth (pixels) of the video stream.
heightHeight (pixels) of the video stream.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until this callback is triggered.

◆ onFirstRemoteVideoFrame()

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

Occurs when the first remote video frame is rendered.

This callback is triggered after the first frame of the remote video is rendered on the video window. The application can retrieve the data of the time elapsed from the user joining the channel until the first video frame is displayed.

Parameters
uidUser ID of the remote user sending the video streams.
widthWidth (pixels) of the video stream.
heightHeight (pixels) of the video stream.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until this callback is triggered.

◆ onUserMuteAudio()

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

Occurs when a remote user 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 is invalid when the number of users or broadcasters in the channel exceeds 20.
Parameters
uidID of the remote user.
mutedWhether the remote user's audio stream is muted/unmuted:
  • true: Muted.
  • false: Unmuted.

◆ onUserMuteVideo()

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

Occurs when a remote user stops/resumes sending the video stream.

The SDK triggers this callback when the remote user stops or resumes sending the video stream by calling the muteLocalVideoStream method. You can also use the onRemoteVideoStateChanged callback with the following parameters for the same function:

  • 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).
Note
This callback is invalid when the number of users or broadcasters in the channel exceeds 20.
Parameters
uidID of the remote user.
mutedWhether the remote user's video stream playback pauses/resumes:
  • true: Pause.
  • false: Resume.

◆ onUserEnableVideo()

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

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

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).

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

The SDK triggers this callback when the remote user enables or disables the video module by calling the enableVideo or disableVideo method.

Note
This callback is invalid when the number of users or broadcasters in the channel exceeds 20.
Parameters
uidUser ID of the remote user.
enabledWhether the specific remote user enables/disables the video module:
  • true: Enable. The remote user can enter a video session.
  • false: Disable. The remote user can only enter a voice session, and cannot send or receive any video stream.

◆ onUserEnableLocalVideo()

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

Occurs when a remote user enables/disables the local video capture 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.

This callback is only applicable to the scenario when the remote user only wants to watch the remote video without sending any video stream to the other user.

Parameters
uidUser ID of the remote user.
enabledWhether the specific remote user enables/disables the local video capturing function:
  • true: Enabled. Other users in the channel can see the video of this remote user.
  • false: 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.rtc.IRtcEngineEventHandler.onVideoSizeChanged ( int  uid,
int  width,
int  height,
int  rotation 
)

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

Parameters
uidUser ID of the remote user or local user (0) whose video size or rotation changes.
widthNew width (pixels) of the video.
heightNew height (pixels) of the video.
rotationNew rotation of the video [0 to 360).

◆ onRemoteAudioStateChanged()

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

Occurs when the remote audio state changes.

Since
v2.9.0.

This callback indicates the state change of the remote audio stream.

Parameters
uidID of the user whose audio state changes.
stateState of the remote audio:
  • REMOTE_AUDIO_STATE_STOPPED(0): The remote audio is in the default state, probably due to REMOTE_AUDIO_REASON_LOCAL_MUTED(3), REMOTE_AUDIO_REASON_REMOTE_MUTED(5), or REMOTE_AUDIO_REASON_REMOTE_OFFLINE(7).
  • 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, probably due to REMOTE_AUDIO_REASON_NETWORK_RECOVERY(2), REMOTE_AUDIO_REASON_LOCAL_UNMUTED(4) or REMOTE_AUDIO_REASON_REMOTE_UNMUTED(6).
  • REMOTE_AUDIO_STATE_FROZEN(3): The remote audio is frozen, probably due to REMOTE_AUDIO_REASON_NETWORK_CONGESTION(1).
  • REMOTE_AUDIO_STATE_FAILED(4): The remote audio fails to start, probably due to REMOTE_AUDIO_REASON_INTERNAL(0).
reasonThe reason of the remote audio state change.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

◆ onRemoteVideoStateChanged()

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

Occurs when the remote video state changes.

Since
v2.9.0.
Parameters
uidID of the remote user whose video state changes.
stateState of the remote video:
  • REMOTE_VIDEO_STATE_STOPPED(0): The remote video is in the default state, probably due to 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, probably due to 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, probably due to 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, probably due to REMOTE_VIDEO_STATE_REASON_INTERNAL(0).
reasonThe reason of the remote video state change:
elapsedTime elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

◆ onChannelMediaRelayStateChanged()

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

Occurs when the state of the media stream relay changes.

Since
v2.9.0.

The SDK reports the state of the current media relay and possible error messages in this callback.

Parameters
stateThe state code:
codeThe error code:

◆ onChannelMediaRelayEvent()

void io.agora.rtc.IRtcEngineEventHandler.onChannelMediaRelayEvent ( int  code)

Reports events during the media stream relay.

Since
v2.9.0.
Parameters
codeThe event code for media stream relay:

◆ onLocalPublishFallbackToAudioOnly()

void io.agora.rtc.IRtcEngineEventHandler.onLocalPublishFallbackToAudioOnly ( boolean  isFallbackOrRecover)

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

If you call setLocalPublishFallbackOption and set option as STREAM_FALLBACK_OPTION_AUDIO_ONLY(2), this callback is triggered when the locally published stream falls back to audio-only mode due to poor uplink conditions, or when the audio stream switches back to the video after the uplink network condition improves.

Parameters
isFallbackOrRecoverWhether the locally published stream fell back to audio-only or switched back to the video:
  • true: The locally published stream fell back to audio-only due to poor network conditions.
  • false: The locally published stream switched back to the video after the network conditions improved.

◆ onRemoteSubscribeFallbackToAudioOnly()

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

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

If you call setRemoteSubscribeFallbackOption and set option as STREAM_FALLBACK_OPTION_AUDIO_ONLY(2), this callback is triggered when the remotely subscribed media stream falls back to audio-only mode due to poor uplink conditions, or when the remotely subscribed media stream switches back to the video after the uplink network condition improves.

Parameters
uidID of the remote user sending the stream.
isFallbackOrRecoverWhether the remote media stream fell back to audio-only or switched back to the video:
  • true: The remote media stream fell back to audio-only due to poor network conditions.
  • false: The remote media stream switched back to the video stream after the network conditions improved.
Note
Once the remote media stream is switched to the low stream due to poor network conditions, you can monitor the stream switch between a high and low stream in the onRemoteVideoStats callback.

◆ onAudioRouteChanged()

void io.agora.rtc.IRtcEngineEventHandler.onAudioRouteChanged ( int  routing)

Occurs when the local audio pkayout route changes.

This callback returns that the audio route switched to an earpiece, speakerphone, headset, or Bluetooth device.

The definition of the routing is listed as follows:

◆ onCameraReady()

void io.agora.rtc.IRtcEngineEventHandler.onCameraReady ( )

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

Deprecated:
From v2.4.1. Use LOCAL_VIDEO_STREAM_STATE_CAPTURING(1) in the onLocalVideoStateChanged callback instead. If the camera fails to turn on, fix the error reported in the onError callback.

◆ onCameraFocusAreaChanged()

void io.agora.rtc.IRtcEngineEventHandler.onCameraFocusAreaChanged ( Rect  rect)

Occurs when the camera focus area is changed.

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

Parameters
rectRectangular area in the camera zoom specifying the focus area.

◆ onCameraExposureAreaChanged()

void io.agora.rtc.IRtcEngineEventHandler.onCameraExposureAreaChanged ( Rect  rect)

The camera exposure area has changed.

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

Since
v2.3.2.
Parameters
rectRectangular area in the camera zoom specifying the exposure area.

◆ onAudioQuality()

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

Reports the statistics of the audio stream from each remote user/host.

Deprecated:
From v2.3.2. Use onRemoteAudioStats instead.

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

Parameters
uidUser ID of the speaker.
qualityAudio quality of the user:
delayTime delay (ms) of the audio packet from the sender to the receiver, including the time delay from audio sampling pre-processing, transmission, and the jitter buffer.
lostPacket loss rate (%) of the audio packet sent from the sender to the receiver.

◆ onRtcStats()

void io.agora.rtc.IRtcEngineEventHandler.onRtcStats ( RtcStats  stats)

Reports the statistics of the RtcEngine once every two seconds.

Parameters
statsRTC engine statistics: RtcStats

◆ onLastmileQuality()

void io.agora.rtc.IRtcEngineEventHandler.onLastmileQuality ( int  quality)

Reports the last mile network quality of the local user once every two seconds before the user joins the channel. Last mile refers to the connection between the local device and Agora's edge server. After the application calls the enableLastmileTest method, this callback reports once every two seconds the uplink and downlink last mile network conditions of the local user before the user joins the channel.

Parameters
qualityThe last mile network quality based on the uplink and dowlink packet loss rate and jitter:

◆ onLastmileProbeResult()

void io.agora.rtc.IRtcEngineEventHandler.onLastmileProbeResult ( LastmileProbeResult  result)

Reports the last-mile network probe result.

Since
v2.4.0.

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

Parameters
resultThe uplink and downlink last-mile network probe test result. For details, see LastmileProbeResult.

◆ onNetworkQuality()

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

Reports the last mile network quality of each user in the channel once every two seconds.

Last mile refers to the connection between the local device and Agora's edge server. This callback reports once every two seconds the last mile network conditions of each user in the channel. If a channel includes multiple users, then this callback will be triggered as many times.

Parameters
uidUser ID. The network quality of the user with this uid is reported. If uid is 0, the local network quality is reported.
txQualityUplink transmission quality of the user in terms of the transmission bitrate, packet loss rate, average RTT (Round-Trip Time) and jitter of the uplink network. txQuality is a quality rating helping you understand how well the current uplink network conditions can support the selected VideoEncoderConfiguration. For example, a 1000 Kbps uplink network may be adequate for video frames with a resolution of 680 × 480 and a frame rate of 30 fps, but may be inadequate for resolutions higher than 1280 × 720.
rxQualityDownlink network quality rating of the user in terms of packet loss rate, average RTT, and jitter of the downlink network.

◆ onLocalVideoStats()

void io.agora.rtc.IRtcEngineEventHandler.onLocalVideoStats ( LocalVideoStats  stats)

Reports the statistics of the local video streams.

The SDK triggers this callback once every two seconds for each user/host. If there are multiple users/hosts in the channel, the SDK triggers this callback as many times.

Parameters
statsThe statistics of the local video stream. See LocalVideoStats.

◆ onRemoteVideoStats()

void io.agora.rtc.IRtcEngineEventHandler.onRemoteVideoStats ( RemoteVideoStats  stats)

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

Parameters
statsStatistics of the received remote video streams: RemoteVideoStats.

◆ onLocalAudioStats()

void io.agora.rtc.IRtcEngineEventHandler.onLocalAudioStats ( LocalAudioStats  stats)

Reports the statistics of the local audio stream.

Since
v2.9.0. The SDK triggers this callback once every two seconds.
Parameters
statsThe statistics of the local audio stream. See LocalAudioStats.

◆ onRemoteAudioStats()

void io.agora.rtc.IRtcEngineEventHandler.onRemoteAudioStats ( RemoteAudioStats  stats)

Reports the statistics of the audio stream from each remote user/host.

Since
v2.3.2. This method replaces the onAudioQuality callback.

The SDK triggers this callback once every two seconds for each remote user/host. If a channel includes multiple remote users, the SDK triggers this callback as many times.

Schemes such as FEC (Forward Error Correction) or retransmission counter the frame loss rate. Hence, users may find the overall audio quality acceptable even when the packet loss rate is high.

Parameters
statsStatistics of the received remote audio streams: RemoteAudioStats.

◆ onLocalVideoStat()

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

Reports the statistics of the uploading local video streams.

Deprecated:
This method is deprecated. We recommend using onLocalVideoStats to get the local video statistics.
Parameters
sentBitrateData transmission bitrate (Kbps) since last count.
sentFrameRateData transmission frame rate (fps) since last count.

◆ onRemoteVideoStat()

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

Reports the statistics of the video stream from each remote user/host.

Deprecated:
This method is deprecated. We recommend using onRemoteVideoStats to get the remote video statistics.
Parameters
uidUser ID of the remote user sending the video streams.
delayTime delay (ms).
receivedBitrateData receiving bitrate (Kbps).
receivedFrameRateData receiving frame rate (fps).

◆ onRemoteAudioTransportStats()

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

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

Deprecated:
This callback is deprecated. Use onRemoteAudioStats instead.

This callback reports the transport-layer statistics, such as the packet loss rate and time delay, once every two seconds after the local user receives an audio packet from a remote user.

Parameters
uidUser ID of the remote user sending the audio packet.
delayNetwork time delay (ms) from the remote user sending the audio packet to the local user.
lostPacket loss rate (%) of the audio packet sent from the remote user.
rxKBitRateReceived bitrate (Kbps) of the audio packet sent from the remote user.

◆ onRemoteVideoTransportStats()

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

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

Deprecated:
This callback is deprecated. Use onRemoteVideoStats instead.

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

Parameters
uidUser ID of the remote user sending the video packet.
delayNetwork time delay (ms) from the remote user sending the video packet to the local user.
lostPacket loss rate (%) of the video packet sent from the remote user.
rxKBitRateReceived bitrate (Kbps) of the video packet sent from the remote user.

◆ onAudioMixingStateChanged()

void io.agora.rtc.IRtcEngineEventHandler.onAudioMixingStateChanged ( int  state,
int  errorCode 
)

Occurs when the state of the local user's audio mixing file changes.

Since
v2.4.0. When you call the startAudioMixing method and the state of audio mixing file changes, the Agora SDK triggers this callback.
  • When the audio mixing file plays, pauses playing, or stops playing, this callback returns 710, 711, or 713 in state, and 0 in errorCode.
  • When exceptions occur during playback, this callback returns 714 in state and an error in errorCode.
  • If the local audio mixing file does not exist, or if the SDK does not support the file format or cannot access the music file URL, the SDK returns WARN_AUDIO_MIXING_OPEN_ERROR = 701.
Parameters
stateThe state code:
errorCodeThe error code:

◆ onAudioMixingFinished()

void io.agora.rtc.IRtcEngineEventHandler.onAudioMixingFinished ( )

Occurs when the audio mixing file playback finishes.

Deprecated:
This callback is deprecated. Use onAudioMixingStateChanged instead.

You can start an audio mixing file playback by calling the startAudioMixing method. This callback is triggered when the audio mixing file playback finishes.

If the startAudioMixing method call fails, an WARN_AUDIO_MIXING_OPEN_ERROR warning returns in the onWarning callback.

◆ onAudioEffectFinished()

void io.agora.rtc.IRtcEngineEventHandler.onAudioEffectFinished ( int  soundId)

Occurs when the audio effect file playback finishes.

You can start a local audio effect playback by calling the playEffect method. This callback is triggered when the local audio effect file playback finishes.

Parameters
soundIdID of the local audio effect. Each local audio effect has a unique ID.

◆ onFirstRemoteAudioDecoded()

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

Occurs when the engine receives the first audio frame from a specified remote user.

Since
v2.4.1.

This callback is triggered in either of the following scenarios:

  • The remote user joins the channel and sends the audio stream.
  • The remote user stops sending the audio stream and re-sends it after 15 seconds. Possible reasons include:
    • The remote user leaves channel.
    • The remote user drops offline.
    • The remote user calls the muteLocalAudioStream method.
    • The remote user calls the disableAudio method.
Parameters
uidUser ID of the remote user sending the audio stream.
elapsedThe time elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

◆ onLocalAudioStateChanged()

void io.agora.rtc.IRtcEngineEventHandler.onLocalAudioStateChanged ( int  state,
int  error 
)

Occurs when the local audio stream state changes.

Since
v2.9.0.

This callback indicates the state change of the local audio stream, including the state of the audio recording and encoding, and allows you to troubleshoot issues when exceptions occur.

Note
When the state is LOCAL_AUDIO_STREAM_STATE_FAILED(3), see the error parameter for details.
Parameters
stateState of the local audio:
errorThe error information of the local audio:

◆ onLocalVideoStateChanged()

void io.agora.rtc.IRtcEngineEventHandler.onLocalVideoStateChanged ( int  localVideoState,
int  error 
)

Occurs when the local video state changes.

Since
v2.4.1.

The SDK returns the current video state in this callback. When the state is LOCAL_VIDEO_STREAM_STATE_FAILED(3), see the error parameter for details.

Parameters
localVideoStateThe local video state:
errorThe detailed error information of the local video:

◆ onRtmpStreamingStateChanged()

void io.agora.rtc.IRtcEngineEventHandler.onRtmpStreamingStateChanged ( String  url,
int  state,
int  errCode 
)

Occurs when the state of the RTMP streaming changes.

Since
v2.4.1. The SDK triggers this callback to report the result of the local user calling the addPublishStreamUrl or removePublishStreamUrl method. This callback returns the URL and its current streaming state. When the streaming state is RTMP_STREAM_PUBLISH_STATE_FAILURE(4), see the errCode parameter for details.

This callback indicates the state of the RTMP streaming. When exceptions occur, you can troubleshoot issues by referring to the detailed error descriptions in the errCode parameter.

Parameters
urlThe RTMP URL address.
stateThe RTMP streaming state:
errCodeThe detailed error information for streaming:

◆ onStreamPublished()

void io.agora.rtc.IRtcEngineEventHandler.onStreamPublished ( String  url,
int  error 
)

Reports the result of calling the addPublishStreamUrl method.

This callback indicates whether you have successfully added an RTMP stream to the CDN.

Parameters
urlThe RTMP URL address.
errorThe detailed error information:

◆ onStreamUnpublished()

void io.agora.rtc.IRtcEngineEventHandler.onStreamUnpublished ( String  url)

Reports the result of calling the removePublishStreamUrl method.

This callback indicates whether you have successfully removed an RTMP stream from the CDN.

Parameters
urlThe RTMP URL address.

◆ onTranscodingUpdated()

void io.agora.rtc.IRtcEngineEventHandler.onTranscodingUpdated ( )

Occurs when the publisher's transcoding settings are updated.

When the LiveTranscoding class in the setLiveTranscoding method updates, the SDK triggers this callback to report the update information.

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

◆ onStreamInjectedStatus()

void io.agora.rtc.IRtcEngineEventHandler.onStreamInjectedStatus ( String  url,
int  uid,
int  status 
)

Reports the status of injecting the online media stream.

Parameters
urlThe URL address of the externally injected stream.
uidUser ID.
statusState of the externally injected stream:

◆ onStreamMessage()

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

Occurs when the local user receives a remote data stream within five seconds.

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

Parameters
uidUser ID of the remote user sending the data stream.
streamIdStream ID.
dataData received by the local user.

◆ onStreamMessageError()

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

Occurs when the local user fails to receive a remote data stream.

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

Parameters
uidUser ID of the remote user sending the data stream.
streamIdStream ID.
errorError code.
missedThe number of lost messages.
cachedThe number of incoming cached messages when the data stream is interrupted.

◆ onMediaEngineLoadSuccess()

void io.agora.rtc.IRtcEngineEventHandler.onMediaEngineLoadSuccess ( )

Occurs when the media engine is loaded.

◆ onMediaEngineStartCallSuccess()

void io.agora.rtc.IRtcEngineEventHandler.onMediaEngineStartCallSuccess ( )

Occurs when the media engine starts.

◆ onNetworkTypeChanged()

void io.agora.rtc.IRtcEngineEventHandler.onNetworkTypeChanged ( int  type)

Occurs when the network type changes.

Since
v2.4.1.

The SDK returns the current network type 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
typeThe network type: