DingRtcSDK interfaces

Updated at:

This topic describes the DingRtcSDK interfaces for the OpenHarmony (OHOS) SDK.

Interface description

Contents

Basic interfaces

API

Description

Minimum supported version

create

Gets a DingRtcEngine instance.

3.0

release

Destroys a DingRtcEngine instance.

3.0

setEventListener

Sets engine callbacks.

3.0

Channel-related interfaces

API

Description

Minimum supported version

joinChannel

Joins a channel.

3.0

leaveChannel

Leaves a channel.

3.0

isInCall

Checks whether the user is in a channel.

3.0

Publishing-related interfaces

API

Description

Minimum supported version

publishLocalVideoStream

Specifies whether to push the local video stream.

3.0

publishLocalAudioStream

Specifies whether to push the audio stream.

3.0

isLocalVideoStreamPublished

Queries whether pushing the video stream is enabled.

3.0

isLocalAudioStreamPublished

Queries whether pushing the audio stream is enabled.

3.0

Subscription-related interfaces

API

Description

Minimum supported version

setRemoteVideoStreamType

Sets the resolution of the subscribed video stream.

3.0

setRemoteDefaultVideoStreamType

Sets the default resolution for subscribed video streams. If not set, the highest resolution is subscribed to by default.

3.0

subscribeAllRemoteAudioStreams

Stops or resumes subscribing to all remote audio streams, including those of users who join later.

3.0

subscribeAllRemoteVideoStreams

Stops or resumes subscribing to all remote video streams, including those of users who join later.

3.0

subscribeRemoteVideoStream

Stops or resumes subscribing to a remote user's video stream.

3.0

Video Sharing APIs

API

Description

Minimum supported version

setScreenShareEncoderConfiguration

Sets the video encoding properties for the screen stream.

3.0

isScreenSharePublished

Queries whether pushing the screen share is enabled.

3.0

startScreenShare

Starts screen sharing.

3.0

stopScreenShare

Stops screen sharing.

3.0

Video-related interfaces

API

Description

Minimum supported version

setLocalViewConfig

Sets the local preview display view.

3.0

enableLocalVideo

Disables or enables local video capture.

3.0

muteLocalVideo

Pauses or resumes sending the local video stream.

3.0

snapshotVideo

Takes a video snapshot.

3.0

setVideoEncoderConfiguration

Sets the video encoding properties for the camera stream.

3.0

setRemoteViewConfig

Sets the remote video display view.

3.0

updateViewConfig

Updates the properties of the local or a remote view.

3.0

switchCamera

Switches between the front and rear cameras.

3.0

Audio-related interfaces

API

Description

Minimum supported version

muteLocalAudio

Stops or resumes sending local audio data.

3.0

enableSpeakerphone

Sets the audio output to the earpiece or speaker.

3.0

isSpeakerphoneEnabled

Checks whether the audio output is the earpiece or speaker.

3.0

setAudioProfile

Sets the audio profile.

3.0

enableAudioVolumeIndication

Sets the volume callback frequency and smoothing coefficient.

3.0

Preview-related interfaces

API

Description

Minimum supported version

startPreview

Starts the local video preview.

3.0

stopPreview

Stops the local video preview.

3.0

Remote user query interfaces

API

Description

Minimum supported version

getOnlineRemoteUsers

Gets the list of online remote users.

3.0

getUserInfo

Queries the status of a remote user.

3.0

isUserOnline

Queries whether a user is online.

3.0

Other interfaces

API

Description

Minimum supported version

setLogLevel

Sets the log level.

3.0

setLogDir

Sets the path to save SDK log files.

