CloudHub Docs
Download Documents

RTC


CloudHubSDK Electron

Channel management

initialize

Initialize the SDK engine.

rtcEngine.initialize ( appId ) ;
ParametersDescription
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. One App ID can only be used to create one RtcEngine

Details

Please call the interface method of the RtcEngine class on the main thread.

setChannelProfile

Set the channel scene.

rtcEngine.setChannelProfile ( profile ) ;
ParametersDescription
profileChannel scene, the values are as follows: 0: (default) communication 1: live broadcast 2: game

Details

RtcEngine will adopt different optimization strategies for different usage scenarios, such as smooth communication scenarios and image quality in live broadcast scenarios.

Note:

setClientRole

Set user roles.。

rtcEngine.setClientRole ( role ) ;
ParametersDescription
roleThe user role in the live broadcast scene, the values are as follows: 1: anchor 2: audience

Details

Before joining the channel, the user needs to set the audience (default) or anchor role through this method. After joining the channel, the user can switch user roles through this method. If you call this method to switch user roles after joining a channel, after the call is successful, the onClientRoleChanged callback will be triggered locally; the remote side will trigger the onUserLeaved and onUserJoind callbacks.

Note: This method is only applicable to live broadcast scenes.

joinChannel

Join the channel.

rtcEngine.joinChannel ( token,channelId,info,uid ) ;
ParametersDescription
tokenThe token generated by the developer’s service side. If the security requirements are not high, you can pass the air
channelIdChannel number
infoUser-defined attributes. It will be synchronized to other users in the channel. It must be a json string and can be passed empty
uidThe unique identifier of the user in the channel. Must be a combination of letters and numbers. If it is empty, the SDK will automatically generate a GUID as the uid and notify it through the onJoinChannel callback. It must be a String

Details

This method allows users to join a call channel, users in the same channel can talk to each other, and multiple users can join the same channel to chat in groups. Apps that use different App IDs cannot communicate with each other. If the call is already in progress, the user must call leaveChannel to exit the current call before entering the next channel. After joining the channel, the onJoinChannel callback will be triggered locally; after the user in the communication scene and the host in the live broadcast scene join the channel, the remote end will trigger the onUserJoined callback.

Note: The uid cannot be repeated among users in the channel. If it is repeated, when a user with the same uid later enters, it will trigger the previous user to leave the channel automatically. At this time, the previous user will receive the onLocalUserEvicted callback.

leaveChannel

Leave the channel.

rtcEngine.leaveChannel ( ) ;

Details

Leave the channel, that is, hang up or exit the call.

After calling the joinChannel method, you must call leaveChannel to end the call, otherwise the next call cannot be started. You can call this method regardless of whether you are currently in a call. This method will release all resources related to the session. This method is an asynchronous operation and does not really exit the channel when the call returns. After successfully calling this method to leave the channel, the onLeaveChannel callback will be triggered locally; after the user in the communication scenario and the anchor in the live broadcast scenario leave the channel, the remote site will trigger the onUserLeaved callback.

renewToken

Update the token.

rtcEngine.renewToken ( token ) ;

Details

This method is used to update the Token. If the Token mechanism is enabled, the used Token will become invalid after a period of time. When any of the following occurs:

on

Bind listening events.

rtcEngine.on ( "onJoinChannel",onJoinChannel ) ;
ParametersDescription
eventThe name of the bound event
callbackBound event listeners

Note:

You need to listen before the corresponding event is called. For example, when listening for joinChannel callbacks, you must listen for rtcEngine.on (“onJoinChannel”,onJoinChannel) before calling the JoinChannel method so that the callback will return after joining the room.

off

Unbind the listening event.

rtcEngine.off ( "onJoinChannel",onJoinChannel ) ;

offAll

Unbind event All listening events.

rtcEngine.offAll ( "joinchannel" ) ;

Audio management

setAudioQuality

Set the audio quality of the local transmission

int setAudioQuality( quality )

Parametric

ParametersDescription
qualityAudio quality, see AUDIO_QUALITY

return

adjustRecordingSignalVolume

Adjusts the volume of the signal captured by the microphone, You can call this method either before or after joining a channel.

rtcEngine.adjustRecordingSignalVolume(volume)

Parameters

ParameterDescription
volumenumber 0-400.
0: Mute
100: Original volume
400: Four times the original volume with signal-clipping protection.

Returns

adjustPlaybackSignalVolume

Adjusts the playback signal volume of all remote users, You can call this method either before or after joining a channel.

rtcEngine.adjustPlaybackSignalVolume(volume)

Parameters

ParameterDescription
volumenumber 0-400.
0: Mute
100: Original volume
400: Four times the original volume with signal-clipping protection.

Returns

adjustUserPlaybackSignalVolume

Adjusts the playback volume of a specified remote user, Call this method after joining a channel. You can call this method as many times as necessary to adjust the playback volume of different remote users, or to repeatedly adjust the playback volume of the same remote user.

rtcEngine.adjustUserPlaybackSignalVolume(uid, volume)

Parameters

ParameterDescription
uidstring : The ID of the remote user
volumenumber 0-100.
0: Mute
100: Original volume

Returns

enableLocalAudio

On/off local audio capture.

rtcEngine.enableLocalAudio ( mute ) ;
ParametersDescription
enabletrue: enable local voice collection, false: stop local voice collection

