CloudHub Docs
Download Documents


CloudHub JSSDK

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.

As you read the interface documentation, we assume that you have the underlying front-end application development experience and understand the underlying concepts.

CloudHubRTC Overview

CloudHub JSSDK is a JavaScript library loaded through HTML web pages. The CloudHub JSSDK library calls the API in a web browser to establish a connection and control audio and video calls and live streaming services. CloudHub JSSDK Support all mainstream browsers, see Browser Support

Be sure to use the HTTPS protocol or localhost, otherwise it will report the not_Support.

For how to import SDK, see Quick Start The SDK import section.

CloudHubRTC is the entry of all the adjustable methods in the CloudHub JSSDK. CloudHubrtc Contains the following methods:

createClientCreates a client object.
createStreamCreates a stream object.
getDeviceManagerGet the device management class.
setSdkLogConfigSet the configuration of the SDK internal log printing.
checkSystemRequirementsChecks the web browser compatibility.

Client client object


initInitializes a client object.
renewTokenRenews the token. If you have used Token when joining the channel, call this method to renew your Token when it expires.

Channel management

setChannelConfigSet the channel configuration.
joinChannelJoin the CloudHubRTC channel.
leaveChannelLeave the CloudhuBRTC channel.
produceChannelMediaRelayConfigProduction of cross-channel media forwarding configuration instances.

Audio and video management

publishPublishes a local stream.
subscribeSubscribes to a remote stream.
unpublishUnpublishes the local stream.
unsubscribeUnsubscribes from the remote stream.
enableAudioVolumeIndicatorEnables the SDK to report the active speaker and his/her volume regularly.
getSignalConnectionStateGet the connection status of the SDK and the signaling server.
getLocalAudioStatsRetrieves the audio statistics of the published local streams.
getLocalVideoStatsRetrieves the video statistics of the published local streams.
getRemoteAudioStatsRetrieves the audio statistics of the remote streams.
getRemoteVideoStatsRetrieves the video statistics of the remote streams.

Event management

offUnbinds events.
onEvent binding.
offAllCancel all event bindings under the specified type.

User Management

evictUserKick the user out the channel.
setPropertyChange the user’s custom user properties.
setClientRoleSets the role of the user (live mode only).

Message management

sendChatMsgSend chat messages.

Signaling management

pubMsgSend signaling message.
delMsgDelete signaling messages.

Recording management

startServerRecordStart the server-side recording.
stopServerRecordStop the server-side recording.
pauseServerRecordPause the server-side recording.
resumeServerRecordRestore server-side recording.

Push management

addPublishStreamUrlAdd a bypass lightning address.
removePublishStreamUrlDelete the bypass lightning address.
setLiveTranscodingSet live stream transcodation.
startChannelMediaRelayStart transfer cross-channel media streams.
updateChannelMediaRelayUpdates the channels for media stream relay.
stopChannelMediaRelayStops the media stream relay.
enableMultiStreamEnable multi-stream mode.

The first step in using CloudHub JSSDK is to call the createclient to create a client object. The client object provides the core functions of audio and video calls, such as joining channels, publishing, and subscribing to audio and video streams. The following table lists all the Method:

Stream audio and video stream object

The audio and video stream object refers to the local or remote video stream in the call, providing settings for audio and video streams. All of the following table lists all the Method:


initInitialized audio video object.

Event management

onEvent binding.
offCancel the event binding.
offAllCancel all event bindings under the specified type.

Audio management

hasAudioGet an audio Flag.
muteAudioDisable audio tracks.
getAudioLevelRetrieves the current audio level.
getAudioTrackRetrieves the audio track in the stream.
setAudioOutputSets the audio output device of the remote stream. You can use it to switch between the microphone and the speakerphone.
setAudioVolumeSets the volume of the remote stream.
unmuteAudioEnable the audio track.
playAudioEnables the audio track in the stream.
resumeAudioRestore audio stream playback.
unplayAudioStop the audio stream.
getAudioVolumeGet the volume size.

Video management

hasVideoRetrieves the video flag.
muteVideoDisables the video track in the stream.
setVideoProfileSets the video profile of the stream.
unplayVideoStop the video stream.
isVideoPlayingReturns whether the video stream is currently playing in the play state.
playVideoPlay the video stream.
replaceTrackReplaces the audio or video track in the local stream.
resumeVideoRestore video stream playback.
getVideoTrackRetrieves the video track in the stream.
closeClose the audio and video stream.
getStatsRetrieves the connection statistics of the stream.
getIdRetrieves the stream ID.
unmuteVideoEnables the video track in the stream.
isPubedVideoWhether the publisher of the stream issued a video.
getVideoProfileGet video properties.
isAudioPlayingReturns whether the audio stream is currently played in the play state.
isRemoteWhether it is a distant stream.
getUserIdGet the user ID of the stream.
getTypeGet the type of the stream.
getSourceIDGet the SourceId of the stream.
switchMobileCameraSwitch the moving end and rear camera.
setMirrorSet whether or not used image.

Device management

switchDeviceSwitch the input device.

Device management objects

Device management objects provide Method for device operations, such as enumerating devices, device detection, and so on. The following table lists all Methods for ‘DeviceManager’:


getDevicesEnumerated media input / output devices, such as microphones, cameras, speakers, etc.
registerDeviceChangeListenerRegister / remove the device listener.
getUserMediaBrowser Navigator.Mediadevices.getusermedia’s package, SDK inside Navigator.Mediadevices.getusermedia has some browser adaptation


startMicrophoneTestStart microphone device detection.
stopMicrophoneTestStop microphone device detection.
setDefaultMicrophoneIdSet the default microphone id.
getDefaultMicrophoneIdGet the default microphone id


startCameraTestStart camera detection.
stopCameraTestStop camera detection.
setDefaultCameraIdSet the default camera id.
getDefaultCameraIdGet the default camera id


startSpeakerTestStart speaker device detection.
stopSpeakerTestStop the speaker device detection.
setDefaultSpeakerIdSet the default speaker id.
associateElementsToSpeakerAssociate the media element node (video/audio) to the speaker.

Desktop sharing

checkScreenIsSupportDetect if a Google plug-in is required for screen/program sharing.

audio and video

getCamerasEnumerate the video input device.
getSpeakersEnumerate the audio output device.
getMicrophonesEnumerate the audio input device.
getVideoTrackGet the video track.
getAudioTrackGet the audio track.
setDefaultVideoProfileSet the default video properties.
getDefaultSpeakerIdGet the default speaker id
audioEleTestPlayAudio node playback test (primarily used to detect whether a browser can allow audio elements to play — some browsers prevent non-human clicks of audio elements from playing).


Listening to the event of Client and Stream Method triggered via Client.on and Stream.on Method.

Scene of the channel (Communication Scene | Live Scene)

The use scenario of the channel, there are two types of communication scene (RTC) and live scene (live), the default is RTC. please see the interface documentation. Constant statement and supplementary description - Use scenario description


The live broadcast scene calls clinet.publish and client.unpublish automatically switches the user’s identity, details Client.setClientRoleClient.publish and Client.unpublish Interface description.