Voice SDK v3.7.1 API Reference for All Platforms (C++)
agora::rtc::IRtcEngineEventHandler Class Reference

Public Member Functions

virtual ~IRtcEngineEventHandler ()
 
virtual void onWarning (int warn, const char *msg)
 
virtual void onError (int err, const char *msg)
 
virtual void onJoinChannelSuccess (const char *channel, uid_t uid, int elapsed)
 
virtual void onRejoinChannelSuccess (const char *channel, uid_t uid, int elapsed)
 
virtual void onLeaveChannel (const RtcStats &stats)
 
virtual void onClientRoleChanged (CLIENT_ROLE_TYPE oldRole, CLIENT_ROLE_TYPE newRole)
 
virtual void onClientRoleChangeFailed (CLIENT_ROLE_CHANGE_FAILED_REASON reason, CLIENT_ROLE_TYPE currentRole)
 
virtual void onUserJoined (uid_t uid, int elapsed)
 
virtual void onUserOffline (uid_t uid, USER_OFFLINE_REASON_TYPE reason)
 
virtual void onProxyConnected (const char *channel, uid_t uid, PROXY_TYPE proxyType, const char *localProxyIp, int elapsed)
 
virtual void onLastmileQuality (int quality)
 
virtual void onLastmileProbeResult (const LastmileProbeResult &result)
 
virtual void onConnectionInterrupted ()
 
virtual void onConnectionLost ()
 
virtual void onConnectionBanned ()
 
virtual void onApiCallExecuted (int err, const char *api, const char *result)
 
virtual void onRequestToken ()
 
virtual void onTokenPrivilegeWillExpire (const char *token)
 
virtual void onAudioQuality (uid_t uid, int quality, unsigned short delay, unsigned short lost)
 
virtual void onRtcStats (const RtcStats &stats)
 
virtual void onNetworkQuality (uid_t uid, int txQuality, int rxQuality)
 
virtual void onLocalVideoStats (const LocalVideoStats &stats)
 
virtual void onRemoteVideoStats (const RemoteVideoStats &stats)
 
virtual void onLocalAudioStats (const LocalAudioStats &stats)
 
virtual void onRemoteAudioStats (const RemoteAudioStats &stats)
 
virtual void onLocalAudioStateChanged (LOCAL_AUDIO_STREAM_STATE state, LOCAL_AUDIO_STREAM_ERROR error)
 
virtual void onRemoteAudioStateChanged (uid_t uid, REMOTE_AUDIO_STATE state, REMOTE_AUDIO_STATE_REASON reason, int elapsed)
 
virtual void onAudioPublishStateChanged (const char *channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState)
 
virtual void onVideoPublishStateChanged (const char *channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState)
 
virtual void onAudioSubscribeStateChanged (const char *channel, uid_t uid, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState)
 
virtual void onVideoSubscribeStateChanged (const char *channel, uid_t uid, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState)
 
virtual void onAudioVolumeIndication (const AudioVolumeInfo *speakers, unsigned int speakerNumber, int totalVolume)
 
virtual void onLocalVoicePitchInHz (int pitchInHz)
 
virtual void onAudioDeviceTestVolumeIndication (AudioDeviceTestVolumeType volumeType, int volume)
 
virtual void onActiveSpeaker (uid_t uid)
 
virtual void onVideoStopped ()
 
virtual void onFirstLocalVideoFrame (int width, int height, int elapsed)
 
virtual void onFirstLocalVideoFramePublished (int elapsed)
 
virtual void onFirstRemoteVideoDecoded (uid_t uid, int width, int height, int elapsed) AGORA_DEPRECATED_ATTRIBUTE
 
virtual void onFirstRemoteVideoFrame (uid_t uid, int width, int height, int elapsed)
 
virtual void onUserMuteAudio (uid_t uid, bool muted)
 
virtual void onUserMuteVideo (uid_t uid, bool muted)
 
virtual void onUserEnableVideo (uid_t uid, bool enabled)
 
virtual void onAudioDeviceStateChanged (const char *deviceId, int deviceType, int deviceState)
 
virtual void onAudioDeviceVolumeChanged (MEDIA_DEVICE_TYPE deviceType, int volume, bool muted)
 
virtual void onCameraReady ()
 
virtual void onCameraFocusAreaChanged (int x, int y, int width, int height)
 
virtual void onFacePositionChanged (int imageWidth, int imageHeight, Rectangle *vecRectangle, int *vecDistance, int numFaces)
 
virtual void onCameraExposureAreaChanged (int x, int y, int width, int height)
 
virtual void onAudioMixingFinished ()
 
virtual void onAudioMixingStateChanged (AUDIO_MIXING_STATE_TYPE state, AUDIO_MIXING_REASON_TYPE reason)
 
virtual void onRemoteAudioMixingBegin ()
 
virtual void onRemoteAudioMixingEnd ()
 
virtual void onRequestAudioFileInfo (const AudioFileInfo &info, AUDIO_FILE_INFO_ERROR error)
 
virtual void onAudioEffectFinished (int soundId)
 
virtual void onFirstRemoteAudioDecoded (uid_t uid, int elapsed) AGORA_DEPRECATED_ATTRIBUTE
 
virtual void onVideoDeviceStateChanged (const char *deviceId, int deviceType, int deviceState)
 
virtual void onLocalVideoStateChanged (LOCAL_VIDEO_STREAM_STATE localVideoState, LOCAL_VIDEO_STREAM_ERROR error)
 
virtual void onVideoSizeChanged (uid_t uid, int width, int height, int rotation)
 
virtual void onRemoteVideoStateChanged (uid_t uid, REMOTE_VIDEO_STATE state, REMOTE_VIDEO_STATE_REASON reason, int elapsed)
 
virtual void onUserEnableLocalVideo (uid_t uid, bool enabled)
 
virtual void onStreamMessage (uid_t uid, int streamId, const char *data, size_t length)
 
virtual void onStreamMessageError (uid_t uid, int streamId, int code, int missed, int cached)
 
virtual void onMediaEngineLoadSuccess ()
 
virtual void onMediaEngineStartCallSuccess ()
 
virtual void onUserSuperResolutionEnabled (uid_t uid, bool enabled, SUPER_RESOLUTION_STATE_REASON reason)
 
virtual void onVirtualBackgroundSourceEnabled (bool enabled, VIRTUAL_BACKGROUND_SOURCE_STATE_REASON reason)
 
virtual void onSnapshotTaken (const char *channel, uid_t uid, const char *filePath, int width, int height, int errCode)
 
virtual void onChannelMediaRelayStateChanged (CHANNEL_MEDIA_RELAY_STATE state, CHANNEL_MEDIA_RELAY_ERROR code)
 
virtual void onChannelMediaRelayEvent (CHANNEL_MEDIA_RELAY_EVENT code)
 
virtual void onFirstLocalAudioFrame (int elapsed) AGORA_DEPRECATED_ATTRIBUTE
 
