Agora RTC Objective-C API Reference Refactor

Instance Methods
<AgoraBaseDelegate> Protocol Reference

Inherits <NSObject>.

Inherited by <AgoraRtcEngineDelegate2>.

## Instance Methods
(void) | - rtcEngine:didLocalUserRegisteredWithUserId:userAccount:
(void) | - rtcEngine:didUserInfoUpdatedWithUserId:userInfo:
(void) | - rtcEngineRequestToken:
(void) | - rtcEngineConnectionDidLost:
(void) | - rtcEngine:reportRtcStats:
(void) | - rtcEngine:lastmileProbeTestResult:
(void) | - rtcEngine:uploadLogResultRequestId:success:reason:
(void) | - rtcEngine:didClientRoleChanged:newRole:newRoleOptions:
(void) | - rtcEngine:didClientRoleChangeFailed:currentRole:
(void) | - rtcEngine:didLeaveChannelWithStats:
(void) | - rtcEngine:firstLocalAudioFramePublished:
(void) | - rtcEngine:localAudioStats:
(void) | - rtcEngine:audioMixingStateChanged:reasonCode:
(void) | - rtcEngine:audioMixingPositionChanged:
(void) | - rtcEngine:cameraExposureDidChangedToRect:
(void) | - rtcEngine:firstLocalVideoFramePublishedWithElapsed:sourceType:
(void) | - rtcEngine:firstLocalVideoFrameWithSize:elapsed:sourceType:
(void) | - rtcEngine:localVideoStats:sourceType:
(void) | - rtcEngine:reportAudioVolumeIndicationOfSpeakers:totalVolume:
(void) | - rtcEngine:remoteAudioStats:
(void) | - rtcEngine:remoteVideoStats:

## Face Detection Delegate Methods
##
(void) | - rtcEngine:facePositionDidChangeWidth:previewHeight:faces:

## Method Documentation

## ◆ rtcEngine:didLocalUserRegisteredWithUserId:userAccount:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didLocalUserRegisteredWithUserId: |  | (NSUInteger) | uid
userAccount: |  | (NSString *_Nonnull) | userAccount
| optional

Occurs when the local user successfully registers a user account by calling the This callback reports the user ID and user account of the local user.

Parameters

  uid | The ID of the local user.
  userAccount | The user account of the local user.

## ◆ rtcEngine:didUserInfoUpdatedWithUserId:userInfo:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didUserInfoUpdatedWithUserId: |  | (NSUInteger) | uid
userInfo: |  | (AgoraUserInfo *_Nonnull) | userInfo
| optional

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

  uid | The ID of the remote user.
  userInfo | The `AgoraUserInfo` object that contains the user ID and user account of the remote user.

## ◆ rtcEngineRequestToken:

- (void) rtcEngineRequestToken: |  | (AgoraRtcEngineKit *_Nonnull) | engine |
| optional

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

  engine | The engine kit

## ◆ rtcEngineConnectionDidLost:

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

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

  engine | The engine kit

## ◆ rtcEngine:reportRtcStats:

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

Statistics of rtc engine status. Updated every two seconds.

Parameters

  engine | The engine kit
  stats | The statistics of rtc status, including duration, sent bytes and received bytes

## ◆ rtcEngine:lastmileProbeTestResult:

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

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

  engine | AgoraRtcEngineKit object.
  result | The uplink and downlink last-mile network probe test result, see [AgoraLastmileProbeResult](AgoraLastmileProbeResult).

## ◆ rtcEngine:uploadLogResultRequestId:success:reason:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
uploadLogResultRequestId: |  | (NSString *_Nonnull) | requestId
success: |  | (BOOL) | success
reason: |  | (AgoraUploadErrorReason) | reason
| optional

Reports the user log upload result

Parameters

  requestId | RequestId of the upload
  success | Is upload success
  reason | Reason of the upload, 0: OK, 1 Network Error, 2 Server Error.

## ◆ rtcEngine:didClientRoleChanged:newRole:newRoleOptions:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didClientRoleChanged: |  | (AgoraClientRole) | oldRole
newRole: |  | (AgoraClientRole) | newRole
newRoleOptions: |  | (AgoraClientRoleOptions *_Nullable) | newRoleOptions
| optional

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

Parameters

  engine | The engine kit
  oldRole | The previous role of the local user
  newRole | The new role of the local user
  newRoleOptions | The client role options of the current role of the local user

## ◆ rtcEngine:didClientRoleChangeFailed:currentRole:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didClientRoleChangeFailed: |  | (AgoraClientRoleChangeFailedReason) | reason
currentRole: |  | (AgoraClientRole) | currentRole
| optional

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

Parameters

  engine | The engine kit
  reason | The reason of the failure of the local user role switches
  currentRole | The current role of the user

