Overview

Last updated: 2021-04-15 10:41:57

    TRTCCloud @ TXLiteAVSDK

    APIs for Tencent Cloud’s video call feature

    Creating TRTC objects

    const TRTCCloud = require('trtc-electron-sdk').default;
    // import TRTCCloud from 'trtc-electron-sdk';
    this.rtcCloud = new TRTCCloud();
    

    Since version 7.9.348, TRTC SDK for Electron has integrated trtc.d.ts for developers using TypeScript.

    import TRTCCloud from 'trtc-electron-sdk';
    
    const rtcCloud: TRTCCloud = new TRTCCloud();
    // Get the SDK version number.
    rtcCloud.getSDKVersion();
    

    Setting callback

    subscribeEvents = (rtcCloud) => {
        rtcCloud.on('onError', (errcode, errmsg) => {
        console.info('trtc_demo: onError :' + errcode + " msg" + errmsg);
        }); 
        rtcCloud.on('onEnterRoom', (elapsed) => {
        console.info('trtc_demo: onEnterRoom elapsed:' + elapsed);
        });
        rtcCloud.on('onExitRoom', (reason) => {
        console.info('onExitRoom: userenter reason:' + reason);
        });
    };
    
    
    subscribeEvents(this.rtcCloud);
    

    Creating and terminating ITRTCCloud singletons

    API Description
    getTRTCShareInstance Creates a ITRTCCloud singleton object during dynamic DLL loading.
    destroyTRTCShareInstance Releases a ITRTCCloud singleton object and frees up resources.

    Room APIs

    API Description
    enterRoom Enters a room. If the room does not exist, the system will create one automatically.
    exitRoom Exits a room.
    switchRoom Switches rooms.
    switchRole Switches roles. This API applies only to the live streaming modes (TRTCAppSceneLIVE and TRTCAppSceneVoiceChatRoom).
    connectOtherRoom Requests cross-room co-anchoring (anchor competition).
    disconnectOtherRoom Ends cross-room co-anchoring (anchor competition).

    CDN APIs

    API Description
    startPublishing Starts pushing to Tencent Cloud’s live streaming CDN.
    stopPublishing Stops pushing to Tencent Cloud’s live streaming CDN.
    startPublishCDNStream Starts relaying to the live streaming CDN of a non-Tencent Cloud vendor.
    stopPublishCDNStream Stops relaying to the live streaming CDN of a non-Tencent Cloud vendor.
    setMixTranscodingConfig Sets On-Cloud MixTranscoding parameters.

    Video APIs

    API Description
    startLocalPreview Enables capture and preview of the local camera.
    stopLocalPreview Disables capture and preview of the local camera.
    muteLocalVideo Block/Unblocks local video.
    startRemoteView Starts displaying the video image of a remote user.
    stopRemoteView Stops displaying the video image of a remote user and pulling the user’s video stream.
    stopAllRemoteView Stops displaying the video images of all users and pulling their video streams.
    muteRemoteVideoStream Pauses receiving a specified remote video stream.
    muteAllRemoteVideoStreams Stops receiving all remote video streams.
    setVideoEncoderParam Sets video encoder parameters.
    setNetworkQosParam Sets QoS control parameters.
    setLocalRenderParams Sets rendering parameters for the local image (primary stream).
    setLocalViewFillMode Disused API: sets the rendering mode of the local image.
    setRemoteRenderParams Sets rendering parameters for a remote image.
    setRemoteViewFillMode Disused API: sets the rendering mode of a remote image.
    setLocalViewRotation Disused API: sets the clockwise rotation degree of the local image.
    setRemoteViewRotation Disused API: sets the clockwise rotation degree of a remote image.
    setVideoEncoderRotation Sets the rotation degree of encoded video images, i.e., images presented to remote users and recorded by the server.
    setLocalViewMirror Disused API: sets the mirror mode of the local camera's preview image.
    setVideoEncoderMirror Sets the mirror mode of encoded images.
    enableSmallVideoStream Enables the dual-channel (big and small images) encoding mode.
    setRemoteVideoStreamType Sets whether to view the big or small image of a specified userId.
    setPriorRemoteVideoStreamType Disused API: sets video quality preferences for viewers.
    snapshotVideo Takes a video screenshot.

    Audio APIs

    API Description
    startLocalAudio Enables local audio capture and upstream data transfer.
    stopLocalAudio Disables local audio capture and upstream data transfer.
    muteLocalAudio Mutes local audio.
    muteRemoteAudio Mutes a remote user and stops pulling the user’s audio stream.
    muteAllRemoteAudio Mutes all remote users and stops pulling their audio streams.
    setAudioCaptureVolume Sets the SDK capture volume.
    getAudioCaptureVolume Gets the SDK capture volume.
    setAudioPlayoutVolume Sets the SDK playback volume.
    getAudioPlayoutVolume Gets the SDK playback volume.
    enableAudioVolumeEvaluation Enables/Disables volume reminders.
    startAudioRecording Starts audio recording.
    stopAudioRecording Stops audio recording.
    setAudioQuality Disused API: sets audio quality.
    setRemoteAudioVolume Sets the playback volume of a remote user.

    Camera APIs

    API Description
    getCameraDevicesList Gets the camera list.
    setCurrentCameraDevice Sets the camera to use.
    getCurrentCameraDevice Gets the camera currently in use.

    Audio device APIs

    API Description
    getMicDevicesList Gets the mic list.
    getCurrentMicDevice Gets the mic currently in use.
    setCurrentMicDevice Sets the mic to use.
    getCurrentMicDeviceVolume Gets the current mic volume.
    setCurrentMicDeviceVolume Sets the current mic volume.
    setCurrentMicDeviceMute Mutes/Unmutes the current mic.
    getCurrentMicDeviceMute Gets whether the current mic is muted.
    getSpeakerDevicesList Gets the speaker list.
    getCurrentSpeakerDevice Gets the speaker currently in use.
    setCurrentSpeakerDevice Sets the speaker to use.
    getCurrentSpeakerVolume Gets the current speaker volume.
    setCurrentSpeakerVolume Sets the current speaker volume.
    setCurrentSpeakerDeviceMute Mutes/Unmutes the current speaker.
    getCurrentSpeakerDeviceMute Gets whether the current speaker is muted.

    Beauty filter APIs

    API Description
    setBeautyStyle Sets the strength of the beauty, brightening, and rosy skin filters.
    setWaterMark Sets watermarks.

    Substream APIs

    API Description
    startRemoteSubStreamView Disused API: starts rendering the substream (screen sharing) image of a remote user.
    stopRemoteSubStreamView Disused API: stops rendering the substream (screen sharing) image of a remote user.
    setRemoteSubStreamViewFillMode Disused API: sets the rendering mode of substream (screen sharing) images.
    setRemoteSubStreamViewRotation Disused API: sets the clockwise rotation degree of substream (screen sharing) images.
    getScreenCaptureSources Enumerates shareable windows.
    selectScreenCaptureTarget Sets screen sharing parameters. This method can be called during screen sharing.
    startScreenCapture Starts screen sharing.
    pauseScreenCapture Pauses screen sharing.
    resumeScreenCapture Resumes screen sharing.
    stopScreenCapture Stops screen sharing.
    setSubStreamEncoderParam Sets encoder parameters for substream (screen sharing) images.
    setSubStreamMixVolume Sets the audio mixing volume of substream (screen sharing) images.

    Custom message sending APIs

    API Description
    sendCustomCmdMsg Sends a custom message to all users in the room.
    sendSEIMsg Embeds small-volume custom data in video frames.

    Background audio mixing APIs

    API Description
    playBGM Disused API: starts background music.
    stopBGM Disused API: stops background music.
    pauseBGM Disused API: pauses background music.
    resumeBGM Disused API: resumes background music.
    getBGMDuration Disused API: gets the total length of the background music file, in milliseconds.
    setBGMPosition Disused API: sets the playback progress of background music.
    setBGMVolume Disused API: sets background music volume.
    setBGMPlayoutVolume Disused API: sets the local playback volume of background music.
    setBGMPublishVolume Disused API: sets the remote playback volume of background music.
    startSystemAudioLoopback Enables system audio capture. Currently, the SDK does not support system audio mixing on macOS or 64-bit Windows. This API can be called only on 32-bit Windows for the time being.
    stopSystemAudioLoopback Disables system audio capture Currently, the SDK does not support system audio mixing on macOS or 64-bit Windows. This API can be called only on 32-bit Windows for the time being.
    setSystemAudioLoopbackVolume Sets the system audio capture volume. Currently, the SDK does not support system audio mixing on macOS or 64-bit Windows. This API can be called only on 32-bit Windows for the time being.
    startPlayMusic Starts background music.
    stopPlayMusic Stops background music.
    pausePlayMusic Pauses background music.
    resumePlayMusic Resumes background music.
    getMusicDurationInMS Gets the total length of the background music file, in milliseconds.
    seekMusicToPosInTime Sets the playback progress of background music.
    setAllMusicVolume Sets background music volume. This API is used to control the playback volume of background music.
    setMusicPlayoutVolume Sets the local playback volume of background music.
    setMusicPublishVolume Sets the remote playback volume of background music.

    Audio effect APIs

    API Description
    playAudioEffect Disused API: plays an audio effect.
    setAudioEffectVolume Disused API: sets the volume of an audio effect.
    stopAudioEffect Disused API: stops an audio effect.
    stopAllAudioEffects Disused API: stops all audio effects.
    setAllAudioEffectsVolume Disused API: sets the volume of all audio effects.
    pauseAudioEffect Disused API: pauses an audio effect.
    resumeAudioEffect Disused API: resumes an audio effect.

    Device and network testing APIs

    API Description
    startSpeedTest Starts network speed testing. This may compromise the quality of video calls and should be avoided during a video call.
    stopSpeedTest Stops server speed testing.
    startCameraDeviceTest Starts camera testing.
    stopCameraDeviceTest Stops camera testing.
    startMicDeviceTest Starts mic testing.
    stopMicDeviceTest Stops mic testing.
    startSpeakerDeviceTest Starts speaker testing.
    stopSpeakerDeviceTest Stops speaker testing.

    Log APIs

    API Description
    getSDKVersion Gets the SDK version.
    setLogLevel Sets the log output level.
    setConsoleEnabled Enables/Disables console log printing.
    setLogCompressEnabled Enables/Disables local log compression.
    setLogDirPath Sets the path to save logs.
    setLogCallback Sets the log callback.
    callExperimentalAPI Calls the experimental API.

    Disused APIs

    API Description
    setMicVolumeOnMixing This API has been disused since version 6.9.

    TRTCCallback @ TXLiteAVSDK

    Callback APIs for Tencent Cloud’s video call feature.

    Error and warning event callback APIs

    API Description
    onError Error callback, which indicates that the SDK encountered an irrecoverable error and must be listened on. The corresponding UI reminders should be displayed based on the actual conditions.
    onWarning Warning callback. This alerts you to non-serious problems such as lag or recoverable decoding failure.

    Room event callback APIs

    API Description
    onEnterRoom Callback of room entry
    onExitRoom Callback of room exit
    onSwitchRole Callback of role switching
    onConnectOtherRoom Callback of the result of requesting cross-room co-anchoring (anchor competition)
    onDisconnectOtherRoom Callback of the result of ending cross-room co-anchoring (anchor competition)
    onSwitchRoom Callback of room switching

    User event callback APIs

    API Description
    onRemoteUserEnterRoom Callback of the entry of a user
    onRemoteUserLeaveRoom Callback of the exit of a user
    onUserVideoAvailable Callback of whether a user has enabled the camera
    onUserSubStreamAvailable Callback of whether a user has started screen sharing
    onUserAudioAvailable Callback of whether a user is sending audio data
    onFirstVideoFrame Callback of the rendering of the first video frame of the local user or remote users
    onFirstAudioFrame Callback of the playing of the first audio frame of a remote user. No notifications are sent for local audio
    onSendFirstLocalVideoFrame Callback of the sending of the first local video frame
    onSendFirstLocalAudioFrame Callback of the sending of the first local audio frame
    onUserEnter Disused API: callback of the entry of an anchor
    onUserExit Disused API: callback of the exit of an anchor

    Callback of statistics on quality and technical metrics

    API Description
    onNetworkQuality Network quality. This callback is triggered every 2 seconds to collect statistics on the quality of current upstream and downstream data transfer.
    onStatistics Callback of statistics on technical metrics

    Server event callbacks

    API Description
    onConnectionLost Callback of the disconnection of the SDK from the server
    onTryToReconnect Callback of the SDK trying to connect to the server again
    onConnectionRecovery Callback of the reconnection of the SDK to the server
    onSpeedTest Callback of server speed test results. The SDK tests the speed of multiple server IPs, and the result of each test is returned through this callback.

    Hardware event callback APIs

    API Description
    onCameraDidReady Callback of the camera being ready
    onMicDidReady Callback of the mic being ready
    onUserVoiceVolume Callback of volume, including the volume of each userId and the total remote volume
    onDeviceChange Callback of the connection/disconnection of a local device
    onTestMicVolume Callback of mic testing volume
    onTestSpeakerVolume Callback of speaker testing volume
    onAudioDeviceCaptureVolumeChanged Callback of volume change of the current audio capture device
    onAudioDevicePlayoutVolumeChanged Callback of volume change of the current audio playback device

    Custom message receiving callback APIs

    API Description
    onRecvCustomCmdMsg Callback of the receipt of a custom message
    onMissCustomCmdMsg Callback of the missing of a custom message
    onRecvSEIMsg Callback of the receipt of an SEI message

    Callback APIs for CDN relayed push

    API Description
    onStartPublishing Callback of starting to push to Tencent Cloud’s live streaming CDN, which corresponds to the startPublishing() API in TRTCCloud
    onStopPublishing Callback of stopping pushing to Tencent Cloud’s live streaming CDN, which corresponds to the stopPublishing() API in TRTCCloud.
    onStartPublishCDNStream Callback of the completion of starting relayed push to CDNs
    onStopPublishCDNStream Callback of the completion of stopping relayed push to CDNs
    onSetMixTranscodingConfig Callback of setting On-Cloud MixTranscoding parameters, which corresponds to the setMixTranscodingConfig() API in TRTCCloud

    Audio effect callback API

    API Description
    onAudioEffectFinished Disused API: callback of ending audio effect playback

    Screen sharing callback APIs

    API Description
    onScreenCaptureCovered Callback of screencapturing failure because the target window is covered. This callback can be used to prompt users to move the window.
    onScreenCaptureStarted Callback of starting screen sharing
    onScreenCapturePaused Callback of pausing screen sharing
    onScreenCaptureResumed Callback of resuming screen sharing
    onScreenCaptureStopped Callback of stopping screen sharing

    Screenshot callback API

    API Description
    onSnapshotComplete Callback of the completion of a screenshot

    Background music callbacks APIs

    API Description
    onPlayBGMBegin Disused API: callback of starting background music
    onPlayBGMProgress Disused API: callback of the playback progress of background music
    onPlayBGMComplete Disused API: callback of ending background music playback

    Definitions of Key Classes

    Key classes

    Class Description
    TRTCParams Room entry parameters
    TRTCVideoEncParam Video encoding parameters
    TRTCNetworkQosParam QoS control parameters
    TRTCQualityInfo Video quality
    TRTCVolumeInfo Volume
    TRTCSpeedTestResult Network speed testing result
    TRTCMixUser Position of the image of each channel in On-Cloud MixTranscoding
    TRTCTranscodingConfig On-Cloud MixTranscoding configuration
    TRTCPublishCDNParam CDN relayed push parameters
    TRTCAudioRecordingParams Audio recording parameters
    TRTCLocalStatistics Local audio/video statistics
    TRTCRemoteStatistics Remote audio/video statistics
    TRTCStatistics Statistics

    Enumerated values

    Enumerated Value Description
    TRTCVideoResolution Video resolution
    TRTCVideoResolutionMode Video resolution mode
    TRTCVideoStreamType Video stream type
    TRTCQuality Image quality
    TRTCVideoFillMode Video image fill mode
    TRTCBeautyStyle Beauty filter (skin smoothing) algorithm
    TRTCAppScene Application scenario
    TRTCRoleType Role, which applies only to live streaming scenarios (TRTCAppSceneLIVE).
    TRTCQosControlMode QoS control mode
    TRTCVideoQosPreference Image quality preference
    TRTCDeviceState Device operation
    TRTCDeviceType Device type
    TRTCWaterMarkSrcType Watermark source type
    TRTCTranscodingConfigMode Configuration mode for stream mixing parameters