Agora RTC Objective-C API Reference  Refactor
Instance Methods
<AgoraRtcEngineDelegate2> Protocol Reference

Inherits <NSObject>, and <AgoraBaseDelegate>.

Instance Methods

(void) - rtcEngine:didJoinChannel:withUid:elapsed:
 
(void) - rtcEngine:didRejoinChannel:withUid:elapsed:
 
(void) - rtcEngine:didJoinedOfUid:elapsed:
 
(void) - rtcEngine:didOfflineOfUid:reason:
 
(void) - rtcEngine:localAudioStateChanged:error:
 
(void) - rtcEngine:remoteAudioStateChangedOfUid:state:reason:elapsed:
 
(void) - rtcEngine:localVideoStateChangedOfState:error:
 
(void) - rtcEngine:remoteVideoStateChangedOfUid:state:reason:elapsed:
 
(void) - rtcEngineIntraRequestReceived:
 
(void) - rtcEngine:bandwidthEstimationUpdate:
 
(void) - rtcEngine:connectionStateChanged:reason:
 
(void) - rtcEngineRequestToken:
 
(void) - rtcEngineConnectionDidLost:
 
(void) - rtcEngine:reportRtcStats:
 
(void) - rtcEngine:lastmileProbeTestResult:
 
(void) - rtcEngine:didApiCallExecute:api:result:
 
(void) - rtcEngine:didClientRoleChanged:newRole:
 
(void) - rtcEngine:didLeaveChannelWithStats:
 
(void) - rtcEngine:firstLocalAudioFramePublished:
 
(void) - rtcEngine:localAudioStats:
 
(void) - rtcEngine:audioMixingStateChanged:errorCode:
 
(void) - rtcEngine:reportAudioVolumeIndicationOfSpeakers:totalVolume:
 
(void) - rtcEngine:remoteAudioStats:
 
(void) - rtcEngine:remoteVideoStats:
 

Method Documentation

◆ rtcEngine:didJoinChannel:withUid:elapsed:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
didJoinChannel: (NSString *_Nonnull)  channelId
withUid: (NSString *_Nonnull)  userId
elapsed: (NSInteger)  elapsed 
optional

Event of the user joined the channel.

Parameters
engineThe engine kit
channelThe channel name
userIdThe remote user id
elapsedThe elapsed time (ms) from session beginning

◆ rtcEngine:didRejoinChannel:withUid:elapsed:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
didRejoinChannel: (NSString *_Nonnull)  channelId
withUid: (NSString *_Nonnull)  userId
elapsed: (NSInteger)  elapsed 
optional

Event of the user rejoined the channel

Parameters
engineThe engine kit
channelThe channel name
userIdThe user id
elapsedThe elapsed time (ms) from session beginning

◆ rtcEngine:didJoinedOfUid:elapsed:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
didJoinedOfUid: (NSString *_Nonnull)  userId
elapsed: (NSInteger)  elapsed 
optional

Event of remote user joined

Parameters
engineThe engine kit
userIdThe remote user id
elapsedThe elapsed time(ms) from the beginning of the session.

◆ rtcEngine:didOfflineOfUid:reason:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
didOfflineOfUid: (NSString *_Nonnull)  userId
reason: (AgoraUserOfflineReason)  reason 
optional

Event of remote user offlined

Parameters
engineThe engine kit
userIdThe remote user id
reasonReason of user offline, quit, drop or became audience

◆ rtcEngine:localAudioStateChanged:error:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
localAudioStateChanged: (AgoraAudioLocalState)  state
error: (AgoraAudioLocalError)  error 
optional

This callback indicates local audio stream state has changed.

Parameters
engineThe engine kit
stateStopped: The initial state Recording: The capturer starts successfully Encoding: The first video frame is successfully encoded Failed: The local video fails to start
errorOK: The local audio is normal Failure: No specified reason for the local audio failure. DeviceNoPermission: No permission to use the local audio device DeviceBusy: The microphone is in use RecordFailure: The local audio recording fails. Check whether the recording device is working properly EncodeFailure: The local audio encoding fails

◆ rtcEngine:remoteAudioStateChangedOfUid:state:reason:elapsed:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
remoteAudioStateChangedOfUid: (NSString *_Nonnull)  userId
state: (AgoraAudioRemoteState)  state
reason: (AgoraAudioRemoteReason)  reason
elapsed: (NSInteger)  elapsed 
optional

This callback indicates remote audio stream state has changed.

