CloudHubSDK Electron
Channel management
initialize
Initialize the SDK engine.
rtcEngine.initialize ( appId ) ;
Parameters | Description |
---|---|
appId | The 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 ) ;
Parameters | Description |
---|---|
profile | Channel 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:
- Users in the same channel must use the same channel scene.
- This method must be called before joining the channel, and the channel scene cannot be set after entering the channel.
setClientRole
Set user roles.。
rtcEngine.setClientRole ( role ) ;
Parameters | Description |
---|---|
role | The 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 ) ;
Parameters | Description |
---|---|
token | The token generated by the developer’s service side. If the security requirements are not high, you can pass the air |
channelId | Channel number |
info | User-defined attributes. It will be synchronized to other users in the channel. It must be a json string and can be passed empty |
uid | The 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:
onRequestToken callback;
App should obtain the Token again, and then call the API to update the Token, otherwise the SDK will not be able to establish a connection with the server;
on
Bind listening events.
rtcEngine.on ( "onJoinChannel",onJoinChannel ) ;
Parameters | Description |
---|---|
event | The name of the bound event |
callback | Bound 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
Parameters | Description |
---|---|
quality | Audio quality, see AUDIO_QUALITY |
return
- 0: Success
- Non 0: failure
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
Parameter | Description |
---|---|
volume | number 0-400. 0: Mute 100: Original volume 400: Four times the original volume with signal-clipping protection. |
Returns
- 0: Success.
- < 0: Failure.
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
Parameter | Description |
---|---|
volume | number 0-400. 0: Mute 100: Original volume 400: Four times the original volume with signal-clipping protection. |
Returns
- 0: Success.
- < 0: Failure.
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
Parameter | Description |
---|---|
uid | string : The ID of the remote user |
volume | number 0-100. 0: Mute 100: Original volume |
Returns
- 0: Success.
- < 0: Failure.
enableLocalAudio
On/off local audio capture.
rtcEngine.enableLocalAudio ( mute ) ;
Parameters | Description |
---|---|
enable | true: 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 ) ;
Parameters | Description |
---|---|
mute | true: 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 ) ;
Parameters | Description |
---|---|
uid | User id to be operated, must be String |
mute | Whether 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...} ) ;
Parameters | Description |
---|---|
config | The 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 ) ;
Parameters | Description |
---|---|
viewId | The id of the dom element that displays the video |
mode | Display 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 }) ;
Parameters | Description |
---|---|
mirror | Whether to mirror true for mirroring false for not mirroring |
options | Optional, 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 }) ;
Parameters | Description |
---|---|
view | The DOM element that holds the video. The element needs to have an id |
options | Optional, 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 }) ;
Parameters | Description |
---|---|
view | DOM element of local video |
options | Optional, 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 ) ;
Parameters | Description |
---|---|
uid | User ID, must be a String |
streamId | Video stream id (onRemoteVideoStateChanged event will return streamId) |
view | Display 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 ) ;
Parameters | Description |
---|---|
uid | User ID, must be a String |
streamId | Video 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.
Parameters | Description |
---|---|
enable | true: 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 |
options | Optional, 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 }) ;
Parameters | Description |
---|---|
mute | true: do not send local video stream false: send local video stream (default) |
options | Optional, 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);
Parameters | Description |
---|---|
streamId | Video stream id |
mute | true: 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 ) ;
Parameters | Description |
---|---|
mute | true: 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 = '' ) ;
Parameters | Description |
---|---|
enable | boolean:Whether open |
options | object: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. |
deviceId | string:Camera id |
setVideoEffectOptions
Turn on or off the advanced beauty function and set the beauty effect option.
rtcEngine.setVideoEffectOptions ( enable, options, deviceId = '' ) ;
Parameters | Description |
---|---|
enable | boolean:Whether open |
options | object: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 |
deviceId | string:Camera id |
Details
A successful call to this method returns a number,
- 0:Success
- < 0:Failure
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
Parameters | Description |
---|---|
channelId | The 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
- Method called successfully, returns a pointer to the IChannel object
- Method call fails, returns a NULL pointer
- If channelId is null, the SDK will return ERR_REFUSED.
Details
- There is no default value for this parameter. Be sure to set a value for it.
- Do not set this parameter to null character “”, otherwise SDK will return ERR_REFUSED.
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... ) ;
Parameters | Description |
---|---|
displayId | Screen ID displayId obtained from getScreenDisplaysInfo |
excludeWindow | WindowId not shared Windows obtained according to getScreenWindowsInfo |
framerate | Frame rate fps |
bitrate | Rate kbps |
isCaptrueCursor | Capture mouse or not |
Returns value
- -1 Description Failed to start desktop sharing
- 0 Desktop sharing succeeds
- 5 Refusing desktop sharing
startScreenCaptureByWindowId
Share the screen through window information
rtcEngine.startScreenCaptureByWindowId ( windowId,excludeWindow... ) ;
Parameters | Description |
---|---|
windowId | Shared windowId |
excludeWindow | Unshared window ID Only one window can not be shared (default: 0) |
framerate | rate (defaults to 5) |
bitrate | Bit rate (default 1200) |
isCaptrueCursor | Whether to capture the mouse (default: false) |
Returns value
- -1 Failed to share the screen through window information
- 0 Sharing the screen through window information succeeded. Procedure
- 5 Deny screen sharing through Windows
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 ( ) ;
Parameters | Description |
---|---|
mediaFile | The path of the music file, which can be a local file or an http path (https protocol is not supported temporarily) |
loopback | Do you just listen to yourself |
cycle | Whether to automatically start from the beginning after playing. The default is false |
paused | Optional, indicates whether to pause immediately after starting |
stopPlayMovie
Stop playing a music file.
rtcEngine.stopPlayMovie ( ) ;
Parameters | Description |
---|---|
mediaFile | See startPlayMovie for details |
pausePlayMovie
Pause playing a music file.
rtcEngine.pausePlayMovie ( mediafile ) ;
Parameters | Description |
---|---|
mediaFile | See startPlayMovie for details |
resumePlayMovie
Resume playing a music file.
rtcEngine.resumePlayMovie ( mediafile ) ;
Parameters | Description |
---|---|
mediaFile | See startPlayMovie for details |
setupLocalMovie
Watch your own music files locally.
rtcEngine.setupLocalMovie ( ) ;
Parameters | Description |
---|---|
view | Show the dom element of the movie, the element needs to have an id |
mediaFile | The 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 ( ) ;
Parameters | Description |
---|---|
mediaFile | See 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 ) ;
Parameters | Description |
---|---|
mediaFile | See startPlayMovie for details |
pos | The target time to move, in milliseconds |
getMovieCurrentPosition
Get the current playing time of the media
int64_t getMovieCurrentPosition ( const char* mediafile )
Parameters
Parameters | Description |
---|---|
mediafile | Media path |
return
The current playing time of the media
getMovieInfo
Get media attributes
int getMovieInfo ( const char* mediafile,
bool& hasAudio,
bool& hasVideo )
Parameters
Parameters | Description |
---|---|
mediafile | Media path |
hasAudio | Whether there is audio |
hasVideo | Is there a video |
return
- 0: success
- Non-zero: failure
getMovieDuration
Get movie duration.
rtcEngine.getMovieDuration ( mediaFile ) ;
Parameters | Description |
---|---|
mediaFile | string: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 ) ;
Parameters | Description |
---|---|
volume | The 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 ) ;
Parameters | Description |
---|---|
soundId | Specifies the ID of the sound effect. Each sound effect has a unique ID |
volume | The 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 ) ;
Parameters | Description |
---|---|
soundId | Specifies the ID of the sound effect. Each sound effect has a unique ID |
filePath | Specify 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 |
loopcount | Set 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 |
gain | Set 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 |
publish | Set 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 |
startTimeMS | Set the time (milliseconds) to start playing, and the file will start playing from there. |
endTimeMS | Set 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 ) ;
Parameters | Description |
---|---|
soundId | Specifies 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;
Parameters | Description |
---|---|
soundId | Specifies the ID of the sound effect. Each sound effect has a unique ID |
filePath | The absolute path of the sound effect file |
unloadEffect
Release the sound file.
rtcEngine.unloadEffect ( soundId: number ) : number;
Parameters | Description |
---|---|
soundId | Specifies the ID of the sound effect. Each sound effect has a unique ID |
pauseEffect
Pause the sound effect file playback.
rtcEngine.pauseEffect ( soundId ) ;
Parameters | Description |
---|---|
soundId | Specifies 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 ) ;
Parameters | Description |
---|---|
soundId | Specifies 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
Parameters | Description |
---|---|
pitch | number: 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
- 0: Success
- Not 0:Failure.
setLocalVoiceEqualization
Example Set local voice and sound balancing
rtcEngine.setLocalVoiceEqualization ( bandFrequency, bandGain )
Parameters
Parameters | Description |
---|---|
bandFrequency | Spectrum 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 。 |
gain | number: Gain (dB). The value ranges from -15 to 15. The default value is 0. Views |
return
- 0: Success
- Not 0:Failure.
setLocalVoiceReverb
Set local sound reverb
rtcEngine.setLocalVoiceReverb ( reverbKey, value ) ;
Parameters
Parameters | Description |
---|---|
reverbType | Reverb sound type,See AUDIO_REVERB_TYPE |
value | number: Set the reverberation value. For the value range of each reverb sound, See AUDIO_REVERB_TYPE |
return
- 0: Success
- Not 0:Failure.
setAudioEffectPreset
Set the SDK’s preset voice sounds.
rtcEngine.setAudioEffectPreset ( preset ) : number
Parameters
Parameters | Description |
---|---|
preset | Preset sound options,See AUDIO_EFFECT_PRESET |
return
- 0: Success
- Not 0:Failure.
enableDeepLearningDenoise
Enable or disable AI noise reduction mode.
rtcEngine.enableDeepLearningDenoise ( enabled ) ;
Parameters
Parameters | Description |
---|---|
enabled | Whether to enable AI noise reduction mode: true:(Default) Enabled. false: Shut down. |
return
- 0: Success
- Not 0:Failure.
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 ) ;
Parameters | Description |
---|---|
url | CDN 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 ) ;
Parameters | Description |
---|---|
url | The 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 ) ;
Parameters | Description |
---|---|
transcoding | See 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 ) ;
Parameters | Description |
---|---|
config | config 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 ) ;
Parameters | Description |
---|---|
config | config 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 ) ;
Parameters | Description |
---|---|
interval | type: 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 |
smooth | type: 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 |
reportVad | type: 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 ) ;
Parameters | Description |
---|---|
isOpen | isOpen is a Boolean type, true: enable, false: disable |
setRemoteVideoStreamType
Sets the type of video stream to subscribe to
rtcEngine.setRemoteVideoStreamType ( uid, streamType ) ;
Parameters | Description |
---|---|
uid | Uid is a user ID of the string type |
streamType | StreamType 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 ) ;
Parameters | Description |
---|---|
type | Type 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:
- lastMileQuality:Return within 2 seconds depending on network conditions. The callback feedback the upstream and downstream network quality by scoring, closer to the subjective feelings of users.
- lastmileProbeResult:Return within 30 seconds depending on network conditions. This callback feeds back the upstream and downstream network quality with objective data and is therefore more objective.
This method is mainly used in the following two scenarios:
- Before joining a channel, users can use this method to judge and predict whether the current uplink network quality is good enough.
- In the live broadcast scenario, when the user role wants to switch from the audience to the master, you can call this method to judge and predict whether the current uplink network quality is good enough.
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 ) ;
Parameters | Description |
---|---|
deviceId | Speaker ID (the speaker ID returned in getAudioPlaybackDevices ()) |
getAudioPlaybackDevices
Gets the speaker list.
console.log ( rtcEngine.getAudioPlaybackDevices ( )) ;
Return parameters | Description |
---|---|
devicename | Speaker name |
deviceid | Speaker Id |
getCurrentAudioPlaybackDevice
Gets the current speaker.
console.log ( rtcEngine.getCurrentAudioPlaybackDevice ( ))
Parameters | Description |
---|---|
devicename | Speaker name |
deviceid | Speaker Id |
setAudioPlaybackDeviceMute
Mute/unmute audio playback device
rtcEngine.setAudioPlaybackDeviceMute( mute )
Parameters
Parameters | Description |
---|---|
mute | boolean 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
Parameters | Description |
---|---|
volume | number type 0-255 |
getAudioPlaybackVolume
Get the volume of the audio playback device
rtcEngine.getAudioPlaybackVolume()
return
- volume 0-255
startAudioPlaybackDeviceTest
The speaker detection starts.
rtcEngine.startAudioPlaybackDeviceTest ( deviceId,filePath,options ) ;
Parameters | Description |
---|---|
deviceId | The id of the speaker you want to test (getAudioPlaybackDevices () returns all speaker information) |
filePath | The playing audio file requires an absolute path |
options | Parameter 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
Parameter | Description |
---|---|
interval | The time interval (ms) ( default:200ms ) |
Returns
- 0: Success.
- 0: Failure.
stopAudioDeviceLoopbackTest
Stops the audio device loopback test.
rtcEngine.stopAudioDeviceLoopbackTest ( ) ;
Returns
- 0: Success.
- 0: Failure.
Audio recording device management
setAudioRecordingDevice
Set up the microphone
rtcEngine.setAudioRecordingDevice ( deviceId ) ;
Parameters | Description |
---|---|
deviceId | Microphone ID (the microphone ID returned in getAudioRecordingDevices ()) |
getAudioRecordingDevices
Get the microphone list.
console.log ( rtcEngine.getAudioRecordingDevices ( )) ;
Return parameters | Description |
---|---|
devicename | Microphone Name |
deviceid | Microphone Id |
getCurrentAudioRecordingDevice
Gets the current microphone.
console.log ( rtcEngine.getCurrentAudioRecordingDevice ( ))
Parameters | Description |
---|---|
devicename | Microphone Name |
deviceid | Microphone Id |
setAudioRecordingDeviceMute
Mute unmute recording equipment
rtcEngine.setAudioRecordingDeviceMute(mute)
Parameters
Parameters | Description |
---|---|
mute | boolean value, true-mute, false-unmute |
getAudioRecordingDeviceMute
Get the mute status of the recording device
rtcEngine.getAudioRecordingDeviceMute()
return
- true / false
setAudioRecordingVolume
Set the volume of the recording device
rtcEngine.setAudioRecordingVolume(volume)
Parameters
Parameters | Description |
---|---|
volume | number tyoe 0-255 |
getAudioRecordingVolume
Get the volume of the recording device
rtcEngine.getAudioRecordingVolume()
return
- volume 0-255
startAudioRecordingDeviceTest
Start microphone detection.
rtcEngine.startAudioRecordingDeviceTest ( deviceId,interval ) ;
Parameters | Description |
---|---|
deviceId | The ID of the microphone you want to test (getAudioRecordingDevices () returns all microphone information) |
interval | Return volume interval (ms default: 200ms) |
stopAudioRecordingDeviceTest
Stop the microphone detection.
rtcEngine.stopAudioRecordingDeviceTest ( ) ;
Video device management
enableMultiStream
Enable multiple cameras
rtcEngine.enableMultiStream ( enable: boolean ) ;
Parameters | Description |
---|---|
enable | true: open, false: close |
setVideoDevice
Set the camera.
rtcEngine.setVideoDevice ( deviceId ) ;
Parameters | Description |
---|---|
deviceId | Camera ID (camera ID returned from getVideoDevices ()) |
getVideoDevices
Gets the camera list.
console.log ( rtcEngine.getVideoDevices ( )) ;
Return parameters | Description |
---|---|
devicename | Camera Name |
deviceid | Camera Id |
getCurrentVideoDevice
Gets the current camera.
console.log ( rtcEngine.getCurrentVideoDevice ( )) ;
Return parameters | Description |
---|---|
devicename | Camera Name |
deviceid | Camera Id |
startVideoDeviceTest
Start camera detection.
rtcEngine.startVideoDeviceTest ( deviceId,view,onCallback ) ;
Parameters | Description |
---|---|
deviceId | Id of camera to detect (getVideoDevices () returns all camera information) |
view | Displays the DOM element of the video |
onCallback | Start 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?: {} }) ;
Parameters | Description |
---|---|
options | Optional, which has the following values:deviceId: Optional, camera ID to be publishedstreamInfo: 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 }) ;
Parameters | Description |
---|---|
options | Optional, 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 ) ;
Parameters | Description |
---|---|
uid | Uid of target user: must be string |
toId | The 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 |
prop | Custom attribute. Must be a JSON string |
Details
There are two ways to set custom properties:
- When a user joins a channel, specify properties in the joinchannel;
- After the user enters the channel, calling setProperty, the user receives the onSetProperty callback.
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:
- If different attributes of the same user are specified multiple times, these attributes will be recorded and sent to the user newly entering the channel through the onuserjoined callback.
- If the same attribute of the same user is specified multiple times, the later set attribute overrides the previously set attribute. For example, repeat the settings for user a twice and pass in {“test”: true} and {“test”: false} respectively. Then user B who newly enters the channel will get the attribute {“test”: false} of user a in the onuserjoined callback about user a.
sendChatMsg
Send a chat message.
rtcEngine.setChatMsg ( toId,message,extraData ) ;
Parameters
Parameters | Description |
---|---|
toId | The 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 |
message | Chat message text |
extraData | This 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... ) ;
Parameters | Description |
---|---|
msgName | The name of the message |
msgId | The message id. Is the unique identifier of a message within a channel |
toId | The 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 |
data | Message content. It needs to be a JSON object |
associatedUserId | Associate the UID of the user. Once a message is associated with a user, the message is automatically deleted when the user exits |
associatedMsgId | Id of the associated message. Once a message is associated with another message, it is automatically deleted when the associated message is deleted |
save | Whether 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 |
extendInfo | Keep 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... ) ;
Parameters | Description |
---|---|
msgName | The name of the message |
msgId | The message ID is to be deleted. The ID is specified when a message is published through the pubMsg method |
toId | The 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. |
data | Keep 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 ) ;
Parameters | Description |
---|---|
uid | Uid of the kicked user, which must be String |
reason | Custom 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 ( ) ;