CloudHubSDK iOS
- Overview
- CloudHubRtcEngineKit
- CloudHubRtcEngineDelegate
- CloudHubRtcChannelKit
- CloudHubRtcChannelDelegate
- CloudHubEnumerates
- CloudHubObjects
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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit instance pointer |
errorCode | CloudHubErrorCode error code |
message | Error 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | User 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 |
elapsed | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | The 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 |
elapsed | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
stats | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
oldRole | CloudHubClientRole Role that the user switches |
newRole | CloudHubClientRole 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | The 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 |
properties | User-defined attributes of this user can be specified through the joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: and setPropertyOfUid:tell:properties: interfaces |
isHistory | Whether this user joined the channel before the local user |
srcChannel | When 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:
- A remote user/host joins the channel by calling the joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: method
- A remote user switches the user role to the host after joining the channel.
- A remote user/host rejoins the channel after a network interruption.
Note:
- The host can receive the callback of the new host joining the channel, and can obtain the uid of the host
- Viewers can also receive a callback for a new host to join the channel, and can obtain the uid of the host
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
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | The ID of the user who leaves the channel or goes offline. |
reason | Reasons 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
state | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
token | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
type | CloudHubPermissionType The permission type that has changed, 1 publish, 2 subscribe |
permission | Is 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:
- After regaining the publishing permission, if you want to publish your own audio and video immediately, you need to call the publishStream method again after receiving the
rtcEngine:onLocalUserPermissionChanged:permission:
callback - When the subscription permission is regained, the subscription will continue automatically, and only need to respond to the following rtcEngine:remoteAudioStateChangedOfUid:state:reason: and rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo:
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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
state | The state of the local audio. For details, SeeCloudHubAudioLocalState |
error | Local 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
state | The state of the local video, SeeCloudHubLocalVideoStreamState |
error | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | The ID of the remote user whose audio state changes. |
state | The state of the remote audio, See CloudHubAudioRemoteState |
reason | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | The ID of the remote user whose video state changes. |
streamId | The 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 |
type | The type of video stream, which may be audio, video, screen sharing, etc. SeeCloudHubMediaType |
state | The state of the remote video, SeeCloudHubVideoRemoteState |
reason | The reason for the remote video state change, SeeCloudHubVideoRemoteStateReason |
streamInfo | User-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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | User 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKitobject |
size | The width and height of the first frame of video |
elapsed | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKitobject |
size | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | The ID of the remote user whose video state changes. |
streamId | The 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 |
type | The type of video stream, which may be audio, video, screen sharing, etc. SeeCloudHubMediaType |
size | Video 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:
- Send video after the remote user goes online for the first time
- The remote user’s video is offline and then goes online to send the video. The video offline means that the local user did not receive the video package within 15 seconds. The possible reasons are as follows:
- The remote user leaves the channel
- Remote user dropped
- The remote user stopped sending the video stream(muteLocalVideoStream: be called )
- The remote user turns off the video (enableLocalVideo:
NO
is called)
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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | The ID of the remote user whose video state changes. |
streamId | The 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 |
type | The type of video stream, which may be audio, video, screen sharing, etc.SeeCloudHubMediaType |
size | Video dimensions |
Statistics events
rtcEngine:remoteAudioStats:
Reports the transport-layer statistics of each remote audio stream.
- (void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
remoteAudioStats:(CloudHubRtcRemoteAudioStats * _Nonnull)stats;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
stats | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
stats | Statistics 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | The network quality of the user with this user ID is reported. |
txQuality | Uplink 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 |
rxQuality | Downlink 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
stats | Local 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
stats | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
stats | Statistics 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
filepath | The file path passed in when calling startPlayingMovie:cycle:view:paused: |
state | Play state, See CloudHubMovieStateCode |
errorCode | Error 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
filepath | The file path passed in when calling startPlayingMovie:cycle:view:paused: |
pos | Play progress (ms) |
total | Total 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
filepath | The file path passed in when calling startPlayingMovie:cycle:view:paused: |
size | The 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;;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
soundId | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
channelID | The target channel number, which is specified when the cross-room media stream forwarding is started/updated |
state | Current state: Details CloudHubMediaRelayStateCloudHub_RELAY_STATE_IDLE(0) : SDK is initializingCloudHub_RELAY_STATE_CONNE CTING(1) : SDK try Cross-channelCloudHub_RELAY_STATE_RUNNING(2) : The host of the source channel successfully added to the target channelCloudHub_RELAY_STATE_FAILURE(3) : An abnormality occurred. Details of the error message indicated in the code |
error | Error code of cross-channel media stream forwarding error: Details CloudHubMediaRelayErrorCloudHub_RELAY_OK(0) : Everything is normalRELAY_ERROR_SERVER_ERROR_R ESPONSE (1) : The server responded with an errorCloudHub_RELAY_ERROR_SERVER _ERROR_RESPONSE(2) : The server did not respondCloudHub_RELAY_ERROR_NO_RES OURCE_AVAILABLE(3) : SDK unable to obtain services, may be due to limited server resourcesCloudHub_RELAY_ERROR_FAILED_ JOIN_SRC(4) : Failed to initiate cross-channel forwarding media stream requestCloudHub_RELAY_ERROR_FAILED_ JOIN_DEST(5) : Failed to accept cross-channel forwarding media stream requestCloudHub_RELAY_ERROR_FAILED_ (PACKET_RECERCD6) Server failed to receive cross-channel forwarding of media streamCloudHub_RELAY_ERROR_FAILED_ PACKET_SENT_TO_DEST(7) : Server failed to send cross-channel forwarding of media streamCloudHub_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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
speakers | Array 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;
Parameters | Description |
---|---|
uid | ID 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.
- If the most active user is always the same user, the SDK will not trigger the onActiveSpeaker callback again.
- If the most active user changes, the SDK will trigger the callback again and report the uid of the new 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit |
isFallbackOrRecover | YES : The local media streams are rolled back to audio streams because the network environment is not idealNO : Due to the improvement of the network environment, the published audio stream is restored to audio and video stream |
deviceId | device 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit |
isFallbackOrRecover | YES: 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. |
uid | user id |
type | MEDIA TYPE. See CloudHubMediaType |
streamId | stream 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
quality | The last mile network quality. See CloudHubNetworkQuality |
rtcEngine:onLastmileProbeResult:
Reports the last mile network probe result.
- (void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onLastmileProbeResult:(CloudHubLastmileProbeResult * _Nonnull)result;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
result | he 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
Parameters | Description |
---|---|
audioFrame | Audio 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 |
data | Received 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
Parameters | Description |
---|---|
audioFrame | Audio 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 |
data | Received 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
clipBaseName | Sound clip basename |
currentClipFileName | Complete sound clip name |
clipTs | Millisecond timestamp |
rtcEngine:onVoiceTranslateTextReady:text:
Sound file recognition callback
-(void) rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onVoiceTranslateTextReady:(NSString* _Nonnull)wavFileName
text:(NSString * _Nonnull)text;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
wavFileName | Sound file |
text | Recognized text |
Device manager
rtcEngine:didAudioRouteChanged:
Audio output device change notification
- (void) rtcEngine:(CloudHubRtcEngineKit *_Nonnull)engine
didAudioRouteChanged:(CloudHubAudioOutputRouting)routing;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit 实例指针 |
routing | See: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
Parameters | Description |
---|---|
uid | User ID |
data | Received 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | ID of the user who posted the video stream |
type | Video stream type, which may be audio, video, screen sharing,See CloudHubMediaType |
streamId | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | ID of the user who posted the video stream |
type | Video stream type, which may be audio, video, screen sharing, etc., details CloudHubMediaType |
streamId | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
state | Current recording state, 0 not started, 1 recording, 2 paused |
startTS | Start time (Milliseconds experienced since 0 a.m. on January 1, 1970) |
currTS | Current server time (Milliseconds experienced since 0 a.m. on January 1, 1970) |
pauseDuration | Total pause duration, ms |
recordDuration | Total 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
uid | User uid whose attribute changed |
fromuid | The user who initiated the operation uid |
prop | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
message | Message text content |
fromuid | The user who initiated the operation uid |
extraData | Additional 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
msgName | Message name |
msgId | Message id, which is the unique identifier of a message in the channel |
fromuid | uid of the message sender |
data | Message content, must be a json string, can be empty |
uid | The uid of the associated user. Once a message is associated with a user, the message will be automatically deleted when the user logs out |
assMsgID | The 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 |
ts | The timestamp when the server last received the message |
extraData | Reserved Parameters |
isHistory | Is 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
msgName | Message name |
msgId | Message id, which is the unique identifier of a message in the channel |
fromuid | uid of the message sender |
data | Message content, must be json string can be empty |
uid | The uid of the associated user. Once a message is associated with a user, the message will be automatically deleted when the user logs out |
assMsgID | The 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 |
ts | The timestamp when the server last received the message |
extraData | Reserved Parameters |
isHistory | Is the message sent before the local user enters the channel |
seq | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
msgName | Message name |
msgId | Message id, which is the unique identifier of a message in the channel |
fromuid | uid of the message sender |
data | Reserved 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
msgName | Message name |
msgId | Message id, which is the unique identifier of a message in the channel |
fromuid | uid of the message sender |
data | Reserved Parameters |
ts | Message sending time |
seq | The 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
reason | The 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:
- When another user called joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess:, the same uid as the local user was used, the server thought Both have the same identity, and the old user is kicked out of the channel. At this time,
reason
is 0 - A user called the evictUser:reason: interface to kick the local user out of the channel. At this time,
reason
is thereason
value passed in when the other party calls
rtcEngine:onChannelForceClosed:reason:
The channel is closed by the server callback
-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onChannelForceClosed:(NSString * _Nonnull)channelID
reason:(CloudHubCloseChannelReason)reason;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit object |
channelID | The number of the closed channel |
reason | The reason why the channel was closed, details CloudHubCloseChannelReason |
error | Error 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 errorCloudHub_RELAY_ERROR_SERVER _ERROR_RESPONSE(2) : The server did not respondCloudHub_RELAY_ERROR_NO_RES OURCE_AVAILABLE(3) : The SDK cannot obtain services, which may be due to limited server resourcesCloudHub_RELAY_ERROR_FAILED_ JOIN_SRC(4) : Failed to initiate a cross-channel forwarding media stream requestCloudHub_RELAY_ERROR_FAILED_ JOIN_DEST(5) : Failure to accept a cross-channel forwarding media stream requestCloudHub_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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit 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;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit instance pointer |
serverts | Server time |
rtcEngine:onDocAddr:serial:
Return the address of the courseware server
-(void)rtcEngine:(CloudHubRtcEngineKit * _Nonnull)engine
onDocAddr:(NSString * _Nonnull)docaddr
serial:(NSString * _Nonnull)serial;
Parameters | Description |
---|---|
engine | CloudHubRtcEngineKit instance pointer |
docaddr | Courseware server address list |
serial | Channel Id |