CloudHub Docs
Download Documents

RTC


CloudHubSDK iOS

API Overview

CloudHub provides a flexible combination of APIs through a globally deployed virtual network, providing reliable real-time audio and video communications for mobile-to-mobile and mobile-to-web

Channel management

MethodDescription
sharedEngineWithAppId:config:Creates and initializes CloudHubRtcEngineKit
sharedEngineWithAppId:config:externalDevices:Creates and initializes CloudHubRtcEngineKit
uninitEnginedestroy RTC CloudHubRtcEngineKit
setChannelProfile:Set the channel profile.
setClientRole:Set the client role.
joinChannelByToken:channelId:properties:uid:
autosubscribeAudio:autoSubscribeVideo:joinSuccess:
Allows a user to join a channel.
joinChannelByToken:channelId:properties:uid:
autosubscribeAudio:autoSubscribeVideo:publishLocalAudio:publishLocalVideo:joinSuccess:
Allows a user to join a channel.
leaveChannel:Leaves a channel.
renewToken:Gets a new token when the current token expires after a period of time.
getConnectionStateGets the current connection state of the SDK.

Channel events

EventDescription
rtcEngine:didJoinChannelwithUid:elapsed:Occurs when a user joins a channel.
rtcEngine:didReJoinChannelwithUid:elapsed:Occurs when a user rejoins the channel.
rtcEngine:didLeaveChannel:Occurs when a user leaves a channel.
rtcEngine:onClientRoleChangedFrom:to:Occurs when the user role switches in the interactive live streaming.
rtcEngine:didJoinedOfUid:properties:isHistory:fromChannel:Occurs when a remote user (Communication)/ host (LiveBroadcasting) joins the channel.
rtcEngine:didOfflineOfUid:reason:Occurs when a remote user (Communication)/ host (LiveBroadcasting) leaves the channel.
rtcEngine:connectionChangedToState:Occurs when the network connection state changes.
rtcEngine:tokenPrivilegeWillExpire:Occurs when the token expires in 30 seconds.
rtcEngineRequestToken:Occurs when the token expires.
rtcEngine:onLocalUserPermissionChanged:permission:Occurs When the local users' publish or subscribe permissions change

Audio management

MethodDescription
enableAudioEnables the audio module.
disableAudioDisables the audio module.
adjustRecordingSignalVolume:Adjusts the volume of the signal captured by the microphone
adjustPlaybackSignalVolume:Adjusts the playback signal volume of all remote users
adjustUserPlaybackSignalVolume:volume:Adjust the playback signal volume of a specified remote user
setPlayoutVolumeRatio:Output volume gain setting
enableLocalAudio:Enables/Disables the local audio capture.
muteLocalAudioStream:Stops or resumes publishing the local audio stream.
muteRemoteAudioStream:mute:Stops or resumes subscribing to the audio stream of a specified user.
muteAllRemoteAudioStreams:Stops or resumes subscribing to the audio streams of all remote users.

Video management

MethodDescription
enableVideoEnable the video module.
disableVideoDisables the video module.
setVideoEncoderConfiguration:Sets the video encoder configuration.
startPlayingLocalVideo:renderMode:mirrorMode:Play local video
startPlayingRemoteVideo:streamId:renderMode:mirrorMode:Start playing remote video
setLocalRenderMode:mirrorMode:Updates the display mode of the local video view.
setRemoteRenderMode:renderMode:mirrorMode:Updates the display mode of the video view of a remote user.
enableLocalVideo:Enables/Disables the local video capture.
muteLocalVideoStream:Stops or resumes publishing the local video stream.
muteRemoteVideoStreamWithUid:mute:Stops or resumes subscribing to the video stream of a specified user.
muteRemoteVideoByStreamId:mute:Stops or resumes subscribing to the video stream of stream id.
muteAllRemoteVideoStreams:Stops or resumes subscribing to the video streams of all remote users.
stopPlayingLocalVideo:Stop local video
stopPlayingRemoteVideo:Stop playing remote video
setLocalVideoHDSet local video HD
setVideoRotation:Set local video rotation mode

Local media events

EventDescription
rtcEngine:localAudioStateChange:error:Occurs when the local audio stream state changes.
rtcEngine:localVideoStateChangeWithState:error:Occurs when the local video stream state changes.
rtcEngineFirstLocalAudioFrame:Occurs when the first audio frame is published.
rtcEngine:firstLocalVideoFrameWithSize:elapsed:Occurs when the first video frame is published.
rtcEngine:onLocalVideoSizeChanged:Callback for local video size change

Remote media events

EventDescription
rtcEngine:remoteAudioStateChangedOfUid:state:reason:Occurs when the remote audio state changes.
rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo:Occurs when the remote video state changes.
rtcEngine:firstRemoteAudioFrameOfUid:Occurs when the first audio frame is received.
rtcEngine:firstRemoteVideoFrameOfUID:streamId:type:Size:Occurs when the first video frame is received.
rtcEngine:remoteVideoSizeChangedOfUID:streamId:type:size:Occurs when the remote video size changes

