Classes | |
class | AudioVolumeInfo |
class | ClientRole |
class | ErrorCode |
class | LocalVideoStats |
class | Quality |
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 | onUserJoined (int uid, int elapsed) |
void | onUserOffline (int uid, 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 | onRemoteVideoStateChanged (int uid, int state) |
void | onLocalPublishFallbackToAudioOnly (boolean isFallbackOrRecover) |
void | onRemoteSubscribeFallbackToAudioOnly (int uid, boolean isFallbackOrRecover) |
void | onAudioRouteChanged (int routing) |
void | onCameraReady () |
void | onCameraFocusAreaChanged (Rect rect) |
void | onAudioQuality (int uid, int quality, short delay, short lost) |
void | onRtcStats (RtcStats stats) |
void | onLastmileQuality (int quality) |
void | onNetworkQuality (int uid, int txQuality, int rxQuality) |
void | onLocalVideoStats (LocalVideoStats stats) |
void | onRemoteVideoStats (RemoteVideoStats 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 | onAudioMixingFinished () |
void | onAudioEffectFinished (int soundId) |
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 () |
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.
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.
warn | Warning code |
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.
err | Error code |
void io.agora.rtc.IRtcEngineEventHandler.onJoinChannelSuccess | ( | String | channel, |
int | uid, | ||
int | elapsed | ||
) |
Occurs when a 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.
channel | Channel name. |
uid | User ID. |
elapsed | Time elapsed (ms) from the user calling joinChannel until this callback is triggered. |
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.
channel | Channel name. |
uid | User ID. |
elapsed | Time elapsed (ms) from starting to reconnect until this callback is triggered. |
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.
stats | Statistics of the call: RtcStats |
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.
oldRole | Role that the user switches from. |
newRole | Role that the user switches to. |
void io.agora.rtc.IRtcEngineEventHandler.onUserJoined | ( | int | uid, |
int | elapsed | ||
) |
Occurs when a remote user (Communication)/host (Live Broadcast) joins the channel.
uid | ID of the user or host who joins the channel. |
elapsed | Time delay (ms) from the user calling joinChannel/setClientRole until this callback is triggered. |
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:
uid | ID of the user or host who leaves the channel or goes offline. |
reason | Reason why the user goes offline:
|
void io.agora.rtc.IRtcEngineEventHandler.onConnectionInterrupted | ( | ) |
Occurs when the connection between the SDK and the server is interrupted.
This callback is triggered when the SDK loses connection with the server for more than four seconds after the connection is established. After triggering this callback, the SDK tries to reconnect with the server. Developers can use this callback as a UI reminder. This callback is different from onConnectionLost:
For both callbacks, the SDK tries to reconnect with the server until the app calls leaveChannel.
void io.agora.rtc.IRtcEngineEventHandler.onConnectionLost | ( | ) |
Occurs when the connection between the SDK and the server is interrupted and the SDK cannot reconnect to the server in 10 seconds.
This callback is triggered when the SDK cannot connect with the server for 10 seconds after calling joinChannel(), regardless of whether the SDK is in the channel or not.
This callback is different from onConnectionInterrupted:
For both callbacks, the SDK tries to reconnect with the server until the application calls leaveChannel.
void io.agora.rtc.IRtcEngineEventHandler.onConnectionBanned | ( | ) |
Occurs when your connection is banned by the Agora Server.
void io.agora.rtc.IRtcEngineEventHandler.onApiCallExecuted | ( | int | error, |
String | api, | ||
String | result | ||
) |
Occurs when an API method is executed.
error | Error Code that the SDK returns when the method call fails. If the SDK returns 0, then the method call was successful. |
api | The method executed by the SDK. |
result | The result of the method call. |
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.
token | The token that expires in 30 seconds. |
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
. In previous SDKs, this notification was provided in the onError callback as the ERR_TOKEN_EXPIRED(109) and ERR_INVALID_TOKEN(110) errors. Starting from v1.7.3 of the SDK, the old method is still valid, but it is recommended to use the onRequestToken() callback.
void io.agora.rtc.IRtcEngineEventHandler.onMicrophoneEnabled | ( | boolean | enabled | ) |
Occurs when the microphone is enabled/disabled.
enabled | Whether the microphone is enabled/disabled:
|
void io.agora.rtc.IRtcEngineEventHandler.onAudioVolumeIndication | ( | AudioVolumeInfo [] | speakers, |
int | totalVolume | ||
) |
Reports which users are speaking and the speakers' volume.
This callback reports the ID and volume of the loudest speakers at the moment in the channel. This callback is disabled by default and can be enabled by the enableAudioVolumeIndication method.
The local user has a dedicated onAudioVolumeIndication callback; all remote speakers share a separate onAudioVolumeIndication callback.
speakers
array has uid
= 0 and volume
= totalVolume
, and speakerNumber
= 1 regardless of whether the local user speaks or not. speakers
array includes the user ID and volume of the loudest speakers in the channel. speakers | An array containing the user ID and volume information for each speaker: AudioVolumeInfo |
totalVolume | Total volume after audio mixing. The value ranges between 0 (lowest volume) and 255 (highest volume). |
speakers
array in the onAudioVolumeIndication callback suggests that no remote user is speaking at the moment. void io.agora.rtc.IRtcEngineEventHandler.onActiveSpeaker | ( | int | uid | ) |
Reports which user is the loudest speaker.
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.
uid | User ID of the active speaker. A uid of 0 represents the local user. |
void io.agora.rtc.IRtcEngineEventHandler.onFirstLocalAudioFrame | ( | int | elapsed | ) |
Occurs when the first local audio frame is sent.
elapsed | Time elapsed (ms) from the local user calling joinChannel until this callback is triggered. |
void io.agora.rtc.IRtcEngineEventHandler.onFirstRemoteAudioFrame | ( | int | uid, |
int | elapsed | ||
) |
Occurs when the first remote audio frame is received.
uid | User ID of the remote user. |
elapsed | Time elapsed (ms) from the remote user calling joinChannel until this callback is triggered. |
void io.agora.rtc.IRtcEngineEventHandler.onVideoStopped | ( | ) |
Occurs when the video stops playing.
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.
void io.agora.rtc.IRtcEngineEventHandler.onFirstLocalVideoFrame | ( | int | width, |
int | height, | ||
int | elapsed | ||
) |
Occurs when the first local video frame is sent.
This callback is triggered after the first local video frame is rendered on the video window.
width | Width (pixels) of the first local video frame. |
height | Height (pixels) of the first local video frame. |
elapsed | Time 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. |
void io.agora.rtc.IRtcEngineEventHandler.onFirstRemoteVideoDecoded | ( | int | uid, |
int | width, | ||
int | height, | ||
int | elapsed | ||
) |
Occurs when the first remote video frame is decoded.
This callback is triggered after the first frame of the remote video is received and decoded. The app can configure the user view settings with this callback.
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 remote user calling joinChannel until this callback is triggered. |
void io.agora.rtc.IRtcEngineEventHandler.onFirstRemoteVideoFrame | ( | int | uid, |
int | width, | ||
int | height, | ||
int | elapsed | ||
) |
Occurs when the first remote video frame is received and 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.
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 calling joinChannel until this callback is triggered. |
void io.agora.rtc.IRtcEngineEventHandler.onUserMuteAudio | ( | int | uid, |
boolean | muted | ||
) |
Occurs when a remote user's audio stream is muted/unmuted.
uid | ID of the remote user. |
muted | Whether the remote user's audio stream is muted/unmuted:
|
void io.agora.rtc.IRtcEngineEventHandler.onUserMuteVideo | ( | int | uid, |
boolean | muted | ||
) |
Occurs when a remote user's video stream playback pauses/resumes.
uid | ID of the remote user. |
muted | Whether the remote user's video stream playback pauses/resumes:
|
void io.agora.rtc.IRtcEngineEventHandler.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.
uid | User ID of the remote user. |
enabled | Whether the specific remote user enables/disables the video module:
|
void io.agora.rtc.IRtcEngineEventHandler.onUserEnableLocalVideo | ( | int | uid, |
boolean | enabled | ||
) |
Occurs when a remote user enables/disables the local video capture function.
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.
uid | User ID of the remote user. |
enabled | Whether the specific remote user enables/disables the local video capturing function:
|
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.
uid | User ID of the remote user or local user (0) whose video size or rotation changes. |
width | New width (pixels) of the video. |
height | New height (pixels) of the video. |
rotation | New rotation of the video [0 to 360). |
void io.agora.rtc.IRtcEngineEventHandler.onRemoteVideoStateChanged | ( | int | uid, |
int | state | ||
) |
Occurs when the remote video stream state changes.
uid | ID of the user whose remote video state changes. |
state | State of the remote video:
|
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.
isFallbackOrRecover | Whether the locally published stream fell back to audio-only or switched back to the video:
|
void io.agora.rtc.IRtcEngineEventHandler.onRemoteSubscribeFallbackToAudioOnly | ( | int | uid, |
boolean | isFallbackOrRecover | ||
) |
Occurs when the subscribed 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.
uid | ID of the remote user sending the stream. |
isFallbackOrRecover | Whether the remotely subscribed media stream fell back to audio-only or switched back to the video:
|
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:
void io.agora.rtc.IRtcEngineEventHandler.onCameraReady | ( | ) |
Occurs when the camera is turned on and ready to capture video.
If the camera fails to turn on, fix the error reported in the onError callback.
void io.agora.rtc.IRtcEngineEventHandler.onCameraFocusAreaChanged | ( | Rect | rect | ) |
Occurs when the camera focus area is changed.
rect | Rectangular area in the camera zoom specifying the focus area. |
void io.agora.rtc.IRtcEngineEventHandler.onAudioQuality | ( | int | uid, |
int | quality, | ||
short | delay, | ||
short | lost | ||
) |
Reports the audio quality of the current call once every two seconds.
This callback is enabled by default.
uid | User ID of the speaker. |
quality | Audio quality of the user:
|
delay | Time delay (ms). |
lost | Audio packet loss rate (%). |
void io.agora.rtc.IRtcEngineEventHandler.onRtcStats | ( | RtcStats | stats | ) |
void io.agora.rtc.IRtcEngineEventHandler.onLastmileQuality | ( | int | quality | ) |
Reports the last mile network quality of the local user after enableLastmileTest is called.
quality | Network quality:
|
void io.agora.rtc.IRtcEngineEventHandler.onNetworkQuality | ( | int | uid, |
int | txQuality, | ||
int | rxQuality | ||
) |
Reports the network quality of each user once every two seconds.
The Agora SDK returns this callback to report on the uplink and downlink network conditions of each user in the channel once every two seconds.
uid | User ID. The network quality of the user with this uid is reported. If uid is 0, the local network quality is reported. |
txQuality | Transmission quality of the user:
|
rxQuality | Receiving quality of the user:
|
void io.agora.rtc.IRtcEngineEventHandler.onLocalVideoStats | ( | LocalVideoStats | stats | ) |
Reports the statistics of the uploading local video streams once every two seconds.
stats | Statistics of the uploading local video streams: LocalVideoStats. |
void io.agora.rtc.IRtcEngineEventHandler.onRemoteVideoStats | ( | RemoteVideoStats | stats | ) |
Reports the statistics of the receiving remote video streams once every two seconds.
If there are multiple remote users/hosts, this callback is triggered multiple times once every two seconds.
stats | Statistics of the receiving remote video streams: RemoteVideoStats. |
void io.agora.rtc.IRtcEngineEventHandler.onLocalVideoStat | ( | int | sentBitrate, |
int | sentFrameRate | ||
) |
Reports the statistics of the uploading local video streams.
sentBitrate | Data transmission bitrate (Kbps) since last count. |
sentFrameRate | Data transmission frame rate (fps) since last count. |
void io.agora.rtc.IRtcEngineEventHandler.onRemoteVideoStat | ( | int | uid, |
int | delay, | ||
int | receivedBitrate, | ||
int | receivedFrameRate | ||
) |
Reports the statistics of the receiving remote video streams.
uid | User ID of the remote user sending the video streams. |
delay | Time delay (ms). |
receivedBitrate | Data receiving bitrate (Kbps). |
receivedFrameRate | Data receiving frame rate (fps). |
void io.agora.rtc.IRtcEngineEventHandler.onRemoteAudioTransportStats | ( | int | uid, |
int | delay, | ||
int | lost, | ||
int | rxKBitRate | ||
) |
Reports the statistics of the remote audio transmission once every two seconds after the user receives the audio data packet from a remote user.
uid | User ID of the remote user sending the audio data packet. |
delay | Time delay (ms) from the remote user to the local client. |
lost | Packet loss rate (%). |
rxKBitRate | Received audio bitrate (Kbps) of the data packet from the remote user. |
void io.agora.rtc.IRtcEngineEventHandler.onRemoteVideoTransportStats | ( | int | uid, |
int | delay, | ||
int | lost, | ||
int | rxKBitRate | ||
) |
Reports the statistics of the remote video transmission once every two seconds after the user receives the video data packet from a remote user.
uid | User ID of the remote user sending the video data packet. |
delay | Time delay (ms) from the remote user to the local client. |
lost | Packet loss rate (%). |
rxKBitRate | Received video bitrate (Kbps) of the data packet from the remote user. |
void io.agora.rtc.IRtcEngineEventHandler.onAudioMixingFinished | ( | ) |
Occurs when the audio mixing file playback finishes.
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.
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.
soundId | ID of the local audio effect. Each local audio effect has a unique ID. |
void io.agora.rtc.IRtcEngineEventHandler.onStreamPublished | ( | String | url, |
int | error | ||
) |
Occurs when a CDN live stream is published.
url | HTTP/HTTPS URL address, to which the publisher publishes the stream. |
error | Error code
|
void io.agora.rtc.IRtcEngineEventHandler.onStreamUnpublished | ( | String | url | ) |
Occurs when a CDN live stream stops.
This callback notifies the host that the CDN live stream is unpublished.
url | HTTP/HTTPS URL address, from which the publisher unpublished the stream. |
void io.agora.rtc.IRtcEngineEventHandler.onTranscodingUpdated | ( | ) |
Occurs when the publisher's transcoding settings are updated.
void io.agora.rtc.IRtcEngineEventHandler.onStreamInjectedStatus | ( | String | url, |
int | uid, | ||
int | status | ||
) |
Reports the status of the injected online media stream.
url | HTTP/HTTPS URL address of the externally injected stream. |
uid | User ID. |
status | State of the externally injected stream:
|
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.
uid | User ID of the remote user sending the message. |
streamId | Stream ID. |
data | Data received by the local user. |
void io.agora.rtc.IRtcEngineEventHandler.onStreamMessageError | ( | int | uid, |
int | streamId, | ||
int | error, | ||
int | missed, | ||
int | cached | ||
) |
Occurs when the local user fails to receive the remote data stream.
uid | User ID of the remote user sending the message. |
streamId | Stream ID. |
error | Error code. |
missed | The number of lost messages. |
cached | The number of incoming cached messages when the data stream is interrupted. |
void io.agora.rtc.IRtcEngineEventHandler.onMediaEngineLoadSuccess | ( | ) |
Occurs when the media engine is loaded.
void io.agora.rtc.IRtcEngineEventHandler.onMediaEngineStartCallSuccess | ( | ) |
Occurs when the media engine starts.