AgoraRtcEngineDelegate Category Reference
Conforms to | NSObject |
---|---|
Declared in | AgoraRtcEngineKit.h |
Overview
The AgoraRtcEngineDelegate protocol enables callbacks to your app.
The SDK uses delegate callbacks in the AgoraRtcEngineDelegate protocol to report runtime events to the app. From v1.1, some block callbacks in the SDK are replaced with delegate callbacks. The old block callbacks are therefore deprecated, but can still be used in the current version. However, Agora recommends replacing block callbacks with delegate callbacks. The SDK calls the block callback if a callback is defined in both the block and delegate callbacks.
Core Delegate Methods
– rtcEngine:didOccurWarning:
Reports a warning during SDK runtime.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurWarning:(AgoraWarningCode)warningCode
Parameters
engine |
AgoraRtcEngineKit object |
---|---|
warningCode |
Warning code: AgoraWarningCode |
Discussion
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 an AgoraWarningCodeOpenChannelTimeout(106) warning upon disconnection from the server and attempts to reconnect.
See AgoraWarningCode.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didOccurError:
Reports an error during SDK runtime.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurError:(AgoraErrorCode)errorCode
Parameters
engine |
AgoraRtcEngineKit object |
---|---|
errorCode |
Error code: AgoraErrorCode |
Discussion
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 AgoraErrorCodeStartCall = 1002 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.
See AgoraErrorCode.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didApiCallExecute:api:result:
Occurs when a method is executed by the SDK.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didApiCallExecute:(NSInteger)error api:(NSString *_Nonnull)api result:(NSString *_Nonnull)result
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
error |
The error code (AgoraErrorCode) returned by the SDK when the method call fails. If the SDK returns 0, then the method call succeeds. |
api |
The method executed by the SDK. |
result |
The result of the method call. |
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didJoinChannel:withUid:elapsed:
Occurs when a user joins a specified channel.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didJoinChannel:(NSString *_Nonnull)channel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
channel |
Channel name. |
uid |
User ID. If the |
elapsed |
Time elapsed (ms) from the user calling the joinChannelByToken method until the SDK triggers this callback. |
Discussion
Same as joinSuccessBlock
in the joinChannelByToken method.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didRejoinChannel:withUid:elapsed:
Occurs when a user rejoins a channel.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didRejoinChannel:(NSString *_Nonnull)channel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
channel |
Channel name. |
uid |
User ID. If the |
elapsed |
Time elapsed (ms) from starting to reconnect to a successful reconnection. |
Discussion
If the client loses connection with the server because of network problems, the SDK automatically attempts to reconnect and then triggers this callback upon reconnection, indicating that the user rejoins the channel with the assigned channel ID and user ID.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didLeaveChannelWithStats:
Occurs when a user leaves a channel.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLeaveChannelWithStats:(AgoraChannelStats *_Nonnull)stats
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
stats |
Statistics of the call: AgoraChannelStats. |
Discussion
When the app calls the leaveChannel method, this callback notifies the app that a user leaves a channel.
With this callback, the app retrieves information, such as the call duration and the statistics of the received/transmitted data reported by the audioQualityOfUid callback.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didClientRoleChanged:newRole:
Occurs when a user role switches in a live broadcast. For example, from a host to an audience or vice versa.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didClientRoleChanged:(AgoraClientRole)oldRole newRole:(AgoraClientRole)newRole
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
oldRole |
Role that the user switches from: AgoraClientRole. |
newRole |
Role that the user switches to: AgoraClientRole. |
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didJoinedOfUid:elapsed:
Occurs when a user or host joins a channel. Same as userJoinedBlock.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didJoinedOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
ID of the user or host who joins the channel. If the |
elapsed |
Time elapsed (ms) from the newly joined user/host calling the joinChannelByToken or setClientRole method until the SDK triggers this callback. |
Discussion
- Communication profile: This callback notifies the app that another user joins the channel. If other users are already in the channel, the SDK also reports to the app on the existing users.
- Live-broadcast profile: This callback notifies the app that a host joins the channel. If other hosts are already in the channel, the SDK also reports to the app on the existing hosts. Agora recommends limiting the number of hosts to 17.
Note:
Live-broadcast 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.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didOfflineOfUid:reason:
Occurs when a remote user (Communication)/host (Live Broadcast) leaves a channel. Same as userOfflineBlock.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOfflineOfUid:(NSUInteger)uid reason:(AgoraUserOfflineReason)reason
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
ID of the user or host who leaves a channel or goes offline. |
reason |
Reason why the user goes offline, see AgoraUserOfflineReason. |
Discussion
There are two reasons for users to be offline:
- Leave a channel: When the user/host leaves a channel, the user/host sends a goodbye message. When the message is received, the SDK assumes that the user/host leaves a channel.
- Drop offline: When no data packet of the user or host is received for a certain period of time (20 seconds for the Communication profile, and more for the Live-broadcast profile), the SDK assumes that the user/host drops offline. Unreliable network connections may lead to false detections, so Agora recommends using a signaling system for more reliable offline detection.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:connectionChangedToState:reason:
Occurs when the network connection state changes.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine connectionChangedToState:(AgoraConnectionStateType)state reason:(AgoraConnectionChangedReason)reason
Parameters
state |
The current network connection state, see AgoraConnectionStateType. |
---|---|
reason |
The reason of the connection state change, see AgoraConnectionChangedReason. |
Discussion
The Agora SDK triggers this callback to report on the current network connection state when it changes, and the reason of the change.
Declared In
AgoraRtcEngineKit.h
– rtcEngineConnectionDidLost:
Occurs when the SDK cannot reconnect to Agora’s edge server 10 seconds after its connection to the server is interrupted.
- (void)rtcEngineConnectionDidLost:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Discussion
The Agora SDK triggers this callback when it cannot connect to the server 10 seconds after calling the joinChannelByToken method, regardless of whether it is in the channel or not.
This callback is different from rtcEngineConnectionDidInterrupted:
- The SDK triggers the rtcEngineConnectionDidInterrupted callback when it loses connection with the server for more than four seconds after it successfully joins the channel.
- The SDK triggers the rtcEngineConnectionDidLost callback when it loses connection with the server for more than 10 seconds, regardless of whether it joins the channel or not.
For both callbacks, the SDK tries to reconnect to the server until the app calls the leaveChannel method.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:tokenPrivilegeWillExpire:
Occurs when the token expires in 30 seconds.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine tokenPrivilegeWillExpire:(NSString *_Nonnull)token
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
token |
The |
Discussion
The user becomes offline if the token
used in the joinChannelByToken method expires. The SDK triggers this callback 30 seconds before the token
expires to remind the app 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.
Declared In
AgoraRtcEngineKit.h
– rtcEngineRequestToken:
Occurs when the token expires.
- (void)rtcEngineRequestToken:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Discussion
After a token
is specified by calling the joinChannelByToken method, if the SDK losses connection to 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.
Th SDK triggers this callback to notify the app to generate a new token
. Call the renewToken method to renew the token
.
In previous SDKs, this notification was provided in the didOccurError callback as the AgoraErrorCodeTokenExpired(-109), AgoraErrorCodeInvalidToken(-110) errors. From v1.7.3, the old method is still valid, but Agora recommends using this callback instead.
Declared In
AgoraRtcEngineKit.h
Media Delegate Methods
– rtcEngine:didMicrophoneEnabled:
Occurs when the microphone is enabled/disabled.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didMicrophoneEnabled:(BOOL)enabled
Parameters
enabled |
Whether the microphone is enabled/disabled:
|
---|
Declared In
AgoraRtcEngineKit.h
– rtcEngine:reportAudioVolumeIndicationOfSpeakers:totalVolume:
Reports which users are speaking and the speakers' volume at the moment.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo*> *_Nonnull)speakers totalVolume:(NSInteger)totalVolume
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
speakers |
An array containing the user ID and volume information for each speaker: AgoraRtcAudioVolumeInfo.
|
totalVolume |
Total volume of all speakers. The value ranges between 0 (lowest volume) and 255 (highest volume). |
Discussion
Same as audioVolumeIndicationBlock.
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 and the remote speakers are reported in separate callbacks:
- In the local user’s callback, the
speakers
array containsuid
= 0 andvolume
=totalVolume
regardless of whether the local user speaks or not. - In the remote speakers' callback, the
speakers
array contains the user ID and volume of each speaker.
Note:
- Calling the muteLocalAudioStream method affects the behavior of the SDK:
- If the local user calls the muteLocalAudioStream method, the SDK stops returning the local user’s callback immediately.
- 15 seconds after a remote speaker calls the muteLocalAudioStream method, the remote speakers' callback excludes information of this user; 15 seconds after all remote users call the muteLocalAudioStream method, the SDK stops triggering the remote speakers' callback.
- An empty
speakers
array in the callback indicates that no remote user is speaking at the moment.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:activeSpeaker:
Reports which user is the loudest speaker over a period of time.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine activeSpeaker:(NSUInteger)speakerUid
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
speakerUid |
The user ID of the active speaker. A |
Discussion
If the user enables the audio volume indication by calling the enableAudioVolumeIndication method, this callback returns the user ID of the active speaker whose voice is detected by the audio volume detection module of the SDK.
Note:
- To receive this callback, you need to call the enableAudioVolumeIndication method.
- This callback returns the user ID of the user with the highest voice volume during a period of time, instead of at the moment.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:firstLocalAudioFrame:
Occurs when the engine sends the first local audio frame.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstLocalAudioFrame:(NSInteger)elapsed
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
elapsed |
Time elapsed (ms) from the local user calling the joinChannelByToken method until the SDK triggers this callback. |
Declared In
AgoraRtcEngineKit.h
– rtcEngine:firstRemoteAudioFrameOfUid:elapsed:
Occurs when the engine receives the first audio frame from a specified remote user.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteAudioFrameOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID of the remote user. |
elapsed |
Time elapsed (ms) from the remote user calling the joinChannelByToken method until the SDK triggers this callback. |
Declared In
AgoraRtcEngineKit.h
– rtcEngineVideoDidStop:
Occurs when the video stops playing.
- (void)rtcEngineVideoDidStop:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Discussion
The app can use this callback to change the configuration of the view (for example, to display other screens in the view) after the video stops.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:firstLocalVideoFrameWithSize:elapsed:
Occurs when the engine sends the first local video frame.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstLocalVideoFrameWithSize:(CGSize)size elapsed:(NSInteger)elapsed
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
size |
Size of the first local video frame (width and height). |
elapsed |
Time elapsed (ms) from the local user calling the joinChannelByToken method until the SDK calls this callback. If the startPreview method is called before the joinChannelByToken method, then |
Discussion
Same as firstLocalVideoFrameBlock.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:firstRemoteVideoDecodedOfUid:size:elapsed:
Occurs when the engine decodes the first video frame from a specified remote user.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoDecodedOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID of the remote user sending the video stream. |
size |
Size of the video frame (width and height). |
elapsed |
Time elapsed (ms) from the remote user calling the joinChannelByToken method until the SDK triggers this callback. |
Discussion
Same as firstRemoteVideoDecodedBlock.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:firstRemoteVideoFrameOfUid:size:elapsed:
Occurs when the first remote video frame is rendered.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine firstRemoteVideoFrameOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID of the remote user sending the video stream. |
size |
Size of the video frame (width and height). |
elapsed |
Time elapsed (ms) from the remote user calling the joinChannelByToken method until the SDK triggers this callback. |
Discussion
Same as firstRemoteVideoFrameBlock.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didAudioMuted:byUid:
Occurs when a remote user’s audio stream is muted/unmuted.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didAudioMuted:(BOOL)muted byUid:(NSUInteger)uid
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
muted |
Whether the remote user’s audio stream is muted/unmuted:
|
uid |
ID of the remote user. |
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didVideoMuted:byUid:
Occurs when a remote user’s video stream playback pauses/resumes. Same as userMuteVideoBlock.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoMuted:(BOOL)muted byUid:(NSUInteger)uid
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
muted |
A remote user’s video stream playback pauses/resumes:
|
uid |
User ID of the remote user. |
Discussion
Note:
This method is invalid when the number of users in a channel exceeds 20.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didVideoEnabled:byUid:
Occurs when a specific remote user enables/disables the video module.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoEnabled:(BOOL)enabled byUid:(NSUInteger)uid
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
enabled |
Whether the remote user enables/disables the video module:
|
uid |
User ID of the remote user. |
Discussion
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.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didLocalVideoEnabled:byUid:
Occurs when a specific remote user enables/disables the local video capturing function.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLocalVideoEnabled:(BOOL)enabled byUid:(NSUInteger)uid
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
enabled |
Whether the specific remote user enables/disables the local video capturing function:
|
uid |
User ID of the remote user. |
Discussion
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.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:videoSizeChangedOfUid:size:rotation:
Occurs when the video size or rotation of a specific remote user changes.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoSizeChangedOfUid:(NSUInteger)uid size:(CGSize)size rotation:(NSInteger)rotation
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID of the remote user or local user (0) whose video size or rotation changes. |
size |
New video size. |
rotation |
New rotation of the video. The value ranges between 0 and 360. |
Declared In
AgoraRtcEngineKit.h
– rtcEngine:remoteVideoStateChangedOfUid:state:
Occurs when the remote video stream state changes.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStateChangedOfUid:(NSUInteger)uid state:(AgoraVideoRemoteState)state
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
ID of the user whose video state changes. |
state |
State of the remote video: Stopped playing, playing normally, or frozen. See AgoraVideoRemoteState. |
Discussion
This callback is triggered when the time interval between two video frames equals or exceeds 600 ms.
Declared In
AgoraRtcEngineKit.h
Fallback Delegate Methods
– rtcEngine:didLocalPublishFallbackToAudioOnly:
Occurs when the published video stream falls back to an audio-only stream due to unreliable network conditions or switches back to the video when the network conditions improve.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didLocalPublishFallbackToAudioOnly:(BOOL)isFallbackOrRecover
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
isFallbackOrRecover |
Whether the published stream falls back to audio-only or switches back to the video:
|
Discussion
If you call the setLocalPublishFallbackOption method and set option
as AgoraStreamFallbackOptionAudioOnly, the SDK triggers this callback when the published stream falls back to audio-only mode due to unreliable uplink conditions, or when the audio stream switches back to the video when the uplink network condition improves.
Note:
Once the published stream falls back to audio only, the remote app receives the userMuteVideoBlock callback.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didRemoteSubscribeFallbackToAudioOnly:byUid:
Occurs when the remote video stream falls back to an audio-only stream due to unreliable network conditions or switches back to the video after the network conditions improve.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didRemoteSubscribeFallbackToAudioOnly:(BOOL)isFallbackOrRecover byUid:(NSUInteger)uid
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
isFallbackOrRecover |
Whether the remote media stream falls back to audio-only or switches back to the video:
|
uid |
ID of the remote user sending the stream. |
Discussion
If you call setRemoteSubscribeFallbackOption and set option
as AgoraStreamFallbackOptionAudioOnly
, the SDK triggers this callback when the remote media stream falls back to audio only due to unreliable network conditions or switches back to the video after the network condition improves.
Note:
Once the remote media stream is switched to the low stream due to unreliable network conditions, you can monitor the stream switch between a high stream and low stream in the remoteVideoStats callback.
Declared In
AgoraRtcEngineKit.h
Device Delegate Methods
– rtcEngine:device:type:stateChanged:
Occurs when the device state changes. (macOS only.)
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine device:(NSString *_Nonnull)deviceId type:(AgoraMediaDeviceType)deviceType stateChanged:(NSInteger)state
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
deviceId |
Device ID. |
deviceType |
Device type: AgoraMediaDeviceType. |
state |
State of the device:
|
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didAudioRouteChanged:
Occurs when the local audio route changes.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didAudioRouteChanged:(AgoraAudioOutputRouting)routing
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
routing |
Audio route: AgoraAudioOutputRouting. |
Discussion
The SDK triggers this callback when the local audio route switches to an earpiece, speakerphone, headset, or Bluetooth device.
Declared In
AgoraRtcEngineKit.h
– rtcEngineCameraDidReady:
Occurs when the camera turns on and is ready to capture video.
- (void)rtcEngineCameraDidReady:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Discussion
Same as cameraReadyBlock.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:cameraFocusDidChangedToRect:
Occurs when a camera focus area changes. (iOS only.)
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine cameraFocusDidChangedToRect:(CGRect)rect
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
rect |
Rectangular area in the camera zoom specifying the focus area. |
Declared In
AgoraRtcEngineKit.h
– rtcEngine:cameraExposureDidChangedToRect:
Occurs when the camera exposure area changes. (iOS only)
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine cameraExposureDidChangedToRect:(CGRect)rect
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
rect |
Rectangular area in the camera zoom specifying the exposure area. |
Declared In
AgoraRtcEngineKit.h
Statistics Delegate Methods
– rtcEngine:reportRtcStats:
Reports the statistics of the current call session once every two seconds.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportRtcStats:(AgoraChannelStats *_Nonnull)stats
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
stats |
RTC engine statistics: AgoraChannelStats. |
Discussion
Same as rtcStatsBlock.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:lastmileQuality:
Reports the last mile network quality of the local user once every two seconds before the user joins a channel.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine lastmileQuality:(AgoraNetworkQuality)quality
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
quality |
The last mile network quality based on the uplink and dowlink packet loss rate and jitter. See AgoraNetworkQuality. |
Discussion
Last mile refers to the connection between the local device and Agora’s edge server. After the app calls the enableLastmileTest method, the SDK triggers this callback once every two seconds to report the uplink and downlink last mile network conditions of the local user before the user joins the channel.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:networkQuality:txQuality:rxQuality:
Reports the last mile network quality of each user in the channel once every two seconds.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine networkQuality:(NSUInteger)uid txQuality:(AgoraNetworkQuality)txQuality rxQuality:(AgoraNetworkQuality)rxQuality
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID. The network quality of the user with this |
txQuality |
Uplink transmission quality of the user in terms of the transmission bitrate, packet loss rate, average RTT (Round-Trip Time), and jitter of the uplink network. |
rxQuality |
Downlink network quality rating of the user in terms of packet loss rate, average RTT, and jitter of the downlink network. See AgoraNetworkQuality. |
Discussion
Last mile refers to the connection between the local device and Agora’s edge server. The SDK triggers this callback once every two seconds to report the uplink last mile network conditions of each user in the channel. If a channel includes multiple users, the SDK triggers this callback as many times.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:localVideoStats:
Reports the statistics of the uploading local video streams once every two seconds.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localVideoStats:(AgoraRtcLocalVideoStats *_Nonnull)stats
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
stats |
Statistics of the uploading local video streams. See AgoraRtcLocalVideoStats. |
Discussion
Same as localVideoStatBlock.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:remoteVideoStats:
Reports the statistics of the video stream from each remote user/host.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStats:(AgoraRtcRemoteVideoStats *_Nonnull)stats
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
stats |
Statistics of the received remote video streams. See AgoraRtcRemoteVideoStats. |
Discussion
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.
This callback reports the statistics more closely linked to the real-user experience of the video transmission quality than the statistics that the videoTransportStatsOfUid callback reports. This callback reports more about media layer statistics such as the frame loss rate, while the videoTransportStatsOfUid callback reports more about the transport layer statistics such as the packet loss rate.
Schemes such as FEC (Forward Error Correction) or retransmission counter the frame loss rate. Hence, users may find the overall video quality acceptable even when the packet loss rate is high.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:remoteAudioStats:
Reports the statistics of the audio stream from each remote user/host.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteAudioStats:(AgoraRtcRemoteAudioStats *_Nonnull)stats
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
stats |
Statistics of the received remote audio streams. See AgoraRtcRemoteAudioStats. |
Discussion
This callback replaces the audioQualityOfUid 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.
This callback reports the statistics more closely linked to the real-user experience of the audio transmission quality than the statistics that the audioTransportStatsOfUid callback reports. This callback reports more about media layer statistics such as the frame loss rate, while the audioTransportStatsOfUid callback reports more about the transport layer statistics such as the packet loss rate.
Schemes such as FEC (Forward Error Correction) or retransmission counter the frame loss rate. Hence, users may find the overall audio quality acceptable even when the packet loss rate is high.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:audioTransportStatsOfUid:delay:lost:rxKBitRate:
Reports the transport-layer statistics of each remote audio stream.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine audioTransportStatsOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost rxKBitRate:(NSUInteger)rxKBitRate
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID of the remote user sending the audio packet. |
delay |
Network time delay (ms) from the remote user sending the audio packet to the local user. |
lost |
Packet loss rate (%) of the audio packet sent from the remote user. |
rxKBitRate |
Received bitrate (Kbps) of the audio packet sent from the remote user. |
Discussion
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.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:videoTransportStatsOfUid:delay:lost:rxKBitRate:
Reports the transport-layer statistics of each remote video stream.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine videoTransportStatsOfUid:(NSUInteger)uid delay:(NSUInteger)delay lost:(NSUInteger)lost rxKBitRate:(NSUInteger)rxKBitRate
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID of the remote user sending the video packet. |
delay |
Network time delay (ms) from the remote user sending the video packet to the local user. |
lost |
Packet loss rate (%) of the video packet sent from the remote user. |
rxKBitRate |
Received bitrate (Kbps) of the video packet sent from the remote user. |
Discussion
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.
Declared In
AgoraRtcEngineKit.h
Audio Player Delegate Methods
– rtcEngineLocalAudioMixingDidFinish:
Occurs when the audio mixing file playback finishes.
- (void)rtcEngineLocalAudioMixingDidFinish:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Discussion
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, a warning code, AgoraWarningCodeAudioMixingOpenError, returns in the didOccurWarning callback.
Declared In
AgoraRtcEngineKit.h
– rtcEngineRemoteAudioMixingDidStart:
Occurs when a remote user starts audio mixing.
- (void)rtcEngineRemoteAudioMixingDidStart:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Discussion
The SDK triggers this callback when a remote user calls the startAudioMixing method.
Declared In
AgoraRtcEngineKit.h
– rtcEngineRemoteAudioMixingDidFinish:
Occurs when a remote user finishes audio mixing.
- (void)rtcEngineRemoteAudioMixingDidFinish:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Declared In
AgoraRtcEngineKit.h
– rtcEngineDidAudioEffectFinish:soundId:
Occurs when the local audio effect playback finishes.
- (void)rtcEngineDidAudioEffectFinish:(AgoraRtcEngineKit *_Nonnull)engine soundId:(NSInteger)soundId
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
soundId |
ID of the local audio effect. Each local audio effect has a unique ID. |
Discussion
You can start a local audio effect playback by calling the playEffect method. The SDK triggers this callback when the local audio effect file playback finishes.
Declared In
AgoraRtcEngineKit.h
CDN Live Streaming Delegate Methods
– rtcEngine:streamPublishedWithUrl:errorCode:
Occurs when a stream is published. (CDN live only.)
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamPublishedWithUrl:(NSString *_Nonnull)url errorCode:(AgoraErrorCode)errorCode
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
url |
URL address, to which the publisher publishes the stream. |
errorCode |
Error code: AgoraErrorCode. Main errors include:
|
Declared In
AgoraRtcEngineKit.h
– rtcEngine:streamUnpublishedWithUrl:
Occurs when a stream is unpublished. (CDN live only.)
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamUnpublishedWithUrl:(NSString *_Nonnull)url
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
url |
URL address, from which the publisher unpublishes the stream. |
Discussion
This callback notifies the host that the CDN live stream is unpublished.
Declared In
AgoraRtcEngineKit.h
– rtcEngineTranscodingUpdated:
Occurs when the CDN live streaming settings are updated.
- (void)rtcEngineTranscodingUpdated:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Declared In
AgoraRtcEngineKit.h
Inject Online Stream Delegate Methods
– rtcEngine:streamInjectedStatusOfUrl:uid:status:
Occurs when a voice or video stream URL address is added to a live broadcast.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamInjectedStatusOfUrl:(NSString *_Nonnull)url uid:(NSUInteger)uid status:(AgoraInjectStreamStatus)status
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
url |
URL address of the externally injected stream. |
uid |
User ID. |
status |
State of the externally injected stream. See AgoraInjectStreamStatus. |
Declared In
AgoraRtcEngineKit.h
Stream Message Delegate Methods
– rtcEngine:receiveStreamMessageFromUid:streamId:data:
Occurs when the local user receives the data stream from a remote user within five seconds.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine receiveStreamMessageFromUid:(NSUInteger)uid streamId:(NSInteger)streamId data:(NSData *_Nonnull)data
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID of the remote user sending the message. |
streamId |
Stream ID. |
data |
Data received by the local user. |
Declared In
AgoraRtcEngineKit.h
– rtcEngine:didOccurStreamMessageErrorFromUid:streamId:error:missed:cached:
Occurs when the local user does not receive the data stream from the remote user within five seconds.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurStreamMessageErrorFromUid:(NSUInteger)uid streamId:(NSInteger)streamId error:(NSInteger)error missed:(NSInteger)missed cached:(NSInteger)cached
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID of the remote user sending the message. |
streamId |
Stream ID. |
error |
Error code. See AgoraErrorCode. |
missed |
Number of lost messages. |
cached |
Number of incoming cached messages when the data stream is interrupted. |
Declared In
AgoraRtcEngineKit.h
Miscellaneous Delegate Methods
– rtcEngineMediaEngineDidLoaded:
Occurs when the media engine loads.
- (void)rtcEngineMediaEngineDidLoaded:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Declared In
AgoraRtcEngineKit.h
– rtcEngineMediaEngineDidStartCall:
Occurs when the media engine call starts.
- (void)rtcEngineMediaEngineDidStartCall:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Declared In
AgoraRtcEngineKit.h
Deprecated Delegates
– rtcEngineConnectionDidInterrupted:
Occurs when the connection between the SDK and the server is interrupted.
- (void)rtcEngineConnectionDidInterrupted:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object. |
---|
Discussion
DEPRECATED from v2.3.2. Use the connectionChangedToState callback instead.
The SDK triggers this callback when it loses connection with the server for more than four seconds after a 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 rtcEngineConnectionDidLost:
- The SDK triggers the rtcEngineConnectionDidInterrupted callback when it loses connection with the server for more than four seconds after it joins the channel.
- The SDK triggers the rtcEngineConnectionDidLost callback when it loses connection with the server for more than 10 seconds, regardless of whether it joins the channel or not.
Whichever callback the SDK triggers, it tries reconnecting to the server until the app calls the leaveChannel method.
Declared In
AgoraRtcEngineKit.h
– rtcEngineConnectionDidBanned:
Occurs when your connection is banned by the Agora server.
- (void)rtcEngineConnectionDidBanned:(AgoraRtcEngineKit *_Nonnull)engine
Parameters
engine |
AgoraRtcEngineKit object |
---|
Discussion
DEPRECATED from v2.3.2. Use connectionChangedToState instead.
Declared In
AgoraRtcEngineKit.h
– rtcEngine:audioQualityOfUid:quality:delay:lost:
Reports the audio quality of the remote user.
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine audioQualityOfUid:(NSUInteger)uid quality:(AgoraNetworkQuality)quality delay:(NSUInteger)delay lost:(NSUInteger)lost
Parameters
engine |
AgoraRtcEngineKit object. |
---|---|
uid |
User ID of the speaker. |
quality |
Audio quality of the user, see AgoraNetworkQuality. |
delay |
Time delay (ms) of the audio packet sent from the sender to the receiver, including the time delay from audio sampling pre-processing, transmission, and the jitter buffer. |
lost |
Packet loss rate (%) of the audio packet sent from the sender to the receiver. |
Discussion
Same as audioQualityBlock.
DEPRECATED from v2.3.2. Use remoteAudioStats instead.
The SDK triggers this callback once every two seconds. This callback reports the audio quality of each remote user/host sending an audio stream. If a channel has multiple users/hosts sending audio streams, then the SDK triggers this callback as many times.
See Also
Declared In
AgoraRtcEngineKit.h