virtual void onFirstLocalAudioFramePublished (int elapsed)
 
virtual void onFirstRemoteAudioFrame (uid_t uid, int elapsed) AGORA_DEPRECATED_ATTRIBUTE
 
virtual void onRtmpStreamingStateChanged (const char *url, RTMP_STREAM_PUBLISH_STATE state, RTMP_STREAM_PUBLISH_ERROR_TYPE errCode)
 
virtual void onRtmpStreamingEvent (const char *url, RTMP_STREAMING_EVENT eventCode)
 
virtual void onStreamPublished (const char *url, int error) AGORA_DEPRECATED_ATTRIBUTE
 
virtual void onStreamUnpublished (const char *url) AGORA_DEPRECATED_ATTRIBUTE
 
virtual void onTranscodingUpdated ()
 
virtual void onStreamInjectedStatus (const char *url, uid_t uid, int status)
 
virtual void onAudioRouteChanged (AUDIO_ROUTE_TYPE routing)
 
virtual void onLocalPublishFallbackToAudioOnly (bool isFallbackOrRecover)
 
virtual void onRemoteSubscribeFallbackToAudioOnly (uid_t uid, bool isFallbackOrRecover)
 
virtual void onRemoteAudioTransportStats (uid_t uid, unsigned short delay, unsigned short lost, unsigned short rxKBitRate) AGORA_DEPRECATED_ATTRIBUTE
 
virtual void onRemoteVideoTransportStats (uid_t uid, unsigned short delay, unsigned short lost, unsigned short rxKBitRate) AGORA_DEPRECATED_ATTRIBUTE
 
virtual void onMicrophoneEnabled (bool enabled) AGORA_DEPRECATED_ATTRIBUTE
 
virtual void onConnectionStateChanged (CONNECTION_STATE_TYPE state, CONNECTION_CHANGED_REASON_TYPE reason)
 
virtual void onNetworkTypeChanged (NETWORK_TYPE type)
 
virtual void onLocalUserRegistered (uid_t uid, const char *userAccount)
 
virtual void onUserInfoUpdated (uid_t uid, const UserInfo &info)
 
virtual void onScreenCaptureInfoUpdated (ScreenCaptureInfo &info)
 

Detailed Description

The SDK uses the IRtcEngineEventHandler interface class to send callbacks to the application. The application inherits the methods of this interface class to retrieve these callbacks.

All methods in this interface class have default (empty) implementations. Therefore, the application can only inherit some required events. In the callbacks, avoid time-consuming tasks or calling blocking APIs, such as the SendMessage method. Otherwise, the SDK may not work properly.

Constructor & Destructor Documentation

◆ ~IRtcEngineEventHandler()

virtual agora::rtc::IRtcEngineEventHandler::~IRtcEngineEventHandler ( )
inlinevirtual

Member Function Documentation

◆ onWarning()

virtual void agora::rtc::IRtcEngineEventHandler::onWarning ( int  warn,
const char *  msg 
)
inlinevirtual

Reports a warning during SDK runtime.

In most cases, the application can ignore the warning reported by the SDK because the SDK can usually fix the issue and resume running. For example, when losing connection with the server, the SDK may report WARN_LOOKUP_CHANNEL_TIMEOUT and automatically try to reconnect.

Parameters
warnWarning code: WARN_CODE_TYPE.
msgPointer to the warning message.

◆ onError()

virtual void agora::rtc::IRtcEngineEventHandler::onError ( int  err,
const char *  msg 
)
inlinevirtual

Reports an error during SDK runtime.

In most cases, the SDK cannot fix the issue and resume running. The SDK requires the application 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 application informs the user that the call initialization failed and invokes the leaveChannel method to leave the channel.

Parameters
errError code: ERROR_CODE_TYPE.
msgPointer to the error message.

◆ onJoinChannelSuccess()

virtual void agora::rtc::IRtcEngineEventHandler::onJoinChannelSuccess ( const char *  channel,
uid_t  uid,
int  elapsed 
)
inlinevirtual

Occurs when a user joins a channel.

This callback notifies the application that a user joins a specified channel when the application calls the joinChannel method.

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

If the uid is not specified in the joinChannel method, the server automatically assigns a uid.

Parameters
channelPointer to the channel name.
uidUser ID of the user joining the channel.
elapsedTime elapsed (ms) from the user calling the joinChannel method until the SDK triggers this callback.

◆ onRejoinChannelSuccess()

virtual void agora::rtc::IRtcEngineEventHandler::onRejoinChannelSuccess ( const char *  channel,
uid_t  uid,
int  elapsed 
)
inlinevirtual

Occurs when a user rejoins the channel after disconnection 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
channelPointer to the channel name.
uidUser ID of the user rejoining the channel.
elapsedTime elapsed (ms) from starting to reconnect until the SDK triggers this callback.

◆ onLeaveChannel()

virtual void agora::rtc::IRtcEngineEventHandler::onLeaveChannel ( const RtcStats stats)
inlinevirtual

Occurs when a user leaves the channel.

This callback notifies the application that a user leaves the channel when the application calls the leaveChannel method.

The application gets information, such as the call duration and statistics.

Parameters
statsPointer to the statistics of the call: RtcStats.

◆ onClientRoleChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onClientRoleChanged ( CLIENT_ROLE_TYPE  oldRole,
CLIENT_ROLE_TYPE  newRole 
)
inlinevirtual

Occurs when the user role switches successfully in the interactive live streaming.

In the LIVE_BROADCASTING channel profile, when the local user successfully calls setClientRole to switch their user role after joining the channel, for example, from a host to an audience member or vice versa, the SDK triggers this callback to report the user role before and after the switch.

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

◆ onClientRoleChangeFailed()

virtual void agora::rtc::IRtcEngineEventHandler::onClientRoleChangeFailed ( CLIENT_ROLE_CHANGE_FAILED_REASON  reason,
CLIENT_ROLE_TYPE  currentRole 
)
inlinevirtual

Occurs when the user role switch fails in the interactive live streaming.

Since
v3.7.0

In the LIVE_BROADCASTING channel profile, when the local user calls setClientRole to switch their user role after joining the channel but the switch fails, the SDK triggers this callback to report the reason for the failure and the current user role.

Parameters
reasonThe reason for the user role switch failure. See CLIENT_ROLE_CHANGE_FAILED_REASON.
currentRoleThe current user role. See CLIENT_ROLE_TYPE.

◆ onUserJoined()

virtual void agora::rtc::IRtcEngineEventHandler::onUserJoined ( uid_t  uid,
int  elapsed 
)
inlinevirtual

Occurs when a remote user (COMMUNICATION)/ host (LIVE_BROADCASTING) joins the channel.

  • COMMUNICATION profile: This callback notifies the application that another user joins the channel. If other users are already in the channel, the SDK also reports to the application on the existing users.
  • LIVE_BROADCASTING profile: This callback notifies the application that the host joins the channel. If other hosts are already in the channel, the SDK also reports to the application on the existing hosts. We recommend limiting the number of hosts to 17.

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

  • A remote user/host joins the channel 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.