3.0

  • Parameters

    • 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.

  • Parameters

    • dir: string

    Returns 

    number

    Ingroup

    • 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`.

  • Parameters

    • context: Context
    • extras?: string

    Returns 

    DingRtc

    Ingroup

    • OHOS_DingRtcEngineBase

    Since

    • 3.0

    Brief

    • Creates an RtcEngine instance.

    Details

    • This is a synchronous call that supports multiple instances.

  • Parameters

    • deviceType: DingRtcConstants.RtcEngineDeviceType

      The audio device type.

    • enable: boolean
           - true: Enables volume observation.
           - false: Disables volume observation.
      

    Returns 

    number

    Ingroup

    • 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.

    • Parameters

      • interval: number

        The 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: number

        The 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: number

        Specifies whether to enable active speaker detection.

        • 1: On.

        • 0: Off.

      Returns 

      number

      Ingroup

      • OHOS_DingRtcEngineAudio

      Since

      • 3.0

      Brief

      • Sets the volume callback frequency and smoothing coefficient.

      Return

        • 0: Success.

        • A value less than 0: Failure.

      • Parameters

        • enabled: boolean
               - true: Enables local video capture.
               - false: Disables local video capture.
          

        Returns 

        number

        Ingroup

        • 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.

        • Parameters

          • enable: boolean

            true: Speaker mode. false: Earpiece mode.

          Returns 

          number

          Brief

          • Sets the audio output to the earpiece or speaker. By default, the speaker is used.

          Return

            • 0: Success.

            • A non-zero value: Failure.

          • Returns 

            Array<string>

            Ingroup

            • OHOS_DingRtcEngineUserInfo

            Since

            • 3.0

            Brief

            • Retrieves the list of online remote users.

            • Parameters

              • uid: string

                The user ID. This is a unique identifier assigned by the application server.

              Returns 

              DingRtcConstants.UserInfo

              Ingroup

              • 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.

              • Returns 

                boolean

                Ingroup

                • 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.

                • Returns 

                  boolean

                  Ingroup

                  • 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.

                  • Returns 

                    boolean

                    Ingroup

                    • 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.

                    • Returns 

                      boolean

                      Ingroup

                      • 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.

                      • Returns 

                        boolean

                        Brief

                        • Checks whether the speakerphone is enabled.

                        Return

                          • true: The speakerphone is enabled.

                          • false: The speakerphone is not enabled.

                        • Parameters

                          • uid: string

                            The user ID. This is a unique identifier assigned by the application server. It cannot be null.

                          Returns 

                          boolean

                          Ingroup

                          • 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.

                          • Parameters

                            • authInfo: DingRtcConstants.AuthInfo

                              The authentication information obtained from the application server.

                            • userName: string

                            Returns 

                            number

                            Ingroup

                            • 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.

                            • Returns 

                              number

                              Ingroup

                              • 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

                              • .

                              • Parameters

                                • mute: boolean
                                      - true: Mutes the local audio and sends silent frames.
                                      - false: Unmutes the local audio.
                                  

                                Returns 

                                number

                                Ingroup

                                • 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.

                                • Parameters

                                  • mute: boolean
                                         - true: Pauses sending the video stream.
                                         - false: Resumes sending the video stream.
                                    
                                  • track: DingRtcConstants.RtcEngineVideoTrack

                                  Returns 

                                  number

                                  Ingroup

                                  • 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.

                                  • Parameters

                                    • enable: boolean
                                      • Specifies whether to publish the local audio stream.

                                      • `true`: Publishes the audio stream.

                                      • `false`: Stops publishing the audio stream.

                                    Returns 

                                    number

                                    Ingroup

                                    • 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.

                                    • Parameters

                                      • enable: boolean
                                        • Specifies whether to publish the local video stream.

                                        • `true`: Publishes the video stream.

                                        • `false`: Stops publishing the video stream.

                                      Returns 

                                      number

                                      Ingroup

                                      • 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.

                                      • Returns 

                                        void

                                        Ingroup

                                        • 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.

                                        • Parameters

                                          • profile: DingRtcConstants.AudioProfile
                                          • scene: DingRtcConstants.AudioScenario

                                          Returns 

                                          number

                                          Ingroup

                                          • 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`.

                                          • Parameters

                                            • defaultToSpeakerphone: boolean

                                              true: Speaker mode (default). false: Earpiece mode.

                                            Returns 

                                            number

                                            Brief

                                            • Sets the default audio output to the speaker. By default, audio is routed to the speaker.

                                            Return

                                              • 0: Success.

                                              • A non-zero value: Failure.

                                            • Parameters

                                              • listener: DingRtcEventListener

                                                The 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.

                                              • Parameters

                                                • renderConfig: DingRtcConstants.RtcEngineVideoCanvas

                                                  The local video display properties.

                                                • track: DingRtcConstants.RtcEngineVideoTrack

                                                  .

                                                Returns 

                                                number

                                                Ingroup

                                                • 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

                                                • .

                                                • Parameters

                                                  • streamType: DingRtcConstants.RtcEngineVideoStreamType

                                                    The resolution of the video stream.

                                                  Returns 

                                                  number

                                                  Ingroup

                                                  • 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.

                                                  • Parameters

                                                    • uid: string

                                                      The user ID. This is a unique identifier assigned by the application server.

                                                    • streamType: DingRtcConstants.RtcEngineVideoStreamType

                                                      The resolution of the video stream.

                                                    Returns 

                                                    number

                                                    Ingroup

                                                    • OHOS_DingRtcEngineSub

                                                    Since

                                                    • 3.0

                                                    Brief

                                                    • Sets the resolution for a specific subscribed video stream.

                                                    Return

                                                      • 0: Success.

                                                      • A non-zero value: Failure.

                                                    • Parameters

                                                      • renderConfig: DingRtcConstants.RtcEngineVideoCanvas

                                                        The remote video display properties.

                                                      • uid: string

                                                        The user ID.

                                                      • track: DingRtcConstants.RtcEngineVideoTrack

                                                      Returns 

                                                      number

                                                      Ingroup

                                                      • 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

                                                      • .

                                                      • Parameters

                                                        • config: DingRtcConstants.RtcEngineScreenShareEncoderConfiguration

                                                        Returns 

                                                        number

                                                        Ingroup

                                                        • 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.

                                                        • Parameters

                                                          • config: DingRtcConstants.RtcEngineVideoEncoderConfiguration

                                                          Returns 

                                                          number

                                                          Ingroup

                                                          • 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.

                                                          • Parameters

                                                            • uid: string

                                                              The user ID. An empty string (`""`) indicates the local user.

                                                            • track: DingRtcConstants.RtcEngineVideoTrack

                                                              .

                                                            • filePath: string

                                                              The 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 

                                                            number

                                                            Ingroup

                                                            • 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.

                                                            • Returns 

                                                              number

                                                              Ingroup

                                                              • 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`.

                                                              • Parameters

                                                                • mode: DingRtcConstants.RtcScreenShareMode

                                                                  The sharing mode, which specifies whether to share system audio.

                                                                Returns 

                                                                number

                                                                Ingroup

                                                                • OHOS_DingRtcEngineScreenShare

                                                                Since

                                                                • 3.0

                                                                Brief

                                                                • Starts screen sharing.

                                                                Return

                                                                  • 0: Success.

                                                                  • A value less than 0: Failure.

                                                                • Returns 

                                                                  number

                                                                  Ingroup

                                                                  • 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.

                                                                  • Returns 

                                                                    number

                                                                    Ingroup

                                                                    • OHOS_DingRtcEngineScreenShare

                                                                    Since

                                                                    • 3.0

                                                                    Brief

                                                                    • Stops screen sharing.

                                                                    Return

                                                                      • 0: Success.

                                                                      • A value less than 0: Failure.

                                                                    • Parameters

                                                                      • sub: boolean
                                                                        • Specifies 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 

                                                                      number

                                                                      Ingroup

                                                                      • 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.

                                                                      • Parameters

                                                                        • sub: boolean
                                                                          • Specifies 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 

                                                                        number

                                                                        Ingroup

                                                                        • 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.

                                                                        • Parameters

                                                                          • uid: string

                                                                            The user ID. This is a unique identifier assigned by the application server.

                                                                          • track: DingRtcConstants.RtcEngineVideoTrack

                                                                            .

                                                                          • sub: boolean
                                                                            • Specifies 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 

                                                                          number

                                                                          Ingroup

                                                                          • 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.

                                                                          • Returns 

                                                                            number

                                                                            Brief

                                                                            • Switches between the front and rear cameras.

                                                                            Return

                                                                              • 0: Success.

                                                                              • A non-zero value: Failure.

                                                                            • Parameters

                                                                              • renderConfig: DingRtcConstants.RtcEngineVideoCanvas

                                                                                The configuration, which includes the window and rendering mode.

                                                                              • uid: string

                                                                                The user ID. An empty string (`""`) indicates the local user.

                                                                              • track: DingRtcConstants.RtcEngineVideoTrack

                                                                                .

                                                                              Returns 

                                                                              number

                                                                              Ingroup

                                                                              • OHOS_DingRtcEngineVideo

                                                                              Since

                                                                              • 3.0

                                                                              Brief

                                                                              • Updates the rendering configuration.

                                                                              Return

                                                                                • 0: Success.

                                                                                • A non-zero value: Failure.