CloudHub Docs
Download Documents

RTC


CloudHubSDK iOS

CloudHubRtcEngineKit

Delegate settings

delegate:

Set CloudHubRtcEngineKit delegate

@property (nonatomic, weak) id<CloudHubRtcEngineDelegate> _Nullable delegate;

Details

See CloudHubRtcEngineDelegate

Channel management

sharedEngineWithAppId:config:

Creates and initializes Creates and initializes CloudHubRtcEngineKit

+ (instancetype _Nonnull)sharedEngineWithAppId:(NSString * _Nonnull)appId
                                        config:(NSString * _Nullable)config;

Parameter

ParameterDescription
appIdThe App ID issued by CloudHub for your app development project. Only users in apps with the same App ID can join the same channel and communicate with each other,An App ID can only be used to create one CloudHubRtcEngineKit
configReserved parameters

Returns

Details

Please call the interface function of the ‘CloudHubRtcEngineKit’ class in the main thread

Note

sharedEngineWithAppId:config:externalDevices:

Get the RTC engine singleton object pointer

-(instancetype _Nonnull)sharedEngineWithAppId:(NSString * _Nonnull)appId
                                         config:(NSString * _Nullable)config
                                         externalDevices:(int)extDevices;

Parameter

ParameterDescription
appIdThe App ID provided by CloudHub for app developers. Only apps with the same App ID can enter the same channel for calls or live broadcasts. An App ID can only be used to create a CloudHubRtcEngineKit
configKeep Parameter
extDevicesExternal Devices

Returns

Details

Please call the interface function of the CloudHubRtcEngineKit class in the main thread

Note

setChannelProfile

Set the channel profile

- (int)setChannelProfile:(CloudHubChannelProfile)profile;

Parameter

ParameterDescription
profileThe channel profile,See CloudHubChannelProfile

Returns

Details

CloudHubRtcEngineKit will adopt different optimization strategies for different use scenarios, such as smooth communication scenarios and picture quality for live broadcast scenarios

Note

setClientRole

Set the client role

- (int)setClientRole:(CloudHubClientRole)role;

Parameter

ParameterDescription
roleThe user role,See CloudHubClientRole

Returns

Details

You can call this method either before or after joining the channel to set the user role as audience or host If you call this method to switch the user role after joining the channel, the SDK triggers the following callbacks:

Note

joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess:

Join channel

- (int)joinChannelByToken:(NSString * _Nullable)token
                channelId:(NSString * _Nonnull)channelId
               properties:(NSString * _Nullable)properties
                      uid:(NSString * _Nullable)uid
       autoSubscribeAudio:(BOOL)autoSubscribeAudio
       autoSubscribeVideo:(BOOL)autoSubscribeVideo
              joinSuccess:(void(^ _Nullable)(NSString * _Nonnull uid, NSInteger elapsed))joinSuccessBlock;

Parameter

ParameterDescription
tokenThe token generated on your server for authentication, Can be nil
channelIdThe name of the channel,This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel name enter the same channel for audio and video interaction. The string length must be less than 64 bytes.
propertiesThe user-defined attribute will be synchronized to other users in the channel. It must be a JSON string and can be nil
uidUser ID,This parameter is used to identify the user in the channel for real-time audio and video interaction. You need to set and manage user IDs yourself, and ensure that each user ID in the same channel is unique,If the user ID is not assigned (or set to 0), the SDK assigns and returns a user ID in the rtcEngine:didJoinChannelwithUid:elapsed: callback
autoSubscribeAudioAutomatically subscribe to audio
autoSubscribeVideoAutomatically subscribe to video
joinSuccessBlockOccurs when a user joins a channel joinSuccessBlock takes higher priority than rtcEngine:didJoinChannelwithUid:elapsed:

Returns

Details

This method allows a user to join the channel with the user account. After the user successfully joins the channel, the SDK triggers the following callbacks: leaveChannel exit the current call to enter the next channel

Note

*Uid cannot be repeated among users in a channel,If repeated,When a user with the same uid enters, it will trigger the previous user to leave the channel automatically,The previous user will receive rtcEngine:onLocalUserEvicted: callbacks

leaveChannel

Leaves a channel

- (int)leaveChannel:(void(^ _Nullable)(void))leaveChannelBlock;

Parameter

ParameterDescription
leaveChannelBlockThis callback indicates that a user leaves a channel,It will be called after rtcEngine:didLeaveChannel:

Returns

Details

This method lets the user leave the channel, for example, by hanging up or exiting the call. After joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess: , you must call this method to end the call, otherwise, the next call cannot be started. No matter whether you are currently in a call or not, you can call this method without side effects. This method releases all resources related to the session

renewToken

Gets a new token when the current token expires after a period of time.

- (int)renewToken:(NSString * _Nonnull)token;

Parameter

ParameterDescription
tokenThe new token.

Returns

Details

Passes a new token to the SDK.A token expires after a certain period of time. In the following two cases, the app should call this method to pass in a new token. Failure to do so will result in the SDK disconnecting from the server.

getConnectionState

Gets the current connection state of the SDK

- (CloudHubConnectionStateType)getConnectionState;

Returns

Audio management

enableAudio

Enables the audio module

- (int)enableAudio;

Returns

Details

The audio mode is enabled by default.

disableAudio

Disables the audio module

- (int)disableAudio;

Returns

Details

The audio mode is enabled by default.

adjustRecordingSignalVolume:

Adjusts the volume of the signal captured by the microphone.

- (int)adjustRecordingSignalVolume:(int)volume;

Parameter

ParameterDescription
volumeThe volume of the signal captured by the microphone. The value ranges between 0 and 400, including the following:
• 0: Mute.
• 100: (Default) Original volume.
• 400: Four times the original volume with signal-clipping protection.

Returns

adjustPlaybackSignalVolume:

Adjusts the playback signal volume of all remote users.

- (int)adjustPlaybackSignalVolume:(int)volume;

Parameter

ParameterDescription
volumeThe playback volume. The value ranges between 0 and 400, including the following:
• 0: Mute.
• 100: (Default) Original volume.
• 400: Four times the original volume with signal-clipping protection.