Note
In the LIVE_BROADCASTING profile:
  • The host receives this callback when another host joins the channel.
  • The audience in the channel receives this callback when a new host joins the channel.
  • When a web application joins the channel, the SDK triggers this callback as long as the web application publishes streams.
Parameters
uidUser ID of the user or host joining the channel.
elapsedTime delay (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

◆ onUserOffline()

virtual void agora::rtc::IRtcEngineEventHandler::onUserOffline ( uid_t  uid,
USER_OFFLINE_REASON_TYPE  reason 
)
inlinevirtual

Occurs when a remote user (COMMUNICATION)/ host (LIVE_BROADCASTING) leaves the channel.

Reasons why the user is offline:

  • Leave the channel: When the user/host leaves the channel, the user/host sends a goodbye message. When the message is received, the SDK assumes 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, the SDK assumes that the user/host drops offline. Unreliable network connections may lead to false detections, so we recommend using the Agora RTM SDK for more reliable offline detection.
Parameters
uidUser ID of the user leaving the channel or going offline.
reasonReason why the user is offline: USER_OFFLINE_REASON_TYPE.

◆ onProxyConnected()

virtual void agora::rtc::IRtcEngineEventHandler::onProxyConnected ( const char *  channel,
uid_t  uid,
PROXY_TYPE  proxyType,
const char *  localProxyIp,
int  elapsed 
)
inlinevirtual

Reports the proxy connection state.

Since
v3.6.2

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

Parameters
channelThe channel name.
uidThe user ID.
proxyTypeThe proxy type connected. See PROXY_TYPE.
localProxyIpReserved for future use.
elapsedThe time elapsed (ms) from the user calling joinChannel until this callback is triggered.

◆ onLastmileQuality()

virtual void agora::rtc::IRtcEngineEventHandler::onLastmileQuality ( int  quality)
inlinevirtual

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: QUALITY_TYPE.

◆ onLastmileProbeResult()

virtual void agora::rtc::IRtcEngineEventHandler::onLastmileProbeResult ( const LastmileProbeResult result)
inlinevirtual

Reports the last-mile network probe result.

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. See LastmileProbeResult.

◆ onConnectionInterrupted()

virtual void agora::rtc::IRtcEngineEventHandler::onConnectionInterrupted ( )
inlinevirtual
Deprecated:
Occurs when the connection between the SDK and the server is interrupted.

Deprecated as of v2.3.2. Replaced by the onConnectionStateChanged(CONNECTION_STATE_RECONNECTING, CONNECTION_CHANGED_INTERRUPTED) callback.

The SDK triggers this callback when it loses connection with the server for more than four seconds after the connection is established.

After triggering this callback, the SDK tries reconnecting 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 it loses connection with the server for more than four seconds after it successfully joins the channel.
  • The SDK triggers the onConnectionLost callback when it loses connection with the server for more than 10 seconds, whether or not it joins the channel.

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

◆ onConnectionLost()

virtual void agora::rtc::IRtcEngineEventHandler::onConnectionLost ( )
inlinevirtual

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

The SDK triggers this callback when it cannot connect to the server 10 seconds after calling the joinChannel method, whether or not it is in the channel.

This callback is different from onConnectionInterrupted:

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

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

◆ onConnectionBanned()

virtual void agora::rtc::IRtcEngineEventHandler::onConnectionBanned ( )
inlinevirtual
Deprecated:
Deprecated as of v2.3.2. Replaced by the onConnectionStateChanged(CONNECTION_STATE_FAILED, CONNECTION_CHANGED_BANNED_BY_SERVER) callback.

Occurs when your connection is banned by the Agora Server.

◆ onApiCallExecuted()

virtual void agora::rtc::IRtcEngineEventHandler::onApiCallExecuted ( int  err,
const char *  api,
const char *  result 
)
inlinevirtual

Occurs when a method is executed by the SDK.

Parameters
errThe error code (ERROR_CODE_TYPE) returned by the SDK when a method call fails. If the SDK returns 0, then the method call is successful.
apiPointer to the method executed by the SDK.
resultPointer to the result of the method call.

◆ onRequestToken()

virtual void agora::rtc::IRtcEngineEventHandler::onRequestToken ( )
inlinevirtual

Occurs when the token expires.

After a token is specified by calling the joinChannel method, 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.

Once you receive this callback, generate a new token on your app server, and call renewToken to pass the new token to the SDK.

◆ onTokenPrivilegeWillExpire()

virtual void agora::rtc::IRtcEngineEventHandler::onTokenPrivilegeWillExpire ( const char *  token)
inlinevirtual

Occurs when the token expires in 30 seconds.

The user becomes offline if the token used in the joinChannel method expires. The SDK triggers this callback 30 seconds before the token expires to remind the application to get a new token. Upon receiving this callback, generate a new token on the server and call the renewToken method to pass the new token to the SDK.

Parameters
tokenThe token that expires in 30 seconds.

◆ onAudioQuality()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioQuality ( uid_t  uid,
int  quality,
unsigned short  delay,
unsigned short  lost 
)
inlinevirtual
Deprecated:
Reports the statistics of the audio stream from each remote user/host.

Deprecated as of v2.3.2. Use the onRemoteAudioStats callback 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 users/hosts sending audio streams, the SDK triggers this callback as many times.

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

◆ onRtcStats()

virtual void agora::rtc::IRtcEngineEventHandler::onRtcStats ( const RtcStats stats)
inlinevirtual

Reports the statistics of the current call.

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

Parameters
statsStatistics of the IRtcEngine: RtcStats.

◆ onNetworkQuality()

virtual void agora::rtc::IRtcEngineEventHandler::onNetworkQuality ( uid_t  uid,
int  txQuality,
int  rxQuality 
)
inlinevirtual

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, the SDK triggers this callback as many times.

Note
txQuality is UNKNOWN when the user is not sending a stream; rxQuality is UNKNOWN when the user is not receiving a stream.
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 rating 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 640 * 480 and a frame rate of 15 fps in the LIVE_BROADCASTING profile, but may be inadequate for resolutions higher than 1280 * 720. See QUALITY_TYPE.
rxQualityDownlink network quality rating of the user in terms of the packet loss rate, average RTT, and jitter of the downlink network. See QUALITY_TYPE.

◆ onLocalVideoStats()

virtual void agora::rtc::IRtcEngineEventHandler::onLocalVideoStats ( const LocalVideoStats stats)
inlinevirtual

Reports the statistics of the local video stream.

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.

Note
If you have called the enableDualStreamMode method, the onLocalVideoStats callback reports the statistics of the high-video stream (high bitrate, and high-resolution video stream).
Parameters
statsStatistics of the local video stream. See LocalVideoStats.

◆ onRemoteVideoStats()

virtual void agora::rtc::IRtcEngineEventHandler::onRemoteVideoStats ( const RemoteVideoStats stats)
inlinevirtual

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 remote video stream. See RemoteVideoStats.

◆ onLocalAudioStats()

virtual void agora::rtc::IRtcEngineEventHandler::onLocalAudioStats ( const LocalAudioStats stats)
inlinevirtual

Reports the statistics of the local audio stream.

The SDK triggers this callback once every two seconds.

Parameters
statsThe statistics of the local audio stream. See LocalAudioStats.

◆ onRemoteAudioStats()

virtual void agora::rtc::IRtcEngineEventHandler::onRemoteAudioStats ( const RemoteAudioStats stats)
inlinevirtual

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

This callback 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.

Parameters
statsPointer to the statistics of the received remote audio streams. See RemoteAudioStats.

◆ onLocalAudioStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onLocalAudioStateChanged ( LOCAL_AUDIO_STREAM_STATE  state,
LOCAL_AUDIO_STREAM_ERROR  error 
)
inlinevirtual

Occurs when the local audio state changes. This callback indicates the state change of the local audio stream, including the state of the audio capturing 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. See LOCAL_AUDIO_STREAM_STATE.
errorThe error information of the local audio. See LOCAL_AUDIO_STREAM_ERROR.

◆ onRemoteAudioStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onRemoteAudioStateChanged ( uid_t  uid,
REMOTE_AUDIO_STATE  state,
REMOTE_AUDIO_STATE_REASON  reason,
int  elapsed 
)
inlinevirtual

Occurs when the remote audio state changes.

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

Note
This callback can be inaccurate when the number of users (in the COMMUNICATION profile) or hosts (in the LIVE_BROADCASTING profile) in a channel exceeds 17.
Parameters
uidID of the remote user whose audio state changes.
stateState of the remote audio. See REMOTE_AUDIO_STATE.
reasonThe reason of the remote audio state change. See REMOTE_AUDIO_STATE_REASON.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

◆ onAudioPublishStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioPublishStateChanged ( const char *  channel,
STREAM_PUBLISH_STATE  oldState,
STREAM_PUBLISH_STATE  newState,
int  elapseSinceLastState 
)
inlinevirtual

Occurs when the audio publishing state changes.

Since
v3.1.0

This callback indicates the publishing state change of the local audio stream.

Parameters
channelThe channel name.
oldStateThe previous publishing state. For details, see STREAM_PUBLISH_STATE.
newStateThe current publishing state. For details, see STREAM_PUBLISH_STATE.
elapseSinceLastStateThe time elapsed (ms) from the previous state to the current state.

◆ onVideoPublishStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onVideoPublishStateChanged ( const char *  channel,
STREAM_PUBLISH_STATE  oldState,
STREAM_PUBLISH_STATE  newState,
int  elapseSinceLastState 
)
inlinevirtual

Occurs when the video publishing state changes.

Since
v3.1.0

This callback indicates the publishing state change of the local video stream.

Parameters
channelThe channel name.
oldStateThe previous publishing state. For details, see STREAM_PUBLISH_STATE.
newStateThe current publishing state. For details, see STREAM_PUBLISH_STATE.
elapseSinceLastStateThe time elapsed (ms) from the previous state to the current state.

◆ onAudioSubscribeStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioSubscribeStateChanged ( const char *  channel,
uid_t  uid,
STREAM_SUBSCRIBE_STATE  oldState,
STREAM_SUBSCRIBE_STATE  newState,
int  elapseSinceLastState 
)
inlinevirtual

Occurs when the audio subscribing state changes.

Since
v3.1.0

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

Parameters
channelThe channel name.
uidThe ID of the remote user.
oldStateThe previous subscribing state. For details, see STREAM_SUBSCRIBE_STATE.
newStateThe current subscribing state. For details, see STREAM_SUBSCRIBE_STATE.
elapseSinceLastStateThe time elapsed (ms) from the previous state to the current state.

◆ onVideoSubscribeStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onVideoSubscribeStateChanged ( const char *  channel,
uid_t  uid,
STREAM_SUBSCRIBE_STATE  oldState,
STREAM_SUBSCRIBE_STATE  newState,
int  elapseSinceLastState 
)
inlinevirtual

Occurs when the audio subscribing state changes.

Since
v3.1.0

This callback indicates the subscribing state change of a remote video stream.

Parameters
channelThe channel name.
uidThe ID of the remote user.
oldStateThe previous subscribing state. For details, see STREAM_SUBSCRIBE_STATE.
newStateThe current subscribing state. For details, see STREAM_SUBSCRIBE_STATE.
elapseSinceLastStateThe time elapsed (ms) from the previous state to the current state.

◆ onAudioVolumeIndication()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioVolumeIndication ( const AudioVolumeInfo speakers,
unsigned int  speakerNumber,
int  totalVolume 
)
inlinevirtual

Reports the volume information of users.

By default, this callback is disabled. You can enable it by calling enableAudioVolumeIndication. Once this callback is enabled and users send streams in the channel, the SDK triggers the onAudioVolumeIndication callback at the time interval set in enableAudioVolumeIndication.

The SDK triggers two independent onAudioVolumeIndication callbacks simultaneously, which separately report the volume information of the local user who sends a stream and the remote users (up to three) whose instantaneous volumes are the highest.

Note
After you enable this callback, calling muteLocalAudioStream affects the SDK's behavior as follows:
  • If the local user calls muteLocalAudioStream, the SDK stops triggering the local user's callback.
  • 20 seconds after a remote user whose volume is one of the three highest calls muteLocalAudioStream, the remote users' callback excludes this remote user's information; 20 seconds after all remote users call muteLocalAudioStream, the SDK stops triggering the remote users' callback.
Parameters
speakersThe volume information of users. See AudioVolumeInfo.

An empty speakers array in the callback indicates that no remote user is in the channel or sending a stream at the moment.

Parameters
speakerNumberTotal number of users.
  • In the local user's callback, when the local user sends a stream, speakerNumber = 1.
  • In the remote users' callback, the value ranges between 0 and 3. If the number of remote users who send streams is greater than or equal to three, speakerNumber = 3.
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 volume of the local user who sends a stream.
  • In the remote users' callback, totalVolume is the sum of the volume of all remote users (up to three) whose instantaneous volumes are the highest.

If the user calls startAudioMixing, totalVolume is the sum of the voice volume and audio-mixing volume.

◆ onLocalVoicePitchInHz()

virtual void agora::rtc::IRtcEngineEventHandler::onLocalVoicePitchInHz ( int  pitchInHz)
inlinevirtual

Reports the voice pitch of the local user.

Since
v3.7.0

After the local audio capture is enabled, and you call enableLocalVoicePitchCallback , the SDK triggers this callback at the time interval set in enableLocalVoicePitchCallback.

Note
After this callback is enabled, if the user disables the local audio capture, for example, by calling enableLocalAudio(false), the SDK immediately stops sending the onLocalVoicePitchInHz callback.
Parameters
pitchInHzThe voice pitch (Hz) of the local user.

◆ onAudioDeviceTestVolumeIndication()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioDeviceTestVolumeIndication ( AudioDeviceTestVolumeType  volumeType,
int  volume 
)
inlinevirtual

Reports the result of an audio device test.

Since
v3.6.2

After successfully calling startRecordingDeviceTest, startPlaybackDeviceTest, or startAudioDeviceLoopbackTest to start an audio device test, the SDK triggers the onAudioDeviceTestVolumeIndication callback at the set time interval to report the volume information of the audio device tested.

Parameters
volumeTypeThe volume type. See AudioDeviceTestVolumeType.
volumeThe volume, in the range of [0,255].

◆ onActiveSpeaker()

virtual void agora::rtc::IRtcEngineEventHandler::onActiveSpeaker ( uid_t  uid)
inlinevirtual

Occurs when the most active remote speaker is detected.

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

When the number of user is no less than two and an active speaker exists, the SDK triggers this callback and reports the uid of the most active speaker.

  • If the most active speaker is always the same user, the SDK triggers this callback only once.
  • If the most active speaker changes to another user, the SDK triggers this callback again and reports the uid of the new active speaker.
Parameters
uidThe user ID of the most active remote speaker.

◆ onVideoStopped()

virtual void agora::rtc::IRtcEngineEventHandler::onVideoStopped ( )
inlinevirtual
Deprecated:
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.

Deprecated as of v2.4.1. Use LOCAL_VIDEO_STREAM_STATE_STOPPED(0) in the onLocalVideoStateChanged callback instead.

◆ onFirstLocalVideoFrame()

virtual void agora::rtc::IRtcEngineEventHandler::onFirstLocalVideoFrame ( int  width,
int  height,
int  elapsed 
)
inlinevirtual

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

Parameters
widthWidth (px) of the first local video frame.
heightHeight (px) of the first local video frame.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback. If you call the startPreview method before calling the joinChannel method, then elapsed is the time elapsed from calling the startPreview method until the SDK triggers this callback.

◆ onFirstLocalVideoFramePublished()

virtual void agora::rtc::IRtcEngineEventHandler::onFirstLocalVideoFramePublished ( int  elapsed)
inlinevirtual

Occurs when the first video frame is published.

Since
v3.1.0

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

Parameters
elapsedThe time elapsed (ms) from the local client calling joinChannel until the SDK triggers this callback.

◆ onFirstRemoteVideoDecoded()

virtual void agora::rtc::IRtcEngineEventHandler::onFirstRemoteVideoDecoded ( uid_t  uid,
int  width,
int  height,
int  elapsed 
)
inlinevirtual

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

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. Reasons for such an interruption include:
    • The remote user leaves the channel.
    • The remote user drops offline.
    • The remote user calls the muteLocalVideoStream method to stop sending the video stream.
    • The remote user calls the disableVideo method to disable video.

The application can configure the user view settings in this callback.

Parameters
uidUser ID of the remote user sending the video stream.
widthWidth (px) of the video stream.
heightHeight (px) of the video stream.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

◆ onFirstRemoteVideoFrame()

virtual void agora::rtc::IRtcEngineEventHandler::onFirstRemoteVideoFrame ( uid_t  uid,
int  width,
int  height,
int  elapsed 
)
inlinevirtual

Occurs when the first remote video frame is rendered.

The SDK triggers this callback when the first frame of the remote video is displayed in the user's video window. The application can get the time elapsed from a user joining the channel until the first video frame is displayed.

Parameters
uidUser ID of the remote user sending the video stream.
widthWidth (px) of the video frame.
heightHeight (px) of the video stream.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

◆ onUserMuteAudio()

virtual void agora::rtc::IRtcEngineEventHandler::onUserMuteAudio ( uid_t  uid,
bool  muted 
)
inlinevirtual

Occurs when a remote user's audio stream playback pauses/resumes.

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

Note
This callback can be inaccurate when the number of users (in the COMMUNICATION profile) or hosts (in the LIVE_BROADCASTING profile) in a channel exceeds 17.
Parameters
uidUser ID of the remote user.
mutedWhether the remote user's audio stream is muted/unmuted:
  • true: Muted.
  • false: Unmuted.

◆ onUserMuteVideo()

virtual void agora::rtc::IRtcEngineEventHandler::onUserMuteVideo ( uid_t  uid,
bool  muted 
)
inlinevirtual

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

When a remote user calls muteLocalVideoStream to stop or resume publishing the video stream, the SDK triggers this callback to report the state of the remote user's publishing stream to the local user.

Note
This callback can be inaccurate when the number of users (in the COMMUNICATION profile) or hosts (in the LIVE_BROADCASTING profile) in a channel exceeds 17.
Parameters
uidThe user ID of the remote user.
mutedWhether the remote user stops publishing the video stream:
  • true: Stop publishing the video stream.
  • false: Publish the video stream.

◆ onUserEnableVideo()

virtual void agora::rtc::IRtcEngineEventHandler::onUserEnableVideo ( uid_t  uid,
bool  enabled 
)
inlinevirtual

Occurs when a specific 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.

Note
This callback returns invalid when the number of users in a channel exceeds 20.
Parameters
uidUser ID of the remote user.
enabledWhether the 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.

◆ onAudioDeviceStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioDeviceStateChanged ( const char *  deviceId,
int  deviceType,
int  deviceState 
)
inlinevirtual

Occurs when the audio device state changes (for macOS and Windows only).

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

Parameters
deviceIdPointer to the device ID.
deviceTypeDevice type: MEDIA_DEVICE_TYPE.
deviceStateThe state of the device:

◆ onAudioDeviceVolumeChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioDeviceVolumeChanged ( MEDIA_DEVICE_TYPE  deviceType,
int  volume,
bool  muted 
)
inlinevirtual

Occurs when the volume of the playback device, microphone, or application changes.

Parameters
deviceTypeDevice type: MEDIA_DEVICE_TYPE.
volumeVolume of the device. The value ranges between 0 and 255.
muted
  • true: The audio device is muted.
  • false: The audio device is not muted.

◆ onCameraReady()

virtual void agora::rtc::IRtcEngineEventHandler::onCameraReady ( )
inlinevirtual
Deprecated:
Occurs when the camera turns on and is ready to capture the video.

If the camera fails to turn on, fix the error reported in the onError callback.

Deprecated as of v2.4.1. Use LOCAL_VIDEO_STREAM_STATE_CAPTURING (1) in the onLocalVideoStateChanged callback instead.

◆ onCameraFocusAreaChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onCameraFocusAreaChanged ( int  x,
int  y,
int  width,
int  height 
)
inlinevirtual

Occurs when the camera focus area changes.

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

Note
This callback is for Android and iOS only.
Parameters
xx coordinate of the changed camera focus area.
yy coordinate of the changed camera focus area.
widthWidth of the changed camera focus area.
heightHeight of the changed camera focus area.

◆ onFacePositionChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onFacePositionChanged ( int  imageWidth,
int  imageHeight,
Rectangle vecRectangle,
int *  vecDistance,
int  numFaces 
)
inlinevirtual

Reports the face detection result of the local user. Applies to Android and iOS only.

Since
v3.0.1

Once you enable face detection by calling enableFaceDetection(true), you can get the following information on the local user in real-time:

  • The width and height of the local video.
  • The position of the human face in the local view.
  • The distance between the human face and the device screen. This value is based on the fitting calculation of the local video size and the position of the human face.
Note
  • If the SDK does not detect a face, it reduces the frequency of this callback to reduce power consumption on the local device.
  • The SDK stops triggering this callback when a human face is in close proximity to the screen.
  • On Android, the distance value reported in this callback may be slightly different from the actual distance. Therefore, Agora does not recommend using it for accurate calculation.
Parameters
imageWidthThe width (px) of the local video.
imageHeightThe height (px) of the local video.
vecRectangleThe position and size of the human face on the local video:
  • x: The x coordinate (px) of the human face in the local view. Taking the top left corner of the view as the origin, the x coordinate represents the relative lateral displacement of the top left corner of the human face to the origin.
  • y: The y coordinate (px) of the human face in the local view. Taking the top left corner of the view as the origin, the y coordinate represents the relative longitudinal displacement of the top left corner of the human face to the origin.
  • width: The width (px) of the human face in the captured video.
  • height: The height (px) of the human face in the captured video.
vecDistanceThe distance (cm) between the human face and the screen.
numFacesThe number of faces detected. If the value is 0, it means that no human face is detected.

◆ onCameraExposureAreaChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onCameraExposureAreaChanged ( int  x,
int  y,
int  width,
int  height 
)
inlinevirtual

Occurs when the camera exposure area changes.

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

Note
This callback is for Android and iOS only.
Parameters
xx coordinate of the changed camera exposure area.
yy coordinate of the changed camera exposure area.
widthWidth of the changed camera exposure area.
heightHeight of the changed camera exposure area.

◆ onAudioMixingFinished()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioMixingFinished ( )
inlinevirtual

Occurs when the audio mixing file playback finishes.

You can start an audio mixing file playback by calling the startAudioMixing method. The SDK triggers this callback when the audio mixing file playback finishes.

If the startAudioMixing method call fails, an error code returns in the onError callback.

◆ onAudioMixingStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioMixingStateChanged ( AUDIO_MIXING_STATE_TYPE  state,
AUDIO_MIXING_REASON_TYPE  reason 
)
inlinevirtual

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

Since
v3.4.0

When the playback state of the local user's music file changes, the SDK triggers this callback and reports the current playback state and the reason for the change.

Parameters
stateThe current music file playback state. See AUDIO_MIXING_STATE_TYPE.
reasonThe reason for the change of the music file playback state. See AUDIO_MIXING_REASON_TYPE.

◆ onRemoteAudioMixingBegin()

virtual void agora::rtc::IRtcEngineEventHandler::onRemoteAudioMixingBegin ( )
inlinevirtual

Occurs when a remote user starts audio mixing.

When a remote user calls startAudioMixing to play the background music, the SDK reports this callback.

◆ onRemoteAudioMixingEnd()

virtual void agora::rtc::IRtcEngineEventHandler::onRemoteAudioMixingEnd ( )
inlinevirtual

Occurs when a remote user finishes audio mixing.

◆ onRequestAudioFileInfo()

virtual void agora::rtc::IRtcEngineEventHandler::onRequestAudioFileInfo ( const AudioFileInfo info,
AUDIO_FILE_INFO_ERROR  error 
)
inlinevirtual

Reports the information of an audio file.

Since
v3.5.1

After successfully calling getAudioFileInfo, the SDK triggers this callback to report the information of the audio file, such as the file path and duration.

Parameters
infoThe information of an audio file. See AudioFileInfo.
errorThe information acquisition state. See AUDIO_FILE_INFO_ERROR.

◆ onAudioEffectFinished()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioEffectFinished ( int  soundId)
inlinevirtual

Occurs when the local audio effect playback finishes.

The SDK triggers this callback when the local audio effect file playback finishes.

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

◆ onFirstRemoteAudioDecoded()

virtual void agora::rtc::IRtcEngineEventHandler::onFirstRemoteAudioDecoded ( uid_t  uid,
int  elapsed 
)
inlinevirtual

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

Deprecated:
v3.0.0

This callback is deprecated. Use onRemoteAudioStateChanged instead.

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. Reasons for such an interruption include:
    • The remote user leaves channel.
    • The remote user drops offline.
    • The remote user calls the muteLocalAudioStream method to stop sending the local audio stream.
    • The remote user calls the disableAudio method to disable audio.
Parameters
uidUser ID of the remote user sending the audio stream.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

◆ onVideoDeviceStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onVideoDeviceStateChanged ( const char *  deviceId,
int  deviceType,
int  deviceState 
)
inlinevirtual

Occurs when the video device state changes (for macOS and Windows only).

Note
On a Windows device with an external camera for video capturing, the video disables once the external camera is unplugged.
Parameters
deviceIdPointer to the device ID of the video device that changes state.
deviceTypeDevice type: MEDIA_DEVICE_TYPE.
deviceStateThe state of the device:

◆ onLocalVideoStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onLocalVideoStateChanged ( LOCAL_VIDEO_STREAM_STATE  localVideoState,
LOCAL_VIDEO_STREAM_ERROR  error 
)
inlinevirtual

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.

The SDK triggers the onLocalVideoStateChanged(LOCAL_VIDEO_STREAM_STATE_FAILED, LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE) callback in the following situations:

  • The application exits to the background, and the system recycles the camera.
  • The camera starts normally, but the captured video is not output for four seconds.

When the camera outputs the captured video frames, if all the video frames are the same for 15 consecutive frames, the SDK triggers the onLocalVideoStateChanged(LOCAL_VIDEO_STREAM_STATE_CAPTURING, LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE) callback. Note that the video frame duplication detection is only available for video frames with a resolution greater than 200 Ɨ 200, a frame rate greater than or equal to 10 fps, and a bitrate less than 20 Kbps.

Note
For some device models, the SDK will not trigger this callback when the state of the local video changes while the local video capturing device is in use, so you have to make your own timeout judgment.
Parameters
localVideoStateState type LOCAL_VIDEO_STREAM_STATE.
errorThe detailed error information: LOCAL_VIDEO_STREAM_ERROR.

◆ onVideoSizeChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onVideoSizeChanged ( uid_t  uid,
int  width,
int  height,
int  rotation 
)
inlinevirtual

Occurs when the video size or rotation of a specified 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).