Details

This method does not affect the reception or playback of remote audio streams, and enableLocalAudio (false) is suitable for user scenarios where only listening but not sending.

muteLocalAudioStream

Turn on/off local audio transmission.

rtcEngine.muteLocalAudioStream ( mute ) ;
ParametersDescription
mutetrue: stop local audio sending, false: open local audio sending

Details

This method is used to allow/prohibit sending local audio streams to the network. After the method is successfully called, the remote end will trigger the onRemoteAudioStateChanged callback. The reason is 5 (stop) /6 (send).

Note:

This method does not affect the recording state, and does not disable the microphone.

muteRemoteAudioStream

Receive/stop receiving the specified remote audio stream.

rtcEngine.muteRemoteAudioStream ( uid,mute ) ;
ParametersDescription
uidUser id to be operated, must be String
muteWhether to stop receiving the user’s voice

Details

After the method is successfully called, the onRemoteAudioStateChanged callback will be triggered locally, and the reason is 5 (stop) /6 (send)

muteAllRemoteAudioStreams

Receive/stop receiving all remote audio streams.

rtcEngine.muteAllRemoteAudioStreams ( mute ) ;

Details

After the method is successfully called, the onRemoteAudioStateChanged callback will be triggered locally, and the reason is 5 (stop) 6 (send)

Video management

enableVideo

Enable the video module.

rtcEngine.enableVideo ( ) ;

Details

This method is used to enable the video mode. It can be called before joining a channel or during a call. Calling enableVideo () before joining a channel will automatically turn on the video mode

disableVideo

Disable video module

rtcEngine.disableVideo ( ) ;

Details

This method is used to disable the video mode.

setVideoEncoderConfiguration

Set video encoding properties.

rtcEngine.setVideoEncoderConfiguration ( {width:100,height:100...} ) ;
ParametersDescription
configThe video encoding attribute configuration item parameters are as follows:
width: width (type: number)
height: height (type: number)
frameRate: video encoding frame rate (fps) The default value is 15 , It is recommended not to exceed 30 (type: number)
bitrate: video encoding bitrate (type: number, unit Kbps)
minFrameRate: lowest frame rate (type: number)
minBitrate: lowest Bit rate (type: number)
degradationPreference: the preference of video encoding when the bandwidth is limited (type: number) The values are as follows: 0=reduce the encoding frame rate to ensure the video quality 1=reduce the video quality to ensure the encoded frame Rate 2 = maintain a balance between encoding frame rate and video quality
orientationMode: video rotation mode (type: number) The values are as follows: 0=default adaptive; 1=horizontal screen mode; 2=portrait mode< br/> deviceId: Optional, configure the encoding attributes of a certain video (type: string)

Details

This method sets video encoding parameters. All the parameters set are the maximum values under ideal conditions. When the video engine cannot reach the maximum resolution or frame rate set due to equipment, network environment, etc., it will take the value closest to the maximum. By default, the rotation mode is adaptive. At this time, if the captured video is horizontal (width is greater than height), the output video is also horizontal, if the captured video is vertical, the output video is also vertical; if If the rotation mode is horizontal screen mode, the output video will remain horizontal, and the vertical screen collection data will be cropped; if the rotation mode is vertical screen, the output video will remain vertical screen, and the horizontal screen collection data will be cropped. When recording is turned on, the rotation mode should not be changed after setting.

setVideoMode

Set the display mode of the video.

rtcEngine.setVideoMode ( viewId: string, mode: number ) ;
ParametersDescription
viewIdThe id of the dom element that displays the video
modeDisplay Mode
0 Priority is given to ensuring that the window is filled. The video size is scaled proportionally until the entire window is filled with the video. If the video length and width are different from the display window, the extra video will be cut off. 1 Priority is given to ensuring that all video content is displayed. The video size is scaled proportionally until one side of the video window is aligned with the window border. If the video length and width are different from the display window, the unfilled area on the window will be blacked out

Details

After playing the video, you can call this method to update the display mode of the video. This method only affects the video images seen by local users, and does not affect the video images published locally.

Note:

This method can be called multiple times during a call.

setLocalVideoMirror

Set the mirroring mode of the local video.

rtcEngine.setLocalVideoMirror ( mirror: boolean, options?: { viewId?: string }) ;
ParametersDescription
mirrorWhether to mirror true for mirroring false for not mirroring
optionsOptional, where viewId is the id of the dom element that displays the video

Details

After playing the local video, you can call this method to update the mirror mode of the local video. This method only affects the video images seen by the local users, and does not affect the locally published video images.

Note:

This method can be called multiple times during a call.

setupLocalVideo

Start playing local video.

rtcEngine.setupLocalVideo ( view: Element, options?: { deviceId?: string }) ;
ParametersDescription
viewThe DOM element that holds the video. The element needs to have an id
optionsOptional, where deviceId is the camera ID to start playing

Details

Call this method to start previewing the local video. You need to call enableVideo 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:

If you want to update the display or mirroring mode of the local video during a call, please use the setVideoMode / setLocalVideoMirror method.

removeLocalVideo

Stop playing local video.

rtcEngine.removeLocalVideo ( view: Element, options?: { deviceId?: string }) ;
ParametersDescription
viewDOM element of local video
optionsOptional, where deviceId is the ID of the camera that stopped playing

setupRemoteVideo

