API.md 33 KB

TRTCCloud

Basic APIs

API Description
sharedInstance Creates a TRTCCloud singleton.
destroySharedInstance Destroys a TRTCCloud singleton.
registerListener Registers an event listener.
unRegisterListener Unregisters an event listener.

Room APIs

API Description
enterRoom Enters a room. If the room does not exist, the system will create one automatically.
exitRoom Exits a room.
switchRole Switches roles. This API works only in live streaming scenarios (TRTC_APP_SCENE_LIVE and TRTC_APP_SCENE_VOICE_CHATROOM).
setDefaultStreamRecvMode Sets the audio/video data receiving mode, which must be set before room entry to take effect.
connectOtherRoom Requests a cross-room call (anchor competition).
disconnectOtherRoom Exits a cross-room call.
switchRoom Switches rooms.

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 preview of the local video.
stopLocalPreview Stops local video capturing and preview.
muteLocalVideo Pauses/Resumes pushing local video data.
startRemoteView Starts displaying the 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/Resumes receiving a specified remote video stream.
muteAllRemoteVideoStreams Pauses/Resumes receiving all remote video streams.
setVideoEncoderParam Sets video encoder parameters.
setNetworkQosParam Sets QoS control parameters.
setLocalRenderParams Sets the rendering mode of the local image.
setRemoteRenderParams Sets remote image parameters.
setVideoEncoderRotation Sets the rotation of encoded video images, i.e., images presented to remote users and recorded by the server.
setVideoEncoderMirror Sets the mirror mode of encoded images.
setGSensorMode Sets the adaptation mode of the G-sensor.
enableEncSmallVideoStream Enables the dual-channel (big and small images) encoding mode.
setRemoteVideoStreamType Switches between the small and big images of a specified user.
snapshotVideo Takes a video screenshot.

Audio APIs

API Description
startLocalAudio Enables local audio capturing and upstream data transfer.
stopLocalAudio Disables local audio capturing and upstream data transfer.
muteLocalAudio Mutes/Unmutes the local audio.
setVideoMuteImage Sets the image to be pushed when local video pushing is paused.
setAudioRoute Sets the audio route.
muteRemoteAudio Mutes/Unmutes the audio of a specified remote user.
muteAllRemoteAudio Mutes/Unmutes all users.
setAudioCaptureVolume Sets the SDK capturing volume.
getAudioCaptureVolume Gets the SDK capturing volume.
setAudioPlayoutVolume Sets the SDK playback volume.
getAudioPlayoutVolume Gets the SDK playback volume.
enableAudioVolumeEvaluation Enables volume reminders.
startAudioRecording Starts audio recording.
stopAudioRecording Stops audio recording.
setSystemVolumeType Sets the system volume type used during calls.

Device management APIs

API Description
getDeviceManager Gets the device management module. For details, see device management APIs.

Beauty filter APIs

API Description
getBeautyManager Gets the beauty filter management object. For details, see the document on beauty filter management.
setWatermark Adds watermarks.

Music and voice effect APIs

API Description
getAudioEffectManager Gets the audio effect management class TXAudioEffectManager, which is used to manage background music, short audio effects, and voice effects. For details, see the document on audio effect management.

Substream APIs

API Description
startScreenCapture Starts screen sharing.
stopScreenCapture Stops screen sharing.
pauseScreenCapture Pauses screen sharing.
resumeScreenCapture Resumes screen sharing.

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.

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.

Log APIs

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

TRTCCloudListener

Callback APIs for the TRTC video call feature

Error and warning event callback APIs

API Description
onError Error callback. This indicates that the SDK encountered an irrecoverable error. Such errors must be listened for, and UI messages should be displayed to users if necessary.
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 a cross-room call (anchor competition)
onDisConnectOtherRoom Callback of the result of ending a cross-room call (anchor competition)
onSwitchRoom Callback of the result of room switching (switchRoom)

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 remote user has a playable primary image (usually the image of the camera)
onUserSubStreamAvailable Callback of whether a remote user has a playable substream image (usually the screen sharing image)
onUserAudioAvailable Callback of whether a remote user has playable audio
onFirstVideoFrame Callback of rendering the first video frame of the local user or a remote user
onFirstAudioFrame Callback of playing the first audio frame of a remote user. No notifications are sent for local audio.
onSendFirstLocalVideoFrame Callback of sending the first local video frame
onSendFirstLocalAudioFrame Callback of sending the first local audio frame

Callback APIs for background music playback

Callback APIs for background music playback

API Description
onMusicObserverStart Callback of starting music playback
onMusicObserverPlayProgress Callback of the music playback progress
onMusicObserverComplete Callback of ending music playback

Callback APIs for statistics on network quality and technical metrics

API Description
onNetworkQuality Callback of 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 callback APIs

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 addresses, 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

Custom message receiving callback APIs

API Description
onRecvCustomCmdMsg Callback of receiving a custom message
onMissCustomCmdMsg Callback of losing a custom message
onRecvSEIMsg Callback of receiving 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

Screen sharing callback APIs

API Description
onScreenCaptureStarted Callback of starting screen sharing
onScreenCapturePaused Callback of pausing screen sharing via the calling of pauseScreenCapture()
onScreenCaptureResumed Callback of resuming screen sharing via the calling of resumeScreenCapture()
onScreenCaptureStoped Callback of stopping screen sharing

Screenshot callback API

API Description
onSnapshotComplete Callback of the completion of a screenshot

Definitions of Key Classes

Class Description
TRTCCloudDef Variables for key class definitions
TRTCParams Room entry parameters
TRTCSwitchRoomConfig Room switching parameters
TRTCVideoEncParam Video encoding parameters
TRTCNetworkQosParam QoS control parameters
TRTCRenderParams Remote image parameters
TRTCMixUser Position of the image of each channel in On-Cloud MixTranscoding
TRTCTranscodingConfig On-Cloud MixTranscoding configuration
TXVoiceChangerType Definitions of voice changing types (little girl, middle-aged man, metal, foreign accent, etc.)
TXVoiceReverbType Definitions of reverb effect types (karaoke, room, hall, low and deep, resonant, etc.)
AudioMusicParam Parameters for music and voice effect setting APIs
TRTCAudioRecordingParams Audio recording parameters
TRTCPublishCDNParam CDN relayed push parameters