◆ onRemoteVideoStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onRemoteVideoStateChanged ( uid_t  uid,
REMOTE_VIDEO_STATE  state,
REMOTE_VIDEO_STATE_REASON  reason,
int  elapsed 
)
inlinevirtual

Occurs when the remote video state changes.

Note
This callback can be inaccurate when the number of users (in the COMMUNICATION profile) or hosts (in the LIVE_BROADCASTING profile) in a channel exceeds 17.
Parameters
uidID of the remote user whose video state changes.
stateState of the remote video. See REMOTE_VIDEO_STATE.
reasonThe reason of the remote video state change. See REMOTE_VIDEO_STATE_REASON.
elapsedTime elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

◆ onUserEnableLocalVideo()

virtual void agora::rtc::IRtcEngineEventHandler::onUserEnableLocalVideo ( uid_t  uid,
bool  enabled 
)
inlinevirtual

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

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

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

Parameters
uidUser ID of the remote user.
enabledWhether the specified remote user enables/disables the local video capturing function:
  • true: Enable. Other users in the channel can see the video of this remote user.
  • false: Disable. 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.

◆ onStreamMessage()

virtual void agora::rtc::IRtcEngineEventHandler::onStreamMessage ( uid_t  uid,
int  streamId,
const char *  data,
size_t  length 
)
inlinevirtual