Returns

adjustUserPlaybackSignalVolume:volume:

Adjust the playback signal volume of a specified remote user.

- (int)adjustUserPlaybackSignalVolume:(NSString* _Nonnull)uid
                               volume:(int)volume;

Parameter

ParameterDescription
volumeThe playback volume of the specified remote user. The value ranges between 0 and 100, including the following:
• 0: Mute.
• 00: (Default) Original volume.

Returns

enableLocalAudio

Enables/Disables the local audio capture

- (int)enableLocalAudio:(BOOL)enabled;

Parameter

ParameterDescription
enabledYES: (Default) Re-enable the local audio function, that is, to start the local audio capturing device (for example, the microphone)
NO: Disable the local audio function, that is, to stop local audio capturing

Returns

Details

The audio function is enabled by default. This method disables or re-enables the local audio function to stop or restart local audio capturing This method does not affect receiving or playing the remote audio streams, and enableLocalAudio:(NO) applies to scenarios where the user wants to receive remote audio streams without sending any audio stream to other users in the channel

Note

muteLocalAudioStream

Stops or resumes publishing the local audio stream.

- (int)muteLocalAudioStream:(BOOL)mute;

Parameter

ParameterDescription
mute• YES: Stop publishing the local audio stream
• NO: (Default) Resumes publishing the local audio stream

Returns

Details

Whether to stop publishing the local audio stream,When the method is successfully called, the remote will trigger rtcEngine:remoteAudioStateChangedOfUid:state:reason: callback(reason is CloudHubAudioRemoteReasonLocalMuted

Note

muteRemoteAudioStream:mute:

Stops or resumes subscribing to the audio stream of a specified user

- (int)muteRemoteAudioStream:(NSString* _Nonnull)uid 
                        mute:(BOOL)mute;

Parameter

ParameterDescription
uidThe user ID of the peer.
muteWhether to stop subscribing to the audio stream of the specified user.

Returns

Note

muteAllRemoteAudioStreams

Stops or resumes subscribing to the audio streams of all remote users

- (int)muteAllRemoteAudioStreams:(BOOL)mute;

Parameter

ParameterDescription
muteWhether to subscribe to the audio streams of all remote users:

Returns

Video management

enableVideo

Enable the video module.

- (int)enableVideo;

Returns

Details

Call this method either before joining a channel or during a call. If this method is called before joining a channel, the call starts in the video mode. Call disableVideo to disable the video mode.

Note

disableVideo

Disables the video module

- (int)disableVideo;

Returns

Details

This method disables video. You can call this method either before or after joining a channel. If you call it before joining a channel, an audio call starts when you join the channel. If you call it after joining a channel, a video call switches to an audio call. Call enableVideo to enable video.

setVideoEncoderConfiguration

Sets the video encoder configuration

- (int)setVideoEncoderConfiguration:(CloudHubVideoEncoderConfiguration * _Nonnull)config;

Parameter

ParameterDescription
configVideo profile. See CloudHubVideoEncoderConfiguration

Returns

Details

This method sets the video coding configuration. Each configuration corresponds to a set of video parameters, such as resolution, frame rate, code rate, video direction, etc. all the set parameters are the maximum value under ideal conditions. When the video engine cannot reach the maximum value of the set resolution, frame rate or code rate due to equipment, network environment and other reasons, it will take the value closest to the maximum value

startPlayingLocalVideo:renderMode:mirrorMode:

Set the view for the local video and start playing

- (int)startPlayingLocalVideo:(VIEW_CLASS * _Nonnull)view  
                   renderMode:(CloudHubVideoRenderMode) renderMode  
                   mirrorMode:(CloudHubVideoMirrorMode) mirrorMode;

Parameter

ParameterDescription
viewUIView
renderModeSee CloudHubVideoRenderMode
mirrorModeSee CloudHubVideoMirrorMode

Returns

Details

To call this method to start previewing the local video, you need to call enableVideo and enableLocalVideo to start the local camera in advance. When you leave the channel and enter again, you need to call this method again to start previewing the local video again

Note

startPlayingRemoteVideo:streamId:renderMode:mirrorMode:

Set the view for the remote video and start playing

- (int)startPlayingRemoteVideo:(VIEW_CLASS * _Nonnull)view 
                      streamId:(NSString * _Nonnull)streamId 
                    renderMode:(CloudHubVideoRenderMode) renderMode
                    mirrorMode:(CloudHubVideoMirrorMode) mirrorMode;

Parameter

ParameterDescription
viewUIView
streamIDID of the remote video stream ,It can be obtained from this callback:rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo:
renderModeSee CloudHubVideoRenderMode
mirrorModeSee CloudHubVideoMirrorMode

Returns

Details

Call this method to start playing remote video. You need to call enableVideo to start the video engine in advance

Note

setLocalRenderMode:mirrorMode:

Updates the display mode of the local video view

- (int)setLocalRenderMode:(CloudHubVideoRenderMode) renderMode
               mirrorMode:(CloudHubVideoMirrorMode) mirrorMode;

Parameter

ParameterDescription
renderModeSee CloudHubVideoRenderMode
mirrorModeSee CloudHubVideoMirrorMode

Returns

Details

After initializing the local video view, you can call this method to update its rendering and mirror modes. It affects only the video view that the local user sees, not the published local video stream

Note

setRemoteRenderMode:renderMode:mirrorMode:

Updates the display mode of the video view of a remote user.

- (int)setRemoteRenderMode:(NSString * _Nonnull)streamId
                renderMode:(CloudHubVideoRenderMode) renderMode
                mirrorMode:(CloudHubVideoMirrorMode) mirrorMode;

Parameter

ParameterDescription
streamIdID of the remote video stream, It can be obtained from this callbackrtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo:
renderModeSee CloudHubVideoRenderMode
mirrorModeSee CloudHubVideoMirrorMode

Returns

Details

After initializing the remote user view, you can adjust this method to update the rendering and mirror mode of the remote user view when displayed locally. This method only affects the video pictures seen by the local user

Note

enableLocalVideo

Enables/Disables the local video capture

- (int)enableLocalVideo:(BOOL)enabled;

Parameter

ParameterDescription
enabledWhether to enable the local video capture:
• YES: (Default) Enable the local video capture
• NO: Disables the local video capture. Once the local video is disabled, the remote users can no longer receive the video stream of this user, while this user can still receive the video streams of the other remote users. When set to NO, this method does not require a local camera

Returns

Details

This method disables or re-enables the local video capturer, and does not affect receiving the remote video stream

Note

muteLocalVideoStream

Stops or resumes publishing the local video stream

- (int)muteLocalVideoStream:(BOOL)mute;

Parameter

ParameterDescription
mute• YES: Stop publishing the local video stream
• NO: (Default) Publish the local video stream

Returns

Details

After the method is successfully called, the remote end will trigger rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo: callback, reason is CloudHubVideoRemoteStateReasonRemoteMuted

Note

muteRemoteVideoStreamWithUid:mute:

Stops or resumes subscribing to the video stream of a specified user

- (int)muteRemoteVideoStreamWithUid:(NSString * _Nonnull)uid
                               mute:(BOOL)mute;

Parameter

ParameterDescription
uidThe user ID of the peer
mute• YES: Stop subscribing to the video streams of the specified user
• NO: (Default) Subscribe to the video stream of the specified user

Returns

Details

After joining the channel

Note

muteRemoteVideoByStreamId:mute:

Stops or resumes subscribing to the video stream of a specified streamId

- (int)muteRemoteVideoByStreamId:(NSString * _Nonnull)streamId
                            mute:(BOOL)mute;

Parameter

ParameterDescription
streamIdID of the remote video stream
mute• YES: Stop subscribing to the video streams
• NO: (Default) Subscribe to the video stream

Returns

Details

After joining the channel

muteAllRemoteVideoStreams

Stops or resumes subscribing to the video streams of all remote users

- (int)muteAllRemoteVideoStreams:(BOOL)mute;

Parameter

ParameterDescription
mute• YES: Stop subscribing to the video streams of all remote users
• NO: (Default) Subscribe to the audio streams of all remote users by default

Returns

stopPlayingLocalVideo

Stop playing the local video and release the local video view

- (int)stopPlayingLocalVideo;

Returns

stopPlayingRemoteVideo

Stop playing remote video and release view

- (int)stopPlayingRemoteVideo:(NSString * _Nonnull)streamId;

Parameter

ParameterDescription
streamIdID of the remote video stream ,It can be obtained from this callback:rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo:

Returns

setLocalVideoHD

Set local video HD acquisition

- (int)setLocalVideoHD;

Returns

Details

This method enables local video HD acquisition, but does not affect the video size sent to the far end。The sent video will be cropped and stretched, which is controlled bysetVideoEncoderConfiguration

setVideoRotation

Set local video rotation mode

- (int)setVideoRotation:(CloudHubVideoRotation)rotation;

Parameter

ParameterDescription
rotationrotation mode,See CloudHubVideoRotation (Default) CloudHubVideoRotationAuto

Returns

Details

This method sets the local video rotation mode. By default, no matter the device is at any angle, your video seen from the far end is always head up: when the mobile phone is held vertically, the video sent is also vertical; When the mobile phone is placed horizontally, the video sent out is also horizontal, but you can set this value to fix the video rotation angle to a certain direction to be consistent with your interface. At this time, your video looks positive at the far end only when the mobile phone direction is consistent with the direction you set

Video pre-process and post-process

setBeautyEffectOptions:options:

- (int)setBeautyEffectOptions:(BOOL)enabled options:(CloudHubBeautyOptions *_Nullable)options;

Set beauty parameter

Parameter

ParameterDescription
enabledTurn on/off the beauty :

* true:Turn on
* false:(Default))Turn off
optionsBeauty options,See CloudHubBeautyOptions

