AgoraRtcEngineDelegate Protocol 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 for details.

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

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 for details.

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 fails. If the SDK returns 0, then the SDK call was successful.

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 uid is specified in the joinChannelByToken method, the specified ID is returned. If the user ID is not specified when joinChannel is called, the server automatically assigns a uid.

elapsed

Time elapsed (ms) from the user calling joinChannelByToken until this callback is triggered.

Discussion

Same as joinSuccessBlock in the joinChannelByToken method.

Declared In

AgoraRtcEngineKit.h

– rtcEngine:didRejoinChannel:withUid:elapsed:

Occurs when a user rejoins the 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 uid is specified in the joinChannelByToken method, the specified ID is returned. If the user ID is not specified when joinChannel is called, the server automatically assigns a uid.

elapsed

Time elapsed (ms) from starting to reconnect to 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 the user leaves the 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 the user leaves the channel.

With this callback, the app retrieves information, such as the call duration and the statistics of the data received/transmitted by audioQualityOfUid.

Declared In

AgoraRtcEngineKit.h

– rtcEngine:didClientRoleChanged:newRole:

Occurs when the 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 the 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 uid is specified in the joinChannelByToken method, the specified ID is returned. If the uid is not specified in the joinChannelByToken method, the Agora server automatically assigns a uid.

elapsed

Time elapsed (ms) from the newly joined user/host calling joinChannelByToken or setClientRole until this callback is triggered.

Discussion

  • Communication channel: 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 channel: This callback notifies the app that the 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:

In the live broadcast channels:

  • The host receives the callback when another host joins the channel.
  • The audience in the channel receives the callback when a new host joins the channel.
  • When a web application joins the channel, this callback is triggered 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 the 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 the channel or goes offline.

reason

Reason why the user goes offline, see AgoraUserOfflineReason for details.

Discussion

