Type Definitions
TurnServer
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
url |
string |
TURN server url |
||
username |
string |
<optional> |
TURN server auth user name |
|
credential |
string |
<optional> |
TURN server password |
|
credentialType |
string |
<optional> |
password
|
TURN server verify password type |
ProxyServer
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
websocketProxy |
string |
<optional> |
websocket service proxy |
|
loggerProxy |
string |
<optional> |
log service agent |
|
turnServer |
Array.<TurnServer> |
<optional> |
media data transmission agent |
|
iceTransportPolicy |
'all' | 'relay' |
<optional> |
'all'
|
'all' gives priority to directly connecting to TRTC, and tries to go to the turn server if the connection fails. |
VideoProfile
Properties:
| Name | Type | Description |
|---|---|---|
width |
number |
Video width |
height |
number |
Video height |
frameRate |
number |
Video frame rate |
bitrate |
number |
Video bitrate |
Configuration for local video stream
Video configuration parameters, can use preset values in string format or custom resolution and other parameters
| Video Profile | Resolution (Width x Height) | Frame Rate (fps) | Bitrate (kbps) | Note |
|---|---|---|---|---|
| 120p_2 | 160 x 120 | 15 | 100 | v5.1.1+ |
| 180p | 320 x 180 | 15 | 350 | |
| 180p_2 | 320 x 180 | 15 | 150 | v5.1.1+ |
| 240p | 320 x 240 | 15 | 400 | |
| 240p_2 | 320 x 240 | 15 | 200 | v5.1.1+ |
| 360p | 640 x 360 | 15 | 800 | |
| 360p_2 | 640 x 360 | 15 | 400 | v5.1.1+ |
| 480p | 640 x 480 | 15 | 900 | |
| 480p_2 | 640 x 480 | 15 | 500 | Default value, v5.1.1+ |
| 720p | 1280 x 720 | 15 | 1500 | |
| 1080p | 1920 x 1080 | 15 | 2000 | |
| 1440p | 2560 x 1440 | 30 | 4860 | |
| 4K | 3840 x 2160 | 30 | 9000 |
Type:
- object | string
Examples
const config = {
option: {
profile: '480p',
},
}
await trtc.startLocalVideo(config);
const config = {
option: {
profile: {
width: 640,
height: 480,
frameRate: 15,
bitrate: 900,
}
}
}
await trtc.startLocalVideo(config);
ScreenShareProfile
Properties:
| Name | Type | Description |
|---|---|---|
width |
number |
Screen sharing width |
height |
number |
Screen sharing height |
frameRate |
number |
Screen sharing frame rate |
bitrate |
number |
Screen sharing bitrate |
Screen sharing resolution, bit rate, and frame rate configuration Screen sharing configuration parameters, can use preset values or custom resolution and other parameters
| Screen Profile | Resolution (width x height) | Frame Rate (fps) | Bitrate (kbps) |
|---|---|---|---|
| 480p | 640 x 480 | 5 | 900 |
| 480p_2 | 640 x 480 | 30 | 1000 |
| 720p | 1280 x 720 | 5 | 1200 |
| 720p_2 | 1280 x 720 | 30 | 3000 |
| 1080p | 1920 x 1080 | 5 | 1600 |
| 1080p_2 | 1920 x 1080 | 30 | 4000 |
- The default resolution for screen sharing is
1080p. - If the above profiles do not meet your business needs, you can also specify custom resolution, frame rate, and bitrate.
Type:
- object | string
Example
const config = {
option: {
profile: '720p',
},
}
await trtc.startScreenShare(config);
TRTCStatistics
Properties:
| Name | Type | Description |
|---|---|---|
rtt |
number |
The round-trip time from SDK to TRTC server(SDK -> TRTC server -> SDK). Unit: ms. |
upLoss |
number |
Uplink loss rate from SDK to TRTC server. Unit: % |
downLoss |
number |
Downlink loss rate from TRTC server to SDK. Unit: % |
bytesSent |
number |
Total bytes sent, including signaling data and media data. Unit: bytes. |
bytesReceived |
number |
Total bytes received, including signaling data and media data. Unit: bytes. |
localStatistics |
TRTCLocalStatistics |
Local statistics. |
remoteStatistics |
Array.<TRTCRemoteStatistics> |
Remote statistics. |
TRTCLocalStatistics
Properties:
| Name | Type | Description |
|---|---|---|
audio |
TRTCAudioStatistic |
Local audio statistics |
video |
Array.<TRTCVideoStatistic> |
Local video statistics |
Local statistics
TRTCRemoteStatistics
Properties:
| Name | Type | Description |
|---|---|---|
userId |
string |
The userId of remote user |
audio |
TRTCAudioStatistic |
Remote audio statistics |
video |
Array.<TRTCVideoStatistic> |
Remote video statistics |
Remote statistics.
TRTCAudioStatistic
Properties:
| Name | Type | Description |
|---|---|---|
bitrate |
number |
Audio bitrate. Unit: kbps |
audioLevel |
number |
Audio level. Value: float from 0 to 1. |
jitterBufferDelay |
number |
Playback delay, unit: ms. Since |
point2pointDelay |
number |
End-to-end delay, unit: ms. This indicator is an estimate and may be affected by network quality. Since |
Audio statistics
TRTCVideoStatistic
Properties:
| Name | Type | Description |
|---|---|---|
bitrate |
number |
Video bitrate. Unit: kbps |
width |
number |
Video width |
height |
number |
Video height |
frameRate |
number |
Video frameRate |
videoType |
'big' | 'small' | 'sub' |
Video type: big, small, sub. |
jitterBufferDelay |
number |
Playback delay, unit: ms. Since |
point2pointDelay |
number |
End-to-end delay, unit: ms. This indicator is an estimate and may be affected by network quality. Since |
Video statistics
EnableAudioFrameEventOptions
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
enable |
boolean |
Whether to enable callback of audio frame |
||
userId |
string |
The userId of the monitored user. '' indicates local microphone data, '*' indicates monitoring the audio data of all remote users. |
||
sampleRate |
number |
<optional> |
48000
|
Set the sampling rate of pcm data, the default is 48000. Support 8000, 16000, 32000, 44100, 48000 |
channelCount |
number |
<optional> |
1
|
Set the number of channels of pcm data, the default is 1. Support 1, 2 |
port |
MessagePort |
<optional> |
Set the MessagePort for the pcm callback |
enableAudioFrameEvent Options
ResumeRemotePlayerOptions
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
userId |
string |
remote userId. |
|
streamType |
string |
<optional> |
PauseRemotePlayerOptions
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
userId |
string |
remote userId. |
|
streamType |
string |
<optional> |
PluginName
Plugin name
Type:
- 'AudioMixer' | 'AIDenoiser' | 'CDNStreaming' | 'Watermark' | 'VirtualBackground' | 'SmallStreamAutoSwitcher' | 'VoiceChanger' | 'RealtimeTranscriber'
UpdateAudioMixerOptions
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
id |
string |
Please set a unique ID for each incoming music url. |
|
url |
string |
The url of the music address in MP3, AAC (and other audio formats supported by the browser). |
|
track |
MediaStreamAudioTrack |
<optional> |
Since v5.4.3+, MediaStreamAudioTrack from tag, If |
loop |
boolean |
<optional> |
Whether the background music is repeated or not |
volume |
number |
<optional> |
Background music playback volume (0-1) |
playbackRate |
number |
<optional> |
Set the playback rate, the default is 1.0 |
onDurationChange |
function |
<optional> |
Callback function, which will be executed after the music is loaded. The parameter is (duration: number) which indicates the total duration of the music |
onTimeUpdate |
function |
<optional> |
Callback function, which will be executed after the music is loaded. The parameter is (duration: number) which indicates the total duration of the music |
onEnded |
function |
<optional> |
Callback function, executed when the music ends (note that it will not be executed every time the music ends during loop), no parameters /** AudioMixer update plugin options |
id |
string |
Unique ID for music you set before. |
|
loop |
boolean |
<optional> |
Whether the background music is repeated or not |
volume |
number |
<optional> |
Background music playback volume (0-1) |
seekFrom |
number |
<optional> |
Start seek from X seconds |
operation |
string |
<optional> |
Operation of the background music: 'pause' | 'resume' | 'stop' |
playbackRate |
number |
<optional> |
Set the playback rate, the default is 1.0 |
onDurationChange |
function |
<optional> |
Callback function, which will be executed after the music is loaded. The parameter is (duration: number) which indicates the total duration of the music |
onTimeUpdate |
function |
<optional> |
Callback function, which will be executed after the music is loaded. The parameter is (duration: number) which indicates the total duration of the music |
onEnded |
function |
<optional> |
Callback function, executed when the music ends (note that it will not be executed every time the music ends during loop), no parameters |
AudioMixer start plugin options
Type:
- Object
StopAudioMixerOptions
Properties:
| Name | Type | Description |
|---|---|---|
id |
string |
Unique ID for music you set before. |
AudioMixer stop plugin options
Type:
- Object
AIDenoiserOptions
Properties:
| Name | Type | Description |
|---|---|---|
assetsPath |
string |
denoiser wasm assets path |
sdkAppId |
number |
application SDKAppId |
userId |
string |
current user's userId |
userSig |
string |
current user's userSig |
mode |
number |
since v5.13.0+, support denoiser mode |
AIDenoiser start plugin options
Type:
- Object
RealtimeTranscriberStartOptions
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
sourceLanguage |
string |
Source language code, currently only supports 'zh' and 'en' |
|
translationLanguages |
string | Array.<string> |
<optional> |
Target translation languages, single language or array, e.g. 'en' or ['en', 'ja'] |
userIdsToTranscribe |
string | Array.<string> |
<optional> |
User IDs to transcribe, default is 'all' (transcribe everyone), or specify one/many user IDs |
transcriberRobotId |
string |
<optional> |
Custom transcriber robot ID. If omitted, the SDK generates one automatically |
Realtime transcriber & translation start plugin options, tutorial see Real-time Transcriber and Translation Plugin
Type:
- Object
RealtimeTranscriberStopOptions
Properties:
| Name | Type | Description |
|---|---|---|
transcriberRobotId |
string |
The transcriber robot ID returned by startPlugin |
Realtime transcriber stop plugin options
Type:
- Object
UpdateDenoiserOptions
Properties:
| Name | Type | Description |
|---|---|---|
mode |
number |
Two modes are supported: |
AIDenoiser update plugin options
Type:
- Object
CDNStreamingOptions
Properties:
| Name | Type | Description |
|---|---|---|
target |
Target |
Target address, supports relaying/transcoding to Tencent or third-party CDN |
encoding |
Encoding |
Encoding output parameters, required for mix streaming mode. You need to specify your expected transcoding output parameters. |
mix |
Mix |
Mix configuration parameters, you need to specify your expected mix transcoding configuration parameters. Invalid in relay mode. |
CDNStreaming plugin options, tutorial see 26-advanced-publish-cdn-stream
Type:
- Object
Target
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
publishMode |
PublishMode |
Select the streaming mode, available values are PublishMode.PublishMainStreamToCDN, PublishMode.PublishSubStreamToCDN, PublishMode.PublishMixStreamToCDN, PublishMode.PublishMixStreamToRoom |
|
streamId |
string |
<optional> |
Stream ID after publishing to CDN. Default value is |
appId |
number |
<optional> |
Application ID (required when relaying to third-party CDN) |
bizId |
number |
<optional> |
The first 6 digits of the default streaming domain (required when relaying to third-party CDN) |
url |
string |
<optional> |
Third-party CDN streaming URL (required when relaying to third-party CDN) |
robotUser |
FixedVideoUser |
<optional> |
Robot user information for pushing back to room (required when streaming mode is push back to room) |
Type:
- Object
Encoding
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
videoWidth |
number |
<optional> |
Width (px) of the transcoded video resolution. The width must be greater than or equal to 0 and able to accommodate all mixed videos. Default is 640 |
videoHeight |
number |
<optional> |
Height (px) of the transcoded video resolution. The height must be greater than or equal to 0 and able to accommodate all mixed videos. Default is 480 |
videoBitrate |
number |
Transcoded video bitrate (kbps). If 0 is passed, the bitrate will be determined by videoWidth and videoHeight |
|
videoFramerate |
number |
<optional> |
Transcoded video frame rate (fps). Default is 15, range is (0, 30] |
videoGOP |
number |
<optional> |
Transcoded video keyframe interval (s). Default is 2, range is [1, 8] |
audioSampleRate |
number |
<optional> |
Transcoded audio sample rate (Hz). Default is 48000 |
audioBitrate |
number |
<optional> |
Transcoded audio bitrate (kbps). Default is 64, range is [32, 192] |
audioChannels |
number |
<optional> |
Transcoded audio channels. Default is 1, range is 1 or 2 |
Encoding configuration (required for mix streaming)
Type:
- Object
Mix
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
backgroundColor |
number |
<optional> |
Background color of the mixed picture, in hexadecimal format. Default is 0x000000 (black) |
backgroundImage |
string |
<optional> |
Background image of the mixed picture. Default is ''. The background image needs to be uploaded in advance in TRTC Console > Application Management > Function Configuration > Material Management, and obtain the corresponding image ID, then convert the image ID to string type and set it to backgroundImage |
audioMixUserList |
Array.<AudioMixUser> |
Audio mix user list. If not filled, all users' audio will be mixed by default |
|
videoLayoutList |
Array.<VideoLayout> |
Video layout in the mix, must include yourself |
Mix configuration (required for mix streaming)
Type:
- Object
AudioMixUser
Properties:
| Name | Type | Description |
|---|---|---|
userId |
string |
User ID |
roomId |
number |
Numeric room ID. If you need to use string room ID, use strRoomId parameter. Either roomId or strRoomId must be filled. If both are filled, roomId takes priority. |
strRoomId |
string |
String room ID |
Type:
- Object
VideoLayout
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
fixedVideoUser |
FixedVideoUser |
The user corresponding to this layout |
|
fixedVideoStreamType |
string |
Specifies the stream type to mix. TRTC.TYPE.STREAM_TYPE_MAIN for camera stream, TRTC.TYPE.STREAM_TYPE_SUB for screen sharing stream |
|
fillMode |
number |
The render mode of this user's stream in the mix. Default is crop mode. 0: crop mode, 1: user stream scaled with background shown, 2: user stream scaled with black background |
|
zOrder |
number |
The layer level of this user's stream in the mix. Range is [1, 15] |
|
width |
number |
<optional> |
Width (px) of this user's stream in the mix. Must be >= 0. Default is 0 |
height |
number |
<optional> |
Height (px) of this user's stream in the mix. Must be >= 0. Default is 0 |
locationX |
number |
<optional> |
X coordinate (px) of this user's stream in the mix, starting from the top-left corner. Must be >= 0. Default is 0 |
locationY |
number |
<optional> |
Y coordinate (px) of this user's stream in the mix, starting from the top-left corner. Must be >= 0. Default is 0 |
Type:
- Object
FixedVideoUser
Properties:
| Name | Type | Description |
|---|---|---|
userId |
string |
User ID |
roomId |
number |
Numeric room ID of this user. If you need to use string room ID, use strRoomId parameter. Either roomId or strRoomId must be filled. If both are filled, roomId takes priority. |
strRoomId |
string |
String room ID |
Type:
- Object
PublishMode
Properties:
| Name | Type | Description |
|---|---|---|
PublishMainStreamToCDN |
string |
Push main stream to CDN |
PublishSubStreamToCDN |
string |
Push sub stream to CDN |
PublishMixStreamToCDN |
string |
Push mix stream to CDN |
Type:
- Enum
VirtualBackgroundOptions
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
sdkAppId |
number |
Current application ID |
|
userId |
string |
Current user ID |
|
userSig |
string |
UserSig corresponding to the user ID |
|
type |
string |
<optional> |
|
enableFaceCentering |
boolean |
<optional> |
Start from v5.11.0, whether to enable face centering. Default is false. |
blurLevel |
number |
<optional> |
Set the level of blur when |
src |
string |
<optional> |
Required if type is |
onAbort |
function |
<optional> |
Callback to stop plugin due to error. |
VirtualBackground start plugin options, tutorial see Enable Virtual Background
Type:
- Object
UpdateVirtualBackgroundOptions
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
type |
string |
|
|
enableFaceCentering |
boolean |
<optional> |
Start from v5.11.0, whether to enable face centering. Default is false. |
blurLevel |
number |
<optional> |
Set the level of blur when |
src |
string |
<optional> |
Required if type is |
onAbort |
function |
<optional> |
Callback to stop plugin due to error. |
VirtualBackground update plugin options, tutorial see Enable Virtual Background
Type:
- Object
WatermarkOptions
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
imageUrl |
string |
Image watermark URL. This parameter is required. |
|
x |
string |
<optional> |
Watermark left margin. This parameter is optional. |
y |
string |
<optional> |
Watermark top margin. This parameter is optional. |
size |
string | number | object |
<optional> |
Specifies the size of the watermark. This parameter is optional. The default is
|
Watermark start plugin options, tutorial see Enable Watermark Plugin
Type:
- Object
SmallStreamAutoSwitcherOptions
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
rttPoorLimit |
number |
<optional> |
200
|
Delay threshold (ms), when network delay exceeds this value, start calculating the condition to switch to small stream |
lossPoorLimit |
number |
<optional> |
20
|
Loss rate threshold (%), when loss rate exceeds this value, start calculating the condition to switch to small stream |
poorDuration |
number |
<optional> |
10000
|
Network poor condition duration threshold (ms), when delay or loss rate continuously exceeds the threshold for this duration, start checking if switching to small stream is needed, default 10000 (10s) |
rttGoodLimit |
number |
<optional> |
100
|
Good delay threshold (ms), when network delay is less than this value, start calculating the condition to switch to large stream |
lossGoodLimit |
number |
<optional> |
10
|
Good loss rate threshold (%), when loss rate is less than this value, start calculating the condition to switch to large stream |
goodDuration |
number |
<optional> |
20000
|
The duration threshold (ms) of good network conditions. When the delay and packet loss rate are continuously lower than the threshold for this duration, the system starts checking whether to switch to large stream, default 20000 (20s) |
sleepTime |
number |
<optional> |
30000
|
The sleep time after switching (ms), during which automatic switching will not be triggered again to avoid frequent switching |
maxAutoSwitchToSmallCount |
number |
<optional> |
2
|
The maximum number of times each user is allowed to automatically switch to small stream. After this number is exceeded, the user will no longer automatically switch to small stream. |
SmallStreamAutoSwitcher start plugin options, tutorial see Enable Small Stream Auto Switcher Plugin
Type:
- Object
VoiceChangerStartOptions
Properties:
| Name | Type | Description |
|---|---|---|
sdkAppId |
number |
sdkAppId |
userId |
string |
userId |
userSig |
string |
userSig |
voiceType |
number |
voice Type |
VoiceChanger start plugin parameters
Type:
- Object
VoiceChangerUpdateOptions
Properties:
| Name | Type | Description |
|---|---|---|
voiceType |
number |
voice Type |
VoiceChanger update plugin parameters
Type:
- Object