Occurs when the local user receives the data stream from the remote user 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 message.
streamIdStream ID.
dataPointer to the data received by the local user.
lengthLength of the data in bytes.

◆ onStreamMessageError()

virtual void agora::rtc::IRtcEngineEventHandler::onStreamMessageError ( uid_t  uid,
int  streamId,
int  code,
int  missed,
int  cached 
)
inlinevirtual

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

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 message.
streamIdStream ID.
codeError code: ERROR_CODE_TYPE.
missedNumber of lost messages.
cachedNumber of incoming cached messages when the data stream is interrupted.

◆ onMediaEngineLoadSuccess()

virtual void agora::rtc::IRtcEngineEventHandler::onMediaEngineLoadSuccess ( )
inlinevirtual

Occurs when the media engine loads.

◆ onMediaEngineStartCallSuccess()

virtual void agora::rtc::IRtcEngineEventHandler::onMediaEngineStartCallSuccess ( )
inlinevirtual

Occurs when the media engine call starts.

◆ onUserSuperResolutionEnabled()

virtual void agora::rtc::IRtcEngineEventHandler::onUserSuperResolutionEnabled ( uid_t  uid,
bool  enabled,
SUPER_RESOLUTION_STATE_REASON  reason 
)
inlinevirtual

Reports whether the super resolution feature is successfully enabled. (beta feature)