Start playing the remote video.

rtcEngine.setupRemoteVideo ( uid: string, streamId: string, view: Element ) ;
ParametersDescription
uidUser ID, must be a String
streamIdVideo stream id (onRemoteVideoStateChanged event will return streamId)
viewDisplay the dom element of the video, the element needs to have an id

Details

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

removeRemoteVideo

Stop playing the remote video.

rtcEngine.removeRemoteVideo ( uid: string, streamId: string ) ;
ParametersDescription
uidUser ID, must be a String
streamIdVideo stream id

enableLocalVideo

This method disables or re-enables local video capture and does not affect the reception of remote video.

enableLocalVideo ( enable: boolean, options?: { deviceId?: string }) ;

Details

After calling enableVideo, the local video is enabled by default. You can call enableLocalVideo (false) to turn off local video capture. If you want to turn it back on after turning it off, you can call enableLocalVideo (true).

After successfully disabling or enabling local video capture.

ParametersDescription
enabletrue: enable local video capture and rendering (default)
false: disable local video capture and rendering. After closing, the remote user will not receive the video stream of the local user; but the local user can still receive the video stream of the remote user
optionsOptional, where deviceId is the camera ID that is disabled or re-enabled

muteLocalVideoStream

Send/stop sending local video stream.

rtcEngine.muteLocalVideoStream ( mute: boolean, options?: { deviceId?: string }) ;
ParametersDescription
mutetrue: do not send local video stream false: send local video stream (default)
optionsOptional, where deviceId is the camera ID corresponding to the sending/stopping video stream

Details

Optional, where deviceId is the camera ID corresponding to the sending/stopping video stream

Note:

When this method is called, the SDK no longer sends the local video stream, but the camera is still working. This method does not affect the acquisition of local video streams and does not disable the camera.

muteRemoteVideoStream

Receive/stop receiving the specified remote user video stream.

rtcEngine.muteRemoteVideoStream(streamId, mute); 
ParametersDescription
streamIdVideo stream id
mutetrue: do not receive the remote video stream false: receive the remote video stream (default)

Details

After the method is successfully called, the onRemoteVideoStateChanged callback will be triggered locally, and the reason is 3 (stop) / 4 (send)

muteAllRemoteVideoStreams

Whether to receive/stop receiving all remote user video streams.

rtcEngine.muteAllRemoteVideoStreams ( mute ) ;
ParametersDescription
mutetrue: do not receive remote video stream
false: receive remote video stream (default)

Details

After the method is successfully called, the onRemoteVideoStateChanged callback will be triggered locally, and the reason is 3 (stop) / 4 (send)

Video pre-process and post-process

setBeautyEffectOptions

Enable or disable the local beautifying function and set the beautifying effect options.

rtcEngine.setBeautyEffectOptions ( enable, options, deviceId = '' ) ;
ParametersDescription
enableboolean:Whether open
optionsobject:Set beauty options.
options.lighteningContrastLevel: 0 | 1 | 2 Contrast, used with lighteningLevel. The larger the value is, the more intense the contrast is
options.lighteningLevel: number Brightness, can be used to achieve whitening and other visual effects. The value ranges from 0.0 to 1.0, where 0.0 indicates the original brightness. The default value is 0.7.
options.rednessLevel: number Ruddy, can be used to achieve rosy complexion and other visual effects. The value ranges from 0.0 to 1.0, where 0.0 indicates the original redness. The default value is 0.1
options.smoothnessLevel: number Smoothness, can be used to achieve acne, skin grinding and other visual effects. The value ranges from 0.0 to 1.0, where 0.0 indicates the original smoothness level. The default value is 0.5.
deviceIdstring:Camera id

setVideoEffectOptions

Turn on or off the advanced beauty function and set the beauty effect option.

rtcEngine.setVideoEffectOptions ( enable, options, deviceId = '' ) ;
ParametersDescription
enableboolean:Whether open
optionsobject:Set beauty options.
options.sharpLevel: number Sharpen. The value range is [0.0,1.0], where 0.0 represents the raw effect. The default value is 0.5. Can be used for visual effects such as sharpening
options.thinFaceLevel: number Thin face, the value range is [0.0,1.0], where 0.0 indicates the original effect and the default value is 0.5. It can be used to achieve visual effects such as face slimming
options.bigEyesLevel: number Big eyes , The value ranges from 0.0 to 1.0, where 0.0 indicates the original effect. The default value is 0.5. Can be used to achieve big eyes and other visual effects
options.sticker: number Sticker 1- Princess Mask 2- Black Cat Glasses 3- Cartoon boy 4- Cartoon girl 5- Funny baby 6- Christmas Elk 7- Happy Birthday 8- Candy cone 9- Lucky cat 10- Cute pig
options.portraitBackground Virtual background 0- None 1- Blue sky 2- Lawn 3- White wall
deviceIdstring:Camera id

Details

A successful call to this method returns a number,

Multi-channel management

createChannel

Create and get an IChannel object.

You can call this method multiple times to create multiple IChannel objects, and then call the joinChannel method in each IChannel object to join multiple channels at the same time.

After joining multiple channels, you can subscribe to the audio and video streams of each channel simultaneously. However, only one channel can release one sound and video stream at a time.

virtual IChannel* createChannel ( const char * channelId )

Parameters

