CloudHub Docs
Download Documents

RTC


CloudHubSDK iOS

CloudHubRTCEngineDelegate

Unless otherwise specified, the callback methods of delegete run on the main thread

Channel events

rtcEngine:didOccurError:withMessage:

An error occurred callback

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
     didOccurError:(CloudHubErrorCode)errorCode
       withMessage:(NSString * _Nonnull)message;
ParametersDescription
engineCloudHubRtcEngineKit instance pointer
errorCodeCloudHubErrorCode error code
messageError description

Details

This callback method indicates that an error occurred inside the SDK

rtcEngine:didJoinChannelwithUid:elapsed:

Occurs when a user joins a channel.

- (void)       rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
   didJoinChannelwithUid:(NSString * _Nonnull)uid
                 elapsed:(NSInteger) elapsed;
ParametersDescription
engineCloudHubRtcEngineKit object
uidUser Id, if the uid is specified in the joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: method, it will return the specified ID; if not, it will be automatically allocated by CloudHubRtcEngineKit
elapsedThe elapsed time (ms) from when joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: was called to when this event occurred

Details

This callback method indicates that the client has successfully joined the specified channel, which is the same as the callback of joinSuccessBlock ofjoinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess:

rtcEngine:didReJoinChannelwithUid:elapsed:

Occurs when a user rejoins the channel.

- (void)       rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
 didReJoinChannelwithUid:(NSString * _Nonnull)uid
                 elapsed:(NSInteger) elapsed;
ParametersDescription
engineCloudHubRtcEngineKit object
uidThe ID of the user who rejoins the channel. If the uid is specified in the joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: method, it will return the specified Id; if not, it will return the automatically assigned by CloudHubRtcEngineKit
elapsedThe elapsed time (ms) from when joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: was called to when this event occurred

Details

When a user loses connection with the server because of network problems, the SDK automatically tries to reconnect and triggers this callback upon reconnection.

rtcEngine:didLeaveChannel:

Occurs when a user leaves a channel.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
  didLeaveChannel:(CloudHubChannelStats * _Nonnull)stats;
ParametersDescription
engineCloudHubRtcEngineKit object
statsThe statistics of the call, See CloudHubChannelStats

Details

This callback notifies the app that the user leaves the channel by calling leaveChannel: . From this callback, the app can get information such as the call duration and quality statistics.

rtcEngine:onClientRoleChangedFrom:to:

Occurs when the user role switches in the interactive live streaming.

- (void)      rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onClientRoleChangedFrom:(CloudHubClientRole)oldRole
                     to:(CloudHubClientRole)newRole;
ParametersDescription
engineCloudHubRtcEngineKit object
oldRoleCloudHubClientRole Role that the user switches
newRoleCloudHubClientRole Role that the user switches

Details

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

rtcEngine:didJoinedOfUid:properties:isHistory:fromChannel:

Occurs when a remote user (CloudHubChannelProfileCommunication)/ host (CloudHubChannelProfileLiveBroadcasting) joins the channel.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
   didJoinedOfUid:(NSString * _Nonnull)uid
       properties: (NSString * _Nullable)properties
        isHistory: (BOOL)isHistory
      fromChannel:(NSString* _Nonnull)srcChannel;
ParametersDescription
engineCloudHubRtcEngineKit object
uidThe ID of the user who rejoins the channel. If the uid is specified in the joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: method, it will return the specified Id; if not, it will return the automatically assigned by CloudHubRtcEngineKit
propertiesUser-defined attributes of this user can be specified through the joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: and setPropertyOfUid:tell:properties: interfaces
isHistoryWhether this user joined the channel before the local user
srcChannelWhen a cross-channel media stream from another channel is forwarded to this channel, the user of this channel will receive rtcEngine:didJoinedOfUid:properties:isHistory:fromChannel:, and srcChannel is the source channel of the forwarded media stream. Channel number, otherwise the value is an empty string

Details

In a communication channel, this callback indicates that a remote user joins the channel. The SDK also triggers this callback to report the existing users in the channel when a user joins the channel.

In a live-broadcast channel, this callback indicates that a host joins the channel. The SDK also triggers this callback to report the existing hosts in the channel when a host joins the channel. Cloudhub recommends limiting the number of hosts to 17.

The SDK triggers this callback under one of the following circumstances:

Note:

rtcEngine:didOfflineOfUid:reason:

Occurs when a remote user (CloudHubChannelProfileCommunication)/ host (CloudHubChannelProfileLiveBroadcasting) leaves the channel.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
  didOfflineOfUid:(NSString * _Nonnull)uid
           reason:(NSInteger)reason
ParametersDescription
engineCloudHubRtcEngineKit object
uidThe ID of the user who leaves the channel or goes offline.
reasonReasons why the user goes offline

