CloudHub JSSDK
- Overview
- CloudHubRTC
- CloudHubRTCObject
- Client
- ClientEvent
- ClientLiveTranscoding
- ClientChannelMediaRelayConfig
- Stream
- StreamEvent
- DeviceManager
- constant
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:
Method | Description |
---|---|
createClient | Creates a client object. |
createStream | Creates a stream object. |
getDeviceManager | Get the device management class. |
setSdkLogConfig | Set the configuration of the SDK internal log printing. |
checkSystemRequirements | Checks the web browser compatibility. |
Client client object
Base
Method | Description |
---|---|
init | Initializes a client object. |
renewToken | Renews the token. If you have used Token when joining the channel, call this method to renew your Token when it expires. |
Channel management
Method | Description |
---|---|
setChannelConfig | Set the channel configuration. |
joinChannel | Join the CloudHubRTC channel. |
leaveChannel | Leave the CloudhuBRTC channel. |
produceChannelMediaRelayConfig | Production of cross-channel media forwarding configuration instances. |
Audio and video management
Method | Description |
---|---|
publish | Publishes a local stream. |
subscribe | Subscribes to a remote stream. |
unpublish | Unpublishes the local stream. |
unsubscribe | Unsubscribes from the remote stream. |
enableAudioVolumeIndicator | Enables the SDK to report the active speaker and his/her volume regularly. |
getSignalConnectionState | Get the connection status of the SDK and the signaling server. |
getLocalAudioStats | Retrieves the audio statistics of the published local streams. |
getLocalVideoStats | Retrieves the video statistics of the published local streams. |
getRemoteAudioStats | Retrieves the audio statistics of the remote streams. |
getRemoteVideoStats | Retrieves the video statistics of the remote streams. |
Event management
Method | Description |
---|---|
off | Unbinds events. |
on | Event binding. |
offAll | Cancel all event bindings under the specified type. |
User Management
Method | Description |
---|---|
evictUser | Kick the user out the channel. |
setProperty | Change the user’s custom user properties. |
setClientRole | Sets the role of the user (live mode only). |
Message management
Method | Description |
---|---|
sendChatMsg | Send chat messages. |
Signaling management
Method | Description |
---|---|
pubMsg | Send signaling message. |
delMsg | Delete signaling messages. |
Recording management
Method | Description |
---|---|
startServerRecord | Start the server-side recording. |
stopServerRecord | Stop the server-side recording. |
pauseServerRecord | Pause the server-side recording. |
resumeServerRecord | Restore server-side recording. |
Push management
Method | Description |
---|---|
addPublishStreamUrl | Add a bypass lightning address. |
removePublishStreamUrl | Delete the bypass lightning address. |
setLiveTranscoding | Set live stream transcodation. |
startChannelMediaRelay | Start transfer cross-channel media streams. |
updateChannelMediaRelay | Updates the channels for media stream relay. |
stopChannelMediaRelay | Stops the media stream relay. |
enableMultiStream | Enable 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:
Base
Method | Description |
---|---|
init | Initialized audio video object. |
Event management
Method | Description |
---|---|
on | Event binding. |
off | Cancel the event binding. |
offAll | Cancel all event bindings under the specified type. |
Audio management
Method | Description |
---|---|
hasAudio | Get an audio Flag. |
muteAudio | Disable audio tracks. |
getAudioLevel | Retrieves the current audio level. |
getAudioTrack | Retrieves the audio track in the stream. |
setAudioOutput | Sets the audio output device of the remote stream. You can use it to switch between the microphone and the speakerphone. |
setAudioVolume | Sets the volume of the remote stream. |
unmuteAudio | Enable the audio track. |
playAudio | Enables the audio track in the stream. |
resumeAudio | Restore audio stream playback. |
unplayAudio | Stop the audio stream. |
getAudioVolume | Get the volume size. |
Video management
Method | Description |
---|---|
hasVideo | Retrieves the video flag. |
muteVideo | Disables the video track in the stream. |
setVideoProfile | Sets the video profile of the stream. |
unplayVideo | Stop the video stream. |
isVideoPlaying | Returns whether the video stream is currently playing in the play state. |
playVideo | Play the video stream. |
replaceTrack | Replaces the audio or video track in the local stream. |
resumeVideo | Restore video stream playback. |
getVideoTrack | Retrieves the video track in the stream. |
close | Close the audio and video stream. |
getStats | Retrieves the connection statistics of the stream. |
getId | Retrieves the stream ID. |
unmuteVideo | Enables the video track in the stream. |
isPubedVideo | Whether the publisher of the stream issued a video. |
getVideoProfile | Get video properties. |
isAudioPlaying | Returns whether the audio stream is currently played in the play state. |
isRemote | Whether it is a distant stream. |
getUserId | Get the user ID of the stream. |
getType | Get the type of the stream. |
getSourceID | Get the SourceId of the stream. |
switchMobileCamera | Switch the moving end and rear camera. |
setMirror | Set whether or not used image. |
Device management
Method | Description |
---|---|
switchDevice | Switch 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’:
Base
Method | Description |
---|---|
getDevices | Enumerated media input / output devices, such as microphones, cameras, speakers, etc. |
registerDeviceChangeListener | Register / remove the device listener. |
getUserMedia | Browser Navigator.Mediadevices.getusermedia’s package, SDK inside Navigator.Mediadevices.getusermedia has some browser adaptation |
microphone
Method | Description |
---|---|
startMicrophoneTest | Start microphone device detection. |
stopMicrophoneTest | Stop microphone device detection. |
setDefaultMicrophoneId | Set the default microphone id. |
getDefaultMicrophoneId | Get the default microphone id |
Camera
Method | Description |
---|---|
startCameraTest | Start camera detection. |
stopCameraTest | Stop camera detection. |
setDefaultCameraId | Set the default camera id. |
getDefaultCameraId | Get the default camera id |
speaker
Method | Description |
---|---|
startSpeakerTest | Start speaker device detection. |
stopSpeakerTest | Stop the speaker device detection. |
setDefaultSpeakerId | Set the default speaker id. |
associateElementsToSpeaker | Associate the media element node (video/audio) to the speaker. |
Desktop sharing
Method | Description |
---|---|
checkScreenIsSupport | Detect if a Google plug-in is required for screen/program sharing. |
audio and video
Method | Description |
---|---|
getCameras | Enumerate the video input device. |
getSpeakers | Enumerate the audio output device. |
getMicrophones | Enumerate the audio input device. |
getVideoTrack | Get the video track. |
getAudioTrack | Get the audio track. |
setDefaultVideoProfile | Set the default video properties. |
getDefaultSpeakerId | Get the default speaker id |
audioEleTestPlay | Audio 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). |
event
Listening to the event of Client and Stream Method triggered via Client.on and Stream.on Method.
Client event, please refer to Client Event Document。
STREAM event, please refer to Stream Event documentation。
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。
live
: Live scenes, there are two user roles of an anchor and audience, and the role of the anchor and the audience can be set via Client.setClientrole Method. An anchor can send and receive voice / video streams, and the viewer can only receive voice / video and cannot be sent.rtc
: Communication scenarios, for common one-to-one call or group chat, any user in the channel can send and receive voice / video streams.
Note:
- One channel can only support one type of use, and determine the use scenario of the channel with the first entry channel.
- We recommend that 1 Channel will only use only one type of use, do not show the use of communication scenarios today, using live scenes tomorrow, if you need to replace the scene, please use the new Channel.
- Communication scene
RTC
Not allowed to enter too many users, in the communication scenario` RTC. Default 1 channel allows 100 people to enter, please contact CloudHub business person if you need to adjust the number of users. - Specify Mode to specify the use scenario of the channel when you specify the use scenario of the channel, for details to view CloudHubRTC data object document ClientConfig description.
The live broadcast scene calls clinet.publish and client.unpublish automatically switches the user’s identity, details Client.setClientRole、 Client.publish and Client.unpublish Interface description.