Parameters
engineThe engine kit
userIdThe user id
stateStopped // The remote audio stopped, default state, audio is started or remote user disabled/muted audio stream. Starting // The first remote audio packet is received. Decoding // The remote audio stream is decoded and plays normally. Frozen // The remote audio is frozen. Failed // The remote audio fails to start.
reasonInteral // Internal reasons. NetworkCongestion // Network congestion. NetworkRecovery // Network recovery. LocalMuted // The local user stops receiving the remote audio stream or disables the audio module. LocalUnmuted // The local user resumes receiving the remote audio stream or enables the audio module. RemoteMuted // The remote user stops sending the audio stream or disables the audio module. RemoteUnmuted // The remote user resumes sending the audio stream or enables the audio module. Offline // The remote user leaves the channel.
elapsedThe elapsed time(ms) from the beginning of the session.

◆ rtcEngine:localVideoStateChangedOfState:error:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
localVideoStateChangedOfState: (AgoraVideoLocalState)  state
error: (AgoraLocalVideoStreamError)  error 
optional

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.

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
engineAgoraRtcEngineKit object
stateState type AgoraVideoLocalState. When the state is AgoraVideoLocalStateFailed (3), see the error parameter for details.
errorThe detailed error information: AgoraLocalVideoStreamError.

◆ rtcEngine:remoteVideoStateChangedOfUid:state:reason:elapsed:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
remoteVideoStateChangedOfUid: (NSString *_Nonnull)  userId
state: (AgoraVideoRemoteState)  state
reason: (AgoraVideoRemoteReason)  reason
elapsed: (NSInteger)  elapsed 
optional

This callback indicates remote video stream state has changed.

Parameters
engineThe engine kit
userIdThe user id
stateStopped // Default state, video is started or remote user disabled/muted video stream Running // Running state, remote video can be displayed normally Frozen // Remote video is frozen, probably due to network issue.
reasonInteral // Internal reasons. NetworkCongestion // Network congestion. NetworkRecovery // Network recovery. LocalMuted // The local user stops receiving the remote audio stream or disables the audio module. LocalUnmuted // The local user resumes receiving the remote audio stream or enables the audio module. RemoteMuted // The remote user stops sending the audio stream or disables the audio module. RemoteUnmuted // The remote user resumes sending the audio stream or enables the audio module. Offline // The remote user leaves the channel. AudioFallback //The remote media stream falls back to the audio-only stream due to poor network conditions. AudioFallbackRecovery // The remote media stream switches back to the video stream after the network conditions improve.
elapsedThe time elapsed (ms) from the local user calling ref "joinChannel" until this callback is triggered.

◆ rtcEngine:publishingRequestReceivedFromUid:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
publishingRequestReceivedFromUid: (NSString *_Nonnull)  userId 
optional

◆ rtcEngine:publishingRequestAnsweredByOwner:accepted:error:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
publishingRequestAnsweredByOwner: (NSString *_Nonnull)  userId
accepted: (BOOL)  accepted
error: (AgoraErrorCode)  error 
optional

◆ rtcEngine:unpublishingRequestReceivedFromOwner:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
unpublishingRequestReceivedFromOwner: (NSString *_Nonnull)  userId 
optional

◆ rtcEngineIntraRequestReceived:

- (void) rtcEngineIntraRequestReceived: (AgoraRtcEngineKit *_Nonnull)  engine
optional

Intra request received.

Parameters
engineThe AgoraRtcEngineKit object.

◆ rtcEngine:bandwidthEstimationUpdate:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
bandwidthEstimationUpdate: (AgoraNetworkInfo *_Nonnull)  networkInfo 
optional

Target bitrate updated.

Parameters
engineThe AgoraRtcEngineKit object.
networkInfoThe suggested network info, including target bitrate bps.

◆ rtcEngine:connectionStateChanged:reason:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
connectionStateChanged: (AgoraConnectionState)  state
reason: (AgoraConnectionChangedReason)  reason 
optional

Occurs when the connection state of the SDK to the server is changed.

Parameters
stateSee AgoraConnectionState.
reasonSee AgoraConnectionChangedReason.

◆ rtcEngineRequestToken:

- (void) rtcEngineRequestToken: (AgoraRtcEngineKit *_Nonnull)  engine
optionalinherited

when token is enabled, and specified token is invalid or expired, this function will be called. APP should generate a new token and call renewToken() to refresh the token. NOTE: to be compatible with previous version, ERR_TOKEN_EXPIRED and ERR_INVALID_TOKEN are also reported via onError() callback. You should move renew of token logic into this callback.

Parameters
engineThe engine kit

◆ rtcEngineConnectionDidLost:

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

Event of loss connection with server. This event is reported after the connection is interrupted and exceed the retry period (10 seconds by default). In the mean time SDK automatically tries to reconnect with the server until APP calls leaveChannel.