Details

It prompts that a remote user/host has left the channel (or dropped). There are two reasons for the user to leave the channel, namely normal leaving and timeout dropped (more than 30 seconds can not communicate with the server normally)

rtcEngine:connectionChangedToState:

Occurs when the network connection state changes.

- (void)       rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
connectionChangedToState:(CloudHubConnectionStateType)state;
ParametersDescription
engineCloudHubRtcEngineKit object
stateThe current connection state. For details, See CloudHubConnectionStateType

Details

When the network connection state changes, the SDK triggers this callback and reports the current connection state and the reason for the change.

rtcEngine:tokenPrivilegeWillExpire:

Occurs when the token expires in 30 seconds.

- (void)       rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
tokenPrivilegeWillExpire:(NSString *_Nonnull)token;
ParametersDescription
engineCloudHubRtcEngineKit object
tokenThe token that expires in 30 seconds.

Details

If Token is specified when calling joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: , because Token has a certain time limit, if Token is about to expire during the call, the SDK will trigger the callback 30 seconds in advance to remind the application to update the Token, When receiving the callback, the user needs to regenerate a new Token on the server, and then call renewToken: to pass the newly generated Token to the SDK

rtcEngineRequestToken:

Occurs when the token expires.

- (void)rtcEngineRequestToken:(CloudHubRtcEngineKit * _Nonnull)engine;
ParametersDescription
engineCloudHubRtcEngineKit object

Details

If Token is specified when calling joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: , since Token has a certain time limit, if the Token has expired during the call, the SDK will immediately trigger the callback to remind the application to update the Token when receiving When this callback is reached, the user needs to regenerate a new Token on the server, and then call renewToken: to pass the newly generated Token to the SDK

rtcEngine:onLocalUserPermissionChanged:permission:

Local user publishing or subscribing permissions have changed

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onLocalUserPermissionChanged:(CloudHubPermissionType)type
                  permission:(BOOL)hasPermission;
ParametersDescription
engineCloudHubRtcEngineKit object
typeCloudHubPermissionType The permission type that has changed, 1 publish, 2 subscribe
permissionIs there currently permission

Details

You can change the publishing and subscribing permissions of any user in the channel through the backend api. When a user’s publishing and subscribing permissions change, the published audio and video streams will be interrupted immediately, and the local will receive rtcEngine:onLocalUserPermissionChanged:permission: callback If you lose the publishing right, other people in the channel will not be able to receive the audio and video of this user; if you lose the subscription right, this user will not be able to receive the audio and video of other people in the channel

Note:

Local media events

rtcEngine:localAudioStateChange:error:

Occurs when the local audio stream state changes.

- (void)    rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
localAudioStateChange:(CloudHubAudioLocalState)state
                error:(CloudHubAudioLocalError)error;
ParametersDescription
engineCloudHubRtcEngineKit object
stateThe state of the local audio. For details, SeeCloudHubAudioLocalState
errorLocal audio state error codes. For details, SeeCloudHubAudioLocalError

Details

When the state of the local audio stream changes (including the state of the audio capture and encoding), the SDK triggers this callback to report the current state. This callback indicates the state of the local audio stream, and allows you to troubleshoot issues when audio exceptions occur.

rtcEngine:localVideoStateChangeWithState:error:

Occurs when the local video stream state changes.

- (void)             rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
localVideoStateChangeWithState:(CloudHubLocalVideoStreamState)state
                         error:(CloudHubLocalVideoStreamError)error;
ParametersDescription
engineCloudHubRtcEngineKit object
stateThe state of the local video, SeeCloudHubLocalVideoStreamState
errorThe detailed error information, SeeCloudHubLocalVideoStreamError

Details

When the state of the local video stream changes (including the state of the video capture and encoding), the SDK triggers this callback to report the current state. 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.

rtcEngineFirstLocalAudioFrame:

已发送本地音频首帧回调

- (void)rtcEngineFirstLocalAudioFrame:(CloudHubRtcEngineKit * _Nonnull)engine;
ParametersDescription
engineCloudHubRtcEngineKit object

Remote media events

rtcEngine:remoteAudioStateChangedOfUid:state:reason:

Occurs when the remote audio state changes.

- (void)           rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
remoteAudioStateChangedOfUid:(NSString * _Nonnull)uid
                       state:(CloudHubAudioRemoteState)state
                      reason:(CloudHubAudioRemoteStateReason)reason;
ParametersDescription
engineCloudHubRtcEngineKit object
uidThe ID of the remote user whose audio state changes.
stateThe state of the remote audio, See CloudHubAudioRemoteState
reasonThe reason of the remote audio state change, SeeCloudHubAudioRemoteStateReason

Details

