DingRtcSDK interfaces
This topic describes the DingRtcSDK interfaces for the OpenHarmony (OHOS) SDK.
Interface description
Contents
Basic interfaces
API | Description | Minimum supported version |
Gets a DingRtcEngine instance. | 3.0 | |
Destroys a DingRtcEngine instance. | 3.0 | |
Sets engine callbacks. | 3.0 |
Channel-related interfaces
API | Description | Minimum supported version |
Joins a channel. | 3.0 | |
Leaves a channel. | 3.0 | |
Checks whether the user is in a channel. | 3.0 |
Publishing-related interfaces
API | Description | Minimum supported version |
Specifies whether to push the local video stream. | 3.0 | |
Specifies whether to push the audio stream. | 3.0 | |
Queries whether pushing the video stream is enabled. | 3.0 | |
Queries whether pushing the audio stream is enabled. | 3.0 |
Subscription-related interfaces
API | Description | Minimum supported version |
Sets the resolution of the subscribed video stream. | 3.0 | |
Sets the default resolution for subscribed video streams. If not set, the highest resolution is subscribed to by default. | 3.0 | |
Stops or resumes subscribing to all remote audio streams, including those of users who join later. | 3.0 | |
Stops or resumes subscribing to all remote video streams, including those of users who join later. | 3.0 | |
Stops or resumes subscribing to a remote user's video stream. | 3.0 |
Video Sharing APIs
API | Description | Minimum supported version |
Sets the video encoding properties for the screen stream. | 3.0 | |
Queries whether pushing the screen share is enabled. | 3.0 | |
Starts screen sharing. | 3.0 | |
Stops screen sharing. | 3.0 |
Video-related interfaces
API | Description | Minimum supported version |
Sets the local preview display view. | 3.0 | |
Disables or enables local video capture. | 3.0 | |
Pauses or resumes sending the local video stream. | 3.0 | |
Takes a video snapshot. | 3.0 | |
Sets the video encoding properties for the camera stream. | 3.0 | |
Sets the remote video display view. | 3.0 | |
Updates the properties of the local or a remote view. | 3.0 | |
Switches between the front and rear cameras. | 3.0 |
Audio-related interfaces
API | Description | Minimum supported version |
Stops or resumes sending local audio data. | 3.0 | |
Sets the audio output to the earpiece or speaker. | 3.0 | |
Checks whether the audio output is the earpiece or speaker. | 3.0 | |
Sets the audio profile. | 3.0 | |
Sets the volume callback frequency and smoothing coefficient. | 3.0 |
Preview-related interfaces
API | Description | Minimum supported version |
Starts the local video preview. | 3.0 | |
Stops the local video preview. | 3.0 |
Remote user query interfaces
API | Description | Minimum supported version |
Gets the list of online remote users. | 3.0 | |
Queries the status of a remote user. | 3.0 | |
Queries whether a user is online. | 3.0 |
Other interfaces
API | Description | Minimum supported version |
Sets the log level. | 3.0 | |
Sets the path to save SDK log files. | 3.0 |
setLogLevel
DingRtcSDK.setLogLevel(level: DingRtcConstants.LogLevel): voidParameters
level: DingRtcConstants.LogLevel
Ingroup
OHOS_DingRtcEngineOthers
Since
3.0
Brief
Sets the log level.
Return
0: Success.
Non-zero: The operation failed. For example, this error occurs if you do not call SetLogDirPath first.
Note
To prevent log loss, call this interface before making any other SDK calls. You must also ensure that the specified folder exists and is writable.
Note
If the destination path is not writable or if log file creation fails, the setting will not take effect and the default log path will be used.
Note
.
Note
Call this method before calling the `setLogDir` method. Otherwise, it may have no effect.
Note
If you set the level to `RtcEngineLogLevelNone`, no logs are output.
setLogDir
DingRtcSDK.setLogDir(dir: string): numberParameters
dir: string
Returns
numberIngroup
OHOS_DingRtcEngineBase
Since
3.0
Brief
Sets the path for saving SDK log files.
Return
The path already exists, or access is denied due to a permission error.
Note
Call this method before you call any other SDK methods to prevent log loss. The application must ensure that the specified folder exists and is writable.
Note
If the destination path is not writable or the log file cannot be created, the default log path is used and the settings specified in this call are ignored.
Note
The default path is `data/app/el2/100/base/packageName/files/dingrtc/log`.
create
DingRtcSDK.create(context: Context, extras?: string): DingRtcParameters
context: Contextextras?: string
Returns
DingRtcIngroup
OHOS_DingRtcEngineBase
Since
3.0
Brief
Creates an RtcEngine instance.
Details
This is a synchronous call that supports multiple instances.
enableAudioLevelObserver
enableAudioLevelObserver(deviceType: DingRtcConstants.RtcEngineDeviceType, enable: boolean): numberParameters
deviceType: DingRtcConstants.RtcEngineDeviceTypeThe audio device type.
enable: boolean- true: Enables volume observation. - false: Disables volume observation.
Returns
numberIngroup
CPP_DingRtcEngineAudioDevice
Since
3.0
Brief
Enables or disables volume observation for the audio device.
Return
0: Success.
A non-zero value: Failure.
Note
The volume values for the capture and playback devices are returned in a callback.
enableAudioVolumeIndication
enableAudioVolumeIndication(interval: number, smooth: number, reportVad: number): numberParameters
interval: numberThe time interval in milliseconds. The minimum value is 100 ms. The recommended value is 300 ms to 500 ms. A value less than or equal to 0 disables the volume and active speaker prompts.
smooth: numberThe smoothing coefficient. A larger value indicates a higher degree of smoothing. A smaller value indicates better real-time performance. The recommended value is 3. The value ranges from 0 to 9.
reportVad: numberSpecifies whether to enable active speaker detection.
1: On.
0: Off.
Returns
numberIngroup
OHOS_DingRtcEngineAudio
Since
3.0
Brief
Sets the volume callback frequency and smoothing coefficient.
Return
0: Success.
A value less than 0: Failure.
enableLocalVideo
enableLocalVideo(enabled: boolean): numberParameters
enabled: boolean- true: Enables local video capture. - false: Disables local video capture.
Returns
numberIngroup
OHOS_DingRtcEngineVideo
Since
3.0
Brief
Enables or disables local video capture.
Return
0: Success.
A non-zero value: Failure.
Note
This feature is enabled by default.
enableSpeakerphone
enableSpeakerphone(enable: boolean): numberParameters
enable: booleantrue: Speaker mode. false: Earpiece mode.
Returns
numberBrief
Sets the audio output to the earpiece or speaker. By default, the speaker is used.
Return
0: Success.
A non-zero value: Failure.
getOnlineRemoteUsers
getOnlineRemoteUsers(): Array<string>Returns
Array<string>Ingroup
OHOS_DingRtcEngineUserInfo
Since
3.0
Brief
Retrieves the list of online remote users.
getUserInfo
getUserInfo(uid: string): DingRtcConstants.UserInfoParameters
uid: stringThe user ID. This is a unique identifier assigned by the application server.
Returns
DingRtcConstants.UserInfoIngroup
OHOS_DingRtcEngineUserInfo
Since
3.0
Brief
Queries the status of a remote user.
Details
Retrieves the status information of a specified remote user by their user ID.
Return
0: Success.
A non-zero value indicates failure. The return value is a specific error code.
isInCall
isInCall(): booleanReturns
booleanIngroup
OHOS_DingRtcEngineChannel
Since
3.0
Brief
Checks whether the user is currently in a channel.
Return
true: The user has joined the channel.
false: The user is not in the channel.
Note
You can call this method before or after joining a channel.
isLocalAudioStreamPublished
isLocalAudioStreamPublished(): booleanReturns
booleanIngroup
OHOS_DingRtcEnginePub
Since
3.0
Brief
Checks whether the local audio stream is being published.
Return
true: The stream is published.
false: Does not push.
isLocalVideoStreamPublished
isLocalVideoStreamPublished(): booleanReturns
booleanIngroup
OHOS_DingRtcEnginePub
Since
3.0
Brief
Checks whether the local video stream is being published.
Return
true: The stream is published.
false: No push is performed.
isScreenSharePublished
isScreenSharePublished(): booleanReturns
booleanIngroup
OHOS_DingRtcEngineScreenShare
Since
3.0
Brief
Checks whether the screen share stream is being published.
Return
true: The stream is published.
false: The data is not pushed.
Note
You can use the `startScreenShare` method to enable screen share publishing.
isSpeakerphoneEnabled
isSpeakerphoneEnabled(): booleanReturns
booleanBrief
Checks whether the speakerphone is enabled.
Return
true: The speakerphone is enabled.
false: The speakerphone is not enabled.
isUserOnline
isUserOnline(uid: string): booleanParameters
uid: stringThe user ID. This is a unique identifier assigned by the application server. It cannot be null.
Returns
booleanIngroup
OHOS_DingRtcEngineUserInfo
Since
3.0
Brief
Checks whether a user is online.
Return
true: The user is online.
false: The user is not online.
Note
Checks whether a specific user is online based on their user ID.
joinChannel
joinChannel(authInfo: DingRtcConstants.AuthInfo, userName: string): numberParameters
authInfo: DingRtcConstants.AuthInfoThe authentication information obtained from the application server.
userName: string
Returns
numberIngroup
OHOS_DingRtcEngineChannel
Since
3.0
Brief
Allows a user to join a channel. Multiple users in the same channel can communicate with each other.
Return
0: Success.
A value less than 0: Failure.
Note
After you receive the callback, call again to join the meeting.
If the `userName` parameter is longer than 64 bytes, the call fails. Your application must prevent excessively long usernames from being passed. A Chinese character typically occupies 3 bytes. A simple emoji occupies 4 to 8 bytes. A complex emoji can occupy 34 or more bytes.
leaveChannel
leaveChannel(): numberReturns
numberIngroup
OHOS_DingRtcEngineChannel
Since
3.0
Brief
Leaving a channel is equivalent to hanging up or ending the call.
Details
Other users in the channel will be notified.
Details
You must leave the channel before you can join another call.
Details
Callback.
Return
0: The operation was successful.
A non-zero value indicates a failure.
Note
.
muteLocalAudio
muteLocalAudio(mute: boolean): numberParameters
mute: boolean- true: Mutes the local audio and sends silent frames. - false: Unmutes the local audio.
Returns
numberIngroup
OHOS_DingRtcEngineAudio
Since
3.0
Brief
Mutes or unmutes the local audio stream.
Return
0: Success.
A non-zero value: Failure.
Note
The mute status persists until you call `muteLocalAudio` again or create a new engine instance.
muteLocalVideo
muteLocalVideo(mute: boolean, track: DingRtcConstants.RtcEngineVideoTrack): numberParameters
mute: boolean- true: Pauses sending the video stream. - false: Resumes sending the video stream.track: DingRtcConstants.RtcEngineVideoTrack
Returns
numberIngroup
OHOS_DingRtcEngineVideo
Since
3.0
Brief
Pauses or resumes sending the local video stream.
Return
0: Success.
A non-zero value: Failure.
Note
When the video stream is paused, the capture and encoding modules continue to operate.
publishLocalAudioStream
publishLocalAudioStream(enable: boolean): numberParameters
enable: booleanSpecifies whether to publish the local audio stream.
`true`: Publishes the audio stream.
`false`: Stops publishing the audio stream.
Returns
numberIngroup
OHOS_DingRtcEnginePub
Since
3.0
Brief
Specifies whether to publish the local audio stream.
Return
0: Success.
A value less than 0 indicates failure and a specific error code is returned.
Note
By default, the SDK does not publish the audio stream. You can call this method before joining a channel to change this setting. The new setting takes effect after you join the channel.
publishLocalVideoStream
publishLocalVideoStream(enable: boolean): numberParameters
enable: booleanSpecifies whether to publish the local video stream.
`true`: Publishes the video stream.
`false`: Stops publishing the video stream.
Returns
numberIngroup
OHOS_DingRtcEnginePub
Since
3.0
Brief
Specifies whether to publish the local video stream from the camera.
Return
0: Success.
A value less than 0 indicates failure and a specific error code is returned.
Note
By default, the SDK does not publish the video stream. You can call this method before joining a channel to change this setting. The new setting takes effect after you join the channel.
release
release(): voidReturns
voidIngroup
OHOS_DingRtcEngineBase
Since
3.0
Brief
Destroys the RtcEngine instance.
Details
Create a new instance.
Note
This is a synchronous call. You must wait for internal resources to be released before you can execute other methods.
Note
To avoid deadlocks, do not call this method from within any SDK callbacks.
setAudioProfile
setAudioProfile(profile: DingRtcConstants.AudioProfile, scene: DingRtcConstants.AudioScenario): numberParameters
profile: DingRtcConstants.AudioProfilescene: DingRtcConstants.AudioScenario
Returns
numberIngroup
OHOS_DingRtcEngineAudio
Since
3.0
Brief
Sets the audio profile.
Return
0: Success.
Other values: Failure.
Note
The previous settings remain in effect.
Note
The default mode is `RtcEngineHighQualityMode`.
setDefaultAudioRouteToSpeakerphone
setDefaultAudioRouteToSpeakerphone(defaultToSpeakerphone: boolean): numberParameters
defaultToSpeakerphone: booleantrue: Speaker mode (default). false: Earpiece mode.
Returns
numberBrief
Sets the default audio output to the speaker. By default, audio is routed to the speaker.
Return
0: Success.
A non-zero value: Failure.
setEventListener
setEventListener(listener: DingRtcEventListener): anyParameters
listener: DingRtcEventListenerThe listener used to receive messages from the engine.
Ingroup
OHOS_DingRtcEngineBase
Since
3.0
Brief
Sets callbacks for listener events.
Details
The SDK uses this class to send callback event notifications to the application. Application developers must implement the methods of this interface class to receive these notifications. By default, all methods have empty implementations, so you only need to implement the ones relevant to your needs.
Note
All callback methods are executed in the SDK's internal threads. Do not perform UI operations directly in these callbacks. Instead, run UI-related operations on the main thread.
Note
Do not perform time-consuming operations in callback methods, such as calling the `Destroy` method of the RtcEngine itself. Doing so can cause blocking and degrade the SDK's performance.
setLocalViewConfig
setLocalViewConfig(renderConfig: DingRtcConstants.RtcEngineVideoCanvas, track: DingRtcConstants.RtcEngineVideoTrack): numberParameters
renderConfig: DingRtcConstants.RtcEngineVideoCanvasThe local video display properties.
track: DingRtcConstants.RtcEngineVideoTrack.
Returns
numberIngroup
OHOS_DingRtcEngineVideo
Since
3.0
Brief
Sets the display view for the local video preview.
Return
0: The operation was successful.
A non-zero value indicates that the operation failed.
Note
.
setRemoteDefaultVideoStreamType
setRemoteDefaultVideoStreamType(streamType: DingRtcConstants.RtcEngineVideoStreamType): numberParameters
streamType: DingRtcConstants.RtcEngineVideoStreamTypeThe resolution of the video stream.
Returns
numberIngroup
OHOS_DingRtcEngineSub
Since
3.0
Brief
Sets the default resolution for subscribed video streams. If this method is not called, the highest resolution is subscribed to by default.
Return
0: Success.
A non-zero value: Failure.
setRemoteVideoStreamType
setRemoteVideoStreamType(uid: string, streamType: DingRtcConstants.RtcEngineVideoStreamType): numberParameters
uid: stringThe user ID. This is a unique identifier assigned by the application server.
streamType: DingRtcConstants.RtcEngineVideoStreamTypeThe resolution of the video stream.
Returns
numberIngroup
OHOS_DingRtcEngineSub
Since
3.0
Brief
Sets the resolution for a specific subscribed video stream.
Return
0: Success.
A non-zero value: Failure.
setRemoteViewConfig
setRemoteViewConfig(renderConfig: DingRtcConstants.RtcEngineVideoCanvas, uid: string, track: DingRtcConstants.RtcEngineVideoTrack): numberParameters
renderConfig: DingRtcConstants.RtcEngineVideoCanvasThe remote video display properties.
uid: stringThe user ID.
track: DingRtcConstants.RtcEngineVideoTrack
Returns
numberIngroup
OHOS_DingRtcEngineVideo
Since
3.0
Brief
Sets the display view for a remote video stream.
Return
0: Success.
A non-zero value indicates a failure.
Note
.
setScreenShareEncoderConfiguration
setScreenShareEncoderConfiguration(config: DingRtcConstants.RtcEngineScreenShareEncoderConfiguration): numberParameters
config: DingRtcConstants.RtcEngineScreenShareEncoderConfiguration
Returns
numberIngroup
OHOS_DingRtcEngineScreenShare
Since
3.0
Brief
Sets the video encoding properties for the screen sharing stream.
Details
This method sets video parameters for the screen sharing stream, such as resolution, frame rate, bitrate, and video orientation. All parameters have valid ranges. If a parameter is set outside its valid range, the SDK automatically adjusts it to a valid value.
Return
0: Success.
A value less than 0: Failure.
setVideoEncoderConfiguration
setVideoEncoderConfiguration(config: DingRtcConstants.RtcEngineVideoEncoderConfiguration): numberParameters
config: DingRtcConstants.RtcEngineVideoEncoderConfiguration
Returns
numberIngroup
OHOS_DingRtcEngineVideo
Since
3.0
Brief
Sets the video encoding properties for the camera stream.
Details
This method sets video parameters for the camera stream, such as resolution, frame rate, bitrate, and video orientation. All parameters have valid ranges. If a parameter is set outside its valid range, the SDK automatically adjusts it to a valid value.
Note
You can call this method before or after joining a channel. If you only need to set the camera stream encoding properties once per session, we recommend calling this method before joining the channel.
snapshotVideo
snapshotVideo(uid: string, track: DingRtcConstants.RtcEngineVideoTrack, filePath: string): numberParameters
uid: stringThe user ID. An empty string (`""`) indicates the local user.
track: DingRtcConstants.RtcEngineVideoTrack.
filePath: stringThe local path to save the snapshot. You must specify the full path, including the file name and format. Ensure that the folder exists and is writable. For example, `xx/yy/zz.jpg`.
Returns
numberIngroup
OHOS_DingRtcEngineVideo
Brief
Takes a snapshot of a specified user's video, generates a JPG image, and saves it to a specified path.
Return
A value less than 0: Failure.
Note
The snapshot result is returned in a callback.
startPreview
startPreview(): numberReturns
numberIngroup
OHOS_DingRtcEnginePreview
Since
3.0
Brief
Starts the local video preview.
Return
0: Success.
A non-zero value: Failure.
Note
This method automatically turns on the camera. Calling `leaveChannel` does not stop the local preview. The preview continues until you call `stopPreview`.
startScreenShare
startScreenShare(mode: DingRtcConstants.RtcScreenShareMode): numberParameters
mode: DingRtcConstants.RtcScreenShareModeThe sharing mode, which specifies whether to share system audio.
Returns
numberIngroup
OHOS_DingRtcEngineScreenShare
Since
3.0
Brief
Starts screen sharing.
Return
0: Success.
A value less than 0: Failure.
stopPreview
stopPreview(): numberReturns
numberIngroup
OHOS_DingRtcEnginePreview
Since
3.0
Brief
Stops the local video preview.
Return
0: Success.
A non-zero value: Failure.
Note
This method stops the local preview. If the camera stream is not being published, the camera is automatically turned off.
stopScreenShare
stopScreenShare(): numberReturns
numberIngroup
OHOS_DingRtcEngineScreenShare
Since
3.0
Brief
Stops screen sharing.
Return
0: Success.
A value less than 0: Failure.
subscribeAllRemoteAudioStreams
subscribeAllRemoteAudioStreams(sub: boolean): numberParameters
sub: booleanSpecifies whether to subscribe to all remote audio streams.
`true`: Subscribes to the audio streams of all users. The audio streams of users who join later are also automatically subscribed to.
`false`: Stops subscribing to the audio streams of all users. The audio streams of users who join later are not automatically subscribed to.
Returns
numberIngroup
OHOS_DingRtcEngineSub
Since
3.0
Brief
Stops or resumes subscribing to all remote audio streams, including those from users who join later. Starting from version 3.4, 'all users' refers to all users in the lobby. For more information, see the note.
Return
0: Success.
A non-zero value indicates failure.
Note
You can call this method before or after joining a channel.
Note
You can use groupid="" to obtain the same result.
subscribeAllRemoteVideoStreams
subscribeAllRemoteVideoStreams(sub: boolean): numberParameters
sub: booleanSpecifies whether to subscribe to all remote video streams.
`true`: Subscribes to the video streams of all users. The video streams of users who join later are also automatically subscribed to.
`false`: Stops subscribing to the video streams of all users. The video streams of users who join later are not automatically subscribed to.
Returns
numberIngroup
OHOS_DingRtcEngineSub
Since
3.0
Brief
Stops or resumes subscribing to all remote video streams, including those from users who join later.
Return
0: Success.
A non-zero value indicates failure.
Note
You can subscribe to a specific user's remote video stream.
subscribeRemoteVideoStream
subscribeRemoteVideoStream(uid: string, track: DingRtcConstants.RtcEngineVideoTrack, sub: boolean): numberParameters
uid: stringThe user ID. This is a unique identifier assigned by the application server.
track: DingRtcConstants.RtcEngineVideoTrack.
sub: booleanSpecifies whether to subscribe to the remote user's video stream.
`true`: Subscribes to the specified user's video stream.
`false`: Stops subscribing to the specified user's video stream.
Returns
numberIngroup
OHOS_DingRtcEngineSub
Since
3.0
Brief
Stops or resumes subscribing to a remote user's video stream.
Return
0: The operation was successful.
A non-zero return value indicates that the setting failed.
Note
Use this method to subscribe to a specific user's remote video stream.
switchCamera
switchCamera(): numberReturns
numberBrief
Switches between the front and rear cameras.
Return
0: Success.
A non-zero value: Failure.
updateViewConfig
updateViewConfig(renderConfig: DingRtcConstants.RtcEngineVideoCanvas, uid: string, track: DingRtcConstants.RtcEngineVideoTrack): numberParameters
renderConfig: DingRtcConstants.RtcEngineVideoCanvasThe configuration, which includes the window and rendering mode.
uid: stringThe user ID. An empty string (`""`) indicates the local user.
track: DingRtcConstants.RtcEngineVideoTrack.
Returns
numberIngroup
OHOS_DingRtcEngineVideo
Since
3.0
Brief
Updates the rendering configuration.
Return
0: Success.
A non-zero value: Failure.