ParametersDescription
channelIdThe value is a character string of up to 64 bytes that identifies the channel name for the call. The following are the supported character sets (89 characters in total) :
• 26 lowercase letters a~z
• 26 uppercase letters A~Z
• 10 numbers 0~9
• Space
• “!"、"#"、"$"、"%"、"&"、” ( “、” ) “、"+"、"-"、":"、";"、"<"、"="、”."、">"、"?"、"@"、"["、"]"、"^"、"_"、" {"、"}"、"

return

Details

Screen sharing

getScreenDisplaysInfo

Obtain screen information This section describes how to obtain the screen ID and related information of the system (macOS or Windows). You can use the obtained screen ID to share the screen. You don’t have to pay attention to the content of the returned object, just use it for screen sharing.

console.log ( rtcEngine.getScreenDisplaysInfo ( )) ;

getScreenWindowsInfo

Obtain window information This method obtains the ID and related information of a system window (macOS or Windows). Needed to pay attention to the specific content of the returned object, directly using the get into the window ID as startScreenCaptureByDisplayId excludeWindow parameters, Specific reference startScreenCaptureByDisplayId.

console.log ( rtcEngine.getScreenWindowsInfo ( )) ;

startScreenCaptureByDisplayId

Start desktop sharing.

  rtcEngine.startScreenCaptureByDisplayId ( displayId,excludeWindow... ) ;
ParametersDescription
displayIdScreen ID displayId obtained from getScreenDisplaysInfo
excludeWindowWindowId not shared Windows obtained according to getScreenWindowsInfo
framerateFrame rate fps
bitrateRate kbps
isCaptrueCursorCapture mouse or not

Returns value

startScreenCaptureByWindowId

Share the screen through window information

rtcEngine.startScreenCaptureByWindowId ( windowId,excludeWindow... ) ;
ParametersDescription
windowIdShared windowId
excludeWindowUnshared window ID Only one window can not be shared (default: 0)
frameraterate (defaults to 5)
bitrateBit rate (default 1200)
isCaptrueCursorWhether to capture the mouse (default: false)

Returns value

stopScreenCapture

Stop desktop sharing.

rtcEngine.stopScreenCapture ( ) ;

startSpeakerCaptureWhileSharing

Enable the desktop sound function when sharing a desktop

rtcEngine.startSpeakerCaptureWhileSharing ( ) ;

stopSpeakerCaptureWhileSharing

Disable the desktop sound when sharing a desktop

rtcEngine.stopSpeakerCaptureWhileSharing ( ) ;

Music file playback

startPlayMovie

Start playing a music file.

rtcEngine.startPlayMovie ( ) ;
ParametersDescription
mediaFileThe path of the music file, which can be a local file or an http path (https protocol is not supported temporarily)
loopbackDo you just listen to yourself
cycleWhether to automatically start from the beginning after playing. The default is false
pausedOptional, indicates whether to pause immediately after starting

stopPlayMovie

Stop playing a music file.

rtcEngine.stopPlayMovie ( ) ;
ParametersDescription
mediaFileSee startPlayMovie for details

pausePlayMovie

Pause playing a music file.

rtcEngine.pausePlayMovie ( mediafile ) ;
ParametersDescription
mediaFileSee startPlayMovie for details

resumePlayMovie

Resume playing a music file.

rtcEngine.resumePlayMovie ( mediafile ) ;
ParametersDescription
mediaFileSee startPlayMovie for details

setupLocalMovie

Watch your own music files locally.

rtcEngine.setupLocalMovie ( ) ;
ParametersDescription
viewShow the dom element of the movie, the element needs to have an id
mediaFileThe path of the music file, which can be a local file or an http path (https protocol is not supported temporarily)

Note:

You need to call this method after calling startPlayMovie to take effect

removeLocalMovie

Cancel watching the music file you played.

rtcEngine.removeLocalMovie ( ) ;
ParametersDescription
mediaFileSee startPlayMovie for details

Note:

Calling this method does not affect other people’s viewing

setMoviePosition

Set the current progress of the music

rtcEngine.setMoviePosition ( mediafile,pos ) ;
ParametersDescription
mediaFileSee startPlayMovie for details
posThe target time to move, in milliseconds

getMovieCurrentPosition

Get the current playing time of the media

int64_t getMovieCurrentPosition ( const char* mediafile )

Parameters

ParametersDescription
mediafileMedia path

return

The current playing time of the media

getMovieInfo

Get media attributes

int getMovieInfo ( const char* mediafile,
                 bool& hasAudio,
                 bool& hasVideo )

Parameters

ParametersDescription
mediafileMedia path
hasAudioWhether there is audio
hasVideoIs there a video

return

getMovieDuration

Get movie duration.

rtcEngine.getMovieDuration ( mediaFile ) ;
ParametersDescription
mediaFilestring:Movie path

Details

A numeric value will be returned after the method is successfully called

Audio effect playback

getEffectsVolume

Get the volume of the playing sound effect file.

rtcEngine.getEffectsVolume ( ) ;

setEffectsVolume

Set the volume of playing sound effect files.

rtcEngine.setEffectsVolume ( volume ) ;
ParametersDescription
volumeThe volume of the sound effect file. The value range is [0.0,100.0], 100.0 is the default value, which means the original volume.

setVolumeOfEffect

Set the volume of a single sound effect file.