Since
v3.5.1

After calling enableRemoteSuperResolution, the SDK triggers this callback to report whether super resolution is successfully enabled. If it is not successfully enabled, use reason for troubleshooting.

Parameters
uidThe user ID of the remote user.
enabledWhether super resolution is successfully enabled:
  • true: Super resolution is successfully enabled.
  • false: Super resolution is not successfully enabled.
reasonThe reason why super resolution is not successfully enabled or the message that confirms success. See SUPER_RESOLUTION_STATE_REASON.

◆ onVirtualBackgroundSourceEnabled()

virtual void agora::rtc::IRtcEngineEventHandler::onVirtualBackgroundSourceEnabled ( bool  enabled,
VIRTUAL_BACKGROUND_SOURCE_STATE_REASON  reason 
)
inlinevirtual

Reports whether the virtual background is successfully enabled.

Since
v3.4.5

After you call enableVirtualBackground, the SDK triggers this callback to report whether the virtual background is successfully enabled.

Note
If the background image customized in the virtual background is in PNG or JPG format, the triggering of this callback is delayed until the image is read.
Parameters
enabledWhether the virtual background is successfully enabled:
  • true: The virtual background is successfully enabled.
  • false: The virtual background is not successfully enabled.
reasonThe reason why the virtual background is not successfully enabled or the message that confirms success. See VIRTUAL_BACKGROUND_SOURCE_STATE_REASON.