## ◆ rtcEngine:didLeaveChannelWithStats:

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

The statistics of the call when leave channel

Parameters

  engine | The engine kit
  stats | The statistics of the call, including duration, sent bytes and received bytes

## ◆ rtcEngine:firstLocalAudioFramePublished:

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

Event of the first audio frame is sent.

Parameters

  engine | The engine kit
  elapsed | The elapsed time(ms) from the beginning of the session.

## ◆ rtcEngine:localAudioStats:

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

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

  engine | The AgoraRtcEngineKit object.
  stats | AgoraRtcLocalAudioStats

## ◆ rtcEngine:audioMixingStateChanged:reasonCode:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
audioMixingStateChanged: |  | (AgoraAudioMixingStateType) | state
reasonCode: |  | (AgoraAudioMixingReasonCode) | reasonCode
| optional

Audio mixing state changed.

Parameters

  engine | The AgoraRtcEngineKit object.
  state | AgoraAudioMixingStateType
  reasonCode | AgoraAudioMixingReasonType

## ◆ rtcEngine:audioMixingPositionChanged:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
audioMixingPositionChanged: |  | (NSInteger) | position
| optional

Reports current AudioMixing progress.

The callback occurs once every one second during the playback and reports the current playback progress.

Parameters

  position | Current AudioMixing progress (millisecond).

## ◆ rtcEngine:cameraExposureDidChangedToRect:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
cameraExposureDidChangedToRect: |  | (CGRect) | rect
| optional

A camera exposure position changed.

Parameters

  engine | AgoraRtcEngineKit object
  rect | Exposure rectangle in the local preview

## ◆ rtcEngine:firstLocalVideoFramePublishedWithElapsed:sourceType:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
firstLocalVideoFramePublishedWithElapsed: |  | (NSInteger) | elapsed
sourceType: |  | (AgoraVideoSourceType) | source
| optional

Event of the first local video frame is published.

Parameters

  engine | The engine kit
  elapsed | The elapsed time(ms) from the beginning of the session.

## ◆ rtcEngine:firstLocalVideoFrameWithSize:elapsed:sourceType:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
firstLocalVideoFrameWithSize: |  | (CGSize) | size
elapsed: |  | (NSInteger) | elapsed
sourceType: |  | (AgoraVideoSourceType) | source
| optional

Event of the first local frame starts rendering on the screen.

Parameters

  engine | The engine kit
  size | The size of local video stream
  elapsed | The elapsed time(ms) from the beginning of the session.

## ◆ rtcEngine:localVideoStats:sourceType:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
localVideoStats: |  | (AgoraRtcLocalVideoStats *_Nonnull) | stats
sourceType: |  | (AgoraVideoSourceType) | source
| optional

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

Parameters

  engine | The engine kit
  stats | The statistics of local video, including sent bitrate, sent framerate

## ◆ rtcEngine:reportAudioVolumeIndicationOfSpeakers:totalVolume:

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

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

Parameters

  engine | The engine kit
  speakers | AgoraRtcAudioVolumeInfo array
  totalVolume | The total volume of speakers

## ◆ rtcEngine:remoteAudioStats:

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

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

Parameters

  engine | The engine kit
  stats | The 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
| optional

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

Parameters

  engine | The engine kit
  stats | The statistics of remote video, including user id, delay, resolution, received bitrate, received framerate, video stream type

## ◆ rtcEngine:rtmpStreamingChangedToState:state:errCode:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
rtmpStreamingChangedToState: |  | (NSString *_Nonnull) | url
state: |  | (AgoraRtmpStreamingState) | state
errCode: |  | (AgoraRtmpStreamingErrorCode) | errCode
| optional

## ◆ rtcEngine:rtmpStreamingEventWithUrl:eventCode:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
rtmpStreamingEventWithUrl: |  | (NSString *_Nonnull) | url
eventCode: |  | (AgoraRtmpStreamingEvent) | eventCode
| optional

## ◆ rtcEngine:facePositionDidChangeWidth:previewHeight:faces:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
facePositionDidChangeWidth: |  | (int) | width
previewHeight: |  | (int) | height
faces: |  | (NSArray< AgoraFacePositionInfo * > *_Nullable) | faces

Reports the face detection result of the local user. (iOS only)

Since:** v3.0.1.

Once you enable face detection by calling [enableFaceDetection]([AgoraRtcEngineKit enableFaceDetection:]), 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 video.

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

Parameters

  engine | AgoraRtcEngineKit object.
  width | The width (px) of the local video.
  height | The height (px) of the local video.
  faces | An AgoraFacePositionInfo array, which contains the information of the detected human face.

The number of the AgoraFacePositionInfo array depends on the number of human faces detected. If the array length is 0, it means that no human face is detected.