rtcEngine.setVolumeOfEffect ( soundId, volume ) ;
ParametersDescription
soundIdSpecifies the ID of the sound effect. Each sound effect has a unique ID
volumeThe volume of the sound effect file. The value range is [0.0,100.0]. 100.0 is the default value

playEffect

Play the specified sound effect file.

This method plays the specified local or online sound effect file. In this method, you can set the number of times the sound effect file is played, the pitch, the spatial position and gain of the sound effect, and whether the remote user can hear the sound effect.

You can call this method multiple times. By passing in the soundID and filePath of different sound effect files, multiple sound effect files can be played at the same time to achieve sound effect superimposition. For the best user experience, we recommend that no more than 3 sound effect files are played at the same time.

After calling this method to play the sound effect, the SDK will trigger the audioEffectFinished callback.

rtcEngine.playEffect ( soundId, filePath, loopcount, gain, publish, startTimeMS, endTimeMS ) ;
ParametersDescription
soundIdSpecifies the ID of the sound effect. Each sound effect has a unique ID
filePathSpecify the absolute path or URL address of the sound effect file (including the file extension). Supported audio formats include: mp3, mp4, m4a, aac, 3gp, mkv and wav
loopcountSet the number of times the sound effect is played in a loop:
0: play the sound effect once
1: play the sound effect twice
-1: play the sound effect in an infinite loop until stopEffect or stopAllEffects is called
gainSet whether to change the volume of a single sound effect. The value range is [0.0,100.0]. The default value is 100.0. The smaller the value, the lower the volume of the sound effect
publishSet whether to transmit the sound effect to the remote site:
true: When the sound effect is played locally, it will be published to the cloud, so remote users can also hear the sound effect.
false: The sound effect will not be published to the cloud. Therefore, the sound effect can only be heard locally
startTimeMSSet the time (milliseconds) to start playing, and the file will start playing from there.
endTimeMSSet the time (in milliseconds) to end the playback, and the file will end when it reaches that point.

stopEffect

Stop playing the specified sound effect file

rtcEngine.stopEffect ( soundId ) ;
ParametersDescription
soundIdSpecifies the ID of the sound effect. Each sound effect has a unique ID

stopAllEffects

Stop playing all sound effect files.

rtcEngine.stopAllEffects ( ) ;

preloadEffect

Preload sound effect files.

rtcEngine.preloadEffect ( soundId: number, filePath: string ) : number;
ParametersDescription
soundIdSpecifies the ID of the sound effect. Each sound effect has a unique ID
filePathThe absolute path of the sound effect file

unloadEffect

Release the sound file.

rtcEngine.unloadEffect ( soundId: number ) : number;
ParametersDescription
soundIdSpecifies the ID of the sound effect. Each sound effect has a unique ID

pauseEffect

Pause the sound effect file playback.

rtcEngine.pauseEffect ( soundId ) ;
ParametersDescription
soundIdSpecifies the ID of the sound effect. Each sound effect has a unique ID

pauseAllEffects

Pause all audio file playback

rtcEngine.pauseAllEffects ( ) ;

resumeEffect

Resume playing the specified sound effect file

rtcEngine.resumeEffect ( soundId ) ;
ParametersDescription
soundIdSpecifies the ID of the sound effect. Each sound effect has a unique ID

resumeAllEffects

Resume playing the specified sound effect file.

rtcEngine.resumeAllEffects ( ) ;

Vocal effects

setLocalVoicePitch

Set the local voice tone

rtcEngine.setLocalVoicePitch ( pitch ) ;

Parameters

ParametersDescription
pitchnumber: Speech frequency. It can be set in the range [0.5,2.0]. The smaller the value, the lower the tone. The default value is 1.0, indicating that the tone does not need to be changed

return

setLocalVoiceEqualization

Example Set local voice and sound balancing

rtcEngine.setLocalVoiceEqualization ( bandFrequency, bandGain )

Parameters

ParametersDescription
bandFrequencySpectrum subband index, value range is [0,7], respectively representing 8 frequency bands, corresponding center frequency is [70 150 250 500 1000 2000 4000 8000] Hz,See AUDIO_EQUALIZATION_BAND_FREQUENCY
gainnumber: Gain (dB). The value ranges from -15 to 15. The default value is 0. Views

return

setLocalVoiceReverb

Set local sound reverb

rtcEngine.setLocalVoiceReverb ( reverbKey, value ) ;

Parameters

ParametersDescription
reverbTypeReverb sound type,See AUDIO_REVERB_TYPE
valuenumber: Set the reverberation value. For the value range of each reverb sound, See AUDIO_REVERB_TYPE

return

setAudioEffectPreset

Set the SDK’s preset voice sounds.

rtcEngine.setAudioEffectPreset ( preset ) : number

Parameters

ParametersDescription
presetPreset sound options,See AUDIO_EFFECT_PRESET

return

enableDeepLearningDenoise

Enable or disable AI noise reduction mode.

rtcEngine.enableDeepLearningDenoise ( enabled ) ;

Parameters

ParametersDescription
enabledWhether to enable AI noise reduction mode:
true:(Default) Enabled.
false: Shut down.

return

CDN push

addPublishStreamUrl

Increase the bypass push address.

After calling this method, the SDK will trigger the streamPublished callback locally to report the status of adding the bypass push address.