When the audio state of a remote user (in the voice/video call channel) or host (in the live streaming channel) changes, the SDK triggers this callback to report the current state of the remote audio stream.

rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo:

Occurs when the remote video state changes.

- (void)            rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
 remoteVideoStateChangedOfUid:(NSString * _Nonnull)uid
                     streamId:(NSString * _Nonnull)streamId
                         type:(CloudHubMediaType)type
                        state:(CloudHubVideoRemoteState)state
                       reason:(CloudHubVideoRemoteStateReason)reason
                       streamInfo:(NSString * _Nullable)streamInfo;
ParametersDescription
engineCloudHubRtcEngineKit object
uidThe ID of the remote user whose video state changes.
streamIdThe only Id of this video stream in the channel. This ID is required to be transmitted when using the Plus version of the interface to call subscription/play/set the remote video streaming method
typeThe type of video stream, which may be audio, video, screen sharing, etc. SeeCloudHubMediaType
stateThe state of the remote video, SeeCloudHubVideoRemoteState
reasonThe reason for the remote video state change, SeeCloudHubVideoRemoteStateReason
streamInfoUser-defined data (Json string format)

Details

When the remote user/host video status changes, the SDK will trigger the callback to report the current remote video stream status to the local user

Each user may have multiple video streams, each video has its type (type), streamId is the unique identifier of a video stream in the channel

rtcEngine:firstRemoteAudioFrameOfUid:

Callback of the first frame of received remote audio

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
firstRemoteAudioFrameOfUid:(NSString * _Nonnull)uid;
ParametersDescription
engineCloudHubRtcEngineKit object
uidUser uid of the remote audio stream

rtcEngine:firstLocalVideoFrameWithSize:elapsed:

Occurs when the first video frame is published.

- (void)           rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
firstLocalVideoFrameWithSize:(CGSize)size
                     elapsed:(NSInteger)elapsed;
ParametersDescription
engineCloudHubRtcEngineKitobject
sizeThe width and height of the first frame of video
elapsedThe time elapsed(ms) from the local client calling joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: until the SDK triggers this callback.

rtcEngine:onLocalVideoSizeChanged:

Callback for local video size change

- (void)      rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onLocalVideoSizeChanged:(CGSize)size;
ParametersDescription
engineCloudHubRtcEngineKitobject
sizeThe width and height of the first frame of video

rtcEngine:firstRemoteVideoFrameOfUID:streamId:type:Size:

Occurs when the first remote video frame is rendered.

- (void)         rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
firstRemoteVideoFrameOfUID:(NSString * _Nonnull)uid
                  streamId:(NSString * _Nonnull)streamId
                      type:(CloudHubMediaType)type
                      Size:(CGSize)size;
ParametersDescription
engineCloudHubRtcEngineKit object
uidThe ID of the remote user whose video state changes.
streamIdThe only Id of this video stream in the channel. This ID is required to be transmitted when using the Plus version of the interface to call subscription/play/set the remote video streaming method
typeThe type of video stream, which may be audio, video, screen sharing, etc. SeeCloudHubMediaType
sizeVideo dimensions

Details

After the first video frame from the remote end is received locally and successfully decoded, the callback will be triggered. There are two situations:

rtcEngine:remoteVideoSizeChangedOfUID:streamId:type:size:

The size of the remote video stream has changed callback

- (void)          rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
remoteVideoSizeChangedOfUID:(NSString * _Nonnull)uid
                   streamId:(NSString * _Nonnull)streamId
                       type:(CloudHubMediaType)type
                       size:(CGSize)size;
ParametersDescription
engineCloudHubRtcEngineKit object
uidThe ID of the remote user whose video state changes.
streamIdThe only Id of this video stream in the channel. This ID is required to be transmitted when using the Plus version of the interface to call subscription/play/set the remote video streaming method
typeThe type of video stream, which may be audio, video, screen sharing, etc.SeeCloudHubMediaType
sizeVideo dimensions

Statistics events

rtcEngine:remoteAudioStats:

Reports the transport-layer statistics of each remote audio stream.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
 remoteAudioStats:(CloudHubRtcRemoteAudioStats * _Nonnull)stats;
ParametersDescription
engineCloudHubRtcEngineKit object
statsThe statistics of the received remote audio streams. See CloudHubRtcRemoteAudioStats

Details

The SDK triggers this callback once every two seconds for each remote user who is sending audio streams. If a channel includes multiple remote users, the SDK triggers this callback as many times.

rtcEngine:onRtcStats:

Reports the statistics of the current call.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
       onRtcStats:(CloudHubChannelStats * _Nonnull)stats;
ParametersDescription
engineCloudHubRtcEngineKit object
statsStatistics of the RTC engine, ,See CloudHubChannelStats

Details

The SDK triggers this callback once every two seconds after the user joins the channel.

rtcEngine:onNetworkQuality:

Reports the last mile network quality of each user in the channel.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
 onNetworkQuality:(NSString * _Nonnull)uid
        txQuality:(CloudHubNetworkQuality)txQuality
        rxQuality:(CloudHubNetworkQuality)rxQuality;
ParametersDescription
engineCloudHubRtcEngineKit object
uidThe network quality of the user with this user ID is reported.
txQualityUplink network quality rating of the user in terms of the transmission bit rate, packet loss rate, average RTT (Round-Trip Time) and jitter of the uplink network. ⻅ CloudHubNetworkQuality
rxQualityDownlink network quality rating of the user in terms of packet loss rate, average RTT, and jitter of the downlink network.,⻅ CloudHubNetworkQuality

Details

This callback describes the statistics of sending media streams and receiving remote media streams during a call. The outgoing media stream and each remote user media stream will be called back separately

rtcEngine:localAudioStats:

Reports the statistics of the local audio stream.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
  localAudioStats:(CloudHubRtcLocalAudioStats * _Nonnull)stats;
ParametersDescription
engineCloudHubRtcEngineKit object
statsLocal audio statistics. For details, See CloudHubRtcLocalAudioStats

Details

The SDK triggers this callback once every two seconds.

rtcEngine:localVideoStats:

Reports the statistics of the local video stream.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
  localVideoStats:(CloudHubRtcLocalVideoStats * _Nonnull)stats;
ParametersDescription
engineCloudHubRtcEngineKit object
statsThe statistics of the local video stream. For details, See CloudHubRtcLocalVideoStats

Details

The SDK triggers this callback once every two seconds to report the statistics of the local video stream.

rtcEngine:remoteVideoStats:

Reports the transport-layer statistics of each remote video stream.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
 remoteVideoStats:(CloudHubRtcRemoteVideoStats * _Nonnull)stats;
ParametersDescription
engineCloudHubRtcEngineKit object
statsStatistics of the remote video stream. For details, See CloudHubRtcRemoteVideoStats

Details

Reports the statistics of the video stream from the remote users. The SDK triggers this callback once every two seconds for each remote user. If a channel has multiple users/hosts sending video streams, the SDK triggers this callback as many times.

Media files play(Mobile currently only supports mp4, wav, mp3) events

rtcEngine:onLocalMovieStateChanged:state:errorCode:

The local user’s music file playback status changes callback

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onLocalMovieStateChanged:(NSString * _Nonnull)filepath
                    state:(CloudHubMovieStateCode)state
                errorCode:(CloudHubMovieErrorCode)errorCode;
ParametersDescription
engineCloudHubRtcEngineKit object
filepathThe file path passed in when calling startPlayingMovie:cycle:view:paused:
statePlay state, See CloudHubMovieStateCode
errorCodeError code, See CloudHubMovieErrorCode

rtcEngine:onLocalMovieProgress:pos:total:

Local user’s music file playback progress callback

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onLocalMovieProgress:(NSString * _Nonnull)filepath
                  pos:(NSUInteger)pos
                total:(NSUInteger)total;
ParametersDescription
engineCloudHubRtcEngineKit object
filepathThe file path passed in when calling startPlayingMovie:cycle:view:paused:
posPlay progress (ms)
totalTotal file duration (ms)

rtcEngine:firstLocalMovieVideoFrame:size:

The callback triggered when the first frame of the local video is played

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
firstLocalMovieVideoFrame:(NSString * _Nonnull)filepath
                      size:(CGSize)size;
ParametersDescription
engineCloudHubRtcEngineKit object
filepathThe file path passed in when calling startPlayingMovie:cycle:view:paused:
sizeThe width and height of the first frame of video

Audio effect file playbac(Mobile currently only supports wav, mp3)events

rtcEngine:onAudioEffectFinish:

Occurs when the playback of the local audio effect file finishes.

- (void)  rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onAudioEffectFinish:(int)soundId;;
ParametersDescription
engineCloudHubRtcEngineKit object
soundIdThe effect ID that was passed in playEffect:filePath:loopCount:
pitch:pan:gain:publish:startTimeMS:endTimeMS:

Media stream relay across channels events

rtcEngine:onChannel:MediaRelayStateChanged:error:

The cross-channel media stream forwarding status has changed callback

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
             onChannel:(NSString* _Nonnull)channelID
MediaRelayStateChanged:(CloudHubMediaRelayState)state
                 error:(CloudHubMediaRelayError)error;