Parameters
engineThe engine kit

◆ rtcEngine:reportRtcStats:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
reportRtcStats: (AgoraChannelStats *_Nonnull)  stats 
optionalinherited

Statistics of rtc engine status. Updated every two seconds.

Parameters
engineThe engine kit
statsThe statistics of rtc status, including duration, sent bytes and received bytes

◆ rtcEngine:lastmileProbeTestResult:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
lastmileProbeTestResult: (AgoraLastmileProbeResult *_Nonnull)  result 
optionalinherited

Reports the last-mile network probe result.

The SDK triggers this callback within 30 seconds after the app calls the [startLastmileProbeTest]([AgoraRtcEngineKit startLastmileProbeTest:]) method.

Parameters
engineAgoraRtcEngineKit object.
resultThe uplink and downlink last-mile network probe test result, see [AgoraLastmileProbeResult](AgoraLastmileProbeResult).

◆ rtcEngine:didApiCallExecute:api:result:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
didApiCallExecute: (NSInteger)  error
api: (NSString *_Nonnull)  api
result: (NSString *_Nonnull)  result 
optionalinherited

Event of API call executed

Parameters
engineThe engine kit
apiThe API description
errorThe error code

◆ rtcEngine:didClientRoleChanged:newRole:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
didClientRoleChanged: (AgoraClientRole)  oldRole
newRole: (AgoraClientRole)  newRole 
optionalinherited

Event of cient role change. only take effect under broadcasting mode

Parameters
engineThe engine kit
oldRolethe previous role
newRolethe new role

◆ rtcEngine:didLeaveChannelWithStats:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
didLeaveChannelWithStats: (AgoraChannelStats *_Nonnull)  stats 
optionalinherited

The statistics of the call when leave channel

Parameters
engineThe engine kit
statsThe statistics of the call, including duration, sent bytes and received bytes

◆ rtcEngine:firstLocalAudioFramePublished:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
firstLocalAudioFramePublished: (NSInteger)  elapsed 
optionalinherited

Event of the first audio frame is sent.

Parameters
engineThe engine kit
elapsedThe elapsed time(ms) from the beginning of the session.

◆ rtcEngine:localAudioStats:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
localAudioStats: (AgoraRtcLocalAudioStats *_Nonnull)  stats 
optionalinherited

The statistics of the local audio stream.

Same as [localAudioStatBlock]([AgoraRtcEngineKit localAudioStatBlock:]). The SDK updates the application on the statistics of the local audio stream once every two seconds.

Parameters
engineThe AgoraRtcEngineKit object.
statsAgoraRtcLocalAudioStats

◆ rtcEngine:audioMixingStateChanged:errorCode:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
audioMixingStateChanged: (AgoraAudioMixingStateType)  state
errorCode: (AgoraAudioMixingErrorType)  errorCode 
optionalinherited

Audio mixing state changed.

Parameters
engineThe AgoraRtcEngineKit object.
stateAgoraAudioMixingStateType
errorCodeAgoraAudioMixingErrorType

◆ rtcEngine:reportAudioVolumeIndicationOfSpeakers:totalVolume:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
reportAudioVolumeIndicationOfSpeakers: (NSArray< AgoraRtcAudioVolumeInfo * > *_Nonnull)  speakers
totalVolume: (NSInteger)  totalVolume 
optionalinherited

The sdk reports the volume of a speaker. The interface is disable by default, and it could be enable by API "enableAudioVolumeIndication"

Parameters
engineThe engine kit
speakersAgoraRtcAudioVolumeInfo array
totalVolumeThe total volume of speakers

◆ rtcEngine:remoteAudioStats:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
remoteAudioStats: (AgoraRtcRemoteAudioStats *_Nonnull)  stats 
optionalinherited

The statistics of remote audio stream. Update every two seconds.

Parameters
engineThe engine kit
statsThe statistics of audio video, including user id, delay, resolution, received bitrate, received framerate, audio stream type

◆ rtcEngine:remoteVideoStats:

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

The statistics of remote video stream. Update every two seconds.

Parameters
engineThe engine kit
statsThe statistics of remote video, including user id, delay, resolution, received bitrate, received framerate, video stream type

◆ rtcEngine:streamStateChanged:state:errCode:

- (void) rtcEngine: (AgoraRtcEngineKit *_Nonnull)  engine
streamStateChanged: (NSString *_Nonnull)  url
state: (AgoraRtmpStreamPublishState)  state
errCode: (AgoraRtmpStreamPublishError)  errCode 
optionalinherited