rtcEngine.addPublishStreamUrl ( url ) ;
ParametersDescription
urlCDN streaming address, the format is RTMP. The character length cannot exceed 1024 bytes, and special characters such as Chinese are not supported.

Note:

This method is only applicable to the host in the live broadcast scene, please call this method after joining the channel.
1. Make sure that the bypass push function is enabled.
2. This method can only add one bypass push address each time. If you need to push multiple streams, you need to call this method multiple times.

removePublishStreamUrl

Delete the bypass streaming address.

After calling this method, the SDK will trigger the streamUnpublished callback locally to report the status of deleting the bypass push address.

rtcEngine.removePublishStreamUrl ( url: string ) ;
ParametersDescription
urlThe stream address to be deleted, the format is RTMP. The character length cannot exceed 1024 bytes.

Note:

This method is only applicable to anchors in live broadcast scenarios.
1. This method can only delete one bypass ingest address each time. If you need to delete multiple streams, you need to call this method multiple times.
2. The ingest address does not support special characters such as Chinese.

setLiveTranscoding

Set live transcoding

When this method is called to update the Transcoding parameter, the SDK triggers the transcodingUpdated callback.

rtcEngine.setLiveTranscoding ( transcoding: TranscodingConfig ) ;
ParametersDescription
transcodingSee the demo for details on setting up the bypass push-to-code map

Cross-channel media circulation (interactive live broadcast only)

startChannelMediaRelay

The method can be used to realize cross-channel communication and other scenarios

rtcEngine.startChannelMediaRelay ( config ) ;
ParametersDescription
configconfig contains: name, data
data contains:action, destChannelInfos
data.action: ‘start’ / ‘update’ / ‘stop’
data.destChannelInfos: data.destChannelInfos Key indicates the ID of the target channel, value has the attribute uid (the uid used when forwarding to the destination channel).

Details

DestChannelInfos if you want to send the stream to multiple target channels, you can add multiple keys to data.destChannelInfos.After a successful call this method, the channel, the SDK will trigger channelMediaRelayStateChanged callback, and report the current across the channel in the callback media flow state. The target channel will receive the onUserJoined callback,

updateChannelMediaRelay

Update channels for media circulation

rtcEngine.updateChannelMediaRelay ( config ) ;
ParametersDescription
configconfig contains: name, data
name: ‘ChannelMediaRelayControl’
data contains:action, destChannelInfos
data.action: ‘start’ / ‘update’ / ‘stop’
data.destChannelInfos: data.destChannelInfos Key indicates the ID of the target channel, value has the attribute uid (the uid used when forwarding to the destination channel).

Details

Call this method if you want to send the stream to multiple target channels or exit the current channel after you have successfully started forwarding media streams across channels.

stopChannelMediaRelay

Stop cross-channel media circulation.

rtcEngine.stopChannelMediaRelay ( ) ;

Details

Once stopped, the anchor will exit all target channels.

Volume indication

enableAudioVolumeIndication

Enable to disable speaker volume prompts.

rtcEngine.enableAudioVolumeIndication ( interval ) ;
ParametersDescription
intervaltype: number
Specify the time interval of the volume alert:
<= 0: Disable the volume alert function
> 0: Alert interval, in milliseconds. It is recommended to set to greater than 200 milliseconds. The minimum is not less than 10 milliseconds. After this method is enabled, no matter whether someone is speaking in the channel, the volume prompt will be returned at the set time interval in the onAudioVolumeIndication callback
smoothtype: number, optional
Smoothing factor, specify the sensitivity of the volume alert. The value range is [0,10], and the recommended value is 3. The larger the number, the more sensitive the fluctuation; the smaller the number, the smoother the fluctuation
reportVadtype: boolean, optional
• true: enable local voice detection. When enabled, the vad parameter of the onAudioVolumeIndication callback will report whether the human voice is detected locally
• false: default) Turn off the local human voice detection function. Except for scenarios where the engine automatically detects local human voices, the vad parameter of the onAudioVolumeIndication callback will not report whether human voices are detected locally

DualStream

enableDualStreamMode

Enable or disable the dualStream function

rtcEngine.enableDualStreamMode ( isOpen ) ;
ParametersDescription
isOpenisOpen is a Boolean type, true: enable, false: disable

setRemoteVideoStreamType

 Sets the type of video stream to subscribe to

rtcEngine.setRemoteVideoStreamType ( uid, streamType ) ;
ParametersDescription
uidUid is a user ID of the string type
streamTypeStreamType is the type of number, the type of video stream, where 0 represents a stream and 1 represents a small stream

setRemoteDefaultVideoStreamType

Sets the type of video stream to subscribe to by default

rtcEngine.setRemoteDefaultVideoStreamType ( type ) ;
ParametersDescription
typeType is the number type. 0- stream 1- small stream

Network test before calling

startLastmileProbeTest

Check network quality before a call starts

rtcEngine.startLastmileProbeTest ( config: LastmileProbeConfig ) ;

Details

After this method is enabled, the SDK reports the bandwidth, packet loss, network jitter, and round-trip delay of the upstream and downstream networks to the user. The SDK returns the following two callbacks at once:

This method is mainly used in the following two scenarios:

Note:

This method will consume a certain amount of network traffic and affect the call quality, so we recommend not to use this method and enableLastmileTest together.
1. After calling this method, do not call other methods until you receive the lastMileQuality and lastmileProbeResult callbacks; otherwise, the method may fail to execute due to too many API operations.
2. In live broadcast scenarios, if the local user plays the main channel, do not invoke this method after joining the channel.