◆ onSnapshotTaken()

virtual void agora::rtc::IRtcEngineEventHandler::onSnapshotTaken ( const char *  channel,
uid_t  uid,
const char *  filePath,
int  width,
int  height,
int  errCode 
)
inlinevirtual

Reports the result of taking a video snapshot.

Since
v3.5.2

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

Parameters
channelThe channel name.
uidThe user ID of the user. A uid of 0 indicates the local user.
filePathThe local path of the snapshot.
widthThe width (px) of the snapshot.
heightThe height (px) of the snapshot.
errCodeThe message that confirms success or the reason why the snapshot is not successfully taken:
  • 0: Success.
  • < 0: Failure:
    • -1: The SDK fails to write data to a file or encode a JPEG image.
    • -2: The SDK does not find the video stream of the specified user within one second after the takeSnapshot method call succeeds.

◆ onChannelMediaRelayStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged ( CHANNEL_MEDIA_RELAY_STATE  state,
CHANNEL_MEDIA_RELAY_ERROR  code 
)
inlinevirtual

Occurs when the state of the media stream relay changes.

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

Parameters
stateThe state code in CHANNEL_MEDIA_RELAY_STATE.
codeThe error code in CHANNEL_MEDIA_RELAY_ERROR.

◆ onChannelMediaRelayEvent()

virtual void agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayEvent ( CHANNEL_MEDIA_RELAY_EVENT  code)
inlinevirtual

Reports events during the media stream relay.

Parameters
codeThe event code in CHANNEL_MEDIA_RELAY_EVENT.

◆ onFirstLocalAudioFrame()

virtual void agora::rtc::IRtcEngineEventHandler::onFirstLocalAudioFrame ( int  elapsed)
inlinevirtual

Occurs when the engine sends the first local audio frame.

Deprecated:
Deprecated as of v3.1.0. Use the onFirstLocalAudioFramePublished callback instead.
Parameters
elapsedTime elapsed (ms) from the local user calling joinChannel until the SDK triggers this callback.

◆ onFirstLocalAudioFramePublished()

virtual void agora::rtc::IRtcEngineEventHandler::onFirstLocalAudioFramePublished ( int  elapsed)
inlinevirtual

Occurs when the first audio frame is published.

Since
v3.1.0

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

Parameters
elapsedThe time elapsed (ms) from the local client calling joinChannel until the SDK triggers this callback.

◆ onFirstRemoteAudioFrame()

virtual void agora::rtc::IRtcEngineEventHandler::onFirstRemoteAudioFrame ( uid_t  uid,
int  elapsed 
)
inlinevirtual

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

Deprecated:
v3.0.0

This callback is deprecated. Use onRemoteAudioStateChanged instead.

Parameters
uidUser ID of the remote user.
elapsedTime elapsed (ms) from the remote user calling joinChannel until the SDK triggers this callback.

◆ onRtmpStreamingStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged ( const char *  url,
RTMP_STREAM_PUBLISH_STATE  state,
RTMP_STREAM_PUBLISH_ERROR_TYPE  errCode 
)
inlinevirtual

Occurs when the state of the RTMP or RTMPS streaming changes.

When the CDN live streaming state changes, the SDK triggers this callback to report the current state and the reason why the state has changed.

