Package io.agora.rtc2

Class IRtcEngineEventHandler

java.lang.Object
io.agora.rtc2.IRtcEngineEventHandler

public abstract class IRtcEngineEventHandler extends Object

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.

  • Constructor Details

    • IRtcEngineEventHandler

      public IRtcEngineEventHandler()
  • Method Details

    • onError

      public void onError(int err)

      An error occurred during SDK runtime.

      In most cases, reporting an error means that the SDK cannot fix the issue and resume running, and therefore requires actions from the application or simply informs the user about the issue. In this case, the application informs the user that the call initialization has failed, and calls the leaveChannel method to exit the channel.

      Parameters:
      err - Error code
    • onJoinChannelSuccess

      public void onJoinChannelSuccess(String channel, int uid, int elapsed)
      Occurs when the local user successfully joins the specified channel.
      Parameters:
      channel - The channel name.
      uid - The user ID. - If you specified a `uid` in the `joinChannel` method, the SDK returns the specified ID; - If not, this callback returns an ID that is automatically assigned by the Agora server.
      elapsed - The time elapsed (ms) from the local user calling joinChannel until this event occurs.
    • onRejoinChannelSuccess

      public void onRejoinChannelSuccess(String channel, int uid, int elapsed)
      Occurs when the local user rejoins the channel after being disconnected due to network problems. When the app loses connection with the server because of network problems, the SDK automatically tries to reconnect to the server, and triggers this callback method upon reconnection.
      Parameters:
      channel - The channel name.
      uid - The user ID.
      elapsed - Time elapsed (ms) from starting to reconnect until this callback is triggered
    • onLeaveChannel

      public void onLeaveChannel(IRtcEngineEventHandler.RtcStats stats)
      Occurs when the local user successfully leaves the channel. When the user successfully leaves the channel after calling leaveChannel, the SDK uses this callback to notify the app that the user has left the channel. This callback also reports information such as the call duration and the statistics of data received or transmitted by the SDK.
      Parameters:
      stats - The statistics on the call: RtcStats.
    • onClientRoleChanged

      public void onClientRoleChanged(int oldRole, int newRole, ClientRoleOptions newRoleOptions)
      Occurs when the user role in a Live-Broadcast channel has switched, for example, from a broadcaster to an audience or vice versa.
      Parameters:
      oldRole - The old role of the user.
      newRole - The new role of the user.
      newRoleOptions - The client role options of the new role.
    • onClientRoleChangeFailed

      public void onClientRoleChangeFailed(int reason, int currentRole)
      Occurs when the user role in a Live-Broadcast channel has switched, for example, from a broadcaster to an audience or vice versa.
      Parameters:
      reason - The reason of the failure of the local user role switches.
      currentRole - The current role of the user
    • onLocalUserRegistered

      public void onLocalUserRegistered(int uid, String userAccount)
      Occurs when the local user registers a user account.
      Parameters:
      uid - The ID of the local user.
      userAccount - The user account of the local user.
      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.
    • onUserInfoUpdated

      public void onUserInfoUpdated(int uid, UserInfo userInfo)
      Occurs when the SDK gets the user ID and user account of the remote user.
      Parameters:
      uid - The ID of the remote user.
      userInfo - The UserInfo object that contains 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.
    • onUserStateChanged

      public void 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

      public void onUserJoined(int uid, int elapsed)
      Occurs when a remote user or broadcaster joins the channel. If other users are already in the channel, the SDK also reports to the app on the existing users. The SDK triggers this callback under one of the following circumstances: - A broadcaster joins the channel by calling joinChannel. - A remote user switches the user role to broadcaster by calling setClientRole. after joining the channel. - A remote user or broadcaster rejoins the channel after a network interruption.
      Parameters:
      uid - ID of the remote user or broadcaster joining the channel.
      elapsed - The time elapsed (ms) from the local user calling `joinChannel` or `setClientRole` until this callback is triggered.
    • onUserOffline

      public void onUserOffline(int uid, int reason)
      Occurs when a remote user or broadcaster goes offline.
      Parameters:
      uid - ID of the remote user or broadcaster who leaves the channel or drops offline.
      reason - The reason why the remote user goes offline: - `USER_OFFLINE_QUIT`(0): When the user leaves the channel, the user sends a goodbye message. When this message is received, the SDK determines that the user leaves the channel. - `USER_OFFLINE_DROPPED`(1): When no data packet of the user is received for a certain period of time, the SDK assumes that the user drops offline. A poor network connection may lead to false detection, so we recommend using the RTM SDK for reliable offline detection. - `USER_OFFLINE_BECOME_AUDIENCE`(2): The user switches the user role from a broadcaster to an audience.
    • onConnectionStateChanged

      public void onConnectionStateChanged(int state, int reason)
      Occurs when the network connection state changes.
      Parameters:
      state - The current network connection state:
      reason - The reason causing the change of the connection state:
      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.
    • onConnectionInterrupted

      public void onConnectionInterrupted()
      The SDK has lost connection to the server. This method is triggered upon connection is lost, while the onConnectionLost method is triggered when the SDK attempts to reconnect after losing connection. Once the connection is lost, and if the application does not call leaveChannel, the SDK automatically tries to reconnect repeatedly.
    • onConnectionLost

      public void onConnectionLost()
      Occurs when the SDK cannot reconnect to the 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.
    • onConnectionBanned

      public void onConnectionBanned()

      Your connection is banned by the Agora Server.

      Note: The SDK does not try to reconnect.

    • onTokenPrivilegeWillExpire

      public void onTokenPrivilegeWillExpire(String token)
      Occurs when the token will expire in 30 seconds. If the token you specified when calling joinChannel expires, the user will drop offline. This callback is triggered 30 seconds before the token expires, to remind you to renew the token. Upon receiving this callback, generate a new token at your app server and call renewToken to pass the new Token to the SDK.
      Parameters:
      token - The token that will expire in 30 seconds.
    • onRequestToken

      public void onRequestToken()
      Occurs when the token has expired. If a token is specified when calling the joinChannel method, the token expires after a certain period of time and you need a new token to reconnect to the server. Upon receiving this callback, generate a new token at your app server and call renewToken to pass the new token to the SDK.
    • onLicenseValidationFailure

      public void 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

      public void onAudioVolumeIndication(IRtcEngineEventHandler.AudioVolumeInfo[] speakers, int totalVolume)
      Reports which users are speaking and the speaker's volume. This callback reports the IDs and volumes of the loudest speakers (at most 3) at the moment in the channel, and whether the local user is speaking. 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 separately report the volume information of the local user and all the remote speakers. For more information, see the detailed parameter descriptions. 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 `muteLocalAudioStream` method, the SDK stops triggering the remote speakers' callback.
      Parameters:
      speakers - An 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. - In the remote users' callback, 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. An empty `speakers` array in the callback indicates that no remote user is speaking at the moment.
      totalVolume - The total volume after audio mixing. The value ranges between 0 (the lowest volume) and 255 (the 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 users' callback, `totalVolume` is the sum of the voice volume and audio-mixing volume of all the remote speakers.
    • onActiveSpeaker

      public void onActiveSpeaker(int uid)
      Occurs when an active speaker is detected. If you have called the enableAudioVolumeIndication method, this callback is triggered when the volume detecting unit has detected an active speaker in the channel. This callback also returns the `uid` of the active speaker. You can add relative functions on your app, for example, the active speaker, once detected, will have the portrait zoomed in.
      Parameters:
      uid - The ID of the active speaker. A `uid` of 0 means the local user.
    • onVideoStopped

      @Deprecated public void onVideoStopped()
      Deprecated.
      Use onLocalVideoStateChanged instead.

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

      The video has stopped playing.

    • onFirstLocalVideoFrame

      public void onFirstLocalVideoFrame(Constants.VideoSourceType source, int width, int height, int elapsed)
      The first local video frame is displayed on the screen.
      Parameters:
      source - source type of the originated video source.
      width - Width (pixels) of the video stream.
      height - Height (pixels) of the video stream.
      elapsed - Time elapsed (ms) from calling joinChannel until this callback is triggered.
    • onFirstLocalVideoFramePublished

      public void onFirstLocalVideoFramePublished(Constants.VideoSourceType source, int elapsed)
      Occurs when the first video frame is published.
      Parameters:
      source - source type of the originated video source.
      elapsed - The time elapsed (ms) from the local user calling joinChannel to the SDK triggers this callback.
    • onFirstRemoteVideoDecoded

      public void onFirstRemoteVideoDecoded(int uid, int width, int height, int elapsed)
      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.
      Occurs when the first remote video frame is received and decoded.
      Parameters:
      uid - User ID of the remote user sending the video streams.
      width - Width (pixels) of the video stream.
      height - Height (pixels) of the video stream.
      elapsed - Time elapsed (ms) from the local user calling the joinChannel method until this callback is triggered.
    • onFirstRemoteVideoFrame

      public void onFirstRemoteVideoFrame(int uid, int width, int height, int elapsed)

      The first frame of the remote video appears in the user's video window.

      The application can retrieve the data of time elapsed from user joining the channel until the first video frame is displayed.

      Parameters:
      uid - User ID of the user whose video streams are received.
      width - Width (pixels) of the video stream.
      height - Height (pixels) of the video stream.
      elapsed - Time elapsed (ms) from calling joinChannel until this callback is triggered.
    • onUserMuteAudio

      public void 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.
      Parameters:
      uid - ID of the remote user.
      muted - Whether the remote user's audio stream playback pauses/resumes:
      • True: User's audio is paused.
      • False: User's audio is resumed.
    • onUserMuteVideo

      public void 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.
      Parameters:
      uid - ID of the remote user.
      muted - Whether the remote user's video stream playback pauses/resumes:
      • True: User's video is paused.
      • False: User's video is resumed.
    • onUserEnableVideo

      public void onUserEnableVideo(int uid, boolean enabled)
      Occurs when a remote user enables/disables the video module. 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.
      Parameters:
      uid - User ID of the remote user.
      enabled - Whether the specific remote user enables/disables the video module:
      • true: Enabled. The remote user can enter a video session.
      • false: Disabled. The remote user can only enter a voice session, and cannot send or receive any video stream.
    • onUserEnableLocalVideo

      @Deprecated public void onUserEnableLocalVideo(int uid, boolean enabled)
      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.
      Occurs when a remote user enables/disables the local video capture function.
      Parameters:
      uid - User ID of the remote user.
      enabled - Whether 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

      public void onVideoSizeChanged(Constants.VideoSourceType source, int uid, int width, int height, int rotation)
      Occurs when the local or remote video size or rotation has changed.
      Parameters:
      source - The video source type.
      uid - The user ID. 0 indicates the local user.
      width - The new width (pixels) of the video.
      height - The new height (pixels) of the video.
      rotation - The rotation information of the video.
    • onRemoteAudioStateChanged

      public void onRemoteAudioStateChanged(int uid, int state, int reason, int elapsed)
      Occurs when the remote audio state changes. This callback indicates the state change of the remote audio stream.
      Parameters:
      uid - ID of the user whose audio state changes.
      state - The state 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)`.
      reason - The reason of the remote audio state change.
      elapsed - Time elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.
    • onAudioPublishStateChanged

      public void onAudioPublishStateChanged(String channel, int oldState, int newState, int elapseSinceLastState)
      Occurs when the audio publish state changed. The publishing states include: - PUB_STATE_IDLE(0) - PUB_STATE_NO_PUBLISHED(1) - PUB_STATE_PUBLISHING(2) - PUB_STATE_PUBLISHED(3)
      Parameters:
      channel - The channel name of user joined.
      oldState - The old state of the audio stream publish.
      newState - The new state of the audio stream publish.
      elapseSinceLastState - The time elapsed (ms) from the old state to the new state.
    • onVideoPublishStateChanged

      public void onVideoPublishStateChanged(Constants.VideoSourceType source, String channel, int oldState, int newState, int elapseSinceLastState)
      Occurs when the audio publish state changed. The publishing states include: - PUB_STATE_IDLE(0) - PUB_STATE_NO_PUBLISHED(1) - PUB_STATE_PUBLISHING(2) - PUB_STATE_PUBLISHED(3)
      Parameters:
      source - source type of the originated video source.
      channel - The channel name of user joined.
      oldState - The old state of the video stream subscribe state.
      newState - The new state of the video stream subscribe state.
      elapseSinceLastState - The time elapsed (ms) from the old state to the new state.
    • onAudioSubscribeStateChanged

      public void onAudioSubscribeStateChanged(String channel, int uid, int oldState, int newState, int elapseSinceLastState)
      Occurs when the audio subscribe state changed. The subscribing states include: - SUB_STATE_IDLE(0) - SUB_STATE_NO_SUBSCRIBED(1) - SUB_STATE_SUBSCRIBING(2) - SUB_STATE_SUBSCRIBED(3)
      Parameters:
      channel - The channel name of user joined.
      uid - The remote user ID that is subscribed to.
      oldState - The old state of the audio stream subscribe.
      newState - The new state of the audio stream subscribe .
      elapseSinceLastState - The time elapsed (ms) from the old state to the new state.
    • onVideoSubscribeStateChanged

      public void onVideoSubscribeStateChanged(String channel, int uid, int oldState, int newState, int elapseSinceLastState)
      Occurs when the video subscribe state changed. The subscribing states include: - SUB_STATE_IDLE(0) - SUB_STATE_NO_SUBSCRIBED(1) - SUB_STATE_SUBSCRIBING(2) - SUB_STATE_SUBSCRIBED(3)
      Parameters:
      channel - The channel name of user joined.
      uid - The remote user ID that is subscribed to.
      oldState - The old state of the video stream subscribe state.
      newState - The new state of the video stream subscribe state.
      elapseSinceLastState - The time elapsed (ms) from the old state to the new state.
    • onRemoteVideoStateChanged

      public void onRemoteVideoStateChanged(int uid, int state, int reason, int elapsed)
      Occurs when the remote video state has changed.
      Parameters:
      uid - ID of the user whose video state has changed.
      state - State 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).
      reason - The reason of 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.
      elapsed - The time elapsed (ms) from the local user calling `joinChannel` until this callback is triggered.
    • onChannelMediaRelayStateChanged

      public void onChannelMediaRelayStateChanged(int state, int code)
      Occurs when the state of the media stream relay changes. The SDK reports the state of the current media relay and possible error messages in this callback.
      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)`: A failure occurs. See the details in `code`.
      code - The error code: - `RELAY_OK(0)`: The state is normal. - `RELAY_ERROR_SERVER_ERROR_RESPONSE(1)`: An error occurs in the server response. - `RELAY_ERROR_SERVER_NO_RESPONSE(2)`: No server response. You can call the leaveChannel method to leave the channel. - `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)`: Fails to send the relay request. - `RELAY_ERROR_FAILED_JOIN_DEST(5)`: 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 the leaveChannel method 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

      public void onFirstLocalAudioFramePublished(int elapsed)
      Occurs when the first audio frame is published.
      Parameters:
      elapsed - The time elapsed (ms) from the local user calling joinChannel to the SDK triggers this callback.
    • onFirstRemoteAudioFrame

      public void onFirstRemoteAudioFrame(int uid, int elapsed)
      Occurs when the first remote audio frame is received.
      Parameters:
      uid - ID of the remote user.
      elapsed - The time elapsed (ms) from the local user calling RtcEngine.joinChannel(java.lang.String, java.lang.String, java.lang.String, int) until this callback is triggered.
    • onFirstRemoteAudioDecoded

      public void onFirstRemoteAudioDecoded(int uid, int elapsed)
      Occurs when the SDK decodes the first remote audio frame for playback.
      Parameters:
      uid - User ID of the remote user sending the audio stream.
      elapsed - The time elapsed (ms) from the loca user calling \ref IRtcEngine::joinChannel "joinChannel()" until this callback is triggered.
    • onRemoteSubscribeFallbackToAudioOnly

      public void onRemoteSubscribeFallbackToAudioOnly(int uid, boolean isFallbackOrRecover)
    • onAudioRouteChanged

      public void onAudioRouteChanged(int routing)
      Occurs when the local audio playback 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: - AUDIO_ROUTE_DEFAULT(-1): The default audio route. - AUDIO_ROUTE_HEADSET(0): Headset. - AUDIO_ROUTE_EARPIECE(1): Earpiece. - AUDIO_ROUTE_HEADSETNOMIC(2): Headset with no microphone. - AUDIO_ROUTE_SPEAKERPHONE(3): Speakerphone. - AUDIO_ROUTE_LOUDSPEAKER(4): Loudspeaker. - AUDIO_ROUTE_BLUETOOTH_DEVICE_HFP(5): Bluetooth headset.
    • onCameraReady

      @Deprecated public void onCameraReady()
      Deprecated.
      Use onLocalVideoStateChanged instead.

      If the camera fails to turn on, an error is passed in the onError method.

      The camera is turned on and ready to capture video.

    • onCameraFocusAreaChanged

      public void onCameraFocusAreaChanged(Rect rect)
      Occurs when the camera focus area has changed.
      Parameters:
      rect - Rectangular area in the camera zoom that specifies the focus area.
    • onCameraExposureAreaChanged

      public void onCameraExposureAreaChanged(Rect rect)
      Occurs when the camera exposure area has changed.
      Parameters:
      rect - Rectangular area in the camera zoom that specifies the focus area.
    • onSnapshotTaken

      public void onSnapshotTaken(int uid, String filePath, int width, int height, int errCode)
      Occurs when takeSnapshot API result is obtained
      Parameters:
      uid - user id
      filePath - image is saveed file path
      width - image width
      height - image height
      errCode - 0 is ok negative is error
    • onFacePositionChanged

      public void onFacePositionChanged(int imageWidth, int imageHeight, IRtcEngineEventHandler.AgoraFacePositionInfo[] faceRectArr)
      Occurs when the camera exposure area has changed.
      Parameters:
      imageWidth - width of output image.
      imageHeight - height of output image.
      faceRectArr - Rectangular area in the camera zoom that specifies the focus area.
    • onAudioQuality

      public void onAudioQuality(int uid, int quality, short delay, short lost)

      The audio quality of the specified user every two seconds.

      By default, this callback is enabled.

      Parameters:
      uid - User ID of the speaker.
      quality - Rating of the audio quality:
      delay - Time delay (ms).
      lost - Packet loss rate (%).
    • onRtcStats

      public void onRtcStats(IRtcEngineEventHandler.RtcStats stats)
      Reports the statistics of the current call. This callback is triggered once every two seconds after the user joins the channel.
      Parameters:
      stats - The statistics on the current call: RtcStats.
    • onLastmileQuality

      public void onLastmileQuality(int quality)
      Reports the last-mile network quality of the local user. This callback is triggered once after `startLastmileProbeTest` is called. When the user is not in a channel and the last-mile network probe test is enabled (by calling `startLastmileProbeTest`), this callback function is triggered to update the app on the network connection quality of the local user.
      Parameters:
      quality - The network quality: - `QUALITY_UNKNOWN(0)`: The quality is unknown. - `QUALITY_EXCELLENT(1)`: The quality is excellent. - `QUALITY_GOOD QUALITY_GOOD(2)`: The quality is quite good, but the bitrate may be slightly lower than excellent. - `QUALITY_POOR(3)`: Users can feel the communication slightly impaired. - `QUALITY_BAD(4)`: Users can communicate not very smoothly. - `QUALITY_VBAD(5)`: The quality is so bad that users can barely communicate. - `QUALITY_DOWN(6)`: The network is disconnected and users cannot communicate at all.
    • onLastmileProbeResult

      public void onLastmileProbeResult(IRtcEngineEventHandler.LastmileProbeResult result)
      Reports the last-mile network probe result. The SDK triggers this callback within 30 seconds after the app calls the startLastmileProbeTest method.
      Parameters:
      result - The uplink and downlink lastmile network probe test result. For details, see LastmileProbeResult.
    • onNetworkQuality

      public void onNetworkQuality(int uid, int txQuality, int rxQuality)
      Reports the network quality of each user. This callback is triggered once every two seconds after the user joins the channel.
      Parameters:
      uid - User ID. If `uid` is 0, the SDK reports the local network quality.
      txQuality - The transmission quality of the user: - `QUALITY_UNKNOWN(0)`: The quality is unknown. - `QUALITY_EXCELLENT(1)`: The quality is excellent. - `QUALITY_GOOD QUALITY_GOOD(2)`: The quality is quite good, but the bitrate may be slightly lower than excellent. - `QUALITY_POOR(3)`: Users can feel the communication slightly impaired. - `QUALITY_BAD(4)`: Users can communicate not very smoothly. - `QUALITY_VBAD(5)`: The quality is so bad that users can barely communicate. - `QUALITY_DOWN(6)`: The network is disconnected and users cannot communicate at all.
      rxQuality - The receiving quality of the user: - `QUALITY_UNKNOWN(0)`: The quality is unknown. - `QUALITY_EXCELLENT(1)`: The quality is excellent. - `QUALITY_GOOD QUALITY_GOOD(2)`: The quality is quite good, but the bitrate may be slightly lower than excellent. - `QUALITY_POOR(3)`: Users can feel the communication slightly impaired. - `QUALITY_BAD(4)`: Users can communicate not very smoothly. - `QUALITY_VBAD(5)`: The quality is so bad that users can barely communicate. - `QUALITY_DOWN(6)`: The network is disconnected and users cannot communicate at all.
    • onLocalAudioStats

      public void onLocalAudioStats(IRtcEngineEventHandler.LocalAudioStats stats)
      Reports the statistics of the local audio stream. The SDK triggers this callback once every two seconds.
      Parameters:
      stats - The statistics of the local audio stream. See LocalAudioStats.
    • onLocalVideoStats

      public void onLocalVideoStats(Constants.VideoSourceType source, IRtcEngineEventHandler.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:
      source - source type of the originated video source
      stats - The statistics of the local video stream. See LocalVideoStats.
    • onRemoteAudioStats

      public void onRemoteAudioStats(IRtcEngineEventHandler.RemoteAudioStats stats)
      Reports the statistics of the audio from each remote user or broadcaster. The SDK triggers this callback once every two seconds for each remote user or broadcaster. If a channel has multiple remote users, the SDK triggers this callback as many times.
      Parameters:
      stats - The statistics of the received audio: RemoteAudioStats.
    • onRemoteVideoStats

      public void onRemoteVideoStats(IRtcEngineEventHandler.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:
      stats - The statistics of the remote video streams. See RemoteVideoStats.
    • onLocalVideoStat

      public void 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

      public void 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

      @Deprecated public void onRemoteAudioTransportStats(int uid, int delay, int lost, int rxKBitRate)
      Deprecated.
      Use onRemoteAudioStats instead.
    • onRemoteVideoTransportStats

      @Deprecated public void onRemoteVideoTransportStats(int uid, int delay, int lost, int rxKBitRate)
      Deprecated.
      Use onRemoteVideoStats instead.
    • onAudioMixingStateChanged

      public void onAudioMixingStateChanged(int state, int reason)
      Occurs when the state of the local user's audio mixing file changes. 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:
      state - The state code: - AUDIO_MIXING_STATE_PLAYING(710): The audio mixing file is playing. - AUDIO_MIXING_STATE_PAUSED(711): The audio mixing file pauses playing. - AUDIO_MIXING_STATE_STOPPED(713): The audio mixing file stops playing. - AUDIO_MIXING_STATE_FAILED(714): An exception occurs when playing the audio mixing file. See the errorCode for details.
      reason - The error code: - AUDIO_MIXING_ERROR_OK(701): No error. - AUDIO_MIXING_ERROR_CAN_NOT_OPEN(701): The SDK cannot open the audio mixing file. - AUDIO_MIXING_REASON_TOO_FREQUENT_CALL(702): The SDK opens the audio mixing file too frequently. - AUDIO_MIXING_ERROR_INTERRUPTED_EOF(703): The audio mixing file playback is interrupted.
    • onAudioMixingPositionChanged

      public void onAudioMixingPositionChanged(long position)
      Parameters:
      position - Current AudioMixing progress (millisecond).
    • onAudioMixingFinished

      @Deprecated public void onAudioMixingFinished()
      Deprecated.
      Use onAudioMixingStateChanged instead.

      If you failed to execute the startAudioMixing method, it returns the error code in the onError callback.

      The audio mixing file playback is finished after calling startAudioMixing.

    • onAudioEffectFinished

      public void onAudioEffectFinished(int soundId)
      The local audio effect playback has finished.
      Parameters:
      soundId - ID of the audio effect. Each audio effect has a unique ID.
    • onRhythmPlayerStateChanged

      public void onRhythmPlayerStateChanged(int state, int reason)
      Occurs when the state of the local user's rhythm player changes. When you call the \ref IRtcEngine::startRhythmPlayer "startRhythmPlayer" method and the state of rhythm player changes, the SDK triggers this callback.
      Parameters:
      state - The state code. See #RHYTHM_PLAYER_STATE_TYPE.
      reason - The error code. See #RHYTHM_PLAYER_REASON_TYPE.
    • onLocalAudioStateChanged

      public void onLocalAudioStateChanged(int state, int reason)
      Occurs when the local audio stream state changes. 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.
      Parameters:
      state - State of the local audio:
      reason - The reason information of the local audio:
    • onLocalVideoStateChanged

      public void onLocalVideoStateChanged(Constants.VideoSourceType source, int state, int reason)
      Occurs when the local video stream state changes. This callback indicates the state of the local video stream, including camera capturing and video encoding, and allows you to troubleshoot issues when exceptions occur.
      Parameters:
      source - source type of the originated video source.
      state - The local video state: - LOCAL_VIDEO_STREAM_STATE_STOPPED(0): The local video is in the initial state. - LOCAL_VIDEO_STREAM_STATE_CAPTURING(1): The local video capturer starts successfully. - LOCAL_VIDEO_STREAM_STATE_ENCODING(2): The first local video frame encodes successfully. - LOCAL_VIDEO_STREAM_STATE_FAILED(3): The local video fails to start.
      reason - The detailed reason information of the local video: - 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_NO_PERMISSION(2): No permission to use the local video device. - LOCAL_VIDEO_STREAM_REASON_DEVICE_BUSY(3): The local video capturer is in use. - LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE(4): The local video capture fails. Check whether the capturer is working properly. - If your app runs in the background on a device running Android 9 or later, you cannot access the camera. - If your app runs on a device running Android 6 or later, this error is reported if the camera is occupied by a third-part app and not property released. Once the camera is released, the SDK triggers this callback again, reporting state `CAPTURING(1)`, and error `ERROR_OK(0)`. - LOCAL_VIDEO_STREAM_REASON_CODEC_NOT_SUPPORT(5): The local video encoding fails.
    • onRtmpStreamingStateChanged

      public void onRtmpStreamingStateChanged(String url, int state, int reason)
      Occurs when the state of the RTMP streaming changes.
      Parameters:
      url - The RTMP URL address.
      state - The RTMP streaming state:
      • RTMP_STREAM_PUBLISH_STATE_IDLE(0): The RTMP or RTMPS streaming has not started or has ended. This state is also triggered after you remove an RTMP or RTMPS stream from the CDN by calling removePublishStreamUrl.
      • RTMP_STREAM_PUBLISH_STATE_CONNECTING(1): The SDK is connecting to Agora streaming server and the CDN server. This state is triggered after you call the addPublishStreamUrl method.
      • RTMP_STREAM_PUBLISH_STATE_RUNNING(2): The RTMP or RTMPS streaming publishes. The SDK successfully publishes the RTMP or RTMPS streaming and returns this state.
      • RTMP_STREAM_PUBLISH_STATE_RECOVERING(3): The RTMP or RTMPS streaming is recovering. When exceptions occur to the CDN, or the streaming is interrupted, the SDK attempts to resume RTMP or RTMPS streaming and returns this state.
      • RTMP_STREAM_PUBLISH_STATE_FAILURE(4): The RTMP or RTMPS streaming fails. See the errCode parameter for the detailed error information. You can also call the addPublishStreamUrl method to publish the RTMP or RTMPS streaming again.
      • RTMP_STREAM_PUBLISH_STATE_DISCONNECTING(5): The SDK is disconnecting from the Agora streaming server and CDN. When you call `remove` or `stop` to stop the streaming normally, the SDK reports the streaming state as `DISCONNECTING`, `IDLE` in sequence.
      reason - The detailed reason information for streaming:
    • onRtmpStreamingEvent

      public void onRtmpStreamingEvent(String url, int event)
      Reports events during the RTMP or RTMPS streaming.
      Parameters:
      url - The CDN streaming URL.
      error - The event code. - RTMP_STREAMING_EVENT_FAILED_LOAD_IMAGE(1): An error occurs when you add a background image or a watermark image to the RTMP or RTMPS stream. - RTMP_STREAMING_EVENT_URL_ALREADY_IN_USE(2): The chosen URL address is already in use for CDN live streaming. - RTMP_STREAMING_EVENT_ADVANCED_FEATURE_NOT_SUPPORT(3):advanced feature not support. - RTMP_STREAMING_EVENT_REQUEST_TOO_OFTEN(4): Client request too frequently.
      Since:
      v3.1.0.
    • onTranscodingUpdated

      public void onTranscodingUpdated()
      Transcoding was successfully updated.
    • onStreamMessage

      public void onStreamMessage(int uid, int streamId, byte[] data)
      Receives the data stream. onRtmpStreamingEvent The SDK triggers this callback when the user receives the data stream that another user sends by calling the sendStreamMessage method within 5 seconds.
      Parameters:
      uid - User ID.
      streamId - Stream ID.
      data - Data received by the recipients.
    • onStreamMessageError

      public void onStreamMessageError(int uid, int streamId, int error, int missed, int cached)
      Fails to receive the data stream. The SDK triggers this callback when the user does not receive the data stream that another user sends by calling the sendStreamMessage method within 5 seconds.
      Parameters:
      uid - ID of the user who sends the data stream.
      streamId - The ID of the stream data.
      error - The error code. See Error code.
      missed - The number of lost messages.
      cached - The number of incoming cached messages when the data stream is interrupted.
    • onRdtMessage

      public void onRdtMessage(int uid, int type, byte[] data)
      Parameters:
      uid - ID of the user who sends the data.
      type - The RDT stream type
      data - The data received.
    • onRdtStateChanged

      public void onRdtStateChanged(int uid, int state)
      Parameters:
      uid - ID of the user who sends the data.
      state - The RDT tunnel state
    • onMediaControlMessage

      public void onMediaControlMessage(int uid, byte[] data)
      Parameters:
      uid - ID of the user who sends the data.
      data - The data received.
    • onMediaEngineLoadSuccess

      public void onMediaEngineLoadSuccess()
      Occurs when the media engine is loaded.
    • onMediaEngineStartCallSuccess

      public void onMediaEngineStartCallSuccess()
      Occurs when the media engine starts.
    • onNetworkTypeChanged

      public void onNetworkTypeChanged(int type)
      Occurs when the network type is changed.
      Parameters:
      type - The network type.
    • onIntraRequestReceived

      public void onIntraRequestReceived()
      Occurs when intra request from remote user is received. This callback is triggered once remote user needs one Key frame.
    • onUplinkNetworkInfoUpdated

      public void onUplinkNetworkInfoUpdated(IRtcEngineEventHandler.UplinkNetworkInfo info)
      Occurs when uplink network info is updated. This callback is used for notifying user to adjust the send pace based on the target bitrate.
      Parameters:
      info - The uplink network info.
    • onEncryptionError

      public void onEncryptionError(int errorType)
      Reports the error type of encryption.
      Parameters:
      type - See #ENCRYPTION_ERROR_TYPE.
    • onPermissionError

      public void onPermissionError(int permission)
      Reports the permission error.
      Parameters:
      permission - of Constants.RECORD_AUDIO, Constants.CAMERA and Constants.SCREEN_CAPTURE
    • onUploadLogResult

      public void 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.
    • onContentInspectResult

      public void onContentInspectResult(int result)
    • onProxyConnected

      public void onProxyConnected(String channel, int uid, int proxyType, String localProxyIp, int elapsed)
      Occurs when the local user joins a specified channel after calling setLocalAccessPoint or setCloudProxy. 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:
      channel - The channel name.
      uid - User ID.
      proxyType - type of proxy agora sdk connected, proxyType will be PROXY_TYPE_NONE_PROXY if not connected to proxy(fallback).
      localProxyIp - local proxy ip, if not join local proxy, it will be ""
      elapsed - Time elapsed (ms) from the user calling joinChannel until this callback is triggered.
    • onVideoRenderingTracingResult

      public void onVideoRenderingTracingResult(int uid, Constants.MEDIA_TRACE_EVENT currentEvent, IRtcEngineEventHandler.VideoRenderingTracingInfo tracingInfo)
      Reports the tracing result of video rendering event of the user.
      Parameters:
      uid - The user ID.
      currentEvent - The current event of the tracing result: #MEDIA_TRACE_EVENT.
      tracingInfo - The tracing result: #VideoRenderingTracingInfo.
    • onLocalVideoTranscoderError

      public void onLocalVideoTranscoderError(LocalTranscoderConfiguration.TranscodingVideoStream stream, int error)
      Occurs when local video transcoder stream has an error.
      Parameters:
      stream - Stream type of TranscodingVideoStream.
      error - The error code: - `VT_ERR_OK(0)`: No error. - `VT_ERR_VIDEO_SOURCE_NOT_READY(1)`: The video track of the video source is not started. - `VT_ERR_INVALID_VIDEO_SOURCE_TYPE(2)`: The video source type is not supported. - `VT_ERR_INVALID_IMAGE_PATH(3)`: The image source url is not correct. - `VT_ERR_UNSUPPORT_IMAGE_FORMAT(4)`: The image format not the type png/jpeg/gif of image source. - `VT_ERR_INVALID_LAYOUT(5)`: The layout is invalid. Possible reason: The width of the layout is zero.
    • onTranscodedStreamLayoutInfo

      public void onTranscodedStreamLayoutInfo(int uid, IRtcEngineEventHandler.VideoLayoutInfo info)
    • onAudioMetadataReceived

      public void onAudioMetadataReceived(int uid, byte[] data)
      Parameters:
      metadata - The pointer of metadata
      length - Size of metadata
      Since:
      v4.3.1
    • onMultipathStats

      public void onMultipathStats(IRtcEngineEventHandler.MultipathStats stats)
      Parameters:
      stats - The multipath statistics. See the MultipathStats structure for details.
      Since:
      4.6.0
    • onRenewTokenResult

      public void onRenewTokenResult(String token, Constants.RenewTokenErrorCode code)
      Parameters:
      token - The token.
      code - The error code.
      Since:
      v4.6.0 Occurs when a user renews the token. This callback notifies the app of the result after the user calls `renewToken` to renew the token. The app can obtain the result of the `renewToken` call from this callback.