stopLastmileProbeTest

Last Mile network quality detection before stopping a call.

rtcEngine.stopLastmileProbeTest ( ) ;

Audio playback device management

setAudioPlaybackDevice

Set the loudspeaker.

rtcEngine.setAudioPlaybackDevice ( deviceId ) ;
ParametersDescription
deviceIdSpeaker ID (the speaker ID returned in getAudioPlaybackDevices ())

getAudioPlaybackDevices

Gets the speaker list.

console.log ( rtcEngine.getAudioPlaybackDevices ( )) ;
Return parametersDescription
devicenameSpeaker name
deviceidSpeaker Id

getCurrentAudioPlaybackDevice

Gets the current speaker.

console.log ( rtcEngine.getCurrentAudioPlaybackDevice ( ))
ParametersDescription
devicenameSpeaker name
deviceidSpeaker Id

setAudioPlaybackDeviceMute

Mute/unmute audio playback device

rtcEngine.setAudioPlaybackDeviceMute( mute )

Parameters

ParametersDescription
muteboolean value, true-mute, false-unmute

getAudioPlaybackDeviceMute

Get the mute status of the audio playback device

rtcEngine.getAudioPlaybackDeviceMute()

setAudioPlaybackVolume

Set the volume of the audio playback device

rtcEngine.setAudioPlaybackVolume(volume)

Parameters

ParametersDescription
volumenumber type 0-255

getAudioPlaybackVolume

Get the volume of the audio playback device

rtcEngine.getAudioPlaybackVolume()

return

startAudioPlaybackDeviceTest

The speaker detection starts.

rtcEngine.startAudioPlaybackDeviceTest ( deviceId,filePath,options ) ;
ParametersDescription
deviceIdThe id of the speaker you want to test (getAudioPlaybackDevices () returns all speaker information)
filePathThe playing audio file requires an absolute path
optionsParameter loop Indicates whether to play in a loop

stopAudioPlaybackDeviceTest

Stop speaker detection.

rtcEngine.stopAudioPlaybackDeviceTest ( ) ;

startAudioDeviceLoopbackTest

Starts the audio device loopback test.

This method tests whether the local audio devices are working properly. After calling this method, the microphone captures the local audio and plays it through the speaker.

Note: This method tests the local audio devices and does not report the network conditions.

rtcEngine.startAudioDeviceLoopbackTest ( interval ) ;

Parameters

ParameterDescription
intervalThe time interval (ms) ( default:200ms )

Returns

stopAudioDeviceLoopbackTest

Stops the audio device loopback test.

rtcEngine.stopAudioDeviceLoopbackTest ( ) ;

Returns

Audio recording device management

setAudioRecordingDevice

Set up the microphone

rtcEngine.setAudioRecordingDevice ( deviceId ) ;
ParametersDescription
deviceIdMicrophone ID (the microphone ID returned in getAudioRecordingDevices ())

getAudioRecordingDevices

Get the microphone list.

console.log ( rtcEngine.getAudioRecordingDevices ( )) ;
Return parametersDescription
devicenameMicrophone Name
deviceidMicrophone Id

getCurrentAudioRecordingDevice

Gets the current microphone.

console.log ( rtcEngine.getCurrentAudioRecordingDevice ( ))
ParametersDescription
devicenameMicrophone Name
deviceidMicrophone Id

setAudioRecordingDeviceMute

Mute unmute recording equipment

rtcEngine.setAudioRecordingDeviceMute(mute)

Parameters

ParametersDescription
muteboolean value, true-mute, false-unmute

getAudioRecordingDeviceMute

Get the mute status of the recording device

rtcEngine.getAudioRecordingDeviceMute()

return

setAudioRecordingVolume

Set the volume of the recording device

rtcEngine.setAudioRecordingVolume(volume)

Parameters

ParametersDescription
volumenumber tyoe 0-255

getAudioRecordingVolume

Get the volume of the recording device

rtcEngine.getAudioRecordingVolume()

return

startAudioRecordingDeviceTest

Start microphone detection.

rtcEngine.startAudioRecordingDeviceTest ( deviceId,interval ) ;
ParametersDescription
deviceIdThe ID of the microphone you want to test (getAudioRecordingDevices () returns all microphone information)
intervalReturn volume interval (ms default: 200ms)

stopAudioRecordingDeviceTest

Stop the microphone detection.

rtcEngine.stopAudioRecordingDeviceTest ( ) ;

Video device management

enableMultiStream

Enable multiple cameras

rtcEngine.enableMultiStream ( enable: boolean ) ;
ParametersDescription
enabletrue: open, false: close

setVideoDevice

Set the camera.

rtcEngine.setVideoDevice ( deviceId ) ;
ParametersDescription
deviceIdCamera ID (camera ID returned from getVideoDevices ())

getVideoDevices

Gets the camera list.

console.log ( rtcEngine.getVideoDevices ( )) ;
Return parametersDescription
devicenameCamera Name
deviceidCamera Id

getCurrentVideoDevice

Gets the current camera.

console.log ( rtcEngine.getCurrentVideoDevice ( )) ;
Return parametersDescription
devicenameCamera Name
deviceidCamera Id

startVideoDeviceTest