Returns

setVideoEffectEnable:options:device:

- (int)setVideoEffectEnable:(BOOL)enabled
                    options:(CloudHubVideoEffectOptions *_Nullable)options
                     device:(NSString *_Nullable)deviceID;

Set beauty parameter

Parameter

ParameterDescription
enabledTurn on/off the beauty:

* true:Turn on
* false:(Default))Turn off
optionsBeauty options,See CloudHubVideoEffectOptions
deviceIDSpecify the camera ID to operate on. In case of single camera mode, this parameter is ignored

Returns

Multi-channel management

createChannel:

Create sub channel

-(CloudHubRtcChannelKit * _Nullable) createChannel:(NSString * _Nonnull)channelId;

Parameter

ParameterDescription
channelIdChannel number, must be a combination of letters and numbers

Returns

destroyChannel:

Destroy sub-channel

-(int) destroyChannel:(CloudHubRtcChannelKit * _Nonnull)channel;

Parameter

ParameterDescription
channelIdChannel number, must be a combination of letters and numbers

Returns

Media file playback

startPlayingMovie:cycle:

Start playing media files

- (int) startPlayingMovie:(NSString * _Nonnull)filepath
                    cycle:(BOOL)cycle;

Parameter

ParameterDescription
filepathThe path of media components can be local or http/https links
cycleAutomatic looping playback, default to NO

Returns

startPlayingMovie:cycle:view:paused:

Start playing media files

- (int) startPlayingMovie:(NSString * _Nonnull)filepath
                    cycle:(BOOL)cycle
                     view:(VIEW_CLASS * _Nullable)view
                   paused:(BOOL)paused;

Parameter

ParameterDescription
filepathThe path of media components can be local or http/https links
cycleAutomatic looping playback, default to NO
viewView of media with video (UIView), can be nil
pausedPause immediately after startup,(Default) NO

Returns

stopPlayingMovie:

Stop playing media files

- (int) stopPlayingMovie:(NSString * _Nonnull)filepath;

Parameter

ParameterDescription
filepathSee startPlayingMovie:cycle:view:paused:

Returns

pausePlayingMovie:

Pause playing media files

- (int) pausePlayingMovie:(NSString * _Nonnull)filepath;

Parameter