Statistics events

After adding a channel, the SDK automatically triggers this group of callbacks every 2 seconds. We provide detailed function description and implementation method documents for these callbacks. Please refer to Quality monitoring during calls.

EventDescription
rtcEngine:remoteAudioStats:Reports the transport-layer statistics of each remote audio stream.
rtcEngine:onRtcStats:Reports the statistics of the current call.
rtcEngine:onNetworkQuality:Reports the last mile network quality of each user in the channel.
rtcEngine:localAudioStats:Reports the statistics of the local audio stream.
rtcEngine:localVideoStats:Reports the statistics of the local video stream.
rtcEngine:remoteVideoStats:Reports the transport-layer statistics of each remote video stream.

Video pre-process and post-process

MethodDescription
setBeautyEffectOptions:options:Set beauty effect
setVideoEffectEnable:options:device:Set advanced beauty

Multi-channel management

MethodDescription
createChannel:Create subchannel
destroyChannel:Destroy subchannels

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

MethodDescription
startPlayingMovie:cycleStart playing media files
startPlayingMovie:cycle:view:paused:Start playing media files
startPlayingMovie:publish:cycle:view:pausedStart playing media files
stopPlayingMovie:Stop playing media files
pausePlayingMovie:Pause playing media files
resumePlayingMovie:Resume playing media files
getMovieInfo:Get media playing duration
getMovieCurrentPosition:Get media playback progress
setMoviePosition:withFile:Set media playback position
setMovie:volume:Set the playback volume of music files
EventDescription
rtcEngine:onLocalMovieStateChanged:state:errorCode:Local media file playback status changes
rtcEngine:onLocalMovieProgress:pos:total:Local media file playback progress
rtcEngine:firstLocalMovieVideoFrame:size:Callback of the first frame of media file playback

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

MethodDescription
getEffectsVolumeRetrieves the volume of the audio effects
setEffectsVolume:Sets the volume of the audio effects
setVolumeOfEffect:volume:Sets the volume of a specified audio effect
playEffect:filePath:loopCount:pitch:pan:gain:publish:startTimeMS:endTimeMS:This method plays the specified local or online audio effect file
stopEffect:Stops playing a specified audio effect
stopAllEffectsStops playing all audio effects
preloadEffect:filePath:Preloads a specified audio effect file into the memory
unloadEffect:Releases a specified preloaded audio effect from the memory
pauseEffect:Pauses a specified audio effect
pauseAllEffectsPauses all audio effects
resumeEffect:Resumes playing a specified audio effect
resumeAllEffectsResumes playing all audio effects
translateWavFileToText:Voice recognition text
EventDescription
rtcEngine:onAudioEffectFinish:Occurs when local effect playback has ended

Voice changer and reverberation

MethodDescription
setAudioQuality:Set local send audio quality.
setLocalVoicePitch:Changes the voice pitch of the local speaker
setLocalVoiceEqualizationOfBandFrequency:withGain:Sets the local voice equalization effect
setLocalVoiceReverbOfType:withValue:Sets the local voice reverberation
setAudioEffectPreset:Sets an SDK preset audio effect
enableDeepLearningDenoise:Turn on / off AI noise reduction mode

Sound localization

MethodDescription
enableSoundPositionIndication:Enables/Disables stereo panning for remote users
setRemoteVoicePosition:pan:gain:Sets the sound position and gain of a remote user

Media stream relay across channels

MethodDescription
startChannelMediaRelay:Starts relaying media streams across channels. This method can be used to implement scenarios such as co-host across channels
updateChannelMediaRelay:Updates the channels for media stream relay
stopChannelMediaRelayStops the media stream relay. Once the relay stops, the host quits all the destination channels
EventDescription
rtcEngine:onChannel:MediaRelayStateChanged:error:Occurs when the state of the media stream relay changes

Volume indication

MethodDescription
enableAudioVolumeIndication:smooth:reportVAD:Enables the reporting of users' volume indication.
EventDescription
rtcEngine:reportAudioVolumeIndication:totalVolume:Reports the volume information of users.
rtcEngine:onActiveSpeaker:Active users detected

Switch speakers or earpieces

MethodDescription
setEnableSpeakerphone:Set current speakers
isSpeakerphoneEnabledGets whether speakers are currently used

In-ear monitoring

MethodDescription
enableInEarMonitoring:Enables in-ear monitoring
setInEarMonitoringVolume:Sets the volume of the in-ear monitor

Dual Stream

MethodDescription
enableDualStreamMode:Sets the stream mode to single- (default) or dual-stream mode.
setRemoteVideo:streamType:Sets the remote user’s video stream type received by the local user when the remote user sends dual streams
setRemoteDefaultVideoStreamType:Sets the default video-stream type for the video received by the local user when the remote user sends dual streams

Stream fallback