Start camera detection.

rtcEngine.startVideoDeviceTest ( deviceId,view,onCallback ) ;
ParametersDescription
deviceIdId of camera to detect (getVideoDevices () returns all camera information)
viewDisplays the DOM element of the video
onCallbackStart the post-detection callback function

stopVideoDeviceTest

Stop camera detection.

rtcEngine.stopVideoDeviceTest ( ) ;

Release management

publish

Start to publish local audio and video.

rtcEngine.publish ( options?: { deviceId?: string, streamInfo?: {} }) ;
ParametersDescription
optionsOptional, which has the following values:
deviceId: Optional, camera ID to be published
streamInfo: Optional, custom data to be carried

Details

Publish your own audio and video to the channel for others to watch and listen. After the release is successful, the local will receive the onLocalVideoStateChanged callback. The remote end will receive the onRemoteVideoStateChanged callback

Note:

This method can only be called after joining the channel successfully.

unPublish

Stop publishing local audio and video.

rtcEngine.unPublish ( options?: { deviceId?: string }) ;
ParametersDescription
optionsOptional, where deviceId is the ID of the camera that stopped publishing

Details

Stop publishing your own audio and video. After you stop publishing, you will receive the onLocalVideoStateChanged callback locally. If the remote end will receive the onRemoteVideoStateChanged callback.

Note:

This method can only be called after joining the channel successfully.

Recording methods

startServerRecord

Start recording

rtcEngine.startServerRecord ( ) ;

Details

The onRecordMsg event is returned after the call is successful. For details, see onRecordMsg 事件

stopServerRecord

To stop recording

rtcEngine.stopServerRecord ( ) ;

Details

The onRecordMsg event is returned after the successful call. For details, see onRecordMsg 事件

pauseServerRecord

The stop

rtcEngine.pauseServerRecord ( ) ;

Details

The onRecordMsg event is returned after the call is successful. For details, see onRecordMsg 事件

resumeServerRecord

Restore the recording

rtcEngine.resumeServerRecord ( ) ;

Details

OnRecordMsg event is returned after the call is successful. For details, see onRecordMsg 事件

Advanced signaling method

Note:

These methods must all be called after joining the channel successfully.

setProperty

Sets custom properties for a user in a channel.

rtcEngine.setProperty ( uid,toId,prop ) ;
ParametersDescription
uidUid of target user: must be string
toIdThe user to notify. If it is blank, everyone in the channel will be notified. If a user’s uid is specified, only the specified user is notified. The default is empty
propCustom attribute. Must be a JSON string

Details

There are two ways to set custom properties:

After the setting is successful, both the notified user and the set user will receive the notification. In addition, the new user entering the channel will also get these properties of the user in the onuserjoined callback.

Note:

sendChatMsg

Send a chat message.

rtcEngine.setChatMsg ( toId,message,extraData ) ;

Parameters

ParametersDescription
toIdThe user to be notified. If it is empty, everyone in the channel is notified. If a user’s UID is specified, only the specified user is notified
messageChat message text
extraDataThis message has custom attributes. It must be a JSON string. Can be null

Details

You can usually use extraData to pass information about fonts, avatars, and so on. Users within the channel will receive the onChatMsg callback.

pubMsg

Publish a custom message.

rtcEngine.pubMsg ( msgName,msgId... ) ;
ParametersDescription
msgNameThe name of the message
msgIdThe message id. Is the unique identifier of a message within a channel
toIdThe user to be notified. There are the following values:
‘__all’: Send a message to everyone in the channel
‘__allExceptSender’: Send messages to everyone on the channel except yourself
‘__none’: Only messages are sent to the signaling server, not to anyone
userId: ID of a user. Note: Send messages only to this user
dataMessage content. It needs to be a JSON object
associatedUserIdAssociate the UID of the user. Once a message is associated with a user, the message is automatically deleted when the user exits
associatedMsgIdId of the associated message. Once a message is associated with another message, it is automatically deleted when the associated message is deleted
saveWhether to save. If saved, subsequent users entering the channel will receive the signaling in the onPubMsg callback until the message is deleted using the delMsg method
extendInfoKeep parameters

Details

The pubMsg mechanism is similar to a message board and is used to save and synchronize the business status within the channel. Both users already in the channel and new users can receive custom messages already published in the current channel through the pubMsg callback.

Note:

The message will only be saved in recorded playback if toId is ’__all‘ or ‘allExceptSender ' and save is true

delMsg

Example Delete a custom message.

rtcEngine.delMsg ( msgName,msgId... ) ;
ParametersDescription
msgNameThe name of the message
msgIdThe message ID is to be deleted. The ID is specified when a message is published through the pubMsg method
toIdThe user to be notified. If it is empty, everyone in the channel is notified. If a user’s UID is specified, only the specified user is notified.
dataKeep parameters

Details

After the call is successful, users already in the channel will receive the onDelMsg message.

Note:

Deleting a message that does not exist fails.

evictUser

Kick a user out of the channel.

rtcEngine.evictUser ( uid,reason ) ;
ParametersDescription
uidUid of the kicked user, which must be String
reasonCustom field

Details

After a successful call, the kicked user receives the onLocalUserEvicted callback. Other users will receive the onUserLeaved callback.

Other methods

getVersion

Obtain the SDK version number.

rtcEngine.getVersion ( ) ;