When exceptions occur, you can troubleshoot issues by referring to the detailed error descriptions in the errCode parameter.

Parameters
urlThe CDN streaming URL.
stateThe RTMP or RTMPS streaming state. See: RTMP_STREAM_PUBLISH_STATE.
errCodeThe detailed error information for streaming. See: RTMP_STREAM_PUBLISH_ERROR_TYPE.

◆ onRtmpStreamingEvent()

virtual void agora::rtc::IRtcEngineEventHandler::onRtmpStreamingEvent ( const char *  url,
RTMP_STREAMING_EVENT  eventCode 
)
inlinevirtual

Reports events during the RTMP or RTMPS streaming.

Since
v3.1.0
Parameters
urlThe RTMP or RTMPS streaming URL.
eventCodeThe event code. See RTMP_STREAMING_EVENT

◆ onStreamPublished()

virtual void agora::rtc::IRtcEngineEventHandler::onStreamPublished ( const char *  url,
int  error 
)
inlinevirtual
Deprecated:
This method is deprecated, use theĀ onRtmpStreamingStateChanged callback instead.

Reports the result of calling the addPublishStreamUrl method. (CDN live only.)

Parameters
urlThe CDN streaming URL.
errorError code: ERROR_CODE_TYPE. Main errors include:

◆ onStreamUnpublished()

virtual void agora::rtc::IRtcEngineEventHandler::onStreamUnpublished ( const char *  url)
inlinevirtual
Deprecated:
This method is deprecated, use theĀ onRtmpStreamingStateChanged callback instead.

Reports the result of calling the removePublishStreamUrl method. (CDN live only.)

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

Parameters
urlThe CDN streaming URL.

◆ onTranscodingUpdated()

virtual void agora::rtc::IRtcEngineEventHandler::onTranscodingUpdated ( )
inlinevirtual

Occurs when the publisher's transcoding is updated.

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

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

◆ onStreamInjectedStatus()

virtual void agora::rtc::IRtcEngineEventHandler::onStreamInjectedStatus ( const char *  url,
uid_t  uid,
int  status 
)
inlinevirtual

Occurs when a voice or video stream URL address is added to the interactive live streaming.

Warning
Agora will soon stop the service for injecting online media streams on the client. If you have not implemented this service, Agora recommends that you do not use it.
Parameters
urlPointer to the URL address of the externally injected stream.
uidUser ID.
statusState of the externally injected stream: INJECT_STREAM_STATUS.

◆ onAudioRouteChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onAudioRouteChanged ( AUDIO_ROUTE_TYPE  routing)
inlinevirtual

Occurs when the local audio route changes.

Note
This callback applies to Android, iOS and macOS only.
Parameters
routingThe current audio routing. See: AUDIO_ROUTE_TYPE.

◆ onLocalPublishFallbackToAudioOnly()

virtual void agora::rtc::IRtcEngineEventHandler::onLocalPublishFallbackToAudioOnly ( bool  isFallbackOrRecover)
inlinevirtual

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

If you call setLocalPublishFallbackOption and set option as STREAM_FALLBACK_OPTION_AUDIO_ONLY, the SDK triggers this callback when the 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.

Note
If the local stream fallbacks to the audio-only stream, the remote user receives the onUserMuteVideo callback.
Parameters
isFallbackOrRecoverWhether the published stream falls back to audio-only or switches back to the video:
  • true: The published stream falls back to audio-only due to poor network conditions.
  • false: The published stream switches back to the video after the network conditions improve.

◆ onRemoteSubscribeFallbackToAudioOnly()

virtual void agora::rtc::IRtcEngineEventHandler::onRemoteSubscribeFallbackToAudioOnly ( uid_t  uid,
bool  isFallbackOrRecover 
)
inlinevirtual

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

If you call setRemoteSubscribeFallbackOption and set option as STREAM_FALLBACK_OPTION_AUDIO_ONLY, the SDK triggers this callback when the remote media stream falls back to audio-only mode due to poor downlink conditions, or when the remote media stream switches back to the video after the downlink network condition improves.

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

◆ onRemoteAudioTransportStats()

virtual void agora::rtc::IRtcEngineEventHandler::onRemoteAudioTransportStats ( uid_t  uid,
unsigned short  delay,
unsigned short  lost,
unsigned short  rxKBitRate 
)
inlinevirtual

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

Deprecated:
This callback is deprecated and replaced by the onRemoteAudioStats callback.

This callback reports the transport-layer statistics, such as the packet loss rate and network 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()

virtual void agora::rtc::IRtcEngineEventHandler::onRemoteVideoTransportStats ( uid_t  uid,
unsigned short  delay,
unsigned short  lost,
unsigned short  rxKBitRate 
)
inlinevirtual

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

Deprecated:
This callback is deprecated and replaced by the onRemoteVideoStats callback.

This callback reports the transport-layer statistics, such as the packet loss rate and network time delay, once every two seconds after the local user receives a 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.

◆ onMicrophoneEnabled()

virtual void agora::rtc::IRtcEngineEventHandler::onMicrophoneEnabled ( bool  enabled)
inlinevirtual

Occurs when the microphone is enabled/disabled.

Deprecated:
v2.9.0

The onMicrophoneEnabled 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.

◆ onConnectionStateChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onConnectionStateChanged ( CONNECTION_STATE_TYPE  state,
CONNECTION_CHANGED_REASON_TYPE  reason 
)
inlinevirtual

Occurs when the connection state between the SDK and the server changes.

Parameters
stateSee CONNECTION_STATE_TYPE.
reasonSee CONNECTION_CHANGED_REASON_TYPE.

◆ onNetworkTypeChanged()

virtual void agora::rtc::IRtcEngineEventHandler::onNetworkTypeChanged ( NETWORK_TYPE  type)
inlinevirtual

Occurs when the local network type changes.

When the network connection is interrupted, this callback indicates whether the interruption is caused by a network type change or poor network conditions.

Parameters
typeSee NETWORK_TYPE.

◆ onLocalUserRegistered()

virtual void agora::rtc::IRtcEngineEventHandler::onLocalUserRegistered ( uid_t  uid,
const char *  userAccount 
)
inlinevirtual

Occurs 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()

virtual void agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated ( uid_t  uid,
const UserInfo info 
)
inlinevirtual

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

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.
infoThe UserInfo object that contains the user ID and user account of the remote user.

◆ onScreenCaptureInfoUpdated()

virtual void agora::rtc::IRtcEngineEventHandler::onScreenCaptureInfoUpdated ( ScreenCaptureInfo info)
inlinevirtual

Occurs when the screen sharing information is updated.

Since
v3.6.1

When you call startScreenCaptureByDisplayId or startScreenCaptureByScreenRect to start screen sharing and use the excludeWindowList attribute to block the specified window, the SDK triggers this callback if the window blocking fails.

Note
This callback is for Windows only.
Parameters
infoThe screen sharing information. See ScreenCaptureInfo