ParameterDescription
filepathSee startPlayingMovie:cycle:view:paused:

Returns

resumePlayingMovie:

Resume playing media files

- (int) resumePlayingMovie:(NSString * _Nonnull)filepath;

Parameter

ParameterDescription
filepathSee startPlayingMovie:cycle:view:paused:

Returns

getMovieInfo:

Get media file data

- (CloudHubLocalMovieInfo * _Nullable) getMovieInfo:(NSString * _Nonnull)filepath;

Parameter

ParameterDescription
filepathSee startPlayingMovie:cycle:view:paused:

Returns

getMovieCurrentPosition:

Get the progress of media files

- (NSUInteger) getMovieCurrentPosition:(NSString * _Nonnull)filepath;

Parameter

ParameterDescription
filepathSee startPlayingMovie:cycle:view:paused:

Returns

setMoviePosition:withFile:

Set progress for media files in play

- (int) setMoviePosition:(NSUInteger)pos 
                withFile:(NSString * _Nonnull)filepath;

Parameter

ParameterDescription
posTarget time (ms)
filepathSee startPlayingMovie:cycle:view:paused:

Returns

Play Effect

getEffectsVolume

Retrieves the volume of the audio effects.

- (int) getEffectsVolume;

Returns

setEffectsVolume:

Sets the volume of the audio effects.

- (int) setEffectsVolume:(int)volume;

Parameter

ParameterDescription
volumeThe playback volume. The value ranges from 0 to 100. The default value is 100, which represents the original volume.

Returns

setVolumeOfEffect:volume:

Sets the volume of a specified audio effect.

- (int) setVolumeOfEffect:(int)soundId 
                   volume:(int)volume;

Parameter

ParameterDescription
soundIdThe ID of the audio effect. Each audio effect has a unique ID.
volumeThe playback volume. The value ranges from 0 to 100. The default value is 100, which represents the original volume.

Returns

playEffect:filePath:loopCount:gain:publish:startTimeMS:endTimeMS:

This method plays the specified local or online audio effect file.

- (int) playEffect:(int)soundId  
          filePath:(NSString * _Nonnull)filepath  
         loopCount:(int)loopCount  
             pitch:(double)pitch
               pan:(double)pan
              gain:(int)gain  
           publish:(BOOL)publish  
       startTimeMS:(NSUInteger)starttime  
         endTimeMS:(NSUInteger)endtime;

Parameter

ParameterDescription
soundIdThe audio effect ID. The ID of each audio effect file is unique.
filepathThe absolute path or URL address (including the suffixes of the filename) of the audio effect file.
loopCountThe number of times the audio effect loops:
• ≥0: The number of playback times. For example, 1 means loop one time, which means play the audio effect two times in total.
• -1: Play the music effect in an infinite loop.
pitchThe pitch of the audio effect. The value range is 0.5 to 2.0. The default value is 1.0, which means the original pitch. The lower the value, the lower the pitch.
panThe spatial position of the audio effect. The value range is 1 to10000.
• -1.0: The audio effect displays to the left.
• 0.0: The audio effect displays ahead.
• 1.0: The audio effect displays to the right.
gainThe volume of the audio effect. The value range is 1 to10000. The default value is 100.0, which means the original volume. The smaller the value, the less the gain.
publishWhether to publish the audio effect to the remote users.
• YES:Publish the audio effect to the remote users. Both the local user and remote users can hear the audio effect.
• NO:Do not publish the audio effect to the remote users. Only the local user can hear the audio effect.
starttimeSet the time to start playing (ms), and the pieces will start playing from there.
endtimeSet the end time to play (ms). When the player is playing, it will end.

Returns

Details

This method can play the specified local or online effects to increase the effects, such as the effects of specific operations in the game

You can set the number and gain of the play in the method, and whether the remote user can hear the effect. To play multiple audio effect files at the same time, call this method multiple times with different soundID and filePath. For the best user experience, Cloudhub recommends playing no more than three audio effect files at the same time. After the playback of an audio effect file completes, the SDK triggers the rtcEngine:onAudioEffectFinish: callback

stopEffect:

Stops playing a specified audio effect.

- (int) stopEffect:(int)soundId;

Parameter

ParameterDescription
soundIdThe valid ID of the transmission when playEffect:filePath:loopCount:pitch:pan:gain:publish:startTimeMS:endTimeMS:

Returns

stopAllEffects

Stops playing all audio effects.

- (int) stopAllEffects;

Returns

preloadEffect:filePath:

Preloads a specified audio effect file into the memory.

- (int) preloadEffect:(int)soundId 
             filePath:(NSString * _Nonnull)filepath;

Parameter

ParameterDescription
soundIdThe ID of the audio effect. Each audio effect has a unique ID.
filepathThe absolute path or URL address (including the suffixes of the filename) of the audio effect file

Returns

unloadEffect:

Releases a specified preloaded audio effect from the memory.

- (int) unloadEffect:(int)soundId;

Parameter

ParameterDescription
soundIdThe ID of the audio effect. Each audio effect has a unique ID.

Returns

pauseEffect:

Pauses a specified audio effect.

- (int) pauseEffect:(int)soundId;

Parameter

ParameterDescription
soundIdThe ID of the audio effect. Each audio effect has a unique ID.

Returns

pauseAllEffects

Pauses all audio effects.

- (int) pauseAllEffects;

Returns

resumeEffect:

Resumes playing a specified audio effect.

- (int) resumeEffect:(int)soundId;

Parameter

ParameterDescription
soundIdThe ID of the audio effect. Each audio effect has a unique ID.

Returns

resumeAllEffects

Resumes playing all audio effects.

- (int) resumeAllEffects;

Returns

translateWavFileToText:

Recognize text from sound files

- (int)translateWavFileToText:(NSString* _Nonnull)wavFile;

Parameter

ParameterDescription
wavFileSound files,Only supported wav

Returns

Details

After the call is successful ,the user will receive rtcEngine:onVoiceTranslateTextReady:text: callback

Voice changer and reverberation

If you want to use the functions related to vocal effect, please contact us first to open it for you

setAudioQuality