ParametersDescription
engineCloudHubRtcEngineKit object
channelIDThe target channel number, which is specified when the cross-room media stream forwarding is started/updated
stateCurrent state: Details CloudHubMediaRelayState
CloudHub_RELAY_STATE_IDLE(0): SDK is initializing
CloudHub_RELAY_STATE_CONNE CTING(1): SDK try Cross-channel
CloudHub_RELAY_STATE_RUNNING(2): The host of the source channel successfully added to the target channel
CloudHub_RELAY_STATE_FAILURE(3): An abnormality occurred. Details of the error message indicated in the code
errorError code of cross-channel media stream forwarding error: Details CloudHubMediaRelayError
CloudHub_RELAY_OK(0): Everything is normal
RELAY_ERROR_SERVER_ERROR_R ESPONSE (1): The server responded with an error
CloudHub_RELAY_ERROR_SERVER _ERROR_RESPONSE(2): The server did not respond
CloudHub_RELAY_ERROR_NO_RES OURCE_AVAILABLE(3): SDK unable to obtain services, may be due to limited server resources
CloudHub_RELAY_ERROR_FAILED_ JOIN_SRC(4): Failed to initiate cross-channel forwarding media stream request
CloudHub_RELAY_ERROR_FAILED_ JOIN_DEST(5): Failed to accept cross-channel forwarding media stream request
CloudHub_RELAY_ERROR_FAILED_ (PACKET_RECERCD6) Server failed to receive cross-channel forwarding of media stream
CloudHub_RELAY_ERROR_FAILED_ PACKET_SENT_TO_DEST(7): Server failed to send cross-channel forwarding of media stream
CloudHub_RELAY_ERROR_SERVER _CONNECTION_LOST(8): SDK disconnected from server due to poor network quality Open, you can call leaveChannel: to leave the current channel

Note: When the cross-channel media stream forwarding status changes, the SDK will trigger the callback and report the current forwarding status and related error information

Volume indication

rtcEngine:reportAudioVolumeIndication:totalVolume:

Reports the volume information of users.

- (void)          rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
reportAudioVolumeIndication:(NSArray * _Nonnull)speakers
                totalVolume:(NSInteger)totalVolume;
ParametersDescription
engineCloudHubRtcEngineKit object
speakersArray of the CloudHubAudioVolumeInfo An empty speakers array in the callback indicates that no remote user is in the channel or sending a stream at the moment.
volume(The volume of the speaker. The value range is [0,255].
In the callback for the local user, totalVolume is the volume of the local user who sends a stream.
n the callback for remote users, totalVolume is the sum of the volume of all remote users (up to three) whose instantaneous volumes are the highest.

Details

This callback reports the user IDs of the users (up to 3) with the highest instantaneous volume in the channel, their volume, and whether the local user is talking

This callback is disabled by default and can be enabled by the enableAudioVolumeIndication:smooth:reportVAD: method; when enabled, the SDK will press enableAudioVolumeIndication:smooth:reportVAD: The callback is triggered at the interval set in the method. Each time it is triggered, the user will receive two separate callbacks, one of which contains the local user’s Volume information, the other contains the volume information of all users at the remote end.

rtcEngine:onActiveSpeaker:

Callback of the most active remote user detected

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
   onActiveSpeaker:(NSString * _Nonnull)uid;
ParametersDescription
uidID of the most active remote user

Details

After successfully calling enableAudioVolumeIndication:smooth:reportVAD:, the SDK will continue to monitor the remote user with the loudest volume, and count the number of times the user is judged to be the loudest. . In the current time period, the remote user with the most accumulated number of times is the most active user.

When the number of users in the channel is greater than or equal to 2 and there are active users, the SDK will trigger the callback and report the uid of the most active user.

Stream fallback

rtcEngine:didLocalPublishFallbackToAudioOnly:deviceId:

The local publishing stream has fallen back to audio stream or reverted to audio and video stream callback

- (void)                rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
didLocalPublishFallbackToAudioOnly:(BOOL)isFallbackOrRecover
                         deviceId:(NSString * _Nonnull)deviceId;
ParametersDescription
engineCloudHubRtcEngineKit
isFallbackOrRecoverYES: The local media streams are rolled back to audio streams because the network environment is not ideal
NO: Due to the improvement of the network environment, the published audio stream is restored to audio and video stream
deviceIddevice Id

rtcEngine:didRemoteSubscribeFallbackToAudioOnly:byUid:type:streamId:

The remote subscription stream has fallen back to an audio stream or reverted to an audio and video stream callback

- (void)                    rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
didRemoteSubscribeFallbackToAudioOnly:(BOOL)isFallbackOrRecover
                                byUid:(NSString * _Nonnull)uid
                                 type:(CloudHubMediaType)type
                             streamId:(NSString * _Nonnull)streamId;
ParametersDescription
engineCloudHubRtcEngineKit
isFallbackOrRecoverYES: The remotely subscribed media stream falls back to audio-only due to poor network conditions.
NO: The remotely subscribed media stream switches back to the video stream after the network conditions improved.
uiduser id
typeMEDIA TYPE. See CloudHubMediaType
streamIdstream id

Pre-call network test events

rtcEngine:onLastmileQuality:

Reports the last-mile network quality of the local user once every two seconds.

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onLastmileQuality:(CloudHubNetworkQuality * _Nonnull)quality;
ParametersDescription
engineCloudHubRtcEngineKit object
qualityThe last mile network quality. See CloudHubNetworkQuality

rtcEngine:onLastmileProbeResult:

Reports the last mile network probe result.

- (void)    rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onLastmileProbeResult:(CloudHubLastmileProbeResult * _Nonnull)result;
ParametersDescription
engineCloudHubRtcEngineKit object
resulthe uplink and downlink last-mile network probe test result. For details, See CloudHubLastmileProbeResult

Raw audio data events

rtcEngine:onRecordAudioFrame:sampleRate:channels:

- (void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onRecordAudioFrame:(NSData * _Nonnull)buffer
        sampleRate:(int)sampelRate
          channels:(int)channels;

Set the format of the collected data callback.

Parameters

ParametersDescription
audioFrameAudio raw data. See: The buffer data in AudioFrame is valid and the data will be sent; false: the buffer data in the audioFrame is invalid and the data will be discarded
dataReceived data

rtcEngine:onPlaybackAudioFrame:sampleRate:channels:

- (void)    rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
 onPlaybackAudioFrame:(NSData * _Nonnull)buffer
           sampleRate:(int)sampelRate
             channels:(int)channels;

Set the format of the playback data callback

Parameters

ParametersDescription
audioFrameAudio raw data. See: The buffer data in AudioFrame is valid and the data will be sent; false: the buffer data in the audioFrame is invalid and the data will be discarded
dataReceived data

Audio recorder events

rtcEngine:voiceClipFileReady:clip:ts:

Record sound clip callback

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
voiceClipFileReady:(NSString* _Nonnull)clipBaseName
               clip:(NSString* _Nonnull)currentClipFileName
                 ts:(int64_t)clipTs;
ParametersDescription
engineCloudHubRtcEngineKit object
clipBaseNameSound clip basename
currentClipFileNameComplete sound clip name
clipTsMillisecond timestamp

rtcEngine:onVoiceTranslateTextReady:text:

Sound file recognition callback

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onVoiceTranslateTextReady:(NSString* _Nonnull)wavFileName
                      text:(NSString * _Nonnull)text;
ParametersDescription
engineCloudHubRtcEngineKit object
wavFileNameSound file
textRecognized text

Device manager

rtcEngine:didAudioRouteChanged:

Audio output device change notification

- (void)   rtcEngine:(CloudHubRtcEngineKit *_Nonnull)engine
didAudioRouteChanged:(CloudHubAudioOutputRouting)routing;
ParametersDescription
engineCloudHubRtcEngineKit 实例指针
routingSee:CloudHubAudioOutputRouting

Data stream events

rtcEngine:onStreamMessagWithUid:data:

- (void)    rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onStreamMessagWithUid:(NSString * _Nonnull)uid
                 data:(NSData * _Nonnull)data;

The callback of receiving the other party’s data stream message.

This callback indicates that the local user has received the stream message sent by the remote user calling the sendStreamMessage: method.

Parameters

ParametersDescription
uidUser ID
dataReceived data

Remote publish event(only when auto subscription mode is turned off)

rtcEngine:onUserPublished:type:stream:

The remote user starts to publish the audio video callback

- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
  onUserPublished:(NSString * _Nonnull)uid
             type:(CloudHubMediaType)type
           stream:(NSString * _Nonnull)streamId;
ParametersDescription
engineCloudHubRtcEngineKit object
uidID of the user who posted the video stream
typeVideo stream type, which may be audio, video, screen sharing,See CloudHubMediaType
streamIdThe only Id of this video stream in the channel. When using the Plus version of the interface to subscribe/play/set the remote video stream method, you need to pass this Id

Details

When a user in the channel successfully publishes an audio and video stream, if the local automatic subscription is turned off, the callback will be received. At this time, if you decide to watch this person, you need to call subscribe,after success, receive rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streaminfo: callback. If the local auto subscription is not closed, you will directly receive the rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo: callback

rtcEngine:onUserUnPublished:type:stream:

The remote user stops publishing audio and video callbacks

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onUserUnPublished:(NSString * _Nonnull)uid
              type:(CloudHubMediaType)type
            stream:(NSString * _Nonnull)streamId;
ParametersDescription
engineCloudHubRtcEngineKit object
uidID of the user who posted the video stream
typeVideo stream type, which may be audio, video, screen sharing, etc., details CloudHubMediaType
streamIdThe only Id of this video stream in the channel. When using the Plus version of the interface to subscribe/play/set the remote video stream method, you need to pass this Id

Details

When a user in the channel stops the audio video stream, if the local automatic subscription is turned off, the callback will be received, and there is no need to actively call unSubscribe method

Server recording events

rtcEngine:onServerRecordStateChange:startTS:currTS:pauseDuration:recordDuration:

The local user’s music file playback status changes callback

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onServerRecordStateChange:(CloudHubRecordingState)state
                   startTS:(NSUInteger)startTS
                    currTS:(NSUInteger)currTS
             pauseDuration:(NSUInteger)pauseDuration
            recordDuration:(NSUInteger)recordDuration;
ParametersDescription
engineCloudHubRtcEngineKit object
stateCurrent recording state, 0 not started, 1 recording, 2 paused
startTSStart time (Milliseconds experienced since 0 a.m. on January 1, 1970)
currTSCurrent server time (Milliseconds experienced since 0 a.m. on January 1, 1970)
pauseDurationTotal pause duration, ms
recordDurationTotal recording time (excluding pause time), ms

Advanced signaling event

rtcEngine:onSetPropertyOfUid:from:properties:

User-defined attribute change callback

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onSetPropertyOfUid:(NSString * _Nonnull)uid
               from:(NSString * _Nullable)fromuid
         properties:(NSString * _Nonnull)prop;
ParametersDescription
engineCloudHubRtcEngineKit object
uidUser uid whose attribute changed
fromuidThe user who initiated the operation uid
propThe changed property, json string

Note:

Only when the local user is within the notification range specified when calling setPropertyOfUid:tell:properties: (if not specified, everyone in the channel will be notified). Will receive the callback

rtcEngine:onChatMessageArrival:from:withExtraData:

Chat message callback

-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onChatMessageArrival:(NSString * _Nonnull)message
                 from:(NSString * _Nullable)fromuid
        withExtraData:(NSString * _Nullable)extraData;
ParametersDescription
engineCloudHubRtcEngineKit object
messageMessage text content
fromuidThe user who initiated the operation uid
extraDataAdditional data, may be empty

Note:

Only when the local user is within the notification range specified when calling sendChatMsg:to:withExtraData: (if not specified, everyone in the channel will be notified). Will receive the callback

rtcEngine:onPubMsg:msgId:from:withData:associatedWithUser:associatedWithMsg:ts:withExtraData:isHistory:

Custom message publishing callback

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
         onPubMsg:(NSString * _Nonnull)msgName
            msgId:(NSString * _Nonnull)msgId
             from:(NSString * _Nullable)fromuid
         withData:(NSString * _Nullable)data
associatedWithUser:(NSString * _Nullable)uid
associatedWithMsg:(NSString * _Nullable)assMsgID
               ts:(NSUInteger)ts
    withExtraData:(NSString * _Nullable)extraData
        isHistory:(BOOL)isHistory;
ParametersDescription
engineCloudHubRtcEngineKit object
msgNameMessage name
msgIdMessage id, which is the unique identifier of a message in the channel
fromuiduid of the message sender
dataMessage content, must be a json string, can be empty
uidThe uid of the associated user. Once a message is associated with a user, the message will be automatically deleted when the user logs out
assMsgIDThe id of the associated message. Once a message is associated with another message, the associated message will be deleted automatically when the associated message is deleted
tsThe timestamp when the server last received the message
extraDataReserved Parameters
isHistoryIs the message sent before the local user enters the channel

Note:

Only when local users call pubMsg:msgId:to:withData:associatedWithUser:associatedWithMsg:save:extraData: within the specified notification range (notify if not specified Everyone in the channel), local users will receive the callback

rtcEngine:onPubMsg:msgId:from:withData:associatedWithUser:associatedWithMsg:ts:withExtraData:isHistory:seq:

Custom message publishing callback

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
         onPubMsg:(NSString * _Nonnull)msgName
            msgId:(NSString * _Nonnull)msgId
             from:(NSString * _Nullable)fromuid
         withData:(NSString * _Nullable)data
associatedWithUser:(NSString * _Nullable)uid
associatedWithMsg:(NSString * _Nullable)assMsgID
               ts:(NSUInteger)ts
    withExtraData:(NSString * _Nullable)extraData
        isHistory:(BOOL)isHistory
              seq:(NSInteger)seq;
ParametersDescription
engineCloudHubRtcEngineKit object
msgNameMessage name
msgIdMessage id, which is the unique identifier of a message in the channel
fromuiduid of the message sender
dataMessage content, must be json string can be empty
uidThe uid of the associated user. Once a message is associated with a user, the message will be automatically deleted when the user logs out
assMsgIDThe id of the associated message. Once a message is associated with another message, the associated message will be deleted automatically when the associated message is deleted
tsThe timestamp when the server last received the message
extraDataReserved Parameters
isHistoryIs the message sent before the local user enters the channel
seqThe order of messages sent by the server

Note:

Only when local users call pubMsg:msgId:to:withData:associatedWithUser:associatedWithMsg:save:extraData: within the specified notification range (notify if not specified Everyone in the channel), local users will receive the callback

rtcEngine:onDelMsg:msgId:from:withData:

Custom message delete callback

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
          onDelMsg:(NSString * _Nonnull)msgName
             msgId:(NSString * _Nonnull)msgId
              from:(NSString * _Nullable)fromuid
          withData:(NSString * _Nullable)data;
ParametersDescription
engineCloudHubRtcEngineKit object
msgNameMessage name
msgIdMessage id, which is the unique identifier of a message in the channel
fromuiduid of the message sender
dataReserved Parameters

Note:

Only when the local user is within the notification range specified when calling delMsg:msgId:to: (not specified means notifying everyone in the channel). Will receive the callback

rtcEngine:onDelMsg:msgId:from:withData:ts:seq:

Custom message delete callback

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
          onDelMsg:(NSString * _Nonnull)msgName
             msgId:(NSString * _Nonnull)msgId
              from:(NSString * _Nullable)fromuid
          withData:(NSString * _Nullable)data
                ts:(NSUInteger)ts
               seq:(NSInteger)seq;
ParametersDescription
engineCloudHubRtcEngineKit object
msgNameMessage name
msgIdMessage id, which is the unique identifier of a message in the channel
fromuiduid of the message sender
dataReserved Parameters
tsMessage sending time
seqThe order of messages sent by the server

Note:

Only when the local user is within the notification range specified when calling delMsg:msgId:to: (not specified means notifying everyone in the channel). Will receive the callback

rtcEngine:onLocalUserEvicted:

Callback when local user is kicked out of the channel

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onLocalUserEvicted:(NSInteger)reason;
ParametersDescription
engineCloudHubRtcEngineKit object
reasonThe reason for being kicked, filled in by the server, or passed in when calling evictUser:reason:, see below Details

Details

When this callback is received, there may be two reasons:

rtcEngine:onChannelForceClosed:reason:

The channel is closed by the server callback

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onChannelForceClosed:(NSString * _Nonnull)channelID
           reason:(CloudHubCloseChannelReason)reason;
ParametersDescription
engineCloudHubRtcEngineKit object
channelIDThe number of the closed channel
reasonThe reason why the channel was closed, details CloudHubCloseChannelReason
errorError code of cross-channel media stream forwarding error: Details CloudHubMediaRelayError
CloudHub_RELAY_OK(0): Everything is normal
RELAY_ERROR_SERVER_ERROR_R ESPONSE(1 ): The server responded with an error
CloudHub_RELAY_ERROR_SERVER _ERROR_RESPONSE(2): The server did not respond
CloudHub_RELAY_ERROR_NO_RES OURCE_AVAILABLE(3): The SDK cannot obtain services, which may be due to limited server resources
CloudHub_RELAY_ERROR_FAILED_ JOIN_SRC(4): Failed to initiate a cross-channel forwarding media stream request
CloudHub_RELAY_ERROR_FAILED_ JOIN_DEST(5): Failure to accept a cross-channel forwarding media stream request
CloudHub_RELAY_ERROR_FAILED_ PACKET_RECEIVERCD_FAILED_ PACKET_RECEIVERCD_FROM_SRC_RECEIVERCD_FROM_SRC(6) Failed to forward media streams across channels<br/> CloudHub_RELAY_ERROR_FAILED_ PACKET_SENT_TO_DEST(7): The server failed to forward media streams across channels.<br/> CloudHub_RELAY_ERROR_SERVER _CONNECTION_LOST(8)`: SDK disconnected from the server due to poor network quality. You can call leaveChannel: to leave the current channel

Details

When the cross-channel media stream forwarding status changes, the SDK will trigger the callback and report the current forwarding status and related error information

rtcEngineOnHistoryDataReady:

Callback after sending historical signaling

-(void)rtcEngineOnHistoryDataReady:(CloudHubRtcEngineKit * _Nonnull**)engine;
ParametersDescription
engineCloudHubRtcEngineKit object

Details

When the historical signaling saved by the server is sent, the SDK will trigger the callback

Other event

rtcEngine:onServerTime:

Callback to return server time

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
      onServerTime:(NSUInteger)serverts;
ParametersDescription
engineCloudHubRtcEngineKit instance pointer
servertsServer time

rtcEngine:onDocAddr:serial:

Return the address of the courseware server

-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
         onDocAddr:(NSString * _Nonnull)docaddr
            serial:(NSString * _Nonnull)serial;
ParametersDescription
engineCloudHubRtcEngineKit instance pointer
docaddrCourseware server address list
serialChannel Id