|
Agora RTC Objective-C API Reference
Refactor
|
Inherits <NSObject>.
Core Delegate Methods | |
| (void) | - rtcEngineRequestToken: |
| (void) | - rtcEngine:tokenPrivilegeWillExpire: |
| (void) | - rtcEngineConnectionDidLost: |
| (void) | - rtcEngine:connectionStateChanged:reason: |
| (void) | - rtcEngine:reportRtcStats: |
| (void) | - rtcEngine:lastmileProbeTestResult: |
| (void) | - rtcEngine:didApiCallExecute:api:result: |
Local User Core Delegate Methods | |
| (void) | - rtcEngine:didJoinChannel:withUid:elapsed: |
| (void) | - rtcEngine:didRejoinChannel:withUid:elapsed: |
| (void) | - rtcEngine:didClientRoleChanged:newRole: |
| (void) | - rtcEngine:didLeaveChannelWithStats: |
Local User Audio Delegate Methods | |
| (void) | - rtcEngine:audioMixingStateChanged:errorType: |
| (void) | - rtcEngine:firstLocalAudioFramePublished: |
| (void) | - rtcEngine:localAudioStats: |
| (void) | - rtcEngine:localAudioStateChanged:error: |
Remote User Core Delegate Methods | |
| (void) | - rtcEngine:didJoinedOfUid:elapsed: |
| (void) | - rtcEngine:didOfflineOfUid:reason: |
Remote User Audio Delegate Methods | |
| (void) | - rtcEngine:remoteAudioStats: |
| (void) | - rtcEngine:reportAudioVolumeIndicationOfSpeakers:totalVolume: |
| (void) | - rtcEngineIntraRequestReceived: |
| (void) | - rtcEngine:bandwidthEstimationUpdate: |
Remote User Video Delegates Methods | |
| (void) | - rtcEngine:localVideoStateChangedOfState:error: |
| (void) | - rtcEngine:remoteVideoStateChangedOfUid:state:reason:elapsed: |
| (void) | - rtcEngine:remoteAudioStateChangedOfUid:state:reason:elapsed: |
| (void) | - rtcEngine:remoteVideoStats: |
Stream Publish Delegate Methods | |
| (void) | - rtcEngine:streamStateChanged:state:errCode: |
| (void) | - rtcEngine:audioMixingStateChanged:errorCode: |
The AgoraRtcEngineDelegate protocol enables callback event notifications to your application.
The SDK uses delegate callbacks in the AgoraRtcEngineDelegate protocol to report runtime events to the application. 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.
| - (void) rtcEngineRequestToken: | (AgoraRtcEngineKit *_Nonnull) | engine |
Occurs when the token has expired.
If a token is specified when calling joinChannelByToken, the token expires after a certain period of time and you need a new token to reconnect to the server.
Upon receiving this callback, generate a new token at your app server and call renewToken to pass the new token to the SDK.
| engine | The AgoraRtcEngineKit object. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| tokenPrivilegeWillExpire: | (NSString *_Nonnull) | token | |
Occurs when the token will expire in 30 seconds.
If the token you specified when calling joinChannelByToken expires, the user drops offline. This callback is triggered 30 seconds before the token expires, to remind you to renew the token. Upon receiving this callback, generate a new token at your app server and call renewToken to pass the new token to the SDK.
| engine | The AgoraRtcEngineKit object. |
| token | The token that will expire in 30 seconds. |
| - (void) rtcEngineConnectionDidLost: | (AgoraRtcEngineKit *_Nonnull) | engine |
Occurs when the SDK cannot reconnect to Agora's edge server 10 seconds after its connection to the server is interrupted.
The SDK triggers this callback when it cannot connect to the server 10 seconds after calling joinChannelByToken, regardless of whether it is in the channel or not.
| engine | The AgoraRtcEngineKit object. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| connectionStateChanged: | (AgoraConnectionState) | state | |
| reason: | (AgoraConnectionChangedReason) | reason | |
Occurs when the connection state of the SDK to the server is changed.
| engine | The AgoraRtcEngineKit object. |
| state | See AgoraConnectionState. |
| reason | See AgoraConnectionChangedReason. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| reportRtcStats: | (AgoraChannelStats *_Nonnull) | stats | |
Reports the statistics of the current call.
This callback is triggered once every two seconds after the user joins the channel.
| engine | The AgoraRtcEngineKit object. |
| stats | The statistics on the current call: AgoraChannelStats. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| lastmileProbeTestResult: | (AgoraLastmileProbeResult *_Nonnull) | result | |
Reports the last-mile network probe result.
The SDK triggers this callback within 30 seconds after the app calls the startLastmileProbeTest method.
| engine | The AgoraRtcEngineKit object. |
| result | The uplink and downlink last-mile network probe test result, see AgoraLastmileProbeResult. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| didApiCallExecute: | (NSInteger) | error | |
| api: | (NSString *_Nonnull) | api | |
| result: | (NSString *_Nonnull) | result | |
The API call was executed successfully.
| engine | The AgoraRtcEngineKit object. |
| error | AgoraErrorCode |
| api | The method executed by the SDK. |
| result | The result of the method call. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| didJoinChannel: | (NSString *_Nonnull) | channel | |
| withUid: | (NSUInteger) | uid | |
| elapsed: | (NSInteger) | elapsed | |
Occurs when the local user successfully joins a specified channel.
| engine | AgoraRtcEngineKit object |
| channel | The channel name. |
| uid | The user ID. |
| elapsed | The time elapsed (ms) from the local user calling joinChannelByToken until this event occurs. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| didRejoinChannel: | (NSString *_Nonnull) | channel | |
| withUid: | (NSUInteger) | uid | |
| elapsed: | (NSInteger) | elapsed | |
Occurs when the local user rejoins a channel.
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.
| engine | The AgoraRtcEngineKit object. |
| channel | The channel name. |
| uid | The user ID. |
| elapsed | Time elapsed (ms) from the local user calling joinChannelByToken until this event occurs. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| didClientRoleChanged: | (AgoraClientRole) | oldRole | |
| newRole: | (AgoraClientRole) | newRole | |
Occurs when the local user role switches in a live broadcast.
| engine | The AgoraRtcEngineKit object. |
| oldRole | The role that the user switches from: AgoraClientRole. |
| newRole | The role that the user switches to: AgoraClientRole. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| didLeaveChannelWithStats: | (AgoraChannelStats *_Nonnull) | stats | |
Occurs when the local user leaves a channel.
When the user successfully leaves the channel after calling leaveChannel method, this callback notifies the app that a user leaves a channel.
This callback also reports information such as the call duration and the statistics of data received or transmitted by the SDK.
| engine | The AgoraRtcEngineKit object. |
| stats | The statistics of the call. See AgoraChannelStats. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| audioMixingStateChanged: | (AgoraAudioMixingStateType) | stateType | |
| errorType: | (AgoraAudioMixingErrorType) | errorType | |
Occurs when the playback state of the local user's audio mixing file changes.
state, and 0 in errorCode.state and an error code in errorCode.| engine | The AgoraRtcEngineKit object. |
| state | AgoraAudioMixingStateType |
| errorCode | AgoraAudioMixingErrorType |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| firstLocalAudioFramePublished: | (NSInteger) | elapsed | |
Occurs when the first local audio frame is published.
| engine | The AgoraRtcEngineKit object. |
| elapsed | The time elapsed (ms) from calling joinChannelByToken until the SDK triggers this callback. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| localAudioStats: | (AgoraRtcLocalAudioStats *_Nonnull) | stats | |
Reports the statistics of the local audio stream.
The SDK triggers this callback once every two seconds.
| engine | The AgoraRtcEngineKit object. |
| stats | The statistics of the local audio stream. See AgoraRtcLocalAudioStats. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| localAudioStateChanged: | (AgoraAudioLocalState) | state | |
| error: | (AgoraAudioLocalError) | error | |
Occurs when the local audio stream state changes.
This callback indicates the state change of the local audio stream, including the state of the audio recording and encoding, and allows you to troubleshoot issues when exceptions occur.
AgoraAudioLocalStateFailed(3), see the error parameter for details. | engine | AgoraRtcEngineKit object |
| state | The state of the local audio. See AgoraAudioLocalState. |
| error | The error information of the local audio. See AgoraAudioLocalError. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| didJoinedOfUid: | (NSUInteger) | uid | |
| elapsed: | (NSInteger) | elapsed | |
Occurs when a remote user or user joins the channel.
If other users or hosts are already in the channel, the SDK also reports to the app on the existing users/hosts.
The SDK triggers this callback under one of the following circumstances:
joinChannelByToken.| engine | The AgoraRtcEngineKit object. |
| uid | The user ID. |
| elapsed | Time elapsed (ms) from calling joinChannelByToken until this callback is triggered. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| didOfflineOfUid: | (NSUInteger) | uid | |
| reason: | (AgoraUserOfflineReason) | reason | |
Occurs when a remote user or host goes offline.
There are two reasons for a user to go offline:
| engine | The AgoraRtcEngineKit object. |
| uid | The ID of the user who goes offline. |
| reason | The reason why the user goes offline: AgoraUserOfflineReason. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| remoteAudioStats: | (AgoraRtcRemoteAudioStats *_Nonnull) | stats | |
Reports the statistics of the remote audio stream.
The SDK triggers this callback once every two seconds for each remote user or broadcaster. If a channel has multiple remote users, the SDK triggers this callback as many times.
| engine | The AgoraRtcEngineKit object. |
| stats | The statistics of the received audio. See AgoraRtcRemoteAudioStats. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| reportAudioVolumeIndicationOfSpeakers: | (NSArray< AgoraRtcAudioVolumeInfo * > *_Nonnull) | speakers | |
| totalVolume: | (NSInteger) | totalVolume | |
This callback reports the IDs and volumes of the loudest speakers at the moment in the channel, and whether the local user is speaking.
Once enabled, this callback is triggered at the set interval, regardless of whether a user speaks or not.
The SDK triggers two independent reportAudioVolumeIndicationOfSpeakers callbacks at one time, which separately report the volume information of the local user and all the remote speakers.
| engine | The AgoraRtcEngineKit object. |
| speakers | An array containing the user ID and volume information for each speaker: AgoraRtcAudioVolumeInfo.
|
| totalVolume | The total volume after audio mixing. The value ranges between 0 (the lowest volume) and 255 (the highest volume).
|
| - (void) rtcEngineIntraRequestReceived: | (AgoraRtcEngineKit *_Nonnull) | engine |
Intra request received.
| engine | The AgoraRtcEngineKit object. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| bandwidthEstimationUpdate: | (AgoraNetworkInfo *_Nonnull) | networkInfo | |
Target bitrate updated.
| engine | The AgoraRtcEngineKit object. |
| networkInfo | The suggested network info, including target bitrate bps. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| localVideoStateChangedOfState: | (AgoraVideoLocalState) | state | |
| error: | (AgoraLocalVideoStreamError) | error | |
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.
| engine | AgoraRtcEngineKit object |
| state | State type AgoraVideoLocalState. When the state is AgoraVideoLocalStateFailed (3), see the error parameter for details. |
| error | The detailed error information: AgoraLocalVideoStreamError. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| remoteVideoStateChangedOfUid: | (NSUInteger) | uid | |
| state: | (AgoraVideoRemoteState) | state | |
| reason: | (AgoraVideoRemoteReason) | reason | |
| elapsed: | (NSInteger) | elapsed | |
A remote video stream state changed.
| engine | AgoraRtcEngineKit object |
| uid | ID of the user whose video state has changed. |
| state | State of the remote video: Running: the remote video is normal Frozen: the remote video is frozen |
| reason | Interal: 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. |
| elapsed | The time elapsed (ms) from the local user calling ref "joinChannel" until this callback is triggered. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| remoteAudioStateChangedOfUid: | (NSUInteger) | uid | |
| state: | (AgoraAudioRemoteState) | state | |
| reason: | (AgoraAudioRemoteReason) | reason | |
| elapsed: | (NSInteger) | elapsed | |
Occurs when the state of a remote audio stream changes.
| engine | The AgoraRtcEngineKit object. |
| uid | The ID of the user whose audio state has changed. |
| state | The state of the remote audio. See AgoraAudioRemoteState. |
| reason | The reason of the remote audio state change. See AgoraAudioRemoteReason. |
| elapsed | The time elapsed (ms) from calling joinChannelByToken until the SDK triggers this callback. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| remoteVideoStats: | (AgoraRtcRemoteVideoStats *_Nonnull) | stats | |
Reports the statistics of the video stream from each remote user/host.
The SDK triggers this callback once every two seconds for each remote user or 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.
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.
| engine | The AgoraRtcEngineKit object. |
| stats | The statistics of the received remote video streams. See AgoraRtcRemoteVideoStats. |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| streamStateChanged: | (NSString *_Nonnull) | url | |
| state: | (AgoraRtmpStreamPublishState) | state | |
| errCode: | (AgoraRtmpStreamPublishError) | errCode | |
Occurs when the state of the RTMP streaming changes.
| engine | The AgoraRtcEngineKit object. |
| url | Address to which the publisher publishes the stream. |
| state | [AgoraRtmpStreamPublishState]([AgoraRtmpStreamPublishState]) |
| errCode | [AgoraRtmpStreamPublishError]([AgoraRtmpStreamPublishError]) |
| - (void) rtcEngine: | (AgoraRtcEngineKit *_Nonnull) | engine | |
| audioMixingStateChanged: | (AgoraAudioMixingStateType) | state | |
| errorCode: | (AgoraAudioMixingErrorType) | errorCode | |
Audio mixing state changed.
| engine | The AgoraRtcEngineKit object. |
| state | AgoraAudioMixingStateType |
| errorCode | AgoraAudioMixingErrorType |
1.8.18