Set local send audio quality

- (int)setAudioQuality:(CloudHubAudioQuality)quality;

Parameter

ParameterDescription
qualityaudio quality,See CloudHubAudioQuality

Returns

setLocalVoicePitch:

Changes the voice pitch of the local speaker.

- (int)setLocalVoicePitch:(double)pitch

Parameter

ParameterDescription
pitchThe value ranges between 0.5 and 2.0. The lower the value, the lower the pitch. The default value is 1 (no change to the pitch).

Returns

Details

This method changes the pitch of the local speaker’s voice. This method needs to be called after enableLocalAudio. Note that calling the enableLocalAudio interface and passing in no will reset the pitch to the default state (i.e. there is no need to modify the tone)

setLocalVoiceEqualizationOfBandFrequency:withGain:

Sets the local voice equalization effect.

- (int)setLocalVoiceEqualizationOfBandFrequency:(CloudHubAudioEqualizationBandFrequency)bandFrequency 
                                       withGain:(NSInteger)gain

Parameter

ParameterDescription
bandFrequencyThe band frequency. The value ranges between 0 and 9; representing the respective 10-band center frequencies of the voice effects, including 31, 62, 125, 250, 500, 1k, 2k, 4k, 8k, and 16k Hz. For more details, See CloudHubAudioEqualizationBandFrequency
gainThe gain of each band in dB. The value ranges between -15 and 15. The default value is 0.

Returns

Details

This method changes the pitch of the local speaker’s voice. This method needs to be called after enableLocalAudio. Note that calling the enableLocalAudionterface and passing in NO will reset the sound equalization to the initial state

setLocalVoiceReverbOfType:withValue:

Sets the local voice reverberation

- (int)setLocalVoiceReverbOfType:(CloudHubAudioReverbType)reverbType
                       withValue:(double)value

Parameter

ParameterDescription
reverbTypeThe reverberation key. Cloudhub provides 5 reverberation keys,See CloudHubAudioReverbType
valueThe value of the reverberation key. See CloudHubAudioReverbType

Returns

Details

This method changes the pitch of the local speaker’s voice. This method needs to be called after enableLocalAudio. Note that calling the enableLocalAudionterface and passing in NO will reset the sound equalization to the initial state

setAudioEffectPreset:

Sets an SDK preset audio effect

- (int)setAudioEffectPreset:(CloudHubAudioEffectPreset)preset

Parameter

ParameterDescription
presetThe options for SDK preset audio effects. See CloudHubAudioEffectPreset

Returns

Details

This method changes the pitch of the local speaker’s voice. This method needs to be called after enableLocalAudio. Note that calling the enableLocalAudionterface and passing in NO will reset the sound equalization to the initial state. This method cannot be mixed with setLocalVoicePitch:setLocalVoiceEqualizationOfBandFrequency:withGain:setLocalVoiceReverbOfType:withValue:

enableDeepLearningDenoise:

Turn on/off AI noise reduction mode

- (int)enableDeepLearningDenoise:(BOOL)enabled

Parameter

ParameterDescription
enabledWhether to turn on AI noise reduction mode:
YES: (Default)Turn on
NO: Turn off

Returns

Sound localization

enableSoundPositionIndication:

Enables/Disables stereo panning for remote users.

- (int)enableSoundPositionIndication:(BOOL)enabled

Parameter

ParameterDescription
enabledWhether to enable stereo panning for remote users:
YES:Enable stereo panning.
NO:Disable stereo panning.

Returns

Details

Ensure that you call this method to enable stereo panning for remote users before enableAudio so that the local user can track the position of a remote user by calling setRemoteVoicePosition:pan:gain:

setRemoteVoicePosition:pan:gain:

Sets the sound position and gain of a remote user.

- (int)setRemoteVoicePosition:(NSString * _Nonnull)uid
                          pan:(double)pan
                         gain:(double)gain

Parameter

ParameterDescription
uidThe ID of the remote user
panThe sound position of the remote user. The value ranges from -1.0 to 1.0:
•(Default)0.0:The remote sound comes from the front.
• -1.0:The remote sound comes from the left.
• 1.0:The remote sound comes from the right.
gainThe gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain.

Returns

Details

This method sets the sound position and gain of a remote user.

When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a sense of space. This method applies to massive multiplayer online games, such as Battle Royale games.

Note

Media stream relay across channels

startChannelMediaRelay:

Starts relaying media streams across channels. This method can be used to implement scenarios such as co-host across channels.

- (int) startChannelMediaRelay: (CloudHubChannelMediaRelayConfig* _Nonnull) config;

Parameter

ParameterDescription
configThe configuration of the media stream relay. For details, See CloudHubChannelMediaRelayConfig

Returns

Details

After a successful method call, the SDK triggers the rtcEngine:onChannel:MediaRelayStateChanged:error: callbacks, and these callbacks return the state and events of the media stream relay.

Note

updateChannelMediaRelay:

Updates the channels for media stream relay.

- (int) updateChannelMediaRelay: (CloudHubChannelMediaRelayConfig* _Nonnull) config;

Parameter

ParameterDescription
configThe configuration of the media stream relay. For more details, See CloudHubChannelMediaRelayConfig

Returns

Details

After the media relay starts, if you want to relay the media stream to more channels, or leave the current relay channel, you can call the updateChannelMediaRelay method.

Note

stopChannelMediaRelay

Stops the media stream relay. Once the relay stops, the host quits all the destination channels.

- (int) stopChannelMediaRelay;

Returns

Details

After a successful method call, the SDK triggers the rtcEngine:onChannel:MediaRelayStateChanged:error: callback. If the callback reports CloudHub_RELAY_STATE_IDLE and CloudHub_RELAY_OK, the host successfully stops the relay.

Note

Volume indication

enableAudioVolumeIndication:smooth:reportVAD:

Enables the reporting of users' volume indication

- (int)enableAudioVolumeIndication:(NSInteger)interval 
                            smooth:(NSInteger)smooth 
                         reportVAD:(BOOL)reportVad;

Parameter

