AgoraRtcChannelDelegate Category Reference

Conforms to NSObject
Declared in AgoraRtcChannel.h

Overview

The AgoraRtcChannelDelegate class.

Since v3.0.0.

– rtcChannel:didOccurWarning:

Reports a warning during SDK runtime.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel didOccurWarning:(AgoraWarningCode)warningCode

Parameters

rtcChannel

AgoraRtcChannel

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

AgoraRtcChannel.h

– rtcChannel:didOccurError:

Reports an error during SDK runtime.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel didOccurError:(AgoraErrorCode)errorCode

Parameters

rtcChannel

AgoraRtcChannel

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

AgoraRtcChannel.h

– rtcChannelDidJoinChannel:withUid:elapsed:

Occurs when the local user joins a specified channel.

- (void)rtcChannelDidJoinChannel:(AgoraRtcChannel *_Nonnull)rtcChannel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed

Parameters

rtcChannel

AgoraRtcChannel

uid

User ID. If the uid is specified in the joinChannelByToken method, the specified user ID is returned. If the user ID is not specified when the joinChannelByToken method is called, the server automatically assigns a uid.

elapsed

Time elapsed (ms) from the user calling the joinChannelByToken method until the SDK triggers this callback.

Declared In

AgoraRtcChannel.h

– rtcChannelDidRejoinChannel:withUid:elapsed:

Occurs when the local user rejoins a channel.

- (void)rtcChannelDidRejoinChannel:(AgoraRtcChannel *_Nonnull)rtcChannel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed

Parameters

rtcChannel

AgoraRtcChannel

uid

User ID. If the uid is specified in the joinChannelByToken method, the specified user ID is returned. If the user ID is not specified when the joinChannelByToken method is called, the server automatically assigns a uid.

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

AgoraRtcChannel.h

– rtcChannelDidLeaveChannel:withStats:

Occurs when the local user leaves a channel.

- (void)rtcChannelDidLeaveChannel:(AgoraRtcChannel *_Nonnull)rtcChannel withStats:(AgoraChannelStats *_Nonnull)stats

Parameters

rtcChannel

AgoraRtcChannel

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.

Declared In

AgoraRtcChannel.h

– rtcChannel:didClientRoleChanged:newRole:

Occurs when the local user role switches in a live broadcast.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel didClientRoleChanged:(AgoraClientRole)oldRole newRole:(AgoraClientRole)newRole

Parameters

rtcChannel

AgoraRtcChannel

oldRole

Role that the user switches from: AgoraClientRole.

newRole

Role that the user switches to: AgoraClientRole.

Discussion

The SDK triggers this callback when the local user switches the user role by calling the setClientRole method after joining the channel.

Declared In

AgoraRtcChannel.h

– rtcChannel:didJoinedOfUid:elapsed:

Occurs when a remote user or host joins a channel.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel didJoinedOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed

Parameters

rtcChannel

AgoraRtcChannel

uid

ID of the user or host who joins the channel. If the uid is specified in the joinChannelByToken method, the specified user 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 local user calling the joinChannelByToken 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.

The SDK triggers this callback under one of the following circumstances: - A remote user/host joins the channel by calling the joinChannelByToken method. - A remote user switches the user role to the host by calling the setClientRole method after joining the channel. - A remote user/host rejoins the channel after a network interruption. - A host injects an online media stream into the channel by calling the addInjectStreamUrl method.

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

AgoraRtcChannel.h

– rtcChannel:didOfflineOfUid:reason:

Occurs when a remote user (Communication)/host (Live Broadcast) leaves a channel.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel didOfflineOfUid:(NSUInteger)uid reason:(AgoraUserOfflineReason)reason

Parameters

rtcChannel

AgoraRtcChannel

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 the Agora RTM SDK for more reliable offline detection.

Declared In

AgoraRtcChannel.h

– rtcChannel:connectionChangedToState:reason:

Occurs when the network connection state changes.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel connectionChangedToState:(AgoraConnectionStateType)state reason:(AgoraConnectionChangedReason)reason

Parameters

rtcChannel

AgoraRtcChannel

state

The current network connection state, see AgoraConnectionStateType.

reason

The reason of the connection state change, see AgoraConnectionChangedReason.

Discussion

The SDK triggers this callback to report on the current network connection state when it changes, and the reason of the change.

Declared In

AgoraRtcChannel.h

– rtcChannelDidLost:

Occurs when the SDK cannot reconnect to Agora’s edge server 10 seconds after its connection to the server is interrupted.

- (void)rtcChannelDidLost:(AgoraRtcChannel *_Nonnull)rtcChannel

Parameters

rtcChannel

AgoraRtcChannel

Discussion

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

If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora’s edge server, the SDK stops rejoining the channel.

Declared In

AgoraRtcChannel.h