There are two reasons for users to be 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 (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 detection, so Agora recommends using a signaling system for more reliable offline detection.

Declared In

AgoraRtcEngineKit.h

– rtcEngineConnectionDidInterrupted:

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

- (void)rtcEngineConnectionDidInterrupted:(AgoraRtcEngineKit *_Nonnull)engine

Parameters

engine

AgoraRtcEngineKit object

Discussion

This callback is triggered when the SDK loses connection with the server for more than four seconds after the connection is established.

After triggering this callback, the SDK tries reconnecting with the server. Developers can use this callback as a UI reminder.

This callback is different from rtcEngineConnectionDidLost:

  • The rtcEngineConnectionDidInterrupted callback is triggered when the SDK loses connection with the server for more than four seconds after the SDK successfully joins the channel.
  • The rtcEngineConnectionDidLost callback is triggered when the SDK loses connection with the server for more than 10 seconds, regardless of whether the SDK joins the channel or not.

For both callbacks, the SDK tries to reconnect with the server until the application calls leaveChannel.

Declared In

AgoraRtcEngineKit.h

– rtcEngineConnectionDidLost:

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

- (void)rtcEngineConnectionDidLost:(AgoraRtcEngineKit *_Nonnull)engine

Parameters

engine

AgoraRtcEngineKit object

Discussion

This callback is triggered when the SDK cannot connect with the server for 10 seconds after calling joinChannelByToken, regardless of whether the SDK is in the channel or not.

This callback is different from rtcEngineConnectionDidInterrupted:

  • The rtcEngineConnectionDidInterrupted callback is triggered when the SDK loses connection with the server for more than four seconds after the SDK successfully joins the channel.
  • The rtcEngineConnectionDidLost callback is triggered when the SDK loses connection with the server for more than 10 seconds, regardless of whether the SDK joins the channel or not.

For both callbacks, the SDK tries to reconnect with the server until the application calls leaveChannel.

Declared In

AgoraRtcEngineKit.h

– rtcEngineConnectionDidBanned:

Occurs when your connection is banned by the Agora Server.

- (void)rtcEngineConnectionDidBanned:(AgoraRtcEngineKit *_Nonnull)engine

Parameters

engine

AgoraRtcEngineKit object

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 token that expires in 30 seconds.

Discussion

The user becomes offline if the token used in joinChannelByToken expires. This callback is triggered 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 renewToken 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 joinChannelByToken, if the SDK losses connection with the Agora server due to network issues, the token may expire after a certain period of time and a new token may be required to reconnect to the server.

This callback notifies the application to generate a new token. Call renewToken to renew the token.

In previous SDKs, this notification was provided in the didOccurError callback as the AgoraErrorCodeTokenExpired(-109), AgoraErrorCodeInvalidToken(-110) errors. Starting from v1.7.3, the old method is still valid, but it is recommended to use this callback.

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:

  • YES: Enabled.
  • NO: Disabled.

Declared In

AgoraRtcEngineKit.h

– rtcEngine:reportAudioVolumeIndicationOfSpeakers:totalVolume:

Reports which users are speaking and the speakers' volume.

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

  • uid: User ID of the speaker.
  • volume: Volume of the speaker. The value ranges between 0 (lowest volume) and 255 (highest volume).
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 contains a uid 0 and a volume that equals to the totalVolume.
  • In the remote speakers' callback, the speakers array contains the user ID and volume of each speaker.

Note:

  • Calling muteLocalAudioStream affects the behavior of the SDK:
    • If the local user calls muteLocalAudioStream, the SDK stops returning the local user’s callback immediately.
    • If a remote speaker calls muteLocalAudioStream, the remote speakers' callback excludes this user after 15 seconds; if all the remote users call muteLocalAudioStream, the SDK stops returning the remote speakers' callback after 15 seconds.
  • 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.

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine activeSpeaker:(NSUInteger)speakerUid

Parameters

engine

AgoraRtcEngineKit object.

speakerUid

The user ID of the active speaker. A speakerUid of 0 represents the local user.

Discussion

If the user enables the audio volume indication by calling enableAudioVolumeIndication, 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 enableAudioVolumeIndication.
  • This callback returns the user ID of the user with the highest voice volume during a period of time, instead of at the moment.

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 joinChannelByToken until this callback is triggered.

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 joinChannelByToken until this callback is triggered.

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, displaying other pictures 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 joinChannelByToken until this callback is triggered.

If startPreview is called before joinChannelByToken, then elapsed is the time elapsed from startPreview until this callback is triggered.

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 joinChannelByToken until this callback is triggered.

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 joinChannelByToken until this callback is triggered.

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:

  • YES: Muted.
  • NO: 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:

  • YES: Pause.
  • NO: Resume.
uid

User ID of the remote user.

Discussion

Note:

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:

  • YES: Enable. The remote user can enter a video session.
  • NO: Disable. The remote user can only enter a voice session, and cannot send or receive any video stream.
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:

  • YES: Enabled. Other users in the channel can see the video of this remote user.
  • NO: Disabled. Other users in the channel do not receive the video stream from this remote user, while this remote user can still receive the video streams from other users.
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 (0 to 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 for details.

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 media 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:

  • YES: The published stream falls back to audio-only due to unreliable network conditions.
  • NO: The published stream switches back to the video after the network conditions improve.

Discussion

If you call setLocalPublishFallbackOption and set option as AgoraStreamFallbackOptionAudioOnly, this callback is triggered 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 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 media 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:

  • YES: The remote media stream falls back to audio-only due to unreliable network conditions.
  • NO: The remote media stream switches back to the video stream after the network conditions improve.
uid

ID of the remote user sending the stream.

Discussion

If you call setRemoteSubscribeFallbackOption and set option to AgoraStreamFallbackOptionAudioOnly, this callback is triggered 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 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:

  • 0: Added.
  • 1: Removed.

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

This callback returns that 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

Statistics Delegate Methods

– rtcEngine:audioQualityOfUid:quality:delay:lost:

Reports the audio quality of the current call once every two seconds. Same as audioQualityBlock.

- (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: AgoraNetworkQuality

delay

Time delay (ms).

lost

Audio packet loss rate (%).

Declared In

AgoraRtcEngineKit.h

– 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 after enableLastmileTest is called.

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine lastmileQuality:(AgoraNetworkQuality)quality

Parameters

engine

AgoraRtcEngineKit object

quality

Network quality: AgoraNetworkQuality

Declared In

AgoraRtcEngineKit.h

– rtcEngine:networkQuality:txQuality:rxQuality:

Reports the network quality of each user 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 uid is reported. If uid is 0, the local network quality is reported.

txQuality

Transmission quality of the user: AgoraNetworkQuality.

rxQuality

Receiving quality of the user: AgoraNetworkQuality.

Discussion

The Agora SDK returns this callback to report on the uplink and downlink network conditions of each user in the channel.

Declared In

AgoraRtcEngineKit.h

– rtcEngine:localVideoStats:

Reports the statistics of the uploading local video streams once every two seconds. Same as localVideoStatBlock.

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localVideoStats:(AgoraRtcLocalVideoStats *_Nonnull)stats

Parameters

engine

AgoraRtcEngineKit object.

stats

Statistics of the uploading local video streams: AgoraRtcLocalVideoStats.

Declared In

AgoraRtcEngineKit.h

– rtcEngine:remoteVideoStats:

Reports the statistics of the receiving remote video streams sent from each user/host once every two seconds.

- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStats:(AgoraRtcRemoteVideoStats *_Nonnull)stats

Parameters

engine

AgoraRtcEngineKit object.

stats

Statistics of the receiving remote video streams: AgoraRtcRemoteVideoStats.

Discussion

If there are multiple remote users/hosts, this callback is triggered multiple times once every two seconds.

Declared In

AgoraRtcEngineKit.h

– rtcEngine:audioTransportStatsOfUid:delay:lost:rxKBitRate:

Reports the statistics of the remote audio transmission once every two seconds after the user receives the audio data packet from a remote user.

- (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 data packet.

delay

Time delay (ms) from the remote user to the local client.

lost

Packet loss rate (%).

rxKBitRate

Received audio bitrate (Kbps) of the data packet from the remote user.

Declared In

AgoraRtcEngineKit.h

– rtcEngine:videoTransportStatsOfUid:delay:lost:rxKBitRate:

Reports the statistics of the remote video transmission once every two seconds after the user receives the video data packet from a remote user.

- (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 data packet.

delay

Time delay (ms) from the remote user to the local client.

lost

Packet loss rate (%).

rxKBitRate

Received video bitrate (Kbps) of the data packet from the remote user.

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

This callback is triggered when a remote user calls startAudioMixing.

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

RTMP URL address, to which the publisher publishes the stream.

errorCode

Error code: AgoraErrorCode. Main errors include:

  • AgoraErrorCodeNoError(0): The publishing succeeded.
  • AgoraErrorCodeFailed(1): The publishing failed.
  • AgoraErrorCodeInvalidArgument(2): Invalid argument used. If, for example, you do not call setLiveTranscoding to configure AgoraLiveTranscoding before calling addPublishStreamUrl, the SDK reports this error.
  • AgoraErrorCodeTimedOut(10): The publishing timed out.
  • AgoraErrorCodeAlreadyInUse(19): The chosen RTMP URL address is already in use for CDN live streaming.
  • AgoraErrorCodeAbort(20): The SDK is disconnected from the CDN streaming server, and the CDN live streaming stops.
  • AgoraErrorCodeResourceLimited(22): The backend system does not have enough resources for the CDN live streaming.
  • AgoraErrorCodeEncryptedStreamNotAllowedPublish(130): You cannot publish an encrypted stream.

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

RTMP URL address, from which the publisher unpublished the stream.

Discussion

This callback notifies the host that the CDN live stream is unpublished.

Declared In

AgoraRtcEngineKit.h

– rtcEngineTranscodingUpdated:

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 HTTP/HTTPS 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

HTTP/HTTPS 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 is loaded.

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

X
Is this page helpful?