ParameterDescription
intervalSets the time interval between two consecutive volume indications:
• < = 0: Disables the volume indication.
• > 0: Time interval (ms) between two consecutive volume indications. We recommend a setting greater than 200 ms. Do not set this parameter to less than 10 milliseconds, otherwise the callback will not be triggered rtcEngine:reportAudioVolumeIndication:totalVolume:
smoothThe smoothing factor sets the sensitivity of the audio volume indicator. The value ranges between 0 and 10. The recommended value is 3. The greater the value, the more sensitive the indicator.
reportVadTurn on/off local voice detection :
• YES :When turn on, the speakers array of rtcEngine:reportAudioVolumeIndication:totalVolume: callback, The ‘VAD’ of CloudHubAudioVolumeInfo report whether sound is detected locally
• NO:(Default)When turn off,the speakers array of rtcEngine:reportAudioVolumeIndication:totalVolume: callback, The ‘VAD’ of CloudHubAudioVolumeInfo does not report whether sound is detected locally

Returns

Switch speakers or earpieces

setEnableSpeakerphone:

Set whether to use speakers

- (int)setEnableSpeakerphone:(BOOL)enableSpeaker;

Parameter

ParameterDescription
enableSpeakerWhether to use speakers (YES)

Returns

Details

This method sets whether to route voice to the speaker (external), which can be called before joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess:

isSpeakerphoneEnabled

Are speakers currently in use

- (BOOL)isSpeakerphoneEnabled;

Returns

Details

When connecting to a wired or Bluetooth headset, the sound will be automatically switched to the headset. At this time, the returns value of isSpeakerphoneEnabled is still the setting before connecting to the headset. When the headset is disconnected, the sound will also return to the playback path set before connecting to the headset

In-ear monitoring

enableInEarMonitoring:

Enables in-ear monitoring.

- (int)enableInEarMonitoring:(BOOL)enabled

Parameter

ParameterDescription
enabledEnables in-ear monitoring.
YES: Enables in-ear monitoring.
NO: (Default) Disables in-ear monitoring.

Returns

Details

You can call this method either before or after joining a channel.

Note

setInEarMonitoringVolume:

Sets the volume of the in-ear monitor.

- (int)setInEarMonitoringVolume:(NSInteger)volume

Parameter

ParameterDescription
volumeThe volume of the in-ear monitor. The value ranges between 0 and 100. The default value is 100.

Returns

Details

You can call this method either before or after joining a channel.

Note

Pre-call network test

startEchoTest:

Starts an audio call test.

- (int)startEchoTest: (int)intervalInSeconds;

Parameter

ParameterDescription
intervalInSecondsThe time interval (s) between when you speak and when the recording plays back.

Returns

Note

stopEchoTest

Stops the audio call test.

- (int)stopEchoTest;

Returns

startLastmileProbeTest:

Starts the last mile network probe test.

- (int)startLastmileProbeTest:(CloudHubLastmileProbeConfig* _Nonnull)config;

Parameter

ParameterDescription
ConfigThe configurations of the last-mile network probe test. See CloudHubLiveTranscoding

Returns

Details

This method starts the last-mile network probe test before joining a channel to get the uplink and downlink last mile network statistics, including the bandwidth, packet loss, jitter, and round-trip time (RTT).

Once this method is enabled, the SDK returns the following callbacks:

Note

stopLastmileProbeTest

Stops the last mile network probe test.

- (int)stopLastmileProbeTest;

Returns

Audio self-capture(only push)

setExternalAudioSourceSampleRate:channels:

-(int) setExternalAudioSourceSampleRate:(int)sampleRate
                                channels:(int)channels;

Set the format of the collected data.

Details This method needs to be called before joining the channel.

Parameter

ParameterDescription
sampleRateSpecify the sampling rate of the Returns data, which can be set to 8000, 16000, 32000, 44100 or 48000
channelSpecify the number of channels of the Returns data in rtcEngine:onRecordAudioFrame:sampleRate:channels:, which can be set to 1 or 2 (1: single channel 2: dual channel)

Returns

pushAudioFrame:

- (int) pushAudioFrame:(NSData * _Nonnull)buffer;

Push external audio frame

Parameter

ParameterDescription
bufferFrame valid data

Returns

Audio self-rendering(only pull))

setExternalAudioSinkSampleRate:channels:

-(int) setExternalAudioSinkSampleRate:(int)sampleRate
                              channels:(int)channels;

Set the format of the rendering data.

Details This method needs to be called before joining the channel.

Parameter

ParameterDescription
sampleRateSpecify the sampling rate of the Returns data, which can be set to 8000, 16000, 32000, 44100 or 48000
channelsSpecify the number of channels of the Returns data in rtcEngine:onRecordAudioFrame:sampleRate:channels:, which can be set to 1 or 2 (1: single channel 2: dual channel)

Returns

pullAudioFrame:

pullAudioFrame:

-(int) pullAudioFrame:(NSData * _Nonnull)buffer;

Pull playback (after mixing) data (pulling 10ms data at a time) (the user needs to continue to call at 10ms intervals).

After calling this method, the App will take an active pull method to obtain the remote-end decoded and mixed audio data for audio playback.

Parameter

ParameterDescription
buffervalid frame data

Returns

Raw audio data

setRecordingAudioFrameSampleRate:channels:samples:

-(int) setRecordingAudioFrameSampleRate:(int)sampleRate
                                 channels:(int)channel
                                  samples:(int)samplesPerCall;

This method sets the collected audio format of the rtcEngine:onRecordAudioFrame:sampleRate:channels: callback.

Details This method needs to be called before joining the channel.

Parameter

ParameterDescription
sampleRateSpecify the sampling rate of the Returns data, which can be set to 8000, 16000, 32000, 44100 or 48000
channelSpecify the number of channels of the Returns data in rtcEngine:onRecordAudioFrame:sampleRate:channels:, which can be set to 1 or 2 (1: single channel 2: dual channel)
samplesPerCallReturns the number of data sampling points, such as RTMP/RTMPS streaming applications, usually 1024

Returns

setPlaybackAudioFrameSampleRate:channels:samples:

-(int) setPlaybackAudioFrameSampleRate:(int)sampleRate
                                channels:(int)channel
                                 samples:(int)samplesPerCall;

This method sets the collected audio format of the rtcEngine:onPlaybackAudioFrame:sampleRate:channels: callback.

Details This method needs to be called before joining the channel.

Parameter

ParameterDescription
sampleRateSpecify the sampling rate of the Returns data, which can be set to 8000, 16000, 32000, 44100 or 48000
channelSpecify the number of channels of the Returns data in rtcEngine:onRecordAudioFrame:sampleRate:channels:, which can be set to 1 or 2 (1: single channel 2: dual channel)
samplesPerCallReturns the number of data sampling points, such as RTMP/RTMPS streaming applications, usually 1024

Returns

Audio recorder

startRecordingVoiceClip:duration:fileType:

Start recording sound clip

- (int)startRecordingVoiceClip:(NSString* _Nonnull) clipBaseName
                      duration:(NSInteger)clipDurationSeconds
                      fileType:(CloudHubMediaFileType) type;

Parameter

ParameterDescription
clipBaseNamesound clip basename
clipDurationSecondsDuration of each sound clip
typeStorage format of recording files(0: ogg (opus) 1: wav),See CloudHubMediaFileType

Returns

Details

After the call is successful, the user will receive rtcEngine:voiceClipFileReady:clip:ts: callback

stopRecordingVoiceClip:

Stop recording sound clip

- (int)stopRecordingVoiceClip:(NSString* _Nonnull) clipBaseName;

Parameter

ParameterDescription
clipBaseNamesound clip basename

Returns

Switch cameras

switchCamera:

Switches between front and rear cameras.

- (int)switchCamera:(BOOL)front;

Parameter

ParameterDescription
frontWhether to use front camera (Default YES)

Returns

Details

This method needs to be called after the camera is started joinChannelByToken:channelId:properties:uid:autosubscribeAudio:autoSubscribeVideo:joinSuccess:

setCameraFlipMode

Set the flip mode of the camera

- (int)setCameraFlipMode:(BOOL)horizontalFlip  Vertivcal:(BOOL)verticalFlip

Parameter

ParameterDescription
horizontalFlipFlip horizontally
verticalFlipFlip vertically

Returns

Details

This method flips the data collected by the camera horizontally and vertically. For the same camera, after the camera is turned off, the engine will still remember the flip settings of the camera. The previous settings will be loaded automatically after the camera is turned on next time, unless the user turns off the video indexing through enableVideo: NO

correctCameraKeystoning

Correcting trapezoidal distortion of camera

- (int)correctCameraKeystoning:(float)fromX FromY:(float)fromY ToX:(float)toX ToY:(float)toY

Parameter

ParameterDescription
fromX,fromYThe vector starting point coordinates of this correction
toX,toYThe vector end point of the correction

Returns

Details

This method corrects the trapezoidal distortion of the camera through the mode of incremental interaction. The vector AB composed of the starting point a (fromx, fromy) and the ending point B (tox, toy) represents the displacement of this correction, which is equivalent to the user dragging the mouse from a to B. the engine will automatically judge which corner of the picture is the corner of this correction according to the position of the starting point A

The coordinates of the upper left corner and the lower right corner of the view are (0.0, 0.0) and (1.0, 1.0). The view is divided into four equal 1 / 4 areas, namely upper left area, upper right area, lower right area and lower left area. Point a and point B must be located in an equal division of the view, and cross region correction is invalid.

resetCameraKeystoning

Cancel correcting the trapezoidal distortion of the camera

- (int)resetCameraKeystoning

Returns

Details

This method disables the trapezoidal correction function of the camera and restores the default behavio

Data stream

sendStreamMessage:

- (int) sendStreamMessage:(NSData * _Nonnull)message;

Sends data stream messages.

Sends data stream messages to all users in a channel. The SDK has the following restrictions on this method.Up to 30 packets can be sent per second in a channel with each packet having a maximum size of 1 KB. Each client can send up to 6 KB of data per second.Each user can have up to five data streams simultaneously.

After successfully calling this method, the remote end will trigger the rtcEngine:onStreamMessagWithUid:data: callback, and the remote user can get the received stream message in this callback.

Parameter

ParameterDescription
messageThe message to be sent.

Returns

Publisher management

setPublishStreamInfo:

Set user data when publishing local audio and video (Json string format)

- (int)setPublishStreamInfo:(NSString * _Nonnull)info;

Returns

Details

This method must be executed after [rtcengine: didjoinchannelwithuid: elapsed:] callback succeeds If the remote successfully subscribes to this video stream, When the callback rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo: is received, the remote end will be notified through the streaminfo parameter

publishStream

Start publishing local audio and video

- (int)publishStream;

Returns

Details

Publish your own audio and video to the channel for others to watch and listen to. After publishing successfully, the local will receive rtcEngine:localVideoStateChangeWithState:error: callback

Note

unPublishStream

Stop publishing local audio and video

- (int)unPublishStream;

Returns

Details

Stop publishing local audio and video. When publishing is stopped, the local will receive rtcEngine:localVideoStateChangeWithState:error: callback. If the remote end turns off automatic subscription, it will receive rtcEngine:onUserUnPublished:type:stream: callback. Whether the remote end turns off automatic subscription or not, it will receive rtcEngine:remoteVideoStateChangedOfUid:streamId:type:state:reason:streamInfo: callback

Note

Manual subscription management

subscribe

Start subscribing to audio and video

- (int)subscribe:(NSString * _Nonnull)streamId;

Parameter

ParameterDescription
streamIdThe unique ID of the video stream in the channel,This ID can be obtained from the callback of rtcEngine:onUserPublished:type:stream:
Returns

Details

Please call it after receiving the rtcEngine:onUserPublished:type:stream:

unSubscribe

Unsubscribe from audio and video

- (int)unSubscribe:(NSString * _Nonnull)streamId;

Parameter

ParameterDescription
streamIdThe unique ID of the video stream in the channel,This ID can be obtained from the callback of rtcEngine:onUserPublished:type:stream: andrtcEngine:onUserUnPublished:type:stream:

Returns

Details

Server recording

startServerRecord

Start server recording

- (int) startServerRecord;

Returns

stopServerRecord

Stop server recording

- (int) stopServerRecord;

Returns

pauseServerRecord

Pause server recording

- (int) pauseServerRecord;

Returns

resumeServerRecord

Resume server recording

- (int) resumeServerRecord;

Returns

Advanced signaling method

Call these methods before joining a channel

setPropertyOfUid:tell:properties:

Set custom properties for a user in the channel

- (int)setPropertyOfUid:(NSString * _Nonnull)uid 
                   tell:(NSString * _Nullable)whom 
             properties:(NSString * _Nonnull)prop;

Parameter

ParameterDescription
uidThe uid of the target user can be obtained from the callback of the rtcEngine:didJoinedOfUid:properties:isHistory:fromChannel:
tellTo notify the user, if empty, notify the owner of the channel. If a user’s uid is specified, only the user of the specified notification is notified. The default is empty.
propCustom properties must be JSON objects

Returns

Details

There are two ways to set custom properties:

Note

sendChatMsg:to:withExtraData:

Send chat message

- (int)sendChatMsg:(NSString * _Nonnull)message 
                to:(NSString * _Nullable)whom 
     withExtraData:(NSString * _Nullable)extraData;

Parameter

ParameterDescription
messageChat message text
whomThe user to be notified. If it is nil, all the people in the channel will be notified. If a user’s uid is specified, only the users specified for notification will be notified
extraDataThis message custom attribute must be a JSON object, which can be nil.

Returns

Details

You can usually use extraData to convey some fonts, heads and other information channels, and users will receive rtcEngine:onChatMessageArrival:from:withExtraData: callbacks.

pubMsg:msgId:to:withData:associatedWithUser:associatedWithMsg:save:extraData:

Post a custom message

- (int)     pubMsg:(NSString * _Nonnull)msgName
             msgId:(NSString * _Nonnull)msgId
                to:(NSString * _Nullable)whom
          withData:(NSString * _Nullable)data
associatedWithUser:(NSString * _Nullable)uid
 associatedWithMsg:(NSString * _Nullable)assMsgID
              save:(BOOL)save
         extraData:(NSString * _Nullable)extra;

Parameter

ParameterDescription
msgNameMessage name
msgIdMessage id, which is the unique identifier of a message in the channel
whomThe user to be notified, if it is empty, everyone in the channel will be notified. If a user’s uid is specified, only the user who is notified will be notified
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
saveWhether to save or not, if you save, users who enter the channel afterwards will be in rtcEngine:onPubMsg:msgId:from:withData:associatedWithUser:associatedWithMsg:ts:withExtraData:isHistory: This signaling is received in the callback, until this message is deleted with the delMsg:msgId:to: method
extraKeep Parameter

Returns

Details

The pubMsg mechanism is similar to a message board, which is used to save and synchronize the business status in the channel. Whether it is a user already in the channel or a new user who joins later, you can use rtcEngine:onPubMsg:msgId:from:withData:associatedWithUser:associatedWithMsg:ts:withExtraData:isHistory: Call back to receive custom messages that have been published in the current channel

delMsg:msgId:to:

Delete a custom message

-(int)delMsg:(NSString * _Nonnull)msgName
        msgId:(NSString * _Nonnull)msgId
           to:(NSString * _Nullable)whom;

with

-(int)delMsg:(NSString * _Nonnull)msgName
        msgId:(NSString * _Nonnull)msgId
           to:(NSString * _Nullable)whom
     withData:(NSString * _Nullable)data;

Parameter

ParameterDescription
msgNameMessage name
msgIdTo delete the message id, use the pubMsg:msgId:to:withData:associatedWithUser:associatedWithMsg:save:extraData: method to specify its id when publishing the message
whomThe user to be notified, if it is empty, everyone in the channel will be notified. If a user’s uid is specified, only the user who is notified will be notified
dataKeep Parameter

Returns

Details

After the call is successful, users already in the channel will receive the message rtcEngine:onDelMsg:msgId:from:withData:

Note

evictUser:reason:

Kick a user out of the channel

-(int)evictUser:(NSString * _Nonnull)uid
           reason:(NSInteger)reason;

Parameter

ParameterDescription
uiduid of the kicked user
reasoncustom field

Returns

Details

After the call is successful, the kicked user will receive the rtcEngine:onLocalUserEvicted: callback, and other users will receive the rtcEngine:didOfflineOfUid:reason: callback

CDN publisher

addPublishStreamUrl:

Publishes the local stream to a specified CDN live streaming URL.

- (int) addPublishStreamUrl:(NSString* _Nonnull)url;

Parameter

ParameterDescription
urlThe CDN streaming URL in the RTMP or RTMPS format. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters.

Returns

removePublishStreamUrl:

Removes an RTMP or RTMPS stream from the CDN.

- (int) removePublishStreamUrl:(NSString* _Nonnull)url;

Parameter

ParameterDescription
urlThe CDN streaming URL to be removed. The maximum length of this parameter is 1024 bytes. The CDN streaming URL must not contain special characters, such as Chinese characters.

Returns

setLiveTranscoding:

Sets the transcoding configurations for CDN live streaming.

- (int) setLiveTranscoding:(CloudHubLiveTranscoding* _Nonnull)transcoding;

Parameter

ParameterDescription
transcodingThe transcoding configurations for CDN live streaming. For details, See CloudHubLiveTranscoding

Returns

Other methods

getCallId

Get channel number

-(NSString * _Nullable)getCallId;

Returns

getSdkVersion

Get the SDK version number

+ (NSString * _Nonnull)getSdkVersion;

Returns

setLogFilter:

Set the log output level

-(int)setLogFilter:(NSUInteger)filter;

Parameter

ParameterDescription
filterSee CloudHubLogFilter

Returns

getNativeHandle

Get Native SDK Engine Handle

-(void *_Nullable)getNativeHandle;

Details

This method obtains the C++ handle of native SDK engine, which is used for special scenes including registering audio and video frame observers