– rtcChannel:tokenPrivilegeWillExpire:

Occurs when the token expires in 30 seconds.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel tokenPrivilegeWillExpire:(NSString *_Nonnull)token

Parameters

rtcChannel

AgoraRtcChannel

token

The token that expires in 30 seconds.

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

AgoraRtcChannel.h

– rtcChannelRequestToken:

Occurs when the token expires.

- (void)rtcChannelRequestToken:(AgoraRtcChannel *_Nonnull)rtcChannel

Parameters

rtcChannel

AgoraRtcChannel

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.

The SDK triggers this callback to notify the app to generate a new token. Call the renewToken method to renew the token.

Declared In

AgoraRtcChannel.h

– rtcChannel:activeSpeaker:

Reports which user is the loudest speaker over a period of time.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel activeSpeaker:(NSUInteger)speakerUid

Parameters

rtcChannel

AgoraRtcChannel

speakerUid

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

Discussion

This callback reports the speaker with the highest accumulative volume during a certain period. 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

AgoraRtcChannel.h

– rtcChannel:videoSizeChangedOfUid:size:rotation:

Occurs when the video size or rotation of a specific remote user changes.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel videoSizeChangedOfUid:(NSUInteger)uid size:(CGSize)size rotation:(NSInteger)rotation

Parameters

rtcChannel

AgoraRtcChannel

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

AgoraRtcChannel.h

– rtcChannel:remoteVideoStateChangedOfUid:state:reason:elapsed:

Occurs when the remote video state changes.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel remoteVideoStateChangedOfUid:(NSUInteger)uid state:(AgoraVideoRemoteState)state reason:(AgoraVideoRemoteStateReason)reason elapsed:(NSInteger)elapsed

Parameters

rtcChannel

AgoraRtcChannel

uid

ID of the remote user whose video state changes.

state

The state of the remote video. See AgoraVideoRemoteState.

reason

The reason of the remote video state change. See AgoraVideoRemoteStateReason.

elapsed

The time elapsed (ms) from the local user calling the joinChannelByToken method until the SDK triggers this callback.

Declared In

AgoraRtcChannel.h

– rtcChannel:remoteAudioStateChangedOfUid:state:reason:elapsed:

Occurs when the local audio state changes.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel remoteAudioStateChangedOfUid:(NSUInteger)uid state:(AgoraAudioRemoteState)state reason:(AgoraAudioRemoteStateReason)reason elapsed:(NSInteger)elapsed

Parameters

rtcChannel

AgoraRtcChannel

uid

ID of the remote user whose audio state changes.

state

State of the remote audio. See AgoraAudioRemoteState.

reason

The reason of the remote audio state change. See AgoraAudioRemoteStateReason.

elapsed

Time elapsed (ms) from the local user calling the joinChannelByToken method until the SDK triggers this callback.

Discussion

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.

Declared In

AgoraRtcChannel.h

– rtcChannel: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)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel didLocalPublishFallbackToAudioOnly:(BOOL)isFallbackOrRecover

Parameters

rtcChannel

AgoraRtcChannel

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

AgoraRtcChannel.h

– rtcChannel: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)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel didRemoteSubscribeFallbackToAudioOnly:(BOOL)isFallbackOrRecover byUid:(NSUInteger)uid

Parameters

rtcChannel

AgoraRtcChannel

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

AgoraRtcChannel.h

– rtcChannel:reportRtcStats:

Reports the statistics of the current call. The SDK triggers this callback once every two seconds after the user joins the channel.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel reportRtcStats:(AgoraChannelStats *_Nonnull)stats

Parameters

rtcChannel

AgoraRtcChannel

stats

Statistics of the AgoraRtcEngineKit: AgoraChannelStats.

Declared In

AgoraRtcChannel.h

– rtcChannel:networkQuality:txQuality:rxQuality:

Reports the last mile network quality of each user in the channel once every two seconds.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel networkQuality:(NSUInteger)uid txQuality:(AgoraNetworkQuality)txQuality rxQuality:(AgoraNetworkQuality)rxQuality

Parameters

rtcChannel

AgoraRtcChannel

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

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. txQuality is a quality rating helping you understand how well the current uplink network conditions can support the selected AgoraVideoEncoderConfiguration. For example, a 1000-Kbps uplink network may be adequate for video frames with a resolution of 640 * 480 and a frame rate of 15 fps in the Live-broadcast profile, but may be inadequate for resolutions higher than 1280 * 720. See AgoraNetworkQuality.

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

AgoraRtcChannel.h

– rtcChannel:remoteVideoStats:

Reports the statistics of the video stream from each remote user/host.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel remoteVideoStats:(AgoraRtcRemoteVideoStats *_Nonnull)stats

Parameters

rtcChannel

AgoraRtcChannel

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

AgoraRtcChannel.h

– rtcChannel:remoteAudioStats:

Reports the statistics of the audio stream from each remote user/host.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel remoteAudioStats:(AgoraRtcRemoteAudioStats *_Nonnull)stats

Parameters

rtcChannel

AgoraRtcChannel

stats

Statistics of the received remote audio streams. See AgoraRtcRemoteAudioStats.

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

AgoraRtcChannel.h

– rtcChannel:rtmpStreamingChangedToState:state:errorCode:

Occurs when the state of the RTMP streaming changes.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel rtmpStreamingChangedToState:(NSString *_Nonnull)url state:(AgoraRtmpStreamingState)state errorCode:(AgoraRtmpStreamingErrorCode)errorCode

Parameters

rtcChannel

AgoraRtcChannel

url

The RTMP URL address.

state

The RTMP streaming state: AgoraRtmpStreamingState. When the streaming state is AgoraRtmpStreamingStateFailure(4), see the errorCode parameter for details.

errorCode

The detailed error information for streaming: AgoraRtmpStreamingErrorCode.

Discussion

The SDK triggers this callback to report the result of the local user calling the addPublishStreamUrl or removePublishStreamUrl method.

This callback returns the URL and its current streaming state.

This callback indicates the state of the RTMP streaming. When exceptions occur, you can troubleshoot issues by referring to the detailed error descriptions in the errorCode parameter.

Declared In

AgoraRtcChannel.h

– rtcChannelTranscodingUpdated:

Occurs when the CDN live streaming settings are updated.

- (void)rtcChannelTranscodingUpdated:(AgoraRtcChannel *_Nonnull)rtcChannel

Parameters

rtcChannel

AgoraRtcChannel

Discussion

When the LiveTranscoding class in the setLiveTranscoding method updates, the SDK triggers the rtcChannelTranscodingUpdated callback to report the update information to the local host.

Note:

If you call the setLiveTranscoding method to set the LiveTranscoding class for the first time, the SDK does not trigger the rtcChannelTranscodingUpdated callback.

Declared In

AgoraRtcChannel.h

– rtcChannel:streamInjectedStatusOfUrl:uid:status:

Reports the status of injecting an online stream to a live broadcast.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel streamInjectedStatusOfUrl:(NSString *_Nonnull)url uid:(NSUInteger)uid status:(AgoraInjectStreamStatus)status

Parameters

rtcChannel

AgoraRtcChannel

url

URL address of the externally injected stream.

uid

User ID.

status

Status of the externally injected stream. See AgoraInjectStreamStatus.

Declared In

AgoraRtcChannel.h

– rtcChannel:receiveStreamMessageFromUid:streamId:data:

Occurs when the local user receives the data stream from a remote user within five seconds.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel receiveStreamMessageFromUid:(NSUInteger)uid streamId:(NSInteger)streamId data:(NSData *_Nonnull)data

Parameters

rtcChannel

AgoraRtcChannel

uid

User ID of the remote user sending the message.

streamId

Stream ID.

data

Data received by the local user.

Discussion

The SDK triggers this callback when the local user receives the stream message that the remote user sends by calling the sendStreamMessage method.

Declared In

AgoraRtcChannel.h

– rtcChannel:didOccurStreamMessageErrorFromUid:streamId:error:missed:cached:

Occurs when the local user does not receive the data stream from the remote user within five seconds.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel didOccurStreamMessageErrorFromUid:(NSUInteger)uid streamId:(NSInteger)streamId error:(NSInteger)error missed:(NSInteger)missed cached:(NSInteger)cached

Parameters

rtcChannel

AgoraRtcChannel

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.

Discussion

The SDK triggers this callback when the local user fails to receive the stream message that the remote user sends by calling the sendStreamMessage method.

Declared In

AgoraRtcChannel.h

– rtcChannel:channelMediaRelayStateDidChange:error:

Occurs when the state of the media stream relay changes.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel channelMediaRelayStateDidChange:(AgoraChannelMediaRelayState)state error:(AgoraChannelMediaRelayError)error

Parameters

rtcChannel

AgoraRtcChannel

state

The state code in AgoraChannelMediaRelayState.

error

The error code in AgoraChannelMediaRelayError.

Discussion

The SDK reports the state of the current media relay and possible error messages in this callback.

Declared In

AgoraRtcChannel.h

– rtcChannel:didReceiveChannelMediaRelayEvent:

Reports events during the media stream relay.

- (void)rtcChannel:(AgoraRtcChannel *_Nonnull)rtcChannel didReceiveChannelMediaRelayEvent:(AgoraChannelMediaRelayEvent)event

Parameters

rtcChannel

AgoraRtcChannel

event

The event code in AgoraChannelMediaRelayEvent.

Declared In

AgoraRtcChannel.h

X
Is this page helpful?