MethodDescription
setLocalPublishFallbackOption:Sets the fallback option for the published video stream under unreliable network conditions
setRemoteSubscribeFallbackOption:Sets the fallback option for the remote stream under unreliable network conditions
EventDescription
rtcEngine:didLocalPublishFallbackToAudioOnly:deviceId:The local publishing stream has fallen back to audio stream or reverted to audio and video stream callback
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

Pre-call network test

MethodDescription
startEchoTest:Starts an audio call test
stopEchoTestStops the audio call test
startLastmileProbeTest:Starts the last mile network probe test
stopLastmileProbeTestStops the last mile network probe test
EventDescription
rtcEngine:onLastmileQuality:Reports the last-mile network quality of the local user once every two seconds
rtcEngine:onLastmileProbeResult:Reports the last mile network probe result

Audio self-capture(only push)

MethodDescription
setExternalAudioSourceSampleRate:channels:Sets the external audio source
pushAudioFrame:Pushes the external audio frame

Audio self-rendering(only pull)

MethodDescription
setExternalAudioSinkSampleRate:channels:Format rendered data
pullAudioFrame:Pulls the external audio frame

Raw audio data

MethodDescription
setRecordingAudioFrameSampleRate:channels:samples:Set the format of the captured raw audio data
setPlaybackAudioFrameSampleRate:channels:samples:Sets the audio data format for playback
EventDescription
rtcEngine:onRecordAudioFrame:sampleRate:channels:Gets the captured audio frame
rtcEngine:onPlaybackAudioFrame:sampleRate:channels:Gtes the audio frame for playback

Audio recorder

MethodDescription
startRecordingVoiceClip:duration:fileType:Start recording sound clip
stopRecordingVoiceClip:Stop recording sound clip
EventDescription
rtcEngine:voiceClipFileReady:clip:ts:Record sound clip callback
rtcEngine:onVoiceTranslateTextReady:text:Sound file recognition callback

Switch cameras

MethodDescription
switchCamera:Switch cameras
setCameraFlipMode:Vertivcal:Set the flip mode of the camera.
correctCameraKeystoning:Calibration camera
resetCameraKeystoningCancel camera calibration

Device manager

EventDescription
rtcEngine:didAudioRouteChanged:Audio output device change notification

Data stream

MethodDescription
sendStreamMessage:Sends data stream messages
EventDescription
rtcEngine:onStreamMessagWithUid:data:Occurs when the local user receives the data stream from the remote user

Publish management

MethodDescription
setPublishStreamInfo:Set user data when publishing local audio and video(Json)
publishStreamStart publishing local audio and video
unPublishStreamStop publishing local audio and video

Manual subscription management

MethodDescription
subscribe:Start subscribing to audio and video
unSubscribe:Stop subscribing to audio and video

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

MethodDescription
rtcEngine:onUserPublished:type:stream:Occurs when remote user starts publishing video
rtcEngine:onUserUnPublished:type:stream:Occurs when remote user stops publishing video

Server recording

MethodDescription
startServerRecordStart server recording
stopServerRecordStop server recording
pauseServerRecordPause server recording
resumeServerRecordResume server recording
EventDescription
rtcEngine:onServerRecordStateChange: startTS:currTS:pauseDuration:recordDuration:Occurs when server recording status change

Advanced signaling method

MethodDescription
setPropertyOfUid:tell:properties:Set custom attributes for a user in the channel
sendChatMsg:to:withExtraData:Send chat message
pubMsg:msgId:to:withData: associatedWithUser:associatedWithMsg:save:extraData:Publish a custom message
delMsg:msgId:to:Delete a custom message
evictUser:reason:Evict user

Advanced signaling event

EventDescription
rtcEngine:onSetPropertyOfUid:from:properties:Occurs when the user property changes
rtcEngine:onChatMessageArrival:from:withExtraData:Occurs when received chat message
rtcEngine:onPubMsg:msgId:from:withData: associatedWithUser:associatedWithMsg:ts:withExtraData:isHistory:Occurs when receiving signaling
rtcEngine:onDelMsg:msgId:from:withData:Occurs when deleteing signaling
rtcEngine:onLocalUserEvicted:Occurs when local users are evicted
rtcEngine:onChannelForceClosed:reason:Occurs when the channel was closed by the server
rtcEngineOnHistoryDataReady:Callback after sending historical signaling

CDN publisher

MethodDescription
addPublishStreamUrl:Publishes the local stream to a specified CDN live streaming URL
removePublishStreamUrl:Removes an RTMP or RTMPS stream from the CDN
setLiveTranscoding:Sets the transcoding configurations for CDN live streaming

Other method

MethodDescription
getCallIdRetrieves the call ID
getSdkVersionGets the SDK version
setLogFilter:Sets the log output level of the SDK.
getNativeHandleGets the Native SDK Engine Handle

Other event

EventDescription
rtcEngine:didOccurError:withMessage:Occur error
rtcEngine:onServerTime:Callback to return server time
rtcEngine:onDocAddr:serial:Return the address of the courseware server