trtc-sdk-v5 5.8.1-beta.2 → 5.8.1-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,170 +1,423 @@
1
- /// <reference path="./core.d.ts" />
1
+ import { CDNStreamingOptions } from './plugins/cdn-streaming';
2
+ import { DeviceDetectorOptions } from './plugins/device-detector';
3
+ import { VirtualBackgroundOptions, UpdateVirtualBackgroundOptions } from './plugins/video-effect/virtual-background';
4
+ import { WatermarkOptions } from './plugins/video-effect/watermark';
5
+ import { BeautyOptions, UpdateBeautyOptions } from './plugins/video-effect/beauty';
6
+ import { BasicBeautyOptions } from './plugins/video-effect/basic-beauty';
7
+ import { StartCrossRoomOption, UpdateCrossRoomOption, StopCrossRoomOption } from './plugins/cross-room';
2
8
 
3
- declare type PluginWithAssets = {
4
- plugin: IPluginClass;
5
- assetsPath?: string;
9
+ export { CDNStreamingOptions, DeviceDetectorOptions, VirtualBackgroundOptions, UpdateVirtualBackgroundOptions, WatermarkOptions, BeautyOptions, UpdateBeautyOptions, BasicBeautyOptions, StartCrossRoomOption, UpdateCrossRoomOption, StopCrossRoomOption };
10
+ export declare class RtcError extends Error implements RTCErrorInterface {
11
+ name: string;
12
+ /**
13
+ *
14
+ * Error code
15
+ * @see Detailed error code list: {@link module:ERROR_CODE ErrorCode}
16
+ * @readonly
17
+ * @memberof RtcError
18
+ */
19
+ code: number;
20
+ /**
21
+ *
22
+ * Extended error code
23
+ * @see Detailed error code list: {@link module:ERROR_CODE ErrorCode}
24
+ * @readonly
25
+ * @memberof RtcError
26
+ */
27
+ extraCode?: number;
28
+ /**
29
+ *
30
+ * The name of the function that throws the error
31
+ * @readonly
32
+ * @memberof RtcError
33
+ */
34
+ functionName: string;
35
+ /**
36
+ *
37
+ * Error message
38
+ * @readonly
39
+ * @memberof RtcError
40
+ */
41
+ message: string;
42
+ /**
43
+ * Error handler. For the following errors, you can call error.handler() for recovering.
44
+ *
45
+ * - {@link module:ERROR_CODE.DEVICE_ERROR ErrorCode.DEVICE_ERROR} extraCode: 5302
46
+ * ```js
47
+ * trtc.startLocalAudio().catch(error => {
48
+ * if (error.extraCode === 5302 && typeof error.handler === 'function') {
49
+ * // Prompt the user the browser permission(camera/microphone/screen sharing) has been denied by system. The browser will jump to the System Settings APP, please enable the relevant permissions!
50
+ * // Available in Windows and MacOS.
51
+ * error.handler();
52
+ * }
53
+ * })
54
+ * ```
55
+ * @since v5.2.0
56
+ * @readonly
57
+ * @memberof RtcError
58
+ */
59
+ handler?: () => void;
60
+ originError?: Error | DOMException | RtcError;
61
+ constructor({ code, extraCode, message, messageParams, fnName, originError }: RTCErrorParams);
62
+ static convertFrom(originError: Error, fnName?: string, fnParams?: any): RtcError;
63
+ }
64
+
65
+ export declare enum LOG_LEVEL {
66
+ /**
67
+ * 输出所有日志
68
+ */
69
+ TRACE = 0,
70
+ /**
71
+ * 输出 DEBUG、INFO、WARN、ERROR 等级日志
72
+ */
73
+ DEBUG = 1,
74
+ /**
75
+ * 输出 INFO、WARN、ERROR 等级日志
76
+ */
77
+ INFO = 2,
78
+ /**
79
+ * 输出 WARN、ERROR 等级日志
80
+ */
81
+ WARN = 3,
82
+ /**
83
+ * 输出 ERROR 等级日志
84
+ */
85
+ ERROR = 4,
86
+ /**
87
+ * 不输出任何日志
88
+ */
89
+ NONE = 5
90
+ }
91
+ export declare const audioProfileMap: {
92
+ readonly standard: {
93
+ readonly sampleRate: 48000;
94
+ readonly channelCount: 1;
95
+ readonly bitrate: 40;
96
+ };
97
+ readonly 'standard-stereo': {
98
+ readonly sampleRate: 48000;
99
+ readonly channelCount: 2;
100
+ readonly bitrate: 64;
101
+ };
102
+ readonly high: {
103
+ readonly sampleRate: 48000;
104
+ readonly channelCount: 1;
105
+ readonly bitrate: 192;
106
+ };
107
+ readonly 'high-stereo': {
108
+ readonly sampleRate: 48000;
109
+ readonly channelCount: 2;
110
+ readonly bitrate: 192;
111
+ };
6
112
  };
7
- declare interface TRTCOptions {
8
- plugins?: Array<IPluginClass>;
9
- enableSEI?: boolean;
10
- assetsPath?: string;
113
+ export declare const videoProfileMap: {
114
+ readonly '120p': {
115
+ readonly width: 160;
116
+ readonly height: 120;
117
+ readonly frameRate: 15;
118
+ readonly bitrate: 200;
119
+ };
120
+ readonly '180p': {
121
+ readonly width: 320;
122
+ readonly height: 180;
123
+ readonly frameRate: 15;
124
+ readonly bitrate: 350;
125
+ };
126
+ readonly '240p': {
127
+ readonly width: 320;
128
+ readonly height: 240;
129
+ readonly frameRate: 15;
130
+ readonly bitrate: 400;
131
+ };
132
+ readonly '360p': {
133
+ readonly width: 640;
134
+ readonly height: 360;
135
+ readonly frameRate: 15;
136
+ readonly bitrate: 800;
137
+ };
138
+ readonly '480p': {
139
+ readonly width: 640;
140
+ readonly height: 480;
141
+ readonly frameRate: 15;
142
+ readonly bitrate: 900;
143
+ };
144
+ readonly '720p': {
145
+ readonly width: 1280;
146
+ readonly height: 720;
147
+ readonly frameRate: 15;
148
+ readonly bitrate: 1500;
149
+ };
150
+ readonly '1080p': {
151
+ readonly width: 1920;
152
+ readonly height: 1080;
153
+ readonly frameRate: 15;
154
+ readonly bitrate: 2000;
155
+ };
156
+ readonly '1440p': {
157
+ readonly width: 2560;
158
+ readonly height: 1440;
159
+ readonly frameRate: 30;
160
+ readonly bitrate: 4860;
161
+ };
162
+ readonly '4K': {
163
+ readonly width: 3840;
164
+ readonly height: 2160;
165
+ readonly frameRate: 30;
166
+ readonly bitrate: 9000;
167
+ };
168
+ };
169
+ export declare const screenProfileMap: {
170
+ readonly '480p': {
171
+ readonly width: 640;
172
+ readonly height: 480;
173
+ readonly frameRate: 5;
174
+ readonly bitrate: 900;
175
+ };
176
+ readonly '480p_2': {
177
+ readonly width: 640;
178
+ readonly height: 480;
179
+ readonly frameRate: 30;
180
+ readonly bitrate: 1000;
181
+ };
182
+ readonly '720p': {
183
+ readonly width: 1280;
184
+ readonly height: 720;
185
+ readonly frameRate: 5;
186
+ readonly bitrate: 1200;
187
+ };
188
+ readonly '720p_2': {
189
+ readonly width: 1280;
190
+ readonly height: 720;
191
+ readonly frameRate: 30;
192
+ readonly bitrate: 3000;
193
+ };
194
+ readonly '1080p': {
195
+ readonly width: 1920;
196
+ readonly height: 1080;
197
+ readonly frameRate: 5;
198
+ readonly bitrate: 1600;
199
+ };
200
+ readonly '1080p_2': {
201
+ readonly width: 1920;
202
+ readonly height: 1080;
203
+ readonly frameRate: 30;
204
+ readonly bitrate: 4000;
205
+ };
206
+ };
207
+ export declare const enum Scene {
208
+ LIVE = "live",
209
+ RTC = "rtc"
11
210
  }
12
- declare interface LocalVideoConfig {
13
- view?: string | HTMLElement | HTMLElement[] | null;
14
- publish?: boolean;
15
- mute?: boolean | string;
16
- option?: {
17
- cameraId?: string;
18
- useFrontCamera?: boolean;
19
- profile?: keyof typeof videoProfileMap | VideoProfile;
20
- fillMode?: 'contain' | 'cover' | 'fill';
21
- mirror?: boolean | string;
22
- small?: keyof typeof videoProfileMap | VideoProfile | boolean;
23
- qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
24
- videoTrack?: MediaStreamTrack;
25
- };
211
+
212
+ export declare const enum NetworkQualityValue {
213
+ UNKNOWN,
214
+ EXCELLENT,
215
+ GOOD,
216
+ POOR,
217
+ BAD,
218
+ VERY_BAD,
219
+ DISCONNECTED
26
220
  }
27
- declare interface ProxyServer {
28
- websocketProxy?: string;
29
- loggerProxy?: string;
30
- turnServer?: TurnServerOptions | TurnServerOptions[];
31
- iceTransportPolicy?: RTCIceTransportPolicy;
32
- webtransportProxy?: string;
33
- scheduleProxy?: string;
34
- unifiedProxy?: string;
221
+
222
+ export declare const enum PlayerState {
223
+ PAUSED = "PAUSED",
224
+ PLAYING = "PLAYING",
225
+ STOPPED = "STOPPED"
226
+ }
227
+ export declare const enum UserRole {
228
+ ANCHOR = "anchor",
229
+ AUDIENCE = "audience"
35
230
  }
36
- declare interface EnterRoomConfig {
37
- sdkAppId: number;
38
- userId: string;
39
- userSig: string;
40
- roomId?: number;
41
- strRoomId?: string;
42
- role?: UserRole;
43
- autoReceiveAudio?: boolean;
44
- autoReceiveVideo?: boolean;
45
- privateMapKey?: string;
46
- latencyLevel?: number;
47
- businessInfo?: string;
48
- enableAutoPlayDialog?: boolean;
49
- proxy?: ProxyServer | string;
50
- scene?: Scene;
51
- userDefineRecordId?: string;
231
+ export declare const enum ConnectionState {
232
+ CONNECTED = "CONNECTED",
233
+ DISCONNECTED = "DISCONNECTED",
234
+ CONNECTING = "CONNECTING",
235
+ RECONNECTED = "RECONNECTED",
236
+ RECONNECTING = "RECONNECTING"
52
237
  }
53
- declare interface ScreenShareConfig {
54
- view?: string | HTMLElement | HTMLElement[] | null;
55
- publish?: boolean;
56
- option?: {
57
- profile?: keyof typeof screenProfileMap | VideoProfile;
58
- fillMode?: 'contain' | 'cover' | 'fill';
59
- systemAudio?: boolean;
60
- echoCancellation?: boolean;
61
- autoGainControl?: boolean;
62
- noiseSuppression?: boolean;
63
- audioTrack?: MediaStreamTrack;
64
- videoTrack?: MediaStreamTrack;
65
- captureElement?: HTMLElement;
66
- preferDisplaySurface?: 'current-tab' | 'tab' | 'window' | 'monitor';
67
- qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
68
- };
238
+ export declare interface NetworkQuality {
239
+ uplinkNetworkQuality: NetworkQualityValue;
240
+ downlinkNetworkQuality: NetworkQualityValue;
241
+ uplinkRTT: number;
242
+ uplinkLoss: number;
243
+ downlinkRTT: number;
244
+ downlinkLoss: number;
69
245
  }
70
- declare interface UpdateScreenShareConfig extends ScreenShareConfig {
71
- option?: {
72
- fillMode?: 'contain' | 'cover' | 'fill';
73
- qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
74
- };
246
+ export declare const enum BannedReason {
247
+ BANNED = "banned",
248
+ KICK = "kick",
249
+ USER_TIME_OUT = "user_time_out",
250
+ ROOM_DISBAND = "room_disband"
75
251
  }
76
- declare interface RemoteVideoConfig {
77
- view?: string | HTMLElement | HTMLElement[] | null;
78
- userId: string;
79
- streamType: TRTCStreamType;
80
- option?: {
81
- fillMode?: 'contain' | 'cover' | 'fill';
82
- mirror?: boolean;
83
- small?: boolean;
84
- receiveWhenViewVisible?: boolean;
85
- viewRoot?: HTMLElement;
86
- canvasRender?: boolean;
87
- };
252
+
253
+ export declare interface IPluginClass {
254
+ Name: string;
255
+ new(core: any): any;
88
256
  }
89
- declare interface StopRemoteVideoConfig {
90
- userId: string;
91
- streamType?: TRTCStreamType;
257
+
258
+ export declare type PluginWithAssets = {
259
+ plugin: IPluginClass;
260
+ assetsPath?: string;
261
+ };
262
+ export declare interface TRTCOptions {
263
+ plugins?: Array<IPluginClass>;
264
+ enableSEI?: boolean;
265
+ assetsPath?: string;
92
266
  }
93
- declare interface LocalAudioConfig {
94
- publish?: boolean;
95
- mute?: boolean;
96
- option?: {
97
- microphoneId?: string;
98
- profile?: keyof typeof audioProfileMap;
99
- audioTrack?: MediaStreamTrack;
100
- captureVolume?: number;
101
- earMonitorVolume?: number;
102
- echoCancellation?: boolean;
103
- autoGainControl?: boolean;
104
- noiseSuppression?: boolean;
105
- };
267
+ export interface VideoProfile { width: number, height: number, frameRate: number, bitrate: number; }
268
+ export interface AudioProfile { sampleRate: number, channelCount: number, bitrate: number; }
269
+ export declare interface LocalVideoConfig {
270
+ view?: string | HTMLElement | HTMLElement[] | null;
271
+ publish?: boolean;
272
+ mute?: boolean | string;
273
+ option?: {
274
+ cameraId?: string;
275
+ useFrontCamera?: boolean;
276
+ profile?: keyof typeof videoProfileMap | VideoProfile;
277
+ fillMode?: 'contain' | 'cover' | 'fill';
278
+ mirror?: boolean | string;
279
+ small?: keyof typeof videoProfileMap | VideoProfile | boolean;
280
+ qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
281
+ videoTrack?: MediaStreamTrack;
282
+ };
106
283
  }
107
- declare interface UpdateLocalAudioConfig extends LocalAudioConfig {
108
- mute?: boolean;
109
- option?: {
110
- microphoneId?: string;
111
- audioTrack?: MediaStreamTrack;
112
- captureVolume?: number;
113
- earMonitorVolume?: number;
114
- echoCancellation?: boolean;
115
- autoGainControl?: boolean;
116
- noiseSuppression?: boolean;
117
- };
284
+ export interface TurnServerOptions {
285
+ url: string;
286
+ username?: string;
287
+ credential?: string;
288
+ credentialType?: 'password';
118
289
  }
119
- declare interface RemoteAudioConfig {
120
- userId: string;
121
- option?: {
122
- volume?: number;
123
- };
290
+ export declare interface ProxyServer {
291
+ websocketProxy?: string;
292
+ loggerProxy?: string;
293
+ turnServer?: TurnServerOptions | TurnServerOptions[];
294
+ iceTransportPolicy?: RTCIceTransportPolicy;
295
+ webtransportProxy?: string;
296
+ scheduleProxy?: string;
297
+ unifiedProxy?: string;
124
298
  }
125
- declare interface StopRemoteAudioConfig {
126
- userId: string;
299
+ export declare interface EnterRoomConfig {
300
+ sdkAppId: number;
301
+ userId: string;
302
+ userSig: string;
303
+ roomId?: number;
304
+ strRoomId?: string;
305
+ role?: UserRole;
306
+ autoReceiveAudio?: boolean;
307
+ autoReceiveVideo?: boolean;
308
+ privateMapKey?: string;
309
+ latencyLevel?: number;
310
+ businessInfo?: string;
311
+ enableAutoPlayDialog?: boolean;
312
+ proxy?: ProxyServer | string;
313
+ scene?: Scene;
314
+ userDefineRecordId?: string;
127
315
  }
128
- declare const enum TRTCStreamType {
129
- Main = "main",
130
- Sub = "sub"
316
+ export declare interface ScreenShareConfig {
317
+ view?: string | HTMLElement | HTMLElement[] | null;
318
+ publish?: boolean;
319
+ option?: {
320
+ profile?: keyof typeof screenProfileMap | VideoProfile;
321
+ fillMode?: 'contain' | 'cover' | 'fill';
322
+ systemAudio?: boolean;
323
+ echoCancellation?: boolean;
324
+ autoGainControl?: boolean;
325
+ noiseSuppression?: boolean;
326
+ audioTrack?: MediaStreamTrack;
327
+ videoTrack?: MediaStreamTrack;
328
+ captureElement?: HTMLElement;
329
+ preferDisplaySurface?: 'current-tab' | 'tab' | 'window' | 'monitor';
330
+ qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
331
+ };
131
332
  }
132
- declare enum TRTCDeviceType {
133
- Camera = "camera",
134
- Microphone = "microphone",
135
- Speaker = "speaker"
333
+ export declare interface UpdateScreenShareConfig extends ScreenShareConfig {
334
+ option?: {
335
+ fillMode?: 'contain' | 'cover' | 'fill';
336
+ qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
337
+ };
136
338
  }
137
- declare enum TRTCDeviceAction {
138
- Remove = "remove",
139
- Add = "add",
140
- Active = "active"
339
+ export declare interface RemoteVideoConfig {
340
+ view?: string | HTMLElement | HTMLElement[] | null;
341
+ userId: string;
342
+ streamType: TRTCStreamType;
343
+ option?: {
344
+ fillMode?: 'contain' | 'cover' | 'fill';
345
+ mirror?: boolean;
346
+ small?: boolean;
347
+ receiveWhenViewVisible?: boolean;
348
+ viewRoot?: HTMLElement;
349
+ canvasRender?: boolean;
350
+ };
141
351
  }
142
- declare interface RTCErrorParams {
143
- code: number;
144
- extraCode?: number;
145
- functionName?: string;
146
- fnName?: string;
147
- message?: string;
148
- messageParams?: any;
149
- originError?: Error | DOMException;
352
+ export declare interface StopRemoteVideoConfig {
353
+ userId: string;
354
+ streamType?: TRTCStreamType;
150
355
  }
151
- declare interface RTCErrorInterface {
152
- readonly name: string;
153
- readonly code: number;
154
- readonly extraCode?: number;
155
- readonly functionName?: string;
156
- readonly message?: string;
157
- readonly originError?: Error | DOMException;
356
+ export declare interface LocalAudioConfig {
357
+ publish?: boolean;
358
+ mute?: boolean;
359
+ option?: {
360
+ microphoneId?: string;
361
+ profile?: keyof typeof audioProfileMap;
362
+ audioTrack?: MediaStreamTrack;
363
+ captureVolume?: number;
364
+ earMonitorVolume?: number;
365
+ echoCancellation?: boolean;
366
+ autoGainControl?: boolean;
367
+ noiseSuppression?: boolean;
368
+ };
158
369
  }
159
- declare interface ErrorMessageParams {
160
- key?: string;
161
- rule?: any;
162
- fnName?: string;
163
- fnParams?: any;
164
- value?: string | number | any;
165
- type?: string;
166
- deviceType?: string;
167
- error?: Error | DOMException | CoreError;
370
+ export declare interface UpdateLocalAudioConfig extends LocalAudioConfig {
371
+ mute?: boolean;
372
+ option?: {
373
+ microphoneId?: string;
374
+ audioTrack?: MediaStreamTrack;
375
+ captureVolume?: number;
376
+ earMonitorVolume?: number;
377
+ echoCancellation?: boolean;
378
+ autoGainControl?: boolean;
379
+ noiseSuppression?: boolean;
380
+ };
381
+ }
382
+ export declare interface RemoteAudioConfig {
383
+ userId: string;
384
+ option?: {
385
+ volume?: number;
386
+ };
387
+ }
388
+ export declare interface StopRemoteAudioConfig {
389
+ userId: string;
390
+ }
391
+ export declare const enum TRTCStreamType {
392
+ Main = "main",
393
+ Sub = "sub"
394
+ }
395
+ export declare enum TRTCDeviceType {
396
+ Camera = "camera",
397
+ Microphone = "microphone",
398
+ Speaker = "speaker"
399
+ }
400
+ export declare enum TRTCDeviceAction {
401
+ Remove = "remove",
402
+ Add = "add",
403
+ Active = "active"
404
+ }
405
+ export declare interface RTCErrorParams {
406
+ code: number;
407
+ extraCode?: number;
408
+ functionName?: string;
409
+ fnName?: string;
410
+ message?: string;
411
+ messageParams?: any;
412
+ originError?: Error | DOMException;
413
+ }
414
+ export declare interface RTCErrorInterface {
415
+ readonly name: string;
416
+ readonly code: number;
417
+ readonly extraCode?: number;
418
+ readonly functionName?: string;
419
+ readonly message?: string;
420
+ readonly originError?: Error | DOMException;
168
421
  }
169
422
  /**
170
423
  * **TRTC Constants**<br>
@@ -173,223 +426,223 @@ declare interface ErrorMessageParams {
173
426
  * // Usage:
174
427
  * TRTC.TYPE.SCENE_LIVE
175
428
  */
176
- declare const TRTCType: {
177
- /**
178
- * Live streaming scene
179
- * @default 'live'
180
- * @memberof module:TYPE
181
- */
182
- readonly SCENE_LIVE: Scene.LIVE;
183
- /**
184
- * RTC scene
185
- * @default 'rtc'
186
- * @memberof module:TYPE
187
- */
188
- readonly SCENE_RTC: Scene.RTC;
189
- /**
190
- * Anchor role
191
- * @default 'anchor'
192
- * @memberof module:TYPE
193
- */
194
- readonly ROLE_ANCHOR: UserRole.ANCHOR;
195
- /**
196
- * Audience role
197
- * @default 'audience'
198
- * @memberof module:TYPE
199
- */
200
- readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
201
- /**
202
- * Main stream
203
- *
204
- * - TRTC has a main video stream (main stream) and an sub video stream (sub stream)
205
- * - The camera is published through the main stream, and the screen sharing is published through the sub stream.
206
- * - The main video stream includes: high-definition large picture and low-definition small picture. By default, {@link TRTC#startRemoteVideo TRTC.startRemoteVideo} plays the high-definition large picture, and the low-definition small picture can be played through the small parameter. Refer to: [Enable small stream function](./tutorial-27-advanced-small-stream.html).
207
- * @default 'main'
208
- * @memberof module:TYPE
209
- */
210
- readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
211
- /**
212
- * Sub stream
213
- * @default 'sub'
214
- * @memberof module:TYPE
215
- */
216
- readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
217
- /**
218
- * Standard audio quality
219
- * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
220
- * | :--- | :--- | :--- | :--- |
221
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
222
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
223
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
224
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
225
- * @default 'standard'
226
- * @memberof module:TYPE
227
- */
228
- readonly AUDIO_PROFILE_STANDARD: "standard";
229
- /**
230
- * Standard stereo audio quality
231
- * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
232
- * | :--- | :--- | :--- | :--- |
233
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
234
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
235
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
236
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
237
- * @default 'standard-stereo'
238
- * @memberof module:TYPE
239
- */
240
- readonly AUDIO_PROFILE_STANDARD_STEREO: "standard-stereo";
241
- /**
242
- * High audio quality
243
- * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
244
- * | :--- | :--- | :--- | :--- |
245
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
246
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
247
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
248
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
249
- * @default 'high'
250
- * @memberof module:TYPE
251
- */
252
- readonly AUDIO_PROFILE_HIGH: "high";
253
- /**
254
- * High-quality stereo audio
255
- * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
256
- * | :--- | :--- | :--- | :--- |
257
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
258
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
259
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
260
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
261
- * @default 'high-stereo'
262
-
263
- * @memberof module:TYPE
264
- */
265
- readonly AUDIO_PROFILE_HIGH_STEREO: "high-stereo";
266
- /**
267
- * When the network is weak, the video encoding strategy takes 'smooth' first, i.e., the priority is to preserve frame rate.
268
- * <br>
269
- * Default 'smooth' first for camera, 'default' clear first for screen sharing
270
- * @default 'smooth'
271
- * @memberof module:TYPE
272
- */
273
- readonly QOS_PREFERENCE_SMOOTH: "smooth";
274
- /**
275
- * When the network is weak, the video encoding strategy takes 'clear' first, i.e., the priority is to preserve resolution.
276
- * <br>
277
- * Default 'smooth' first for camera, 'default' clear first for screen sharing
278
- * @default 'clear'
279
- * @memberof module:TYPE
280
- */
281
- readonly QOS_PREFERENCE_CLEAR: "clear";
429
+ export declare const TRTCType: {
430
+ /**
431
+ * Live streaming scene
432
+ * @default 'live'
433
+ * @memberof module:TYPE
434
+ */
435
+ readonly SCENE_LIVE: Scene.LIVE;
436
+ /**
437
+ * RTC scene
438
+ * @default 'rtc'
439
+ * @memberof module:TYPE
440
+ */
441
+ readonly SCENE_RTC: Scene.RTC;
442
+ /**
443
+ * Anchor role
444
+ * @default 'anchor'
445
+ * @memberof module:TYPE
446
+ */
447
+ readonly ROLE_ANCHOR: UserRole.ANCHOR;
448
+ /**
449
+ * Audience role
450
+ * @default 'audience'
451
+ * @memberof module:TYPE
452
+ */
453
+ readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
454
+ /**
455
+ * Main stream
456
+ *
457
+ * - TRTC has a main video stream (main stream) and an sub video stream (sub stream)
458
+ * - The camera is published through the main stream, and the screen sharing is published through the sub stream.
459
+ * - The main video stream includes: high-definition large picture and low-definition small picture. By default, {@link TRTC#startRemoteVideo TRTC.startRemoteVideo} plays the high-definition large picture, and the low-definition small picture can be played through the small parameter. Refer to: [Enable small stream function](./tutorial-27-advanced-small-stream.html).
460
+ * @default 'main'
461
+ * @memberof module:TYPE
462
+ */
463
+ readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
464
+ /**
465
+ * Sub stream
466
+ * @default 'sub'
467
+ * @memberof module:TYPE
468
+ */
469
+ readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
470
+ /**
471
+ * Standard audio quality
472
+ * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
473
+ * | :--- | :--- | :--- | :--- |
474
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
475
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
476
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
477
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
478
+ * @default 'standard'
479
+ * @memberof module:TYPE
480
+ */
481
+ readonly AUDIO_PROFILE_STANDARD: "standard";
482
+ /**
483
+ * Standard stereo audio quality
484
+ * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
485
+ * | :--- | :--- | :--- | :--- |
486
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
487
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
488
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
489
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
490
+ * @default 'standard-stereo'
491
+ * @memberof module:TYPE
492
+ */
493
+ readonly AUDIO_PROFILE_STANDARD_STEREO: "standard-stereo";
494
+ /**
495
+ * High audio quality
496
+ * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
497
+ * | :--- | :--- | :--- | :--- |
498
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
499
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
500
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
501
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
502
+ * @default 'high'
503
+ * @memberof module:TYPE
504
+ */
505
+ readonly AUDIO_PROFILE_HIGH: "high";
506
+ /**
507
+ * High-quality stereo audio
508
+ * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
509
+ * | :--- | :--- | :--- | :--- |
510
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
511
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
512
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
513
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
514
+ * @default 'high-stereo'
515
+
516
+ * @memberof module:TYPE
517
+ */
518
+ readonly AUDIO_PROFILE_HIGH_STEREO: "high-stereo";
519
+ /**
520
+ * When the network is weak, the video encoding strategy takes 'smooth' first, i.e., the priority is to preserve frame rate.
521
+ * <br>
522
+ * Default 'smooth' first for camera, 'default' clear first for screen sharing
523
+ * @default 'smooth'
524
+ * @memberof module:TYPE
525
+ */
526
+ readonly QOS_PREFERENCE_SMOOTH: "smooth";
527
+ /**
528
+ * When the network is weak, the video encoding strategy takes 'clear' first, i.e., the priority is to preserve resolution.
529
+ * <br>
530
+ * Default 'smooth' first for camera, 'default' clear first for screen sharing
531
+ * @default 'clear'
532
+ * @memberof module:TYPE
533
+ */
534
+ readonly QOS_PREFERENCE_CLEAR: "clear";
282
535
  };
283
- declare interface AudioMixerOptions {
284
- id: string;
285
- url: string;
286
- loop?: boolean;
287
- volume?: number;
536
+ export declare interface AudioMixerOptions {
537
+ id: string;
538
+ url: string;
539
+ loop?: boolean;
540
+ volume?: number;
288
541
  }
289
- declare interface UpdateAudioMixerOptions {
290
- id: string;
291
- loop?: boolean;
292
- volume?: number;
293
- seekFrom?: number;
294
- operation?: 'pause' | 'resume' | 'stop';
542
+ export declare interface UpdateAudioMixerOptions {
543
+ id: string;
544
+ loop?: boolean;
545
+ volume?: number;
546
+ seekFrom?: number;
547
+ operation?: 'pause' | 'resume' | 'stop';
295
548
  }
296
- declare interface StopAudioMixerOptions {
297
- id: string;
549
+ export declare interface StopAudioMixerOptions {
550
+ id: string;
298
551
  }
299
- declare interface AIDenoiserOptions {
300
- assetsPath: string;
301
- sdkAppId: number;
302
- userId: string;
303
- userSig: string;
552
+ export declare interface AIDenoiserOptions {
553
+ assetsPath: string;
554
+ sdkAppId: number;
555
+ userId: string;
556
+ userSig: string;
304
557
  }
305
- declare type PluginStartOptionsMap = {
306
- 'AudioMixer': AudioMixerOptions;
307
- 'AIDenoiser': AIDenoiserOptions;
308
- 'CDNStreaming': CDNStreamingOptions;
309
- 'VirtualBackground': VirtualBackgroundOptions;
310
- 'Watermark': WatermarkOptions;
311
- 'Beauty': BeautyOptions;
312
- 'BasicBeauty': BasicBeautyOptions;
313
- 'DeviceDetector': DeviceDetectorOptions;
314
- 'SEI': undefined;
315
- 'Debug': undefined;
316
- 'CrossRoom': StartCrossRoomOption;
558
+ export declare type PluginStartOptionsMap = {
559
+ 'AudioMixer': AudioMixerOptions;
560
+ 'AIDenoiser': AIDenoiserOptions;
561
+ 'CDNStreaming': CDNStreamingOptions;
562
+ 'VirtualBackground': VirtualBackgroundOptions;
563
+ 'Watermark': WatermarkOptions;
564
+ 'Beauty': BeautyOptions;
565
+ 'BasicBeauty': BasicBeautyOptions;
566
+ 'DeviceDetector': DeviceDetectorOptions;
567
+ 'SEI': undefined;
568
+ 'Debug': undefined;
569
+ 'CrossRoom': StartCrossRoomOption;
317
570
  };
318
- declare type PluginUpdateOptionsMap = {
319
- 'AudioMixer': UpdateAudioMixerOptions;
320
- 'CDNStreaming': CDNStreamingOptions;
321
- 'VirtualBackground': UpdateVirtualBackgroundOptions;
322
- 'Beauty': UpdateBeautyOptions;
323
- 'BasicBeauty': BasicBeautyOptions;
324
- 'SEI': UpdateSEIOptions;
325
- 'CrossRoom': UpdateCrossRoomOption;
571
+ export declare type PluginUpdateOptionsMap = {
572
+ 'AudioMixer': UpdateAudioMixerOptions;
573
+ 'CDNStreaming': CDNStreamingOptions;
574
+ 'VirtualBackground': UpdateVirtualBackgroundOptions;
575
+ 'Beauty': UpdateBeautyOptions;
576
+ 'BasicBeauty': BasicBeautyOptions;
577
+ 'SEI': UpdateSEIOptions;
578
+ 'CrossRoom': UpdateCrossRoomOption;
326
579
  };
327
- declare interface UpdateSEIOptions {
328
- buffer: ArrayBuffer;
329
- options: {
330
- seiPayloadType: number;
331
- toSubStream?: boolean;
332
- };
580
+ export declare interface UpdateSEIOptions {
581
+ buffer: ArrayBuffer;
582
+ options: {
583
+ seiPayloadType: number;
584
+ toSubStream?: boolean;
585
+ };
333
586
  }
334
- declare type PluginStopOptionsMap = {
335
- 'AudioMixer': StopAudioMixerOptions;
336
- 'AIDenoiser': undefined;
337
- 'CDNStreaming': CDNStreamingOptions;
338
- 'VirtualBackground': undefined;
339
- 'Watermark': undefined;
340
- 'Beauty': undefined;
341
- 'BasicBeauty': undefined;
342
- 'DeviceDetector': undefined;
343
- 'Debug': undefined;
344
- 'CrossRoom': StopCrossRoomOption | undefined;
587
+ export declare type PluginStopOptionsMap = {
588
+ 'AudioMixer': StopAudioMixerOptions;
589
+ 'AIDenoiser': undefined;
590
+ 'CDNStreaming': CDNStreamingOptions;
591
+ 'VirtualBackground': undefined;
592
+ 'Watermark': undefined;
593
+ 'Beauty': undefined;
594
+ 'BasicBeauty': undefined;
595
+ 'DeviceDetector': undefined;
596
+ 'Debug': undefined;
597
+ 'CrossRoom': StopCrossRoomOption | undefined;
345
598
  };
346
- declare interface TRTCStatistics {
347
- rtt: number;
348
- downLoss: number;
349
- upLoss: number;
350
- bytesSent: number;
351
- bytesReceived: number;
352
- localStatistics: LocalStatistic;
353
- remoteStatistics: RemoteStatistic[];
599
+ export declare interface TRTCStatistics {
600
+ rtt: number;
601
+ downLoss: number;
602
+ upLoss: number;
603
+ bytesSent: number;
604
+ bytesReceived: number;
605
+ localStatistics: LocalStatistic;
606
+ remoteStatistics: RemoteStatistic[];
354
607
  }
355
- interface LocalStatistic {
356
- audio: {
357
- bitrate: number;
358
- audioLevel: number;
359
- };
360
- video: {
361
- width: number;
362
- height: number;
363
- frameRate: number;
364
- bitrate: number;
365
- videoType: TRTCVideoType;
366
- }[];
608
+ export declare interface LocalStatistic {
609
+ audio: {
610
+ bitrate: number;
611
+ audioLevel: number;
612
+ };
613
+ video: {
614
+ width: number;
615
+ height: number;
616
+ frameRate: number;
617
+ bitrate: number;
618
+ videoType: TRTCVideoType;
619
+ }[];
367
620
  }
368
- declare enum TRTCVideoType {
369
- Big = "big",
370
- Small = "small",
371
- Sub = "sub"
621
+ export declare enum TRTCVideoType {
622
+ Big = "big",
623
+ Small = "small",
624
+ Sub = "sub"
372
625
  }
373
- interface RemoteStatistic {
374
- audio: {
375
- bitrate: number;
376
- audioLevel: number;
377
- };
378
- video: {
379
- width: number;
380
- height: number;
381
- frameRate: number;
382
- bitrate: number;
383
- videoType: TRTCVideoType;
384
- }[];
385
- userId: string;
626
+ export declare interface RemoteStatistic {
627
+ audio: {
628
+ bitrate: number;
629
+ audioLevel: number;
630
+ };
631
+ video: {
632
+ width: number;
633
+ height: number;
634
+ frameRate: number;
635
+ bitrate: number;
636
+ videoType: TRTCVideoType;
637
+ }[];
638
+ userId: string;
386
639
  }
387
- declare interface VideoFrameConfig {
388
- userId?: string;
389
- streamType?: TRTCStreamType;
640
+ export declare interface VideoFrameConfig {
641
+ userId?: string;
642
+ streamType?: TRTCStreamType;
390
643
  }
391
- declare enum AutoStartPluginName {
392
- Debug = "Debug"
644
+ export declare enum AutoStartPluginName {
645
+ Debug = "Debug"
393
646
  }
394
647
 
395
648
  /**
@@ -440,1403 +693,1410 @@ declare enum AutoStartPluginName {
440
693
  * // Usage:
441
694
  * trtc.on(TRTC.EVENT.ERROR, () => {});
442
695
  */
443
- declare const TRTCEvent: {
444
- /**
445
- * Error event, non-API call error, SDK throws when an unrecoverable error occurs during operation.
446
- *
447
- * - Error code (error.code): {@link module:ERROR_CODE.OPERATION_FAILED ErrorCode.OPERATION_FAILED}
448
- * - Possible extended error codes (error.extraCode): 5501, 5502
449
- * @default 'error'
450
- * @memberof module:EVENT
451
- * @see {@link RtcError RtcError}
452
- * @e
453
- * @example
454
- *
455
- * trtc.on(TRTC.EVENT.ERROR, error => {
456
- * console.error('trtc error observed: ' + error);
457
- * const errorCode = error.code;
458
- * const extraCode = error.extraCode;
459
- * });
460
- */
461
- readonly ERROR: "error";
462
- /**
463
- * @description Automatic playback failed, refer to {@tutorial 21-advanced-auto-play-policy}
464
- * @default 'autoplay-failed'
465
- * @memberof module:EVENT
466
- * @example
467
- * trtc.on(TRTC.EVENT.AUTOPLAY_FAILED, event => {
468
- * // Guide user to click the page, SDK will resume playback automatically when user click the page.
469
- * // Since v5.1.3+, you can get userId on this event.
470
- * console.log(event.userId);
471
- * });
472
- */
473
- readonly AUTOPLAY_FAILED: "autoplay-failed";
474
- /**
475
- * @description Kicked out of the room for some reason, including:<br>
476
- * - kick: The same user with same userId enters same room. The user who enters the room first will be kicked out of the room by the user who enters later.
477
- * - Entering a room with the same userId is not allowed behavior, which may lead to abnormal audio/video calls between the two parties, and should be avoided on the business side.
478
- * - Users with the same userId who enter the same room with the same audience role may not receive this event.
479
- * - banned: kicked out by the administrator using [Server API - RemoveUser](https://trtc.io/document/34267/34268).
480
- * - room_disband: kicked out by the administrator using [Server API - DismissRoom](https://trtc.io/document/34267/34269).
481
- * @default 'kicked-out'
482
- * @memberof module:EVENT
483
- * @example
484
- *
485
- * trtc.on(TRTC.EVENT.KICKED_OUT, event => {
486
- * console.log(event.reason)
487
- * });
488
- */
489
- readonly KICKED_OUT: "kicked-out";
490
- /**
491
- * Remote user enters the room event.
492
- *
493
- * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
494
- * - In `live` mode, only the anchor has the notification of entering and exiting the room, and the audience does not have the notification of entering and exiting the room. The audience can receive the notification of entering and exiting the room of the anchor.
495
- * @default 'remote-user-enter'
496
- * @memberof module:EVENT
497
- * @example
498
- *
499
- * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, event => {
500
- * const userId = event.userId;
501
- * });
502
- */
503
- readonly REMOTE_USER_ENTER: "remote-user-enter";
504
- /**
505
- * Remote user exits the room event.
506
- *
507
- * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
508
- * - In `live` mode, only the anchor has the notification of entering and exiting the room, and the audience does not have the notification of entering and exiting the room. The audience can receive the notification of entering and exiting the room of the anchor.
509
- * @default 'remote-user-exit'
510
- * @memberof module:EVENT
511
- * @example
512
- *
513
- * trtc.on(TRTC.EVENT.REMOTE_USER_EXIT, event => {
514
- * const userId = event.userId;
515
- * });
516
- */
517
- readonly REMOTE_USER_EXIT: "remote-user-exit";
518
- /**
519
- * Remote user publishes audio. You will receive this notification when the remote user turns on the microphone. Refer to: [Turn on/off camera and microphone](./tutorial-15-basic-dynamic-add-video.html)
520
- *
521
- * - By default, the SDK automatically plays remote audio, and you do not need to call the API to play remote audio. You can listen for this event and {@link module:EVENT.REMOTE_AUDIO_UNAVAILABLE REMOTE_AUDIO_UNAVAILABLE} to update the UI icon for "whether the remote microphone is turned on".
522
- * - Note: If the user has not interacted with the page before entering the room, automatic audio playback may fail due to the [browser's automatic playback policy restrictions](./tutorial-21-advanced-auto-play-policy.html). You need to refer to the [suggestions for handling automatic playback restrictions](./tutorial-21-advanced-auto-play-policy.html) for processing.
523
- * - If you do not want the SDK to automatically play audio, you can set `autoReceiveAudio` to `false` to turn off automatic audio playback when calling {@link TRTC#enterRoom trtc.enterRoom()}.
524
- * - Listen for the {@link module:EVENT.REMOTE_AUDIO_AVAILABLE TRTC.EVENT.REMOTE_AUDIO_AVAILABLE} event, record the userId with remote audio, and call the {@link TRTC#muteRemoteAudio trtc.muteRemoteAudio(userId, false)} method when you need to play audio.
525
- * @default 'remote-audio-available'
526
- * @memberof module:EVENT
527
- * @example
528
- * // Listen before entering the room
529
- * trtc.on(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE, event => {
530
- * const userId = event.userId;
531
- * });
532
- */
533
- readonly REMOTE_AUDIO_AVAILABLE: "remote-audio-available";
534
- /**
535
- * Remote user stops publishing audio. You will receive this notification when the remote user turns off the microphone.
536
- *
537
- * @default 'remote-audio-unavailable'
538
- * @memberof module:EVENT
539
- * @example
540
- * // Listen before entering the room
541
- * trtc.on(TRTC.EVENT.REMOTE_AUDIO_UNAVAILABLE, event => {
542
- * const userId = event.userId;
543
- *
544
- * });
545
- */
546
- readonly REMOTE_AUDIO_UNAVAILABLE: "remote-audio-unavailable";
547
- /**
548
- * Remote user publishes video. You will receive this notification when the remote user turns on the camera. Refer to: [Turn on/off camera and microphone](./tutorial-15-basic-dynamic-add-video.html)
549
- *
550
- * - You can listen for this event and {@link module:EVENT.REMOTE_VIDEO_UNAVAILABLE REMOTE_VIDEO_UNAVAILABLE} to update the UI icon for "whether the remote camera is turned on".
551
- * @see {@link module:TYPE.STREAM_TYPE_MAIN STREAM_TYPE_MAIN}
552
- * @see {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB}
553
- * @default 'remote-video-available'
554
- * @memberof module:EVENT
555
- * @example
556
- * // Listen before entering the room
557
- * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
558
- * const userId = event.userId;
559
- * const streamType = event.streamType;
560
- * trtc.startRemoteVideo({userId, streamType, view});
561
- * });
562
- */
563
- readonly REMOTE_VIDEO_AVAILABLE: "remote-video-available";
564
- /**
565
- * Remote user stops publishing video. You will receive this notification when the remote user turns off the camera.
566
- * @default 'remote-video-unavailable'
567
- * @memberof module:EVENT
568
- * @example
569
- * // Listen before entering the room
570
- * trtc.on(TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE, event => {
571
- * const userId = event.userId;
572
- * const streamType = event.streamType;
573
- * // At this point, the SDK will automatically stop playing, and there is no need to call stopRemoteVideo.
574
- * });
575
- */
576
- readonly REMOTE_VIDEO_UNAVAILABLE: "remote-video-unavailable";
577
- /**
578
- * @description Volume event<br>
579
- * After calling the {@link TRTC#enableAudioVolumeEvaluation enableAudioVolumeEvaluation} interface to enable the volume callback, the SDK will throw this event regularly to notify the volume of each userId.<br>
580
- * **Note**
581
- * - The callback contains the volume of the local microphone and the volume of the remote user. The callback will be triggered regardless of whether anyone is speaking.
582
- * - The event.result will be sorted from large to small according to the volume size.
583
- * - When userId is an empty string, it represents the volume of the local microphone.
584
- * - volume is a positive integer with a value of 0-100.
585
- * @default 'audio-volume'
586
- * @memberof module:EVENT
587
- * @example
588
- * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
589
- * event.result.forEach(({ userId, volume }) => {
590
- * const isMe = userId === ''; // When userId is an empty string, it represents the volume of the local microphone.
591
- * if (isMe) {
592
- * console.log(`my volume: ${volume}`);
593
- * } else {
594
- * console.log(`user: ${userId} volume: ${volume}`);
595
- * }
596
- * })
597
- * });
598
- *
599
- * // Enable volume callback and trigger the event every 1000ms
600
- * trtc.enableAudioVolumeEvaluation(1000);
601
- */
602
- readonly AUDIO_VOLUME: "audio-volume";
603
- /**
604
- * @description Network quality statistics data event, which starts to be counted after entering the room and triggers every two seconds. This data reflects the network quality of your local uplink and downlink.
605
- * - The uplink network quality (uplinkNetworkQuality) refers to the network situation of uploading local streams (uplink connection network quality from SDK to Tencent Cloud)
606
- * - The downlink network quality (downlinkNetworkQuality) refers to the average network situation of downloading all streams (average network quality of all downlink connections from Tencent Cloud to SDK)
607
- *
608
- * The enumeration values and meanings are shown in the following table:
609
- * | Value | Meaning |
610
- * | :--- | :---- |
611
- * | 0 | Network state is unknown, indicating that the current trtc instance has not established an uplink/downlink connection |
612
- * | 1 | Network state is excellent |
613
- * | 2 | Network state is good |
614
- * | 3 | Network state is average |
615
- * | 4 | Network state is poor |
616
- * | 5 | Network state is very poor |
617
- * | 6 | Network connection is disconnected<br/>Note: If the downlink network quality is this value, it means that all downlink connections have been disconnected |
618
- * - uplinkRTT, uplinkLoss are the uplink RTT (ms) and uplink packet loss rate.
619
- * - downlinkRTT, downlinkLoss are the average RTT (ms) and average packet loss rate of all downlink connections.
620
- *
621
- * **Note**
622
- * - If you want to know the uplink and downlink network conditions of the other party, you need to broadcast the other party's network quality through IM.
623
- *
624
- * @default 'network-quality'
625
- * @memberof module:EVENT
626
- * @example
627
- * trtc.on(TRTC.EVENT.NETWORK_QUALITY, event => {
628
- * console.log(`network-quality, uplinkNetworkQuality:${event.uplinkNetworkQuality}, downlinkNetworkQuality: ${event.downlinkNetworkQuality}`)
629
- * console.log(`uplink rtt:${event.uplinkRTT} loss:${event.uplinkLoss}`)
630
- * console.log(`downlink rtt:${event.downlinkRTT} loss:${event.downlinkLoss}`)
631
- * })
632
- */
633
- readonly NETWORK_QUALITY: "network-quality";
634
- /**
635
- * @description SDK and Tencent Cloud connection state change event, you can use this event to listen to the overall connection state of the SDK and Tencent Cloud.<br>
636
- * - 'DISCONNECTED': Connection disconnected
637
- * - 'CONNECTING': Connecting
638
- * - 'CONNECTED': Connected
639
- *
640
- * Meanings of different state changes:
641
- *
642
- * - DISCONNECTED -> CONNECTING: Trying to establish a connection, triggered when calling the enter room interface or when the SDK automatically reconnects.
643
- * - CONNECTING -> DISCONNECTED: Connection establishment failed, triggered when calling the exit room interface to interrupt the connection or when the connection fails after SDK retries.
644
- * - CONNECTING -> CONNECTED: Connection established successfully, triggered when the connection is successful.
645
- * - CONNECTED -> DISCONNECTED: Connection interrupted, triggered when calling the exit room interface or when the connection is disconnected due to network anomalies.
646
- *
647
- * Suggestion: You can listen to this event and display different UIs in different states to remind users of the current connection state.
648
- *
649
- * @default 'connection-state-changed'
650
- * @memberof module:EVENT
651
- * @example
652
- * trtc.on(TRTC.EVENT.CONNECTION_STATE_CHANGED, event => {
653
- * const prevState = event.prevState;
654
- * const curState = event.state;
655
- * });
656
- */
657
- readonly CONNECTION_STATE_CHANGED: "connection-state-changed";
658
- /**
659
- * @description Audio playback state change event
660
- *
661
- * event.userId When userId is an empty string, it represents the local user, and when it is a non-empty string, it represents a remote user.
662
- *
663
- * event.state The value is as follows:
664
- * - 'PLAYING': start playing
665
- * - event.reason is 'playing' or 'unmute'.
666
- * - 'PAUSED': pause playback
667
- * - When event.reason is 'pause', it is triggered by the pause event of the \<audio\> element. The following situations will trigger:
668
- * - Call the HTMLMediaElement.pause interface.
669
- * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
670
- * - When userId is oneself, this event is triggered, indicating that audio collection is paused, usually caused by device abnormalities, such as being preempted by other applications on the device, at this time, the user needs to be guided to recollect.
671
- * - When userId is others, this event is triggered, indicating that the received audio data is not enough to play. Usually caused by network jitter, no processing is required on the access side. When the received data is sufficient to play, it will automatically resume.
672
- * - 'STOPPED': stop playing
673
- * - event.reason is 'ended'.
674
- *
675
- * event.reason The reason for the state change, the value is as follows:
676
- * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
677
- * - 'mute': The audio track cannot provide data temporarily, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
678
- * - 'unmute': The audio track resumes providing data, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/unmute_event | MediaStreamTrack.unmute_event}
679
- * - 'ended': The audio track has been closed
680
- * - 'pause': Playback paused
681
- * @default 'audio-play-state-changed'
682
- * @memberof module:EVENT
683
- * @example
684
- * trtc.on(TRTC.EVENT.AUDIO_PLAY_STATE_CHANGED, event => {
685
- * console.log(`${event.userId} player is ${event.state} because of ${event.reason}`);
686
- * });
687
- */
688
- readonly AUDIO_PLAY_STATE_CHANGED: "audio-play-state-changed";
689
- /**
690
- * @description Video playback state change event
691
- *
692
- * event.userId When userId is an empty string, it represents the local user, and when it is a non-empty string, it represents a remote user.
693
- *
694
- * event.streamType Stream type, value: {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN} {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}
695
- *
696
- * event.state The value is as follows:
697
- * - 'PLAYING': start playing
698
- * - event.reason is 'playing' or 'unmute'.
699
- * - 'PAUSED': pause playback
700
- * - When event.reason is 'pause', it is triggered by the pause event of the \<video\> element. The following situations will trigger:
701
- * - Call the HTMLMediaElement.pause interface.
702
- * - After successful playback, the view container for playing the video is removed from the DOM.
703
- * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
704
- * - When userId is oneself, this event is triggered, indicating that video collection is paused, usually caused by device abnormalities, such as being preempted by other applications on the device, at this time, the user needs to be guided to recollect.
705
- * - When userId is others, this event is triggered, indicating that the received video data is not enough to play. Usually caused by network jitter, no processing is required on the access side. When the received data is sufficient to play, it will automatically resume.
706
- * - 'STOPPED': stop playing
707
- * - event.reason is 'ended'.
708
- *
709
- * event.reason The reason for the state change, the value is as follows:
710
- * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
711
- * - 'mute': The video track cannot provide data temporarily, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
712
- * - 'unmute': The video track resumes providing data, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/unmute_event | MediaStreamTrack.unmute_event}
713
- * - 'ended': The video track has been closed
714
- * - 'pause': Playback paused
715
- * @default 'video-play-state-changed'
716
- * @memberof module:EVENT
717
- * @example
718
- * trtc.on(TRTC.EVENT.VIDEO_PLAY_STATE_CHANGED, event => {
719
- * console.log(`${event.userId} ${event.streamType} video player is ${event.state} because of ${event.reason}`);
720
- * });
721
- */
722
- readonly VIDEO_PLAY_STATE_CHANGED: "video-play-state-changed";
723
- /**
724
- * @description Notification event for local screen sharing stop, only valid for local screen sharing streams.
725
- * @default 'screen-share-stopped'
726
- * @memberof module:EVENT
727
- * @example
728
- * trtc.on(TRTC.EVENT.SCREEN_SHARE_STOPPED, () => {
729
- * console.log('screen sharing was stopped');
730
- * });
731
- */
732
- readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
733
- /**
734
- * @description Notification event for device changes such as camera and microphone.
735
- * - event.device is a [MediaDeviceInfo](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) object with properties:
736
- * - deviceId: device ID
737
- * - label: device description information
738
- * - groupId: device group ID
739
- * - event.type value: `'camera'|'microphone'|'speaker'`
740
- * - event.action value:
741
- * - 'add' device has been added.
742
- * - 'remove' device has been removed.
743
- * - 'active' device has been activated, for example: after startLocalVideo is successful, this event will be triggered.
744
- * @default 'device-changed'
745
- * @memberof module:EVENT
746
- * @example
747
- * trtc.on(TRTC.EVENT.DEVICE_CHANGED, (event) => {
748
- * console.log(`${event.type}(${event.device.label}) ${event.action}`);
749
- * });
750
- */
751
- readonly DEVICE_CHANGED: "device-changed";
752
- /**
753
- * @description Publish state change event.
754
- * - event.mediaType media type, value: `'audio'|'video'|'screen'`.
755
- * - event.state current publish state, value:
756
- * - `'starting'` trying to publish stream
757
- * - `'started'` publish stream succeeded
758
- * - `'stopped'` publish stream stopped, see event.reason field for the reason
759
- * - event.prevState the publish state at the last event trigger, with the same type as event.state.
760
- * - event.reason the reason for the publish state to become `'stopped'`, value:
761
- * - `'timeout'` publish stream timeout, usually caused by network jitter or firewall interception. The SDK will keep retrying, and the business side can guide the user to check the network or change the network at this time.
762
- * - `'error'` publish stream error, at this time, you can get the specific error information from event.error, usually caused by the browser not supporting H264 encoding.
763
- * - `'api-call'` publish stream stopped due to business side API call, for example, stopLocalVideo was called to stop the publish stream before startLocalVideo was successful, which is a normal behavior and the business side does not need to pay attention to it.
764
- * - event.error error information when event.reason is `'error'`.
765
- * @default 'publish-state-changed'
766
- * @memberof module:EVENT
767
- * @example
768
- * trtc.on(TRTC.EVENT.PUBLISH_STATE_CHANGED, (event) => {
769
- * console.log(`${event.mediaType} ${event.state} ${event.reason}`);
770
- * });
771
- */
772
- readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
773
- /**
774
- * @since v5.3.0
775
- * @description a new MediaStreamTrack object received.
776
- * @default 'track'
777
- * @memberof module:EVENT
778
- * @example
779
- * trtc.on(TRTC.EVENT.TRACK, event => {
780
- * // userId === '' means event.track is a local track, otherwise it's a remote track
781
- * const isLocal = event.userId === '';
782
- * // Usually the sub stream is a screen-sharing video stream.
783
- * const isSubStream = event.streamType === TRTC.TYPE.STREAM_TYPE_SUB;
784
- * const mediaStreamTrack = event.track;
785
- * const kind = event.track.kind; // audio or video
786
- * })
787
- */
788
- readonly TRACK: "track";
789
- /**
790
- * @description TRTC statistics.<br>
791
- *
792
- * - SDK will fires this event once every 2s.
793
- * - You can get the network quality, statistics of audio and video from this event. For detailed parameter description, please refer to {@link TRTCStatistics}.
794
- * @default 'statistics'
795
- * @since v5.2.0
796
- * @memberof module:EVENT
797
- * @example
798
- * trtc.on(TRTC.EVENT.STATISTICS, statistics => {
799
- * console.warn(statistics.rtt, statistics.upLoss, statistics.downLoss);
800
- * })
801
- */
802
- readonly STATISTICS: "statistics";
803
- /**
804
- * @since v5.3.0
805
- * @description SEI message received<br>
806
- * @default 'sei-message'
807
- * @memberof module:EVENT
808
- * @example
809
- * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
810
- * console.log(`received sei message from ${event.userId}, data: ${event.data}, streamType: ${event.streamType}`)
811
- * })
812
- */
813
- readonly SEI_MESSAGE: "sei-message";
814
- /**
815
- * @since v5.6.0
816
- * @description received a new custom message.
817
- * @default 'custom-message'
818
- * @memberof module:EVENT
819
- * @example
820
- * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
821
- * // event.userId: remote userId.
822
- * // event.cmdId: message cmdId.
823
- * // event.seq: message sequence number.
824
- * // event.data: custom message data, type is ArrayBuffer.
825
- * })
826
- */
827
- readonly CUSTOM_MESSAGE: "custom-message";
696
+ export declare const TRTCEvent: {
697
+ /**
698
+ * Error event, non-API call error, SDK throws when an unrecoverable error occurs during operation.
699
+ *
700
+ * - Error code (error.code): {@link module:ERROR_CODE.OPERATION_FAILED ErrorCode.OPERATION_FAILED}
701
+ * - Possible extended error codes (error.extraCode): 5501, 5502
702
+ * @default 'error'
703
+ * @memberof module:EVENT
704
+ * @see {@link RtcError RtcError}
705
+ * @e
706
+ * @example
707
+ *
708
+ * trtc.on(TRTC.EVENT.ERROR, error => {
709
+ * console.error('trtc error observed: ' + error);
710
+ * const errorCode = error.code;
711
+ * const extraCode = error.extraCode;
712
+ * });
713
+ */
714
+ readonly ERROR: "error";
715
+ /**
716
+ * @description Automatic playback failed, refer to {@tutorial 21-advanced-auto-play-policy}
717
+ * @default 'autoplay-failed'
718
+ * @memberof module:EVENT
719
+ * @example
720
+ * trtc.on(TRTC.EVENT.AUTOPLAY_FAILED, event => {
721
+ * // Guide user to click the page, SDK will resume playback automatically when user click the page.
722
+ * // Since v5.1.3+, you can get userId on this event.
723
+ * console.log(event.userId);
724
+ * });
725
+ */
726
+ readonly AUTOPLAY_FAILED: "autoplay-failed";
727
+ /**
728
+ * @description Kicked out of the room for some reason, including:<br>
729
+ * - kick: The same user with same userId enters same room. The user who enters the room first will be kicked out of the room by the user who enters later.
730
+ * - Entering a room with the same userId is not allowed behavior, which may lead to abnormal audio/video calls between the two parties, and should be avoided on the business side.
731
+ * - Users with the same userId who enter the same room with the same audience role may not receive this event.
732
+ * - banned: kicked out by the administrator using [Server API - RemoveUser](https://trtc.io/document/34267/34268).
733
+ * - room_disband: kicked out by the administrator using [Server API - DismissRoom](https://trtc.io/document/34267/34269).
734
+ * @default 'kicked-out'
735
+ * @memberof module:EVENT
736
+ * @example
737
+ *
738
+ * trtc.on(TRTC.EVENT.KICKED_OUT, event => {
739
+ * console.log(event.reason)
740
+ * });
741
+ */
742
+ readonly KICKED_OUT: "kicked-out";
743
+ /**
744
+ * Remote user enters the room event.
745
+ *
746
+ * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
747
+ * - In `live` mode, only the anchor has the notification of entering and exiting the room, and the audience does not have the notification of entering and exiting the room. The audience can receive the notification of entering and exiting the room of the anchor.
748
+ * @default 'remote-user-enter'
749
+ * @memberof module:EVENT
750
+ * @example
751
+ *
752
+ * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, event => {
753
+ * const userId = event.userId;
754
+ * });
755
+ */
756
+ readonly REMOTE_USER_ENTER: "remote-user-enter";
757
+ /**
758
+ * Remote user exits the room event.
759
+ *
760
+ * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
761
+ * - In `live` mode, only the anchor has the notification of entering and exiting the room, and the audience does not have the notification of entering and exiting the room. The audience can receive the notification of entering and exiting the room of the anchor.
762
+ * @default 'remote-user-exit'
763
+ * @memberof module:EVENT
764
+ * @example
765
+ *
766
+ * trtc.on(TRTC.EVENT.REMOTE_USER_EXIT, event => {
767
+ * const userId = event.userId;
768
+ * });
769
+ */
770
+ readonly REMOTE_USER_EXIT: "remote-user-exit";
771
+ /**
772
+ * Remote user publishes audio. You will receive this notification when the remote user turns on the microphone. Refer to: [Turn on/off camera and microphone](./tutorial-15-basic-dynamic-add-video.html)
773
+ *
774
+ * - By default, the SDK automatically plays remote audio, and you do not need to call the API to play remote audio. You can listen for this event and {@link module:EVENT.REMOTE_AUDIO_UNAVAILABLE REMOTE_AUDIO_UNAVAILABLE} to update the UI icon for "whether the remote microphone is turned on".
775
+ * - Note: If the user has not interacted with the page before entering the room, automatic audio playback may fail due to the [browser's automatic playback policy restrictions](./tutorial-21-advanced-auto-play-policy.html). You need to refer to the [suggestions for handling automatic playback restrictions](./tutorial-21-advanced-auto-play-policy.html) for processing.
776
+ * - If you do not want the SDK to automatically play audio, you can set `autoReceiveAudio` to `false` to turn off automatic audio playback when calling {@link TRTC#enterRoom trtc.enterRoom()}.
777
+ * - Listen for the {@link module:EVENT.REMOTE_AUDIO_AVAILABLE TRTC.EVENT.REMOTE_AUDIO_AVAILABLE} event, record the userId with remote audio, and call the {@link TRTC#muteRemoteAudio trtc.muteRemoteAudio(userId, false)} method when you need to play audio.
778
+ * @default 'remote-audio-available'
779
+ * @memberof module:EVENT
780
+ * @example
781
+ * // Listen before entering the room
782
+ * trtc.on(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE, event => {
783
+ * const userId = event.userId;
784
+ * });
785
+ */
786
+ readonly REMOTE_AUDIO_AVAILABLE: "remote-audio-available";
787
+ /**
788
+ * Remote user stops publishing audio. You will receive this notification when the remote user turns off the microphone.
789
+ *
790
+ * @default 'remote-audio-unavailable'
791
+ * @memberof module:EVENT
792
+ * @example
793
+ * // Listen before entering the room
794
+ * trtc.on(TRTC.EVENT.REMOTE_AUDIO_UNAVAILABLE, event => {
795
+ * const userId = event.userId;
796
+ *
797
+ * });
798
+ */
799
+ readonly REMOTE_AUDIO_UNAVAILABLE: "remote-audio-unavailable";
800
+ /**
801
+ * Remote user publishes video. You will receive this notification when the remote user turns on the camera. Refer to: [Turn on/off camera and microphone](./tutorial-15-basic-dynamic-add-video.html)
802
+ *
803
+ * - You can listen for this event and {@link module:EVENT.REMOTE_VIDEO_UNAVAILABLE REMOTE_VIDEO_UNAVAILABLE} to update the UI icon for "whether the remote camera is turned on".
804
+ * @see {@link module:TYPE.STREAM_TYPE_MAIN STREAM_TYPE_MAIN}
805
+ * @see {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB}
806
+ * @default 'remote-video-available'
807
+ * @memberof module:EVENT
808
+ * @example
809
+ * // Listen before entering the room
810
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
811
+ * const userId = event.userId;
812
+ * const streamType = event.streamType;
813
+ * trtc.startRemoteVideo({userId, streamType, view});
814
+ * });
815
+ */
816
+ readonly REMOTE_VIDEO_AVAILABLE: "remote-video-available";
817
+ /**
818
+ * Remote user stops publishing video. You will receive this notification when the remote user turns off the camera.
819
+ * @default 'remote-video-unavailable'
820
+ * @memberof module:EVENT
821
+ * @example
822
+ * // Listen before entering the room
823
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE, event => {
824
+ * const userId = event.userId;
825
+ * const streamType = event.streamType;
826
+ * // At this point, the SDK will automatically stop playing, and there is no need to call stopRemoteVideo.
827
+ * });
828
+ */
829
+ readonly REMOTE_VIDEO_UNAVAILABLE: "remote-video-unavailable";
830
+ /**
831
+ * @description Volume event<br>
832
+ * After calling the {@link TRTC#enableAudioVolumeEvaluation enableAudioVolumeEvaluation} interface to enable the volume callback, the SDK will throw this event regularly to notify the volume of each userId.<br>
833
+ * **Note**
834
+ * - The callback contains the volume of the local microphone and the volume of the remote user. The callback will be triggered regardless of whether anyone is speaking.
835
+ * - The event.result will be sorted from large to small according to the volume size.
836
+ * - When userId is an empty string, it represents the volume of the local microphone.
837
+ * - volume is a positive integer with a value of 0-100.
838
+ * @default 'audio-volume'
839
+ * @memberof module:EVENT
840
+ * @example
841
+ * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
842
+ * event.result.forEach(({ userId, volume }) => {
843
+ * const isMe = userId === ''; // When userId is an empty string, it represents the volume of the local microphone.
844
+ * if (isMe) {
845
+ * console.log(`my volume: ${volume}`);
846
+ * } else {
847
+ * console.log(`user: ${userId} volume: ${volume}`);
848
+ * }
849
+ * })
850
+ * });
851
+ *
852
+ * // Enable volume callback and trigger the event every 1000ms
853
+ * trtc.enableAudioVolumeEvaluation(1000);
854
+ */
855
+ readonly AUDIO_VOLUME: "audio-volume";
856
+ /**
857
+ * @description Network quality statistics data event, which starts to be counted after entering the room and triggers every two seconds. This data reflects the network quality of your local uplink and downlink.
858
+ * - The uplink network quality (uplinkNetworkQuality) refers to the network situation of uploading local streams (uplink connection network quality from SDK to Tencent Cloud)
859
+ * - The downlink network quality (downlinkNetworkQuality) refers to the average network situation of downloading all streams (average network quality of all downlink connections from Tencent Cloud to SDK)
860
+ *
861
+ * The enumeration values and meanings are shown in the following table:
862
+ * | Value | Meaning |
863
+ * | :--- | :---- |
864
+ * | 0 | Network state is unknown, indicating that the current trtc instance has not established an uplink/downlink connection |
865
+ * | 1 | Network state is excellent |
866
+ * | 2 | Network state is good |
867
+ * | 3 | Network state is average |
868
+ * | 4 | Network state is poor |
869
+ * | 5 | Network state is very poor |
870
+ * | 6 | Network connection is disconnected<br/>Note: If the downlink network quality is this value, it means that all downlink connections have been disconnected |
871
+ * - uplinkRTT, uplinkLoss are the uplink RTT (ms) and uplink packet loss rate.
872
+ * - downlinkRTT, downlinkLoss are the average RTT (ms) and average packet loss rate of all downlink connections.
873
+ *
874
+ * **Note**
875
+ * - If you want to know the uplink and downlink network conditions of the other party, you need to broadcast the other party's network quality through IM.
876
+ *
877
+ * @default 'network-quality'
878
+ * @memberof module:EVENT
879
+ * @example
880
+ * trtc.on(TRTC.EVENT.NETWORK_QUALITY, event => {
881
+ * console.log(`network-quality, uplinkNetworkQuality:${event.uplinkNetworkQuality}, downlinkNetworkQuality: ${event.downlinkNetworkQuality}`)
882
+ * console.log(`uplink rtt:${event.uplinkRTT} loss:${event.uplinkLoss}`)
883
+ * console.log(`downlink rtt:${event.downlinkRTT} loss:${event.downlinkLoss}`)
884
+ * })
885
+ */
886
+ readonly NETWORK_QUALITY: "network-quality";
887
+ /**
888
+ * @description SDK and Tencent Cloud connection state change event, you can use this event to listen to the overall connection state of the SDK and Tencent Cloud.<br>
889
+ * - 'DISCONNECTED': Connection disconnected
890
+ * - 'CONNECTING': Connecting
891
+ * - 'CONNECTED': Connected
892
+ *
893
+ * Meanings of different state changes:
894
+ *
895
+ * - DISCONNECTED -> CONNECTING: Trying to establish a connection, triggered when calling the enter room interface or when the SDK automatically reconnects.
896
+ * - CONNECTING -> DISCONNECTED: Connection establishment failed, triggered when calling the exit room interface to interrupt the connection or when the connection fails after SDK retries.
897
+ * - CONNECTING -> CONNECTED: Connection established successfully, triggered when the connection is successful.
898
+ * - CONNECTED -> DISCONNECTED: Connection interrupted, triggered when calling the exit room interface or when the connection is disconnected due to network anomalies.
899
+ *
900
+ * Suggestion: You can listen to this event and display different UIs in different states to remind users of the current connection state.
901
+ *
902
+ * @default 'connection-state-changed'
903
+ * @memberof module:EVENT
904
+ * @example
905
+ * trtc.on(TRTC.EVENT.CONNECTION_STATE_CHANGED, event => {
906
+ * const prevState = event.prevState;
907
+ * const curState = event.state;
908
+ * });
909
+ */
910
+ readonly CONNECTION_STATE_CHANGED: "connection-state-changed";
911
+ /**
912
+ * @description Audio playback state change event
913
+ *
914
+ * event.userId When userId is an empty string, it represents the local user, and when it is a non-empty string, it represents a remote user.
915
+ *
916
+ * event.state The value is as follows:
917
+ * - 'PLAYING': start playing
918
+ * - event.reason is 'playing' or 'unmute'.
919
+ * - 'PAUSED': pause playback
920
+ * - When event.reason is 'pause', it is triggered by the pause event of the \<audio\> element. The following situations will trigger:
921
+ * - Call the HTMLMediaElement.pause interface.
922
+ * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
923
+ * - When userId is oneself, this event is triggered, indicating that audio collection is paused, usually caused by device abnormalities, such as being preempted by other applications on the device, at this time, the user needs to be guided to recollect.
924
+ * - When userId is others, this event is triggered, indicating that the received audio data is not enough to play. Usually caused by network jitter, no processing is required on the access side. When the received data is sufficient to play, it will automatically resume.
925
+ * - 'STOPPED': stop playing
926
+ * - event.reason is 'ended'.
927
+ *
928
+ * event.reason The reason for the state change, the value is as follows:
929
+ * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
930
+ * - 'mute': The audio track cannot provide data temporarily, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
931
+ * - 'unmute': The audio track resumes providing data, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/unmute_event | MediaStreamTrack.unmute_event}
932
+ * - 'ended': The audio track has been closed
933
+ * - 'pause': Playback paused
934
+ * @default 'audio-play-state-changed'
935
+ * @memberof module:EVENT
936
+ * @example
937
+ * trtc.on(TRTC.EVENT.AUDIO_PLAY_STATE_CHANGED, event => {
938
+ * console.log(`${event.userId} player is ${event.state} because of ${event.reason}`);
939
+ * });
940
+ */
941
+ readonly AUDIO_PLAY_STATE_CHANGED: "audio-play-state-changed";
942
+ /**
943
+ * @description Video playback state change event
944
+ *
945
+ * event.userId When userId is an empty string, it represents the local user, and when it is a non-empty string, it represents a remote user.
946
+ *
947
+ * event.streamType Stream type, value: {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN} {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}
948
+ *
949
+ * event.state The value is as follows:
950
+ * - 'PLAYING': start playing
951
+ * - event.reason is 'playing' or 'unmute'.
952
+ * - 'PAUSED': pause playback
953
+ * - When event.reason is 'pause', it is triggered by the pause event of the \<video\> element. The following situations will trigger:
954
+ * - Call the HTMLMediaElement.pause interface.
955
+ * - After successful playback, the view container for playing the video is removed from the DOM.
956
+ * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
957
+ * - When userId is oneself, this event is triggered, indicating that video collection is paused, usually caused by device abnormalities, such as being preempted by other applications on the device, at this time, the user needs to be guided to recollect.
958
+ * - When userId is others, this event is triggered, indicating that the received video data is not enough to play. Usually caused by network jitter, no processing is required on the access side. When the received data is sufficient to play, it will automatically resume.
959
+ * - 'STOPPED': stop playing
960
+ * - event.reason is 'ended'.
961
+ *
962
+ * event.reason The reason for the state change, the value is as follows:
963
+ * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
964
+ * - 'mute': The video track cannot provide data temporarily, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
965
+ * - 'unmute': The video track resumes providing data, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/unmute_event | MediaStreamTrack.unmute_event}
966
+ * - 'ended': The video track has been closed
967
+ * - 'pause': Playback paused
968
+ * @default 'video-play-state-changed'
969
+ * @memberof module:EVENT
970
+ * @example
971
+ * trtc.on(TRTC.EVENT.VIDEO_PLAY_STATE_CHANGED, event => {
972
+ * console.log(`${event.userId} ${event.streamType} video player is ${event.state} because of ${event.reason}`);
973
+ * });
974
+ */
975
+ readonly VIDEO_PLAY_STATE_CHANGED: "video-play-state-changed";
976
+ /**
977
+ * @description Notification event for local screen sharing stop, only valid for local screen sharing streams.
978
+ * @default 'screen-share-stopped'
979
+ * @memberof module:EVENT
980
+ * @example
981
+ * trtc.on(TRTC.EVENT.SCREEN_SHARE_STOPPED, () => {
982
+ * console.log('screen sharing was stopped');
983
+ * });
984
+ */
985
+ readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
986
+ /**
987
+ * @description Notification event for device changes such as camera and microphone.
988
+ * - event.device is a [MediaDeviceInfo](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) object with properties:
989
+ * - deviceId: device ID
990
+ * - label: device description information
991
+ * - groupId: device group ID
992
+ * - event.type value: `'camera'|'microphone'|'speaker'`
993
+ * - event.action value:
994
+ * - 'add' device has been added.
995
+ * - 'remove' device has been removed.
996
+ * - 'active' device has been activated, for example: after startLocalVideo is successful, this event will be triggered.
997
+ * @default 'device-changed'
998
+ * @memberof module:EVENT
999
+ * @example
1000
+ * trtc.on(TRTC.EVENT.DEVICE_CHANGED, (event) => {
1001
+ * console.log(`${event.type}(${event.device.label}) ${event.action}`);
1002
+ * });
1003
+ */
1004
+ readonly DEVICE_CHANGED: "device-changed";
1005
+ /**
1006
+ * @description Publish state change event.
1007
+ * - event.mediaType media type, value: `'audio'|'video'|'screen'`.
1008
+ * - event.state current publish state, value:
1009
+ * - `'starting'` trying to publish stream
1010
+ * - `'started'` publish stream succeeded
1011
+ * - `'stopped'` publish stream stopped, see event.reason field for the reason
1012
+ * - event.prevState the publish state at the last event trigger, with the same type as event.state.
1013
+ * - event.reason the reason for the publish state to become `'stopped'`, value:
1014
+ * - `'timeout'` publish stream timeout, usually caused by network jitter or firewall interception. The SDK will keep retrying, and the business side can guide the user to check the network or change the network at this time.
1015
+ * - `'error'` publish stream error, at this time, you can get the specific error information from event.error, usually caused by the browser not supporting H264 encoding.
1016
+ * - `'api-call'` publish stream stopped due to business side API call, for example, stopLocalVideo was called to stop the publish stream before startLocalVideo was successful, which is a normal behavior and the business side does not need to pay attention to it.
1017
+ * - event.error error information when event.reason is `'error'`.
1018
+ * @default 'publish-state-changed'
1019
+ * @memberof module:EVENT
1020
+ * @example
1021
+ * trtc.on(TRTC.EVENT.PUBLISH_STATE_CHANGED, (event) => {
1022
+ * console.log(`${event.mediaType} ${event.state} ${event.reason}`);
1023
+ * });
1024
+ */
1025
+ readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
1026
+ /**
1027
+ * @since v5.3.0
1028
+ * @description a new MediaStreamTrack object received.
1029
+ * @default 'track'
1030
+ * @memberof module:EVENT
1031
+ * @example
1032
+ * trtc.on(TRTC.EVENT.TRACK, event => {
1033
+ * // userId === '' means event.track is a local track, otherwise it's a remote track
1034
+ * const isLocal = event.userId === '';
1035
+ * // Usually the sub stream is a screen-sharing video stream.
1036
+ * const isSubStream = event.streamType === TRTC.TYPE.STREAM_TYPE_SUB;
1037
+ * const mediaStreamTrack = event.track;
1038
+ * const kind = event.track.kind; // audio or video
1039
+ * })
1040
+ */
1041
+ readonly TRACK: "track";
1042
+ /**
1043
+ * @description TRTC statistics.<br>
1044
+ *
1045
+ * - SDK will fires this event once every 2s.
1046
+ * - You can get the network quality, statistics of audio and video from this event. For detailed parameter description, please refer to {@link TRTCStatistics}.
1047
+ * @default 'statistics'
1048
+ * @since v5.2.0
1049
+ * @memberof module:EVENT
1050
+ * @example
1051
+ * trtc.on(TRTC.EVENT.STATISTICS, statistics => {
1052
+ * console.warn(statistics.rtt, statistics.upLoss, statistics.downLoss);
1053
+ * })
1054
+ */
1055
+ readonly STATISTICS: "statistics";
1056
+ /**
1057
+ * @since v5.3.0
1058
+ * @description SEI message received<br>
1059
+ * @default 'sei-message'
1060
+ * @memberof module:EVENT
1061
+ * @example
1062
+ * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
1063
+ * console.log(`received sei message from ${event.userId}, data: ${event.data}, streamType: ${event.streamType}`)
1064
+ * })
1065
+ */
1066
+ readonly SEI_MESSAGE: "sei-message";
1067
+ /**
1068
+ * @since v5.6.0
1069
+ * @description received a new custom message.
1070
+ * @default 'custom-message'
1071
+ * @memberof module:EVENT
1072
+ * @example
1073
+ * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
1074
+ * // event.userId: remote userId.
1075
+ * // event.cmdId: message cmdId.
1076
+ * // event.seq: message sequence number.
1077
+ * // event.data: custom message data, type is ArrayBuffer.
1078
+ * })
1079
+ */
1080
+ readonly CUSTOM_MESSAGE: "custom-message";
828
1081
  };
829
- declare interface TRTCEventTypes {
830
- [TRTCEvent.ERROR]: [RtcError];
831
- [TRTCEvent.AUTOPLAY_FAILED]: [{
832
- userId: string;
833
- }];
834
- [TRTCEvent.KICKED_OUT]: [{
835
- reason: Exclude<BannedReason, 'user_time_out'>;
836
- }];
837
- [TRTCEvent.REMOTE_USER_ENTER]: [{
838
- userId: string;
839
- }];
840
- [TRTCEvent.REMOTE_USER_EXIT]: [{
841
- userId: string;
842
- }];
843
- [TRTCEvent.REMOTE_AUDIO_AVAILABLE]: [{
844
- userId: string;
845
- }];
846
- [TRTCEvent.REMOTE_AUDIO_UNAVAILABLE]: [{
847
- userId: string;
848
- }];
849
- [TRTCEvent.REMOTE_VIDEO_AVAILABLE]: [{
850
- userId: string;
851
- streamType: TRTCStreamType;
852
- }];
853
- [TRTCEvent.REMOTE_VIDEO_UNAVAILABLE]: [{
854
- userId: string;
855
- streamType: TRTCStreamType;
856
- }];
857
- [TRTCEvent.AUDIO_VOLUME]: [{
858
- result: {
859
- userId: string;
860
- volume: number;
861
- }[];
862
- }];
863
- [TRTCEvent.NETWORK_QUALITY]: [NetworkQuality];
864
- [TRTCEvent.CONNECTION_STATE_CHANGED]: [{
865
- prevState: ConnectionState;
866
- state: ConnectionState;
867
- }];
868
- [TRTCEvent.AUDIO_PLAY_STATE_CHANGED]: [{
869
- userId: string;
870
- state: PlayerState;
871
- reason: string;
872
- }];
873
- [TRTCEvent.VIDEO_PLAY_STATE_CHANGED]: [{
874
- userId: string;
875
- streamType: TRTCStreamType;
876
- state: PlayerState;
877
- reason: string;
878
- }];
879
- [TRTCEvent.SCREEN_SHARE_STOPPED]: [];
880
- [TRTCEvent.DEVICE_CHANGED]: [{
881
- type: TRTCDeviceType;
882
- action: TRTCDeviceAction;
883
- device: DeviceInfo;
884
- }];
885
- [TRTCEvent.PUBLISH_STATE_CHANGED]: [
886
- {
887
- mediaType: 'audio' | 'video' | 'screen';
888
- state: 'started' | 'stopped' | 'starting';
889
- prevState: 'started' | 'stopped' | 'starting';
890
- reason?: 'timeout' | 'error' | 'api-call';
891
- error?: RtcError;
892
- }
893
- ];
894
- [TRTCEvent.SEI_MESSAGE]: [{
895
- data: ArrayBuffer;
896
- userId: string;
897
- streamType: TRTCStreamType;
898
- seiPayloadType: number;
899
- }];
900
- [TRTCEvent.STATISTICS]: [statistics: TRTCStatistics];
901
- [TRTCEvent.TRACK]: [{
902
- userId: string;
903
- streamType?: TRTCStreamType;
904
- track: MediaStreamTrack;
905
- }];
906
- [TRTCEvent.CUSTOM_MESSAGE]: [CustomMessage];
1082
+ export declare interface TRTCEventTypes {
1083
+ [TRTCEvent.ERROR]: [RtcError];
1084
+ [TRTCEvent.AUTOPLAY_FAILED]: [{
1085
+ userId: string;
1086
+ }];
1087
+ [TRTCEvent.KICKED_OUT]: [{
1088
+ reason: Exclude<BannedReason, 'user_time_out'>;
1089
+ }];
1090
+ [TRTCEvent.REMOTE_USER_ENTER]: [{
1091
+ userId: string;
1092
+ }];
1093
+ [TRTCEvent.REMOTE_USER_EXIT]: [{
1094
+ userId: string;
1095
+ }];
1096
+ [TRTCEvent.REMOTE_AUDIO_AVAILABLE]: [{
1097
+ userId: string;
1098
+ }];
1099
+ [TRTCEvent.REMOTE_AUDIO_UNAVAILABLE]: [{
1100
+ userId: string;
1101
+ }];
1102
+ [TRTCEvent.REMOTE_VIDEO_AVAILABLE]: [{
1103
+ userId: string;
1104
+ streamType: TRTCStreamType;
1105
+ }];
1106
+ [TRTCEvent.REMOTE_VIDEO_UNAVAILABLE]: [{
1107
+ userId: string;
1108
+ streamType: TRTCStreamType;
1109
+ }];
1110
+ [TRTCEvent.AUDIO_VOLUME]: [{
1111
+ result: {
1112
+ userId: string;
1113
+ volume: number;
1114
+ }[];
1115
+ }];
1116
+ [TRTCEvent.NETWORK_QUALITY]: [NetworkQuality];
1117
+ [TRTCEvent.CONNECTION_STATE_CHANGED]: [{
1118
+ prevState: ConnectionState;
1119
+ state: ConnectionState;
1120
+ }];
1121
+ [TRTCEvent.AUDIO_PLAY_STATE_CHANGED]: [{
1122
+ userId: string;
1123
+ state: PlayerState;
1124
+ reason: string;
1125
+ }];
1126
+ [TRTCEvent.VIDEO_PLAY_STATE_CHANGED]: [{
1127
+ userId: string;
1128
+ streamType: TRTCStreamType;
1129
+ state: PlayerState;
1130
+ reason: string;
1131
+ }];
1132
+ [TRTCEvent.SCREEN_SHARE_STOPPED]: [];
1133
+ [TRTCEvent.DEVICE_CHANGED]: [{
1134
+ type: TRTCDeviceType;
1135
+ action: TRTCDeviceAction;
1136
+ device: MediaDeviceInfo;
1137
+ }];
1138
+ [TRTCEvent.PUBLISH_STATE_CHANGED]: [
1139
+ {
1140
+ mediaType: 'audio' | 'video' | 'screen';
1141
+ state: 'started' | 'stopped' | 'starting';
1142
+ prevState: 'started' | 'stopped' | 'starting';
1143
+ reason?: 'timeout' | 'error' | 'api-call';
1144
+ error?: RtcError;
1145
+ }
1146
+ ];
1147
+ [TRTCEvent.SEI_MESSAGE]: [{
1148
+ data: ArrayBuffer;
1149
+ userId: string;
1150
+ streamType: TRTCStreamType;
1151
+ seiPayloadType: number;
1152
+ }];
1153
+ [TRTCEvent.STATISTICS]: [statistics: TRTCStatistics];
1154
+ [TRTCEvent.TRACK]: [{
1155
+ userId: string;
1156
+ streamType?: TRTCStreamType;
1157
+ track: MediaStreamTrack;
1158
+ }];
1159
+ [TRTCEvent.CUSTOM_MESSAGE]: [CustomMessage];
1160
+ }
1161
+
1162
+ export declare interface CustomMessageData {
1163
+ cmdId: number;
1164
+ data: ArrayBuffer;
1165
+ }
1166
+ export declare interface CustomMessage extends CustomMessageData {
1167
+ userId: string;
1168
+ seq: number;
907
1169
  }
908
- class TRTC extends EventEmitter<TRTCEventTypes> {
909
- /**
910
- * Create a TRTC object for implementing functions such as entering a room, previewing, publishing, and subscribing streams.<br>
911
- *
912
- * **Note:**
913
- * - You must create a TRTC object first and call its methods and listen to its events to implement various functions required by the business.
914
- * @example
915
- * // Create a TRTC object
916
- * const trtc = TRTC.create();
917
- *
918
- * @returns {TRTC} TRTC object
919
- */
920
- static create(options?: TRTCOptions): TRTC;
921
- get room(): IRoom;
922
- /**
923
- * @private
924
- * 注册插件 <br>
925
- *
926
- * @example
927
- * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
928
- * trtc.use({ plugin: VirtualBackground });
929
- *
930
- * @example
931
- * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
932
- * trtc.use({ plugin: VirtualBackground, assetsPath: './js/assets/' });
933
- *
934
- * @example
935
- * // 简写使用
936
- * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
937
- * trtc.use(VirtualBackground);
938
- */
939
- use(pluginObject: PluginWithAssets | IPluginClass): void;
940
- _use(pluginClass: IPluginClass, assetsPath?: string): void;
941
- /**
942
- * @typedef TurnServer
943
- * @property {string} url TURN server url
944
- * @property {string=} username TURN server auth user name
945
- * @property {string=} credential TURN server password
946
- * @property {string=} [credentialType=password] TURN server verify password type
947
- */
948
- /**
949
- * @typedef ProxyServer
950
- * @property {string} [websocketProxy] websocket service proxy
951
- * @property {string} [loggerProxy] log service agent
952
- * @property {TurnServer[]} [turnServer] media data transmission agent
953
- * @property {'all'|'relay'} [iceTransportPolicy='all'] 'all' gives priority to directly connecting to TRTC, and tries to go to the turn server if the connection fails.<br>
954
- * 'relay' forces the connection through the TURN server.
955
- */
956
- /**
957
- * Enter a video call room.<br>
958
- * - Entering a room means starting a video call session. Only after entering the room successfully can you make audio and video calls with other users in the room.
959
- * - You can publish local audio and video streams through {@link TRTC#startLocalVideo startLocalVideo()} and {@link TRTC#startLocalAudio startLocalAudio()} respectively. After successful publishing, other users in the room will receive the {@link module:EVENT.REMOTE_AUDIO_AVAILABLE REMOTE_AUDIO_AVAILABLE} and {@link module:EVENT.REMOTE_VIDEO_AVAILABLE REMOTE_VIDEO_AVAILABLE} event notifications.
960
- * - By default, the SDK automatically plays remote audio. You need to call {@link TRTC#startRemoteVideo startRemoteVideo()} to play remote video.
961
- *
962
- * @param {object} options Enter room parameters
963
- * @param {number} options.sdkAppId sdkAppId <br>
964
- * You can obtain the sdkAppId information in the **Application Information** section after creating a new application by clicking **Application Management** > **Create Application** in the [TRTC Console](https://console.intl.cloud.tencent.com/trtc).
965
- * @param {string} options.userId User ID <br>
966
- * It is recommended to limit the length to 32 bytes, and only allow uppercase and lowercase English letters (a-zA-Z), numbers (0-9), underscores, and hyphens.
967
- * @param {string} options.userSig UserSig signature <br>
968
- * Please refer to [UserSig related](https://www.tencentcloud.com/document/product/647/35166) for the calculation method of userSig.
969
- * @param {number=} options.roomId
970
- * the value must be an integer between 1 and 4294967294<br>
971
- * <font color="red">If you need to use a string type room id, please use the strRoomId parameter. One of roomId and strRoomId must be passed in. If both are passed in, the roomId will be selected first.</font>
972
- * @param {string=} options.strRoomId
973
- * String type room id, the length is limited to 64 bytes, and only supports the following characters:
974
- * - Uppercase and lowercase English letters (a-zA-Z)
975
- * - Numbers (0-9)
976
- * - Space ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | ~ ,
977
- * <font color="red">Note: It is recommended to use a numeric type roomId. The string type room id "123" is not the same room as the numeric type room id 123.</font>
978
- * @param {string} [options.scene] Application scene, currently supports the following two scenes:
979
- * - {@link module:TYPE.SCENE_RTC TRTC.TYPE.SCENE_RTC} (default) Real-time call scene, which is suitable for 1-to-1 audio and video calls, or online meetings with up to 300 participants. {@tutorial 04-info-uplink-limits}.
980
- * - {@link module:TYPE.SCENE_LIVE TRTC.TYPE.SCENE_LIVE} Interactive live streaming scene, which is suitable for online live streaming scenes with up to 100,000 people, but you need to specify the role field in the options parameter introduced next.
981
- * @param {string=} [options.role] User role, only meaningful in the {@link module:TYPE.SCENE_LIVE TRTC.TYPE.SCENE_LIVE} scene, and the {@link module:TYPE.SCENE_RTC TRTC.TYPE.SCENE_RTC} scene does not need to specify the role. Currently supports two roles:
982
- * - {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} (default) Anchor
983
- * - {@link module:TYPE.ROLE_AUDIENCE TRTC.TYPE.ROLE_AUDIENCE} Audience
984
- * Note: The audience role does not have the permission to publish local audio and video, only the permission to watch remote streams. If the audience wants to interact with the anchor by connecting to the microphone, please switch the role to the anchor through {@link TRTC#switchRole switchRole()} before publishing local audio and video.
985
- * @param {boolean} [options.autoReceiveAudio=true] Whether to automatically receive audio. When a remote user publishes audio, the SDK automatically plays the remote user's audio.
986
- * @param {boolean} [options.autoReceiveVideo=false] Whether to automatically receive video. When a remote user publishes video, the SDK automatically subscribes and decodes the remote video. You need to call {@link TRTC#startRemoteVideo startRemoteVideo} to play the remote video.
987
- * - The default value was changed to `false` since v5.6.0. Refer to [Breaking Changed for v5.6.0](https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/tutorial-00-info-update-guideline.html).
988
- * @param {boolean} [options.enableAutoPlayDialog] Whether to enable the SDK's automatic playback failure dialog box, default: true.
989
- * - Enabled by default. When automatic playback fails, the SDK will pop up a dialog box to guide the user to click the page to restore audio and video playback.
990
- * - Can be set to false in order to turn off. Refer to {@tutorial 21-advanced-auto-play-policy}.
991
- * @param {string|ProxyServer} [options.proxy] proxy config. Refer to {@tutorial 34-advanced-proxy}.
992
- * @param {boolean} [options.privateMapKey] Key for entering a room. If permission control is required, please carry this parameter (empty or incorrect value will cause a failure in entering the room).<br>[privateMapKey permission configuration](https://www.tencentcloud.com/document/product/647/35157?lang=en&pg=).
993
- * @throws
994
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
995
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
996
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
997
- * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
998
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
999
- * @example
1000
- * const trtc = TRTC.create();
1001
- * await trtc.enterRoom({ roomId: 8888, sdkAppId, userId, userSig });
1002
- */
1003
- enterRoom(params: EnterRoomConfig): Promise<void>;
1004
- /**
1005
- * Exit the current audio and video call room.
1006
- * - After exiting the room, the connection with remote users will be closed, and remote audio and video will no longer be received and played, and the publishing of local audio and video will be stopped.
1007
- * - The capture and preview of the local camera and microphone will not stop. You can call {@link TRTC#stopLocalVideo stopLocalVideo()} and {@link TRTC#stopLocalAudio stopLocalAudio()} to stop capturing local microphone and camera.
1008
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1009
- * @memberof TRTC
1010
- * @example
1011
- * await trtc.exitRoom();
1012
- */
1013
- exitRoom(): Promise<void>;
1014
- /**
1015
- * Switches the user role, only effective in TRTC.TYPE.SCENE_LIVE interactive live streaming mode.
1016
- *
1017
- * In interactive live streaming mode, a user may need to switch between "audience" and "anchor".
1018
- * You can determine the role through the role field in {@link TRTC#enterRoom enterRoom()}, or switch roles after entering the room through switchRole.
1019
- * - Audience switches to anchor, call trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR) to convert the user role to TRTC.TYPE.ROLE_ANCHOR anchor role, and then call {@link TRTC#startLocalVideo startLocalVideo()} and {@link TRTC#startLocalAudio startLocalAudio()} to publish local audio and video as needed.
1020
- * - Anchor switches to audience, call trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE) to convert the user role to TRTC.TYPE.ROLE_AUDIENCE audience role. If there is already published local audio and video, the SDK will cancel the publishing of local audio and video.
1021
- * > !
1022
- * > - This interface can only be called after entering the room successfully.
1023
- * > - After closing the camera and microphone, it is recommended to switch to the audience role in time to avoid the anchor role occupying the resources of 50 upstreams.
1024
- * @param {string} role User role
1025
- * - TRTC.TYPE.ROLE_ANCHOR anchor, can publish local audio and video, up to 50 anchors can publish local audio and video in a single room at the same time.
1026
- * - TRTC.TYPE.ROLE_AUDIENCE audience, cannot publish local audio and video, can only watch remote streams, and there is no upper limit on the number of audience members in a single room.
1027
- * @param {object} [option]
1028
- * @param {string} [option.privateMapKey] `Since v5.3.0+` <br>
1029
- * The privateMapKey may expire after a timeout, so you can use this parameter to update the privateMapKey.
1030
- * @throws
1031
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1032
- * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1033
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1034
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1035
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1036
- * @memberof TRTC
1037
- * @example
1038
- * // After entering the room successfully
1039
- * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, audience switches to anchor
1040
- * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR);
1041
- * // Switch from audience role to anchor role and start streaming
1042
- * await trtc.startLocalVideo();
1043
- *
1044
- * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, anchor switches to audience
1045
- * await trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE);
1046
- * @example
1047
- * // Since v5.3.0+
1048
- * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR, { privateMapKey: 'your new privateMapKey' });
1049
- */
1050
- switchRole(role: UserRole, option?: {
1051
- privateMapKey?: string;
1052
- latencyLevel?: number;
1053
- }): Promise<void>;
1054
- /**
1055
- * Destroy the TRTC instance <br/>
1056
- *
1057
- * After exiting the room, if the business side no longer needs to use trtc, you need to call this interface to destroy the trtc instance in time and release related resources.
1058
- *
1059
- * Note:
1060
- * - The trtc instance after destruction cannot be used again.
1061
- * - If you have entered the room, you need to call the {@link TRTC#exitRoom TRTC.exitRoom} interface to exit the room successfully before calling this interface to destroy trtc.
1062
- *
1063
- * @example
1064
- * // When the call is over
1065
- * await trtc.exitRoom();
1066
- * // If the trtc is no longer needed, destroy the trtc and release the reference.
1067
- * trtc.destroy();
1068
- * trtc = null;
1069
- * @throws {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1070
- * @memberof TRTC
1071
- */
1072
- destroy(): void;
1073
- /**
1074
- * Start collecting audio from the local microphone and publish it to the current room.
1075
- * - When to call: can be called before or after entering the room, cannot be called repeatedly.
1076
- * - Only one microphone can be opened for a trtc instance. If you need to open another microphone for testing in the case of already opening one microphone, you can create multiple trtc instances to achieve it.
1077
- *
1078
- * @param {object} [config] - Configuration item
1079
- * @param {boolean} [config.publish] - Whether to publish local audio to the room, default is true. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1080
- * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1081
- * @param {object} [config.option] - Local audio options
1082
- * @param {string} [config.option.microphoneId]- Specify which microphone to use
1083
- * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1084
- * @param {number} [config.option.captureVolume] - Set the capture volume of microphone. The default value is 100. Setting above 100 enlarges the capture volume. Since v5.2.1+.
1085
- * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1086
- * @param {string} [config.option.profile] - Audio encoding configuration, default {@link module:TYPE.AUDIO_PROFILE_STANDARD TRTC.TYPE.AUDIO_PROFILE_STANDARD}
1087
- * @throws
1088
- * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1089
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1090
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1091
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1092
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1093
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1094
- * @example
1095
- * // Collect the default microphone and publish
1096
- * await trtc.startLocalAudio();
1097
- * @example
1098
- * // The following is a code example for testing microphone volume, which can be used for microphone volume detection.
1099
- * trtc.enableAudioVolumeEvaluation();
1100
- * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => { });
1101
- * // No need to publish audio for testing microphone
1102
- * await trtc.startLocalAudio({ publish: false });
1103
- * // After the test is completed, turn off the microphone
1104
- * await trtc.stopLocalAudio();
1105
- * @memberof TRTC
1106
- */
1107
- startLocalAudio(config?: LocalAudioConfig): Promise<void>;
1108
- /**
1109
- * Update the configuration of the local microphone.
1110
- * - When to call: This interface needs to be called after {@link TRTC#startLocalAudio startLocalAudio()} is successful and can be called multiple times.
1111
- * - This method uses incremental update: only update the passed parameters, and keep the parameters that are not passed unchanged.
1112
- * @param {object} [config]
1113
- * @param {boolean} [config.publish] - Whether to publish local audio to the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1114
- * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1115
- * @param {object} [config.option] - Local audio configuration
1116
- * @param {string} [config.option.microphoneId] - Specify which microphone to use to switch microphones.
1117
- * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1118
- * @param {number} [config.option.captureVolume] - Set the capture volume of microphone. The default value is 100. Setting above 100 enlarges the capture volume. Since v5.2.1+.
1119
- * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1120
- * @throws
1121
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1122
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1123
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1124
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1125
- * @example
1126
- * // Switch microphone
1127
- * const microphoneList = await TRTC.getMicrophoneList();
1128
- * if (microphoneList[1]) {
1129
- * await trtc.updateLocalAudio({ option: { microphoneId: microphoneList[1].deviceId }});
1130
- * }
1131
- * @memberof TRTC
1132
- */
1133
- updateLocalAudio(config: UpdateLocalAudioConfig): Promise<void>;
1134
- /**
1135
- * Stop collecting and publishing the local microphone.
1136
- * - If you just want to mute the microphone, please use updateLocalAudio({ mute: true }). Refer to: {@tutorial 15-basic-dynamic-add-video}.
1137
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1138
- * @example
1139
- * await trtc.stopLocalAudio();
1140
- */
1141
- stopLocalAudio(): Promise<void>;
1142
- /**
1143
- * @typedef {object|string} VideoProfile - Configuration for local video stream
1144
- *
1145
- * Video configuration parameters, can use preset values in string format or custom resolution and other parameters
1146
- * | Video Profile | Resolution (Width x Height) | Frame Rate (fps) | Bitrate (kbps) | Remarks |
1147
- * | :--- | :--- | :--- | :--- | :--- |
1148
- * | 120p | 160 x 120 | 15 | 200 ||
1149
- * | 180p | 320 x 180 | 15 | 350 ||
1150
- * | 240p | 320 x 240 | 15 | 400 ||
1151
- * | 360p | 640 x 360 | 15 | 800 ||
1152
- * | 480p | 640 x 480 | 15 | 900 ||
1153
- * | 720p | 1280 x 720 | 15 | 1500 ||
1154
- * | 1080p | 1920 x 1080 | 15 | 2000 ||
1155
- * | 1440p | 2560 x 1440 | 30 | 4860 ||
1156
- * | 4K | 3840 x 2160 | 30 | 9000 ||
1157
- * @property {number} width - Video width
1158
- * @property {number} height - Video height
1159
- * @property {number} frameRate - Video frame rate
1160
- * @property {number} bitrate - Video bitrate
1161
- * @example
1162
- * const config = {
1163
- * option: {
1164
- * profile: '480p',
1165
- * },
1166
- * }
1167
- * await trtc.startLocalVideo(config);
1168
- * @example
1169
- * const config = {
1170
- * option: {
1171
- * profile: {
1172
- * width: 640,
1173
- * height: 480,
1174
- * frameRate: 15,
1175
- * bitrate: 900,
1176
- * }
1177
- * }
1178
- * }
1179
- * await trtc.startLocalVideo(config);
1180
- */
1181
- /**
1182
- * Start collecting video from the local camera, play the camera's video on the specified HTMLElement tag, and publish the camera's video to the current room.
1183
- * - When to call: can be called before or after entering the room, but cannot be called repeatedly.
1184
- * - Only one camera can be started per trtc instance. If you need to start another camera for testing while one camera is already started, you can create multiple trtc instances to achieve this.
1185
-
1186
- * @param {object} [config]
1187
- * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or ID for local video preview. If not passed or passed as null, the video will not be played.
1188
- * @param {boolean} [config.publish] - Whether to publish the local video to the room. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1189
- * @param {boolean | string} [config.mute] - Whether to mute camera. Supports passing in image url string, the image will be published instead of origin camera stream, Other users in the room will receive the REMOTE_AUDIO_AVAILABLE event. It does not support calling when the camera is turned off. More information: {@tutorial 15-basic-dynamic-add-video}.
1190
- * @param {object} [config.option] - Local video configuration
1191
- * @param {string} [config.option.cameraId] - Specify which camera to use for switching cameras.
1192
- * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera.
1193
- * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1194
- * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
1195
- * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
1196
- * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
1197
- * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
1198
- * - false: Boolean value, represents no mirroring.
1199
- *
1200
- * <font color="orange"> Note: Before version 5.3.2, only boolean can be passed, where true represents local preview mirroring, and false represents no mirroring.</font>
1201
- * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `cover`. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1202
- * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main video.
1203
- * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1204
- * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first(default) ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1205
- * @throws
1206
- * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1207
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1208
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1209
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1210
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1211
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1212
- * @example
1213
- * // Preview and publish the camera
1214
- * await trtc.startLocalVideo({
1215
- * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1216
- * });
1217
- * @example
1218
- * // Preview the camera without publishing. Can be used for camera testing.
1219
- * const config = {
1220
- * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1221
- * publish: false // Do not publish the camera
1222
- * }
1223
- * await trtc.startLocalVideo(config);
1224
- * // Call updateLocalVideo when you need to publish the video
1225
- * await trtc.updateLocalVideo({ publish:true });
1226
- * @example
1227
- * // Use a specified camera.
1228
- * const cameraList = await TRTC.getCameraList();
1229
- * if (cameraList[0]) {
1230
- * await trtc.startLocalVideo({
1231
- * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1232
- * option: {
1233
- * cameraId: cameraList[0].deviceId,
1234
- * }
1235
- * });
1236
- * }
1237
- *
1238
- * // use front camera on mobile device.
1239
- * await trtc.startLocalVideo({ view, option: { useFrontCamera: true }});
1240
- * // use rear camera on mobile device.
1241
- * await trtc.startLocalVideo({ view, option: { useFrontCamera: false }});
1242
- * @memberof TRTC
1243
- */
1244
- startLocalVideo(config?: LocalVideoConfig): Promise<void>;
1245
- /**
1246
- * Update the local camera configuration.
1247
- * - This interface needs to be called after {@link TRTC#startLocalVideo startLocalVideo()} is successful.
1248
- * - This interface can be called multiple times.
1249
- * - This method uses incremental update: only updates the passed-in parameters, and keeps the parameters that are not passed in unchanged.
1250
- * @param {object} [config]
1251
- * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id of the preview camera. If not passed in or passed in null, the video will not be rendered, but the container that consumes bandwidth will still be pushed.
1252
- * @param {boolean} [config.publish] - Whether to publish the local video to the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1253
- * @param {boolean | string} [config.mute] - Whether to mute camera. Supports passing in image url string, the image will be published instead of origin camera stream, Other users in the room will receive the REMOTE_AUDIO_AVAILABLE event. It does not support calling when the camera is turned off. More information: {@tutorial 15-basic-dynamic-add-video}.
1254
- * @param {object} [config.option] - Local video configuration
1255
- * @param {string} [config.option.cameraId] - Specify which camera to use
1256
- * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera
1257
- * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1258
- * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
1259
- * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
1260
- * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
1261
- * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
1262
- * - false: Boolean value, represents no mirroring.
1263
- * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit| CSS object-fit} property
1264
- * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main stream
1265
- * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1266
- * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1267
- * @throws
1268
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1269
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1270
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1271
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1272
- * @example
1273
- * // Switch camera
1274
- * const cameraList = await TRTC.getCameraList();
1275
- * if (cameraList[1]) {
1276
- * await trtc.updateLocalVideo({ option: { cameraId: cameraList[1].deviceId }});
1277
- * }
1278
- * @example
1279
- * // Stop publishing video, but keep local preview
1280
- * await trtc.updateLocalVideo({ publish:false });
1281
- * @memberof TRTC
1282
- */
1283
- updateLocalVideo(config: LocalVideoConfig): Promise<void>;
1284
- /**
1285
- * Stop capturing, previewing, and publishing the local camera.
1286
- * - If you only want to stop publishing video but keep the local camera preview, you can use the {@link TRTC#updateLocalVideo updateLocalVideo({ publish:false })} method.<br>
1287
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1288
- * @example
1289
- * await trtc.stopLocalVideo();
1290
- */
1291
- stopLocalVideo(): Promise<void>;
1292
- /**
1293
- * @typedef {object|string} ScreenShareProfile - Screen sharing resolution, bit rate, and frame rate configuration
1294
- * Screen sharing configuration parameters, can use preset values or custom resolution and other parameters
1295
- * | Screen Profile | Resolution (width x height) | Frame Rate (fps) | Bitrate (kbps) |
1296
- * | :--- | :--- | :--- | :--- |
1297
- * | 480p | 640 x 480 | 5 | 900 |
1298
- * | 480p_2 | 640 x 480 | 30 | 1000 |
1299
- * | 720p | 1280 x 720 | 5 | 1200 |
1300
- * | 720p_2 | 1280 x 720 | 30 | 3000 |
1301
- * | 1080p | 1920 x 1080 | 5 | 1600 |
1302
- * | 1080p_2 | 1920 x 1080 | 30 | 4000 |
1303
- * - The default resolution for screen sharing is `1080p`.
1304
- * - If the above profiles do not meet your business needs, you can also specify custom resolution, frame rate, and bitrate.
1305
-
1306
- * @property {number} width - Screen sharing width
1307
- * @property {number} height - Screen sharing height
1308
- * @property {number} frameRate - Screen sharing frame rate
1309
- * @property {number} bitrate - Screen sharing bitrate
1310
- * @example
1311
- * const config = {
1312
- * option: {
1313
- * profile: '720p',
1314
- * },
1315
- * }
1316
- * await trtc.startScreenShare(config);
1317
- */
1318
- /**
1319
- * Start screen sharing.
1320
- *
1321
- * - After starting screen sharing, other users in the room will receive the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE REMOTE_VIDEO_AVAILABLE} event, with streamType as {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB}, and other users can play screen sharing through {@link TRTC#startRemoteVideo startRemoteVideo}.
1322
- * @param {object} [config]
1323
- * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id for previewing local screen sharing. If not passed or passed as null, local screen sharing will not be rendered.
1324
- * @param {boolean} [config.publish] - Whether to publish screen sharing to the room. The default is true. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1325
- * @param {object} [config.option] - Screen sharing configuration
1326
- * @param {boolean} [config.option.systemAudio] - Whether to capture system audio. The default is false.
1327
- * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `contain`, refer to {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1328
- * @param {ScreenShareProfile} [config.option.profile] - Screen sharing encoding configuration.
1329
- * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first(default) ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1330
- * @param {HTMLElement} [config.option.captureElement] - Capture screen from the specified element of current tab. Available on Chrome 104+.
1331
- * @param {'current-tab' | 'tab' | 'window' | 'monitor'} [config.option.preferDisplaySurface='monitor'] - The prefer display surface for screen sharing. Available on Chrome 94+.
1332
- * - The default is monitor, which means that monitor capture will be displayed first in the Screen Sharing Capture pre-checkbox。
1333
- * - If you fill in 'current-tab', the pre-checkbox will only show the current page.
1334
- * @throws
1335
- * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1336
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1337
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1338
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1339
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1340
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1341
- * @example
1342
- * // Start screen sharing
1343
- * await trtc.startScreenShare();
1344
- * @memberof TRTC
1345
- */
1346
- startScreenShare(config?: ScreenShareConfig): Promise<void>;
1347
- /**
1348
- * Update screen sharing configuration
1349
- * - This interface needs to be called after {@link TRTC#startScreenShare startScreenShare()} is successful.
1350
- * - This interface can be called multiple times.
1351
- * - This method uses incremental update: only update the passed-in parameters, and keep the parameters that are not passed-in unchanged.
1352
- * @param {object} [config]
1353
- * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id for screen sharing preview. If not passed in or passed in null, the screen sharing will not be rendered.
1354
- * @param {boolean} [config.publish=true] - Whether to publish screen sharing to the room
1355
- * @param {object} [config.option] - Screen sharing configuration
1356
- * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `contain`, refer to {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1357
- * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1358
- * @throws
1359
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1360
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1361
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1362
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1363
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1364
- * @example
1365
- * // Stop screen sharing, but keep the local preview of screen sharing
1366
- * await trtc.updateScreenShare({ publish:false });
1367
- * @memberof TRTC
1368
- */
1369
- updateScreenShare(config: UpdateScreenShareConfig): Promise<void>;
1370
- /**
1371
- * Stop screen sharing.
1372
-
1373
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1374
- * @example
1375
- * await trtc.stopScreenShare();
1376
- */
1377
- stopScreenShare(): Promise<void>;
1378
- /**
1379
- * Play remote video
1380
- *
1381
- * - When to call: Call after receiving the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE TRTC.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE)} event.
1382
- * @param {object} [config]
1383
- * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id used to play remote video. If not passed or passed null, the video will not be rendered, but the bandwidth will still be consumed.
1384
- * @param {string} config.userId - Remote user ID
1385
- * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1386
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1387
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1388
- * @param {object} [config.option] - Remote video configuration
1389
- * @param {boolean} [config.option.small] - Whether to subscribe small streams
1390
- * @param {boolean} [config.option.mirror] - Whether to enable mirror
1391
- * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1392
- * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1393
- * @param {HTMLElement} [config.option.viewRoot=document.body] - Since v5.4.0 <br>The root element is the parent element of the view and is used to calculate whether the view is visible relative to the root. The default value is document.body, and it is recommended that you use the first-level parent of the video view list. Refer to: {@tutorial 27-advanced-small-stream}.
1394
- * @throws
1395
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1396
- * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1397
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1398
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1399
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1400
- * @example
1401
- * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, ({ userId, streamType }) => {
1402
- * // You need to place the video container in the DOM in advance, and it is recommended to use `${userId}_${streamType}` as the element id.
1403
- * trtc.startRemoteVideo({ userId, streamType, view: `${userId}_${streamType}` });
1404
- * })
1405
- * @memberof TRTC
1406
- */
1407
- startRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1408
- /**
1409
- * Update remote video playback configuration<br>
1410
- * - This method should be called after {@link TRTC#startRemoteVideo startRemoteVideo} is successful.
1411
- * - This method can be called multiple times.
1412
- * - This method uses incremental updates, so only the configuration items that need to be updated need to be passed in.
1413
- * @param {object} [config]
1414
- * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id used to play remote video. If not passed or passed null, the video will not be rendered, but the bandwidth will still be consumed.
1415
- * @param {string} config.userId - Remote user ID
1416
- * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1417
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1418
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1419
- * @param {object} [config.option] - Remote video configuration
1420
- * @param {boolean} [config.option.small] - Whether to subscribe small streams. Refer to: {@tutorial 27-advanced-small-stream}.
1421
- * @param {boolean} [config.option.mirror] - Whether to enable mirror
1422
- * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1423
- * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1424
- * @param {HTMLElement} [config.option.viewRoot=document.body] - Since v5.4.0 <br>The root element is the parent element of the view and is used to calculate whether the view is visible relative to the root. The default value is document.body, and it is recommended that you use the first-level parent of the video view list. Refer to: {@tutorial 27-advanced-small-stream}.
1425
- * @throws
1426
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1427
- * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1428
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1429
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1430
- * @example
1431
- * const config = {
1432
- * view: document.getElementById(userId), // you can use a new view to update the position of video.
1433
- * userId,
1434
- * streamType: TRTC.TYPE.STREAM_TYPE_MAIN
1435
- * }
1436
- * await trtc.updateRemoteVideo(config);
1437
- * @memberof TRTC
1438
- */
1439
- updateRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1440
- /**
1441
- * Used to stop remote video playback.<br>
1442
- * @param {object} config - Remote video configuration
1443
- * @param {string} config.userId - Remote user ID, '*' represents all users.
1444
- * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} [config.streamType] - Remote stream type. This field is required when userId is not '*'.
1445
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1446
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1447
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1448
- * @example
1449
- * // Stop playing all remote users
1450
- * await trtc.stopRemoteVideo({ userId: '*' });
1451
- */
1452
- stopRemoteVideo(config: StopRemoteVideoConfig): Promise<void>;
1453
- /**
1454
- * Mute a remote user and stop subscribing audio data from that user. Only effective for the current user, other users in the room can still hear the muted user's voice.<br>
1455
- *
1456
- * Note:
1457
- * - By default, after entering the room, the SDK will automatically play remote audio. You can call this interface to mute or unmute remote users.
1458
- * - If the parameter autoReceiveAudio = false is passed in when entering the room, remote audio will not be played automatically. When audio playback is required, you need to call this method (mute is passed in false) to play remote audio.
1459
- * - This interface is effective before or after entering the room (enterRoom), and the mute state will be reset to false after exiting the room (exitRoom).
1460
- * - If you want to continue subscribing audio data from the user but not play it, you can call setRemoteAudioVolume(userId, 0)
1461
- * @param {string} userId - Remote user ID, '*' represents all users.
1462
- * @param {boolean} mute - Whether to mute
1463
- * @throws
1464
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1465
- * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1466
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1467
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1468
- * @example
1469
- * // Mute all remote users
1470
- * await trtc.muteRemoteAudio('*', true);
1471
- */
1472
- muteRemoteAudio(userId: string, mute: boolean): Promise<void>;
1473
- /**
1474
- * Used to control the playback volume of remote audio.<br>
1475
- *
1476
- * - Not supported by iOS Safari
1477
- * @param {string} userId - Remote user ID。'*' represents all remote users.
1478
- * @param {number} volume - Volume, ranging from 0 to 100. The default value is 100.<br>
1479
- * Since `v5.1.3+`, the volume can be set higher than 100.
1480
- * @example
1481
- * await trtc.setRemoteAudioVolume('123', 90);
1482
- */
1483
- setRemoteAudioVolume(userId: string, volume: number): void;
1484
- startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1485
- startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1486
- updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1487
- updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1488
- stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1489
- stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1490
- /**
1491
- * Enables or disables the volume callback.<br>
1492
- *
1493
- * - After enabling this function, whether someone is speaking in the room or not, the SDK will regularly throw the {@link module:EVENT.AUDIO_VOLUME TRTC.on(TRTC.EVENT.AUDIO_VOLUME)} event, which feedbacks the volume evaluation value of each user.<br>
1494
- *
1495
- * @param {number} [interval=2000] Used to set the time interval for triggering the volume callback event. The default is 2000(ms), and the minimum value is 100(ms). If set to less than or equal to 0, the volume callback will be turned off.
1496
- * @param {boolean} [enableInBackground=false] For performance reasons, when the page switches to the background, the SDK will not throw volume callback events. If you need to receive volume callback events when the page is switched to the background, you can set this parameter to true.
1497
- * @memberof TRTC
1498
- * @example
1499
- * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
1500
- * event.result.forEach(({ userId, volume }) => {
1501
- * const isMe = userId === ''; // When userId is an empty string, it represents the local microphone volume.
1502
- * if (isMe) {
1503
- * console.log(`my volume: ${volume}`);
1504
- * } else {
1505
- * console.log(`user: ${userId} volume: ${volume}`);
1506
- * }
1507
- * })
1508
- * });
1509
- *
1510
- * // Enable volume callback and trigger the event every 1000ms
1511
- * trtc.enableAudioVolumeEvaluation(1000);
1512
- *
1513
- * // To turn off the volume callback, pass in an interval value less than or equal to 0
1514
- * trtc.enableAudioVolumeEvaluation(-1);
1515
- */
1516
- enableAudioVolumeEvaluation(interval?: number, enableInBackground?: boolean): void;
1517
- /**
1518
- * Listen to TRTC events<br><br>
1519
- * For a detailed list of events, please refer to: {@link module:EVENT TRTC.EVENT}
1520
- *
1521
- * @param {string} eventName Event name
1522
- * @param {function} handler Event callback function
1523
- * @param {context} context Context
1524
- * @memberof TRTC
1525
- * @example
1526
- * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
1527
- * // REMOTE_VIDEO_AVAILABLE event handler
1528
- * });
1529
- */
1530
- on<T extends keyof TRTCEventTypes>(event: T, handler: (...args: TRTCEventTypes[T]) => void, context?: any): this;
1531
- /**
1532
- * Remove event listener<br>
1533
- *
1534
- * @param {string} eventName Event name. Passing in the wildcard '*' will remove all event listeners.
1535
- * @param {function} handler Event callback function
1536
- * @param {context} context Context
1537
- * @memberof TRTC
1538
- * @example
1539
- * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, function peerJoinHandler(event) {
1540
- * // REMOTE_USER_ENTER event handler
1541
- * console.log('remote user enter');
1542
- *
1543
- * trtc.off(TRTC.EVENT.REMOTE_USER_ENTER, peerJoinHandler);
1544
- * });
1545
- *
1546
- * // Remove all event listeners
1547
- * trtc.off('*');
1548
- */
1549
- off<T extends keyof TRTCEventTypes>(event: T | '*', handler: T extends '*' ? never : (...args: TRTCEventTypes[T]) => void, context?: any): this;
1550
- /**
1551
- * Get audio track
1552
- *
1553
- * @returns {MediaStreamTrack?} Audio track
1554
- * @param {Object|string} [config] If not passed, get the local microphone audioTrack
1555
- * @param {string} [config.userId] If not passed or passed an empty string, get the local audioTrack. Pass the userId of the remote user to get the remote user's audioTrack.
1556
- * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1557
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's microphone)(default)
1558
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing audio). Only works for local screen sharing audio because there is only one remote audioTrack, and there is no distinction between Main and Sub for remote audioTrack.
1559
- * @memberof TRTC
1560
- * @example
1561
- * // Version before v5.4.3
1562
- * trtc.getAudioTrack(); // Get local microphone audioTrack, captured by trtc.startLocalAudio()
1563
- * trtc.getAudioTrack('remoteUserId'); // Get remote audioTrack
1564
- *
1565
- * // Since v5.4.3+, you can get local screen audioTrack by passing the streamType = TRTC.STREAM_TYPE_SUB
1566
- * trtc.getAudioTrack({ streamType: TRTC.STREAM_TYPE_SUB });
1567
- */
1568
- getAudioTrack(configOrUserId?: {
1569
- userId?: string;
1570
- streamType?: TRTCStreamType;
1571
- } | string): MediaStreamTrack | null;
1572
- /**
1573
- * Get video track
1574
- *
1575
- * @param {string} [config] If not passed, get the local camera videoTrack
1576
- * @param {string} [config.userId] If not passed or passed an empty string, get the local videoTrack. Pass the userId of the remote user to get the remote user's videoTrack.
1577
- * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1578
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's camera)(default)
1579
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing)
1580
- * @returns {MediaStreamTrack|null} Video track
1581
- * @memberof TRTC
1582
- * @example
1583
- * // Get local camera videoTrack
1584
- * const videoTrack = trtc.getVideoTrack();
1585
- * // Get local screen sharing videoTrack
1586
- * const screenVideoTrack = trtc.getVideoTrack({ streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1587
- * // Get remote user's main stream videoTrack
1588
- * const remoteMainVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_MAIN });
1589
- * // Get remote user's sub stream videoTrack
1590
- * const remoteSubVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1591
- */
1592
- getVideoTrack(config?: {
1593
- userId?: string;
1594
- streamType?: TRTCStreamType;
1595
- }): MediaStreamTrack | null;
1596
- /**
1597
- * Get video snapshot <br>
1598
- * Notice: must play the video before it can obtain the snapshot. If there is no playback, an empty string will be returned.
1599
- * @param {string} config.userId - Remote user ID
1600
- * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType
1601
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream
1602
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream
1603
- * @since 5.4.0
1604
- * @example
1605
- * // get self main stream video frame
1606
- * trtc.getVideoSnapshot()
1607
- * // get self sub stream video frame
1608
- * trtc.getVideoSnapshot({streamType:TRTC.TYPE.STREAM_TYPE_SUB})
1609
- * // get remote user main stream video frame
1610
- * trtc.getVideoSnapshot({userId: 'remote userId', streamType:TRTC.TYPE.STREAM_TYPE_MAIN})
1611
- * @memberof TRTC
1612
- */
1613
- getVideoSnapshot(config?: VideoFrameConfig): string;
1614
- setCurrentSpeaker(speakerId: string): void;
1615
- /**
1616
- * Send SEI Message <br>
1617
- *
1618
- * > The header of a video frame has a header block called SEI.
1619
- * > The principle of this interface is to use the SEI to embed the custom data you want to send along with the video frame.
1620
- * > SEI messages can accompany video frames all the way to the live CDN.
1621
- *
1622
- * Applicable scenarios: synchronization of lyrics, live answering questions, etc.
1623
- *
1624
- * When to call: call after {@link TRTC#startLocalVideo trtc.startLocalVideo} or {@link TRTC#startLocalScreen trtc.startLocalScreen} when set 'toSubStream' option to true successfully.
1625
- *
1626
- * Note:
1627
- * 1. Maximum 1KB(Byte) sent in a single call, maximum 30 calls per second, maximum 8KB sent per second.
1628
- * 2. Currently only support Chrome 86+, Edge 86+, Opera 72+ browsers.
1629
- * 3. Since SEI is sent along with video frames, there is a possibility that video frames may be lost, and therefore SEI may be lost as well. The number of times it can be sent can be increased within the frequency limit, and the business side needs to do message de-duplication on the receiving side.
1630
- * 4. SEI cannot be sent without trtc.startLocalVideo(or trtc.startLocalScreen when set 'toSubStream' option to true); SEI cannot be received without startRemoteVideo.
1631
- * 5. Only H264 encoder is supported to send SEI.
1632
- * 6. SEI sending and receiving is not supported for small streams for the time being.
1633
- * @see {@link module:EVENT.SEI_MESSAGE TRTC.EVENT.SEI_MESSAGE}
1634
- * @since v5.3.0
1635
- * @param {ArrayBuffer} buffer SEI data to be sent
1636
- * @param {Object=} options
1637
- * @param {Number} options.seiPayloadType Set the SEI payload type. SDK uses the custom payloadType 243 by default, the business side can use this parameter to set the payloadType to the standard 5. When the business side uses the 5 payloadType, you need to follow the specification to make sure that the first 16 bytes of the `buffer` are the business side's customized uuid.
1638
- * @param {Boolean} [options.toSubStream=false] Send SEI data to substream. Need call trtc.startLocalScreen first. Since v5.7.0+.
1639
- * @example
1640
- * // 1. enable SEI
1641
- * const trtc = TRTC.create({
1642
- * enableSEI: true
1643
- * })
1644
- *
1645
- * // 2. send SEI
1646
- * try {
1647
- * await trtc.enterRoom({
1648
- * userId: 'user_1',
1649
- * roomId: 12345,
1650
- * })
1651
- * await trtc.startLocalVideo();
1652
- * const unit8Array = new Uint8Array([1, 2, 3]);
1653
- * trtc.sendSEIMessage(unit8Array.buffer);
1654
- * } catch(error) {
1655
- * console.warn(error);
1656
- * }
1657
- *
1658
- * // 3. receive SEI
1659
- * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
1660
- * console.warn(`sei ${event.data} from ${event.userId}`);
1661
- * })
1662
- */
1663
- sendSEIMessage(buffer: ArrayBuffer, options?: {
1664
- seiPayloadType?: number;
1665
- toSubStream?: boolean;
1666
- }): void;
1667
- /**
1668
- * Send Custom Message to all remote users in the room. <br>
1669
- *
1670
- * Note:
1671
- *
1672
- * 1. Only {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} can call sendCustomMessage.
1673
- * 2. You should call this api after {@link TRTC#enterRoom TRTC.enterRoom} successfully.
1674
- * 3. The custom message will be sent in order and as reliably as possible, but it's possible to loss messages in a very bad network. The receiver will also receive the message in order.
1675
- * @since v5.6.0
1676
- * @see Listen for the event {@link module:EVENT.CUSTOM_MESSAGE TRTC.EVENT.CUSTOM_MESSAGE} to receive custom message.
1677
- * @param {object} message
1678
- * @param {number} message.cmdId message Id. Integer, range [1, 10]. You can set different cmdId for different types of messages to reduce the delay of transferring message.
1679
- * @param {ArrayBuffer} message.data - message content. <br/>
1680
- * - Maximum 1KB(Byte) sent in a single call.
1681
- * - Maximum 30 calls per second
1682
- * - Maximum 8KB sent per second.
1683
- * @example
1684
- * // send custom message
1685
- * trtc.sendCustomMessage({
1686
- * cmdId: 1,
1687
- * data: new TextEncoder().encode('hello').buffer
1688
- * });
1689
- *
1690
- * // receive custom message
1691
- * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
1692
- * // event.userId: remote userId.
1693
- * // event.cmdId: message cmdId.
1694
- * // event.seq: message sequence number.
1695
- * // event.data: custom message data, type is ArrayBuffer.
1696
- * console.log(`received custom msg from ${event.userId}, message: ${new TextDecoder().decode(event.data)}`)
1697
- * })
1698
- */
1699
- sendCustomMessage(message: CustomMessageData): void;
1700
- static EVENT: {
1701
- readonly ERROR: "error";
1702
- readonly AUTOPLAY_FAILED: "autoplay-failed";
1703
- readonly KICKED_OUT: "kicked-out";
1704
- readonly REMOTE_USER_ENTER: "remote-user-enter";
1705
- readonly REMOTE_USER_EXIT: "remote-user-exit";
1706
- readonly REMOTE_AUDIO_AVAILABLE: "remote-audio-available";
1707
- readonly REMOTE_AUDIO_UNAVAILABLE: "remote-audio-unavailable";
1708
- readonly REMOTE_VIDEO_AVAILABLE: "remote-video-available";
1709
- readonly REMOTE_VIDEO_UNAVAILABLE: "remote-video-unavailable";
1710
- readonly AUDIO_VOLUME: "audio-volume";
1711
- readonly NETWORK_QUALITY: "network-quality";
1712
- readonly CONNECTION_STATE_CHANGED: "connection-state-changed";
1713
- readonly AUDIO_PLAY_STATE_CHANGED: "audio-play-state-changed";
1714
- readonly VIDEO_PLAY_STATE_CHANGED: "video-play-state-changed";
1715
- readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
1716
- readonly DEVICE_CHANGED: "device-changed";
1717
- readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
1718
- readonly TRACK: "track";
1719
- readonly STATISTICS: "statistics";
1720
- readonly SEI_MESSAGE: "sei-message";
1721
- readonly CUSTOM_MESSAGE: "custom-message";
1722
- };
1723
- static ERROR_CODE: {
1724
- INVALID_PARAMETER: number;
1725
- INVALID_OPERATION: number;
1726
- ENV_NOT_SUPPORTED: number;
1727
- DEVICE_ERROR: number;
1728
- SERVER_ERROR: number;
1729
- OPERATION_FAILED: number;
1730
- OPERATION_ABORT: number;
1731
- UNKNOWN_ERROR: number;
1732
- };
1733
- static TYPE: {
1734
- readonly SCENE_LIVE: Scene.LIVE;
1735
- readonly SCENE_RTC: Scene.RTC;
1736
- readonly ROLE_ANCHOR: UserRole.ANCHOR;
1737
- readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
1738
- readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
1739
- readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
1740
- readonly AUDIO_PROFILE_STANDARD: "standard";
1741
- readonly AUDIO_PROFILE_STANDARD_STEREO: "standard-stereo";
1742
- readonly AUDIO_PROFILE_HIGH: "high";
1743
- readonly AUDIO_PROFILE_HIGH_STEREO: "high-stereo";
1744
- readonly QOS_PREFERENCE_SMOOTH: "smooth";
1745
- readonly QOS_PREFERENCE_CLEAR: "clear";
1746
- };
1747
- static frameWorkType: number;
1748
- /**
1749
- * Set the log output level
1750
- * <br>
1751
- * It is recommended to set the DEBUG level during development and testing, which includes detailed prompt information.
1752
- * The default output level is INFO, which includes the log information of the main functions of the SDK.
1753
- *
1754
- * @param {0-5} [level] Log output level 0: TRACE 1: DEBUG 2: INFO 3: WARN 4: ERROR 5: NONE
1755
- * @param {boolean} [enableUploadLog=true] Whether to enable log upload, which is enabled by default. It is not recommended to turn it off, which will affect problem troubleshooting.
1756
- * @example
1757
- * // Output log levels above DEBUG
1758
- * TRTC.setLogLevel(1);
1759
- */
1760
- static setLogLevel(level: LOG_LEVEL, enableUploadLog?: boolean): void;
1761
- /**
1762
- * Check if the TRTC Web SDK is supported by the current browser
1763
- *
1764
- * - Reference: {@tutorial 05-info-browser}.
1765
- * @example
1766
- * TRTC.isSupported().then((checkResult) => {
1767
- * if(!checkResult.result) {
1768
- * console.log('checkResult', checkResult.result, 'checkDetail', checkResult.detail);
1769
- * // The SDK is not supported by the current browser, guide the user to use the latest version of Chrome browser.
1770
- * }
1771
- * });
1772
- *
1773
- * @returns {Promise.<object>} Promise returns the detection result
1774
- * | Property | Type | Description |
1775
- * |--------------------------------------------|---------|-------------------------------------|
1776
- * | checkResult.result | boolean | Detection result |
1777
- * | checkResult.detail.isBrowserSupported | boolean | Whether the current browser is supported by the SDK |
1778
- * | checkResult.detail.isWebRTCSupported | boolean | Whether the current browser supports WebRTC |
1779
- * | checkResult.detail.isWebCodecsSupported | boolean | Whether the current browser supports WebCodecs |
1780
- * | checkResult.detail.isMediaDevicesSupported | boolean | Whether the current browser supports obtaining media devices and media streams |
1781
- * | checkResult.detail.isScreenShareSupported | boolean | Whether the current browser supports screen sharing |
1782
- * | checkResult.detail.isSmallStreamSupported | boolean | Whether the current browser supports small streams |
1783
- * | checkResult.detail.isH264EncodeSupported | boolean | Whether the current browser supports H264 encoding for uplink |
1784
- * | checkResult.detail.isH264DecodeSupported | boolean | Whether the current browser supports H264 decoding for downlink |
1785
- * | checkResult.detail.isVp8EncodeSupported | boolean | Whether the current browser supports VP8 encoding for uplink |
1786
- * | checkResult.detail.isVp8DecodeSupported | boolean | Whether the current browser supports VP8 decoding for downlink |
1787
- */
1788
- static isSupported(): Promise<any>;
1789
- /**
1790
- * Returns the list of camera devices
1791
- * <br>
1792
- * **Note**
1793
- * - This interface does not support use under the http protocol, please use the https protocol to deploy your website. {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Privacy_and_security Privacy and security}
1794
- * - You can call the browser's native interface [getCapabilities](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities) to get the maximum resolutions supported by the camera, frame rate, mobile devices to distinguish between front and rear cameras, etc. This interface supports Chrome 67+, Edge 79+, Safari 17+, Opera 54+.
1795
- * @param {boolean} [requestPermission=true] `Since v5.6.3`. Whether to request permission to use the camera. If requestPermission is true, calling this method may temporarily open the camera to ensure that the camera list can be normally obtained, and the SDK will automatically stop the camera capture later.
1796
- * @example
1797
- * const cameraList = await TRTC.getCameraList();
1798
- * if (cameraList[0] && cameraList[0].getCapabilities) {
1799
- * const { width, height, frameRate, facingMode } = cameraList[0].getCapabilities();
1800
- * console.log(width.max, height.max, frameRate.max);
1801
- * if (facingMode) {
1802
- * if (facingMode[0] === 'user') {
1803
- * // front camera
1804
- * } else if (facingMode[0] === 'environment') {
1805
- * // rear camera
1806
- * }
1807
- * }
1808
- * }
1809
- * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1810
- */
1811
- static getCameraList(requestPermission?: boolean): Promise<DeviceInfo[]>;
1812
- /**
1813
- * Returns the list of microphone devices
1814
- * <br>
1815
- * **Note**
1816
- * - This interface does not support use under the http protocol, please use the https protocol to deploy your website. {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Privacy_and_security Privacy and security}
1817
- * - You can call the browser's native interface [getCapabilities](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities) to get information about the microphone's capabilities, e.g. the maximum number of channels supported, etc. This interface supports Chrome 67+, Edge 79+, Safari 17+, Opera 54+.
1818
- * @param {boolean} [requestPermission=true] `Since v5.6.3`. Whether to request permission to use the microphone. If requestPermission is true, calling this method may temporarily open the microphone to ensure that the microphone list can be normally obtained, and the SDK will automatically stop the microphone capture later.
1819
- * @example
1820
- * const microphoneList = await TRTC.getMicrophoneList();
1821
- * if (microphoneList[0] && microphoneList[0].getCapabilities) {
1822
- * const { channelCount } = microphoneList[0].getCapabilities();
1823
- * console.log(channelCount.max);
1824
- * }
1825
- * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1826
- */
1827
- static getMicrophoneList(requestPermission?: boolean): Promise<DeviceInfo[]>;
1828
- /**
1829
- * Returns the list of speaker devices. Only support PC browser, not support mobile browser.
1830
- * <br>
1831
- * @param {boolean} [requestPermission=true] `Since v5.6.3`. Whether to request permission to use the microphone. If requestPermission is true, calling this method may temporarily open the microphone to ensure that the microphone list can be normally obtained, and the SDK will automatically stop the microphone capture later.
1832
- * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1833
- */
1834
- static getSpeakerList(requestPermission?: boolean): Promise<DeviceInfo[]>;
1835
- /**
1836
- * Set the current speaker for audio playback
1837
- *
1838
- * @param {string} speakerId Speaker ID
1839
- */
1840
- static setCurrentSpeaker(speakerId: string): Promise<void>;
1170
+ export declare class TRTC {
1171
+ /**
1172
+ * Create a TRTC object for implementing functions such as entering a room, previewing, publishing, and subscribing streams.<br>
1173
+ *
1174
+ * **Note:**
1175
+ * - You must create a TRTC object first and call its methods and listen to its events to implement various functions required by the business.
1176
+ * @example
1177
+ * // Create a TRTC object
1178
+ * const trtc = TRTC.create();
1179
+ *
1180
+ * @returns {TRTC} TRTC object
1181
+ */
1182
+ static create(options?: TRTCOptions): TRTC;
1183
+ /**
1184
+ * @private
1185
+ * regi <br>
1186
+ *
1187
+ * @example
1188
+ * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
1189
+ * trtc.use({ plugin: VirtualBackground });
1190
+ *
1191
+ * @example
1192
+ * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
1193
+ * trtc.use({ plugin: VirtualBackground, assetsPath: './js/assets/' });
1194
+ *
1195
+ * @example
1196
+ * // 简写使用
1197
+ * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
1198
+ * trtc.use(VirtualBackground);
1199
+ */
1200
+ use(pluginObject: PluginWithAssets | IPluginClass): void;
1201
+ /**
1202
+ * @typedef TurnServer
1203
+ * @property {string} url TURN server url
1204
+ * @property {string=} username TURN server auth user name
1205
+ * @property {string=} credential TURN server password
1206
+ * @property {string=} [credentialType=password] TURN server verify password type
1207
+ */
1208
+ /**
1209
+ * @typedef ProxyServer
1210
+ * @property {string} [websocketProxy] websocket service proxy
1211
+ * @property {string} [loggerProxy] log service agent
1212
+ * @property {TurnServer[]} [turnServer] media data transmission agent
1213
+ * @property {'all'|'relay'} [iceTransportPolicy='all'] 'all' gives priority to directly connecting to TRTC, and tries to go to the turn server if the connection fails.<br>
1214
+ * 'relay' forces the connection through the TURN server.
1215
+ */
1216
+ /**
1217
+ * Enter a video call room.<br>
1218
+ * - Entering a room means starting a video call session. Only after entering the room successfully can you make audio and video calls with other users in the room.
1219
+ * - You can publish local audio and video streams through {@link TRTC#startLocalVideo startLocalVideo()} and {@link TRTC#startLocalAudio startLocalAudio()} respectively. After successful publishing, other users in the room will receive the {@link module:EVENT.REMOTE_AUDIO_AVAILABLE REMOTE_AUDIO_AVAILABLE} and {@link module:EVENT.REMOTE_VIDEO_AVAILABLE REMOTE_VIDEO_AVAILABLE} event notifications.
1220
+ * - By default, the SDK automatically plays remote audio. You need to call {@link TRTC#startRemoteVideo startRemoteVideo()} to play remote video.
1221
+ *
1222
+ * @param {object} options Enter room parameters
1223
+ * @param {number} options.sdkAppId sdkAppId <br>
1224
+ * You can obtain the sdkAppId information in the **Application Information** section after creating a new application by clicking **Application Management** > **Create Application** in the [TRTC Console](https://console.intl.cloud.tencent.com/trtc).
1225
+ * @param {string} options.userId User ID <br>
1226
+ * It is recommended to limit the length to 32 bytes, and only allow uppercase and lowercase English letters (a-zA-Z), numbers (0-9), underscores, and hyphens.
1227
+ * @param {string} options.userSig UserSig signature <br>
1228
+ * Please refer to [UserSig related](https://www.tencentcloud.com/document/product/647/35166) for the calculation method of userSig.
1229
+ * @param {number=} options.roomId
1230
+ * the value must be an integer between 1 and 4294967294<br>
1231
+ * <font color="red">If you need to use a string type room id, please use the strRoomId parameter. One of roomId and strRoomId must be passed in. If both are passed in, the roomId will be selected first.</font>
1232
+ * @param {string=} options.strRoomId
1233
+ * String type room id, the length is limited to 64 bytes, and only supports the following characters:
1234
+ * - Uppercase and lowercase English letters (a-zA-Z)
1235
+ * - Numbers (0-9)
1236
+ * - Space ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | ~ ,
1237
+ * <font color="red">Note: It is recommended to use a numeric type roomId. The string type room id "123" is not the same room as the numeric type room id 123.</font>
1238
+ * @param {string} [options.scene] Application scene, currently supports the following two scenes:
1239
+ * - {@link module:TYPE.SCENE_RTC TRTC.TYPE.SCENE_RTC} (default) Real-time call scene, which is suitable for 1-to-1 audio and video calls, or online meetings with up to 300 participants. {@tutorial 04-info-uplink-limits}.
1240
+ * - {@link module:TYPE.SCENE_LIVE TRTC.TYPE.SCENE_LIVE} Interactive live streaming scene, which is suitable for online live streaming scenes with up to 100,000 people, but you need to specify the role field in the options parameter introduced next.
1241
+ * @param {string=} [options.role] User role, only meaningful in the {@link module:TYPE.SCENE_LIVE TRTC.TYPE.SCENE_LIVE} scene, and the {@link module:TYPE.SCENE_RTC TRTC.TYPE.SCENE_RTC} scene does not need to specify the role. Currently supports two roles:
1242
+ * - {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} (default) Anchor
1243
+ * - {@link module:TYPE.ROLE_AUDIENCE TRTC.TYPE.ROLE_AUDIENCE} Audience
1244
+ * Note: The audience role does not have the permission to publish local audio and video, only the permission to watch remote streams. If the audience wants to interact with the anchor by connecting to the microphone, please switch the role to the anchor through {@link TRTC#switchRole switchRole()} before publishing local audio and video.
1245
+ * @param {boolean} [options.autoReceiveAudio=true] Whether to automatically receive audio. When a remote user publishes audio, the SDK automatically plays the remote user's audio.
1246
+ * @param {boolean} [options.autoReceiveVideo=false] Whether to automatically receive video. When a remote user publishes video, the SDK automatically subscribes and decodes the remote video. You need to call {@link TRTC#startRemoteVideo startRemoteVideo} to play the remote video.
1247
+ * - The default value was changed to `false` since v5.6.0. Refer to [Breaking Changed for v5.6.0](https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/tutorial-00-info-update-guideline.html).
1248
+ * @param {boolean} [options.enableAutoPlayDialog] Whether to enable the SDK's automatic playback failure dialog box, default: true.
1249
+ * - Enabled by default. When automatic playback fails, the SDK will pop up a dialog box to guide the user to click the page to restore audio and video playback.
1250
+ * - Can be set to false in order to turn off. Refer to {@tutorial 21-advanced-auto-play-policy}.
1251
+ * @param {string|ProxyServer} [options.proxy] proxy config. Refer to {@tutorial 34-advanced-proxy}.
1252
+ * @param {boolean} [options.privateMapKey] Key for entering a room. If permission control is required, please carry this parameter (empty or incorrect value will cause a failure in entering the room).<br>[privateMapKey permission configuration](https://www.tencentcloud.com/document/product/647/35157?lang=en&pg=).
1253
+ * @throws
1254
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1255
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1256
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1257
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1258
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1259
+ * @example
1260
+ * const trtc = TRTC.create();
1261
+ * await trtc.enterRoom({ roomId: 8888, sdkAppId, userId, userSig });
1262
+ */
1263
+ enterRoom(params: EnterRoomConfig): Promise<void>;
1264
+ /**
1265
+ * Exit the current audio and video call room.
1266
+ * - After exiting the room, the connection with remote users will be closed, and remote audio and video will no longer be received and played, and the publishing of local audio and video will be stopped.
1267
+ * - The capture and preview of the local camera and microphone will not stop. You can call {@link TRTC#stopLocalVideo stopLocalVideo()} and {@link TRTC#stopLocalAudio stopLocalAudio()} to stop capturing local microphone and camera.
1268
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1269
+ * @memberof TRTC
1270
+ * @example
1271
+ * await trtc.exitRoom();
1272
+ */
1273
+ exitRoom(): Promise<void>;
1274
+ /**
1275
+ * Switches the user role, only effective in TRTC.TYPE.SCENE_LIVE interactive live streaming mode.
1276
+ *
1277
+ * In interactive live streaming mode, a user may need to switch between "audience" and "anchor".
1278
+ * You can determine the role through the role field in {@link TRTC#enterRoom enterRoom()}, or switch roles after entering the room through switchRole.
1279
+ * - Audience switches to anchor, call trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR) to convert the user role to TRTC.TYPE.ROLE_ANCHOR anchor role, and then call {@link TRTC#startLocalVideo startLocalVideo()} and {@link TRTC#startLocalAudio startLocalAudio()} to publish local audio and video as needed.
1280
+ * - Anchor switches to audience, call trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE) to convert the user role to TRTC.TYPE.ROLE_AUDIENCE audience role. If there is already published local audio and video, the SDK will cancel the publishing of local audio and video.
1281
+ * > !
1282
+ * > - This interface can only be called after entering the room successfully.
1283
+ * > - After closing the camera and microphone, it is recommended to switch to the audience role in time to avoid the anchor role occupying the resources of 50 upstreams.
1284
+ * @param {string} role User role
1285
+ * - TRTC.TYPE.ROLE_ANCHOR anchor, can publish local audio and video, up to 50 anchors can publish local audio and video in a single room at the same time.
1286
+ * - TRTC.TYPE.ROLE_AUDIENCE audience, cannot publish local audio and video, can only watch remote streams, and there is no upper limit on the number of audience members in a single room.
1287
+ * @param {object} [option]
1288
+ * @param {string} [option.privateMapKey] `Since v5.3.0+` <br>
1289
+ * The privateMapKey may expire after a timeout, so you can use this parameter to update the privateMapKey.
1290
+ * @throws
1291
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1292
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1293
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1294
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1295
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1296
+ * @memberof TRTC
1297
+ * @example
1298
+ * // After entering the room successfully
1299
+ * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, audience switches to anchor
1300
+ * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR);
1301
+ * // Switch from audience role to anchor role and start streaming
1302
+ * await trtc.startLocalVideo();
1303
+ *
1304
+ * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, anchor switches to audience
1305
+ * await trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE);
1306
+ * @example
1307
+ * // Since v5.3.0+
1308
+ * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR, { privateMapKey: 'your new privateMapKey' });
1309
+ */
1310
+ switchRole(role: UserRole, option?: {
1311
+ privateMapKey?: string;
1312
+ latencyLevel?: number;
1313
+ }): Promise<void>;
1314
+ /**
1315
+ * Destroy the TRTC instance <br/>
1316
+ *
1317
+ * After exiting the room, if the business side no longer needs to use trtc, you need to call this interface to destroy the trtc instance in time and release related resources.
1318
+ *
1319
+ * Note:
1320
+ * - The trtc instance after destruction cannot be used again.
1321
+ * - If you have entered the room, you need to call the {@link TRTC#exitRoom TRTC.exitRoom} interface to exit the room successfully before calling this interface to destroy trtc.
1322
+ *
1323
+ * @example
1324
+ * // When the call is over
1325
+ * await trtc.exitRoom();
1326
+ * // If the trtc is no longer needed, destroy the trtc and release the reference.
1327
+ * trtc.destroy();
1328
+ * trtc = null;
1329
+ * @throws {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1330
+ * @memberof TRTC
1331
+ */
1332
+ destroy(): void;
1333
+ /**
1334
+ * Start collecting audio from the local microphone and publish it to the current room.
1335
+ * - When to call: can be called before or after entering the room, cannot be called repeatedly.
1336
+ * - Only one microphone can be opened for a trtc instance. If you need to open another microphone for testing in the case of already opening one microphone, you can create multiple trtc instances to achieve it.
1337
+ *
1338
+ * @param {object} [config] - Configuration item
1339
+ * @param {boolean} [config.publish] - Whether to publish local audio to the room, default is true. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1340
+ * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1341
+ * @param {object} [config.option] - Local audio options
1342
+ * @param {string} [config.option.microphoneId]- Specify which microphone to use
1343
+ * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1344
+ * @param {number} [config.option.captureVolume] - Set the capture volume of microphone. The default value is 100. Setting above 100 enlarges the capture volume. Since v5.2.1+.
1345
+ * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1346
+ * @param {string} [config.option.profile] - Audio encoding configuration, default {@link module:TYPE.AUDIO_PROFILE_STANDARD TRTC.TYPE.AUDIO_PROFILE_STANDARD}
1347
+ * @throws
1348
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1349
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1350
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1351
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1352
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1353
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1354
+ * @example
1355
+ * // Collect the default microphone and publish
1356
+ * await trtc.startLocalAudio();
1357
+ * @example
1358
+ * // The following is a code example for testing microphone volume, which can be used for microphone volume detection.
1359
+ * trtc.enableAudioVolumeEvaluation();
1360
+ * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => { });
1361
+ * // No need to publish audio for testing microphone
1362
+ * await trtc.startLocalAudio({ publish: false });
1363
+ * // After the test is completed, turn off the microphone
1364
+ * await trtc.stopLocalAudio();
1365
+ * @memberof TRTC
1366
+ */
1367
+ startLocalAudio(config?: LocalAudioConfig): Promise<void>;
1368
+ /**
1369
+ * Update the configuration of the local microphone.
1370
+ * - When to call: This interface needs to be called after {@link TRTC#startLocalAudio startLocalAudio()} is successful and can be called multiple times.
1371
+ * - This method uses incremental update: only update the passed parameters, and keep the parameters that are not passed unchanged.
1372
+ * @param {object} [config]
1373
+ * @param {boolean} [config.publish] - Whether to publish local audio to the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1374
+ * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1375
+ * @param {object} [config.option] - Local audio configuration
1376
+ * @param {string} [config.option.microphoneId] - Specify which microphone to use to switch microphones.
1377
+ * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1378
+ * @param {number} [config.option.captureVolume] - Set the capture volume of microphone. The default value is 100. Setting above 100 enlarges the capture volume. Since v5.2.1+.
1379
+ * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1380
+ * @throws
1381
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1382
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1383
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1384
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1385
+ * @example
1386
+ * // Switch microphone
1387
+ * const microphoneList = await TRTC.getMicrophoneList();
1388
+ * if (microphoneList[1]) {
1389
+ * await trtc.updateLocalAudio({ option: { microphoneId: microphoneList[1].deviceId }});
1390
+ * }
1391
+ * @memberof TRTC
1392
+ */
1393
+ updateLocalAudio(config: UpdateLocalAudioConfig): Promise<void>;
1394
+ /**
1395
+ * Stop collecting and publishing the local microphone.
1396
+ * - If you just want to mute the microphone, please use updateLocalAudio({ mute: true }). Refer to: {@tutorial 15-basic-dynamic-add-video}.
1397
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1398
+ * @example
1399
+ * await trtc.stopLocalAudio();
1400
+ */
1401
+ stopLocalAudio(): Promise<void>;
1402
+ /**
1403
+ * @typedef {object|string} VideoProfile - Configuration for local video stream
1404
+ *
1405
+ * Video configuration parameters, can use preset values in string format or custom resolution and other parameters
1406
+ * | Video Profile | Resolution (Width x Height) | Frame Rate (fps) | Bitrate (kbps) | Remarks |
1407
+ * | :--- | :--- | :--- | :--- | :--- |
1408
+ * | 120p | 160 x 120 | 15 | 200 ||
1409
+ * | 180p | 320 x 180 | 15 | 350 ||
1410
+ * | 240p | 320 x 240 | 15 | 400 ||
1411
+ * | 360p | 640 x 360 | 15 | 800 ||
1412
+ * | 480p | 640 x 480 | 15 | 900 ||
1413
+ * | 720p | 1280 x 720 | 15 | 1500 ||
1414
+ * | 1080p | 1920 x 1080 | 15 | 2000 ||
1415
+ * | 1440p | 2560 x 1440 | 30 | 4860 ||
1416
+ * | 4K | 3840 x 2160 | 30 | 9000 ||
1417
+ * @property {number} width - Video width
1418
+ * @property {number} height - Video height
1419
+ * @property {number} frameRate - Video frame rate
1420
+ * @property {number} bitrate - Video bitrate
1421
+ * @example
1422
+ * const config = {
1423
+ * option: {
1424
+ * profile: '480p',
1425
+ * },
1426
+ * }
1427
+ * await trtc.startLocalVideo(config);
1428
+ * @example
1429
+ * const config = {
1430
+ * option: {
1431
+ * profile: {
1432
+ * width: 640,
1433
+ * height: 480,
1434
+ * frameRate: 15,
1435
+ * bitrate: 900,
1436
+ * }
1437
+ * }
1438
+ * }
1439
+ * await trtc.startLocalVideo(config);
1440
+ */
1441
+ /**
1442
+ * Start collecting video from the local camera, play the camera's video on the specified HTMLElement tag, and publish the camera's video to the current room.
1443
+ * - When to call: can be called before or after entering the room, but cannot be called repeatedly.
1444
+ * - Only one camera can be started per trtc instance. If you need to start another camera for testing while one camera is already started, you can create multiple trtc instances to achieve this.
1445
+
1446
+ * @param {object} [config]
1447
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or ID for local video preview. If not passed or passed as null, the video will not be played.
1448
+ * @param {boolean} [config.publish] - Whether to publish the local video to the room. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1449
+ * @param {boolean | string} [config.mute] - Whether to mute camera. Supports passing in image url string, the image will be published instead of origin camera stream, Other users in the room will receive the REMOTE_AUDIO_AVAILABLE event. It does not support calling when the camera is turned off. More information: {@tutorial 15-basic-dynamic-add-video}.
1450
+ * @param {object} [config.option] - Local video configuration
1451
+ * @param {string} [config.option.cameraId] - Specify which camera to use for switching cameras.
1452
+ * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera.
1453
+ * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1454
+ * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
1455
+ * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
1456
+ * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
1457
+ * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
1458
+ * - false: Boolean value, represents no mirroring.
1459
+ *
1460
+ * <font color="orange"> Note: Before version 5.3.2, only boolean can be passed, where true represents local preview mirroring, and false represents no mirroring.</font>
1461
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `cover`. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1462
+ * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main video.
1463
+ * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1464
+ * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first(default) ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1465
+ * @throws
1466
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1467
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1468
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1469
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1470
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1471
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1472
+ * @example
1473
+ * // Preview and publish the camera
1474
+ * await trtc.startLocalVideo({
1475
+ * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1476
+ * });
1477
+ * @example
1478
+ * // Preview the camera without publishing. Can be used for camera testing.
1479
+ * const config = {
1480
+ * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1481
+ * publish: false // Do not publish the camera
1482
+ * }
1483
+ * await trtc.startLocalVideo(config);
1484
+ * // Call updateLocalVideo when you need to publish the video
1485
+ * await trtc.updateLocalVideo({ publish:true });
1486
+ * @example
1487
+ * // Use a specified camera.
1488
+ * const cameraList = await TRTC.getCameraList();
1489
+ * if (cameraList[0]) {
1490
+ * await trtc.startLocalVideo({
1491
+ * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1492
+ * option: {
1493
+ * cameraId: cameraList[0].deviceId,
1494
+ * }
1495
+ * });
1496
+ * }
1497
+ *
1498
+ * // use front camera on mobile device.
1499
+ * await trtc.startLocalVideo({ view, option: { useFrontCamera: true }});
1500
+ * // use rear camera on mobile device.
1501
+ * await trtc.startLocalVideo({ view, option: { useFrontCamera: false }});
1502
+ * @memberof TRTC
1503
+ */
1504
+ startLocalVideo(config?: LocalVideoConfig): Promise<void>;
1505
+ /**
1506
+ * Update the local camera configuration.
1507
+ * - This interface needs to be called after {@link TRTC#startLocalVideo startLocalVideo()} is successful.
1508
+ * - This interface can be called multiple times.
1509
+ * - This method uses incremental update: only updates the passed-in parameters, and keeps the parameters that are not passed in unchanged.
1510
+ * @param {object} [config]
1511
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id of the preview camera. If not passed in or passed in null, the video will not be rendered, but the container that consumes bandwidth will still be pushed.
1512
+ * @param {boolean} [config.publish] - Whether to publish the local video to the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1513
+ * @param {boolean | string} [config.mute] - Whether to mute camera. Supports passing in image url string, the image will be published instead of origin camera stream, Other users in the room will receive the REMOTE_AUDIO_AVAILABLE event. It does not support calling when the camera is turned off. More information: {@tutorial 15-basic-dynamic-add-video}.
1514
+ * @param {object} [config.option] - Local video configuration
1515
+ * @param {string} [config.option.cameraId] - Specify which camera to use
1516
+ * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera
1517
+ * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1518
+ * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
1519
+ * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
1520
+ * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
1521
+ * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
1522
+ * - false: Boolean value, represents no mirroring.
1523
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit| CSS object-fit} property
1524
+ * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main stream
1525
+ * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1526
+ * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1527
+ * @throws
1528
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1529
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1530
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1531
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1532
+ * @example
1533
+ * // Switch camera
1534
+ * const cameraList = await TRTC.getCameraList();
1535
+ * if (cameraList[1]) {
1536
+ * await trtc.updateLocalVideo({ option: { cameraId: cameraList[1].deviceId }});
1537
+ * }
1538
+ * @example
1539
+ * // Stop publishing video, but keep local preview
1540
+ * await trtc.updateLocalVideo({ publish:false });
1541
+ * @memberof TRTC
1542
+ */
1543
+ updateLocalVideo(config: LocalVideoConfig): Promise<void>;
1544
+ /**
1545
+ * Stop capturing, previewing, and publishing the local camera.
1546
+ * - If you only want to stop publishing video but keep the local camera preview, you can use the {@link TRTC#updateLocalVideo updateLocalVideo({ publish:false })} method.<br>
1547
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1548
+ * @example
1549
+ * await trtc.stopLocalVideo();
1550
+ */
1551
+ stopLocalVideo(): Promise<void>;
1552
+ /**
1553
+ * @typedef {object|string} ScreenShareProfile - Screen sharing resolution, bit rate, and frame rate configuration
1554
+ * Screen sharing configuration parameters, can use preset values or custom resolution and other parameters
1555
+ * | Screen Profile | Resolution (width x height) | Frame Rate (fps) | Bitrate (kbps) |
1556
+ * | :--- | :--- | :--- | :--- |
1557
+ * | 480p | 640 x 480 | 5 | 900 |
1558
+ * | 480p_2 | 640 x 480 | 30 | 1000 |
1559
+ * | 720p | 1280 x 720 | 5 | 1200 |
1560
+ * | 720p_2 | 1280 x 720 | 30 | 3000 |
1561
+ * | 1080p | 1920 x 1080 | 5 | 1600 |
1562
+ * | 1080p_2 | 1920 x 1080 | 30 | 4000 |
1563
+ * - The default resolution for screen sharing is `1080p`.
1564
+ * - If the above profiles do not meet your business needs, you can also specify custom resolution, frame rate, and bitrate.
1565
+
1566
+ * @property {number} width - Screen sharing width
1567
+ * @property {number} height - Screen sharing height
1568
+ * @property {number} frameRate - Screen sharing frame rate
1569
+ * @property {number} bitrate - Screen sharing bitrate
1570
+ * @example
1571
+ * const config = {
1572
+ * option: {
1573
+ * profile: '720p',
1574
+ * },
1575
+ * }
1576
+ * await trtc.startScreenShare(config);
1577
+ */
1578
+ /**
1579
+ * Start screen sharing.
1580
+ *
1581
+ * - After starting screen sharing, other users in the room will receive the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE REMOTE_VIDEO_AVAILABLE} event, with streamType as {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB}, and other users can play screen sharing through {@link TRTC#startRemoteVideo startRemoteVideo}.
1582
+ * @param {object} [config]
1583
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id for previewing local screen sharing. If not passed or passed as null, local screen sharing will not be rendered.
1584
+ * @param {boolean} [config.publish] - Whether to publish screen sharing to the room. The default is true. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1585
+ * @param {object} [config.option] - Screen sharing configuration
1586
+ * @param {boolean} [config.option.systemAudio] - Whether to capture system audio. The default is false.
1587
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `contain`, refer to {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1588
+ * @param {ScreenShareProfile} [config.option.profile] - Screen sharing encoding configuration.
1589
+ * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first(default) ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1590
+ * @param {HTMLElement} [config.option.captureElement] - Capture screen from the specified element of current tab. Available on Chrome 104+.
1591
+ * @param {'current-tab' | 'tab' | 'window' | 'monitor'} [config.option.preferDisplaySurface='monitor'] - The prefer display surface for screen sharing. Available on Chrome 94+.
1592
+ * - The default is monitor, which means that monitor capture will be displayed first in the Screen Sharing Capture pre-checkbox。
1593
+ * - If you fill in 'current-tab', the pre-checkbox will only show the current page.
1594
+ * @throws
1595
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1596
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1597
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1598
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1599
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1600
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1601
+ * @example
1602
+ * // Start screen sharing
1603
+ * await trtc.startScreenShare();
1604
+ * @memberof TRTC
1605
+ */
1606
+ startScreenShare(config?: ScreenShareConfig): Promise<void>;
1607
+ /**
1608
+ * Update screen sharing configuration
1609
+ * - This interface needs to be called after {@link TRTC#startScreenShare startScreenShare()} is successful.
1610
+ * - This interface can be called multiple times.
1611
+ * - This method uses incremental update: only update the passed-in parameters, and keep the parameters that are not passed-in unchanged.
1612
+ * @param {object} [config]
1613
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id for screen sharing preview. If not passed in or passed in null, the screen sharing will not be rendered.
1614
+ * @param {boolean} [config.publish=true] - Whether to publish screen sharing to the room
1615
+ * @param {object} [config.option] - Screen sharing configuration
1616
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `contain`, refer to {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1617
+ * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1618
+ * @throws
1619
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1620
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1621
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1622
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1623
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1624
+ * @example
1625
+ * // Stop screen sharing, but keep the local preview of screen sharing
1626
+ * await trtc.updateScreenShare({ publish:false });
1627
+ * @memberof TRTC
1628
+ */
1629
+ updateScreenShare(config: UpdateScreenShareConfig): Promise<void>;
1630
+ /**
1631
+ * Stop screen sharing.
1632
+
1633
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1634
+ * @example
1635
+ * await trtc.stopScreenShare();
1636
+ */
1637
+ stopScreenShare(): Promise<void>;
1638
+ /**
1639
+ * Play remote video
1640
+ *
1641
+ * - When to call: Call after receiving the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE TRTC.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE)} event.
1642
+ * @param {object} [config]
1643
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id used to play remote video. If not passed or passed null, the video will not be rendered, but the bandwidth will still be consumed.
1644
+ * @param {string} config.userId - Remote user ID
1645
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1646
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1647
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1648
+ * @param {object} [config.option] - Remote video configuration
1649
+ * @param {boolean} [config.option.small] - Whether to subscribe small streams
1650
+ * @param {boolean} [config.option.mirror] - Whether to enable mirror
1651
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1652
+ * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1653
+ * @param {HTMLElement} [config.option.viewRoot=document.body] - Since v5.4.0 <br>The root element is the parent element of the view and is used to calculate whether the view is visible relative to the root. The default value is document.body, and it is recommended that you use the first-level parent of the video view list. Refer to: {@tutorial 27-advanced-small-stream}.
1654
+ * @throws
1655
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1656
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1657
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1658
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1659
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1660
+ * @example
1661
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, ({ userId, streamType }) => {
1662
+ * // You need to place the video container in the DOM in advance, and it is recommended to use `${userId}_${streamType}` as the element id.
1663
+ * trtc.startRemoteVideo({ userId, streamType, view: `${userId}_${streamType}` });
1664
+ * })
1665
+ * @memberof TRTC
1666
+ */
1667
+ startRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1668
+ /**
1669
+ * Update remote video playback configuration<br>
1670
+ * - This method should be called after {@link TRTC#startRemoteVideo startRemoteVideo} is successful.
1671
+ * - This method can be called multiple times.
1672
+ * - This method uses incremental updates, so only the configuration items that need to be updated need to be passed in.
1673
+ * @param {object} [config]
1674
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id used to play remote video. If not passed or passed null, the video will not be rendered, but the bandwidth will still be consumed.
1675
+ * @param {string} config.userId - Remote user ID
1676
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1677
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1678
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1679
+ * @param {object} [config.option] - Remote video configuration
1680
+ * @param {boolean} [config.option.small] - Whether to subscribe small streams. Refer to: {@tutorial 27-advanced-small-stream}.
1681
+ * @param {boolean} [config.option.mirror] - Whether to enable mirror
1682
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1683
+ * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1684
+ * @param {HTMLElement} [config.option.viewRoot=document.body] - Since v5.4.0 <br>The root element is the parent element of the view and is used to calculate whether the view is visible relative to the root. The default value is document.body, and it is recommended that you use the first-level parent of the video view list. Refer to: {@tutorial 27-advanced-small-stream}.
1685
+ * @throws
1686
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1687
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1688
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1689
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1690
+ * @example
1691
+ * const config = {
1692
+ * view: document.getElementById(userId), // you can use a new view to update the position of video.
1693
+ * userId,
1694
+ * streamType: TRTC.TYPE.STREAM_TYPE_MAIN
1695
+ * }
1696
+ * await trtc.updateRemoteVideo(config);
1697
+ * @memberof TRTC
1698
+ */
1699
+ updateRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1700
+ /**
1701
+ * Used to stop remote video playback.<br>
1702
+ * @param {object} config - Remote video configuration
1703
+ * @param {string} config.userId - Remote user ID, '*' represents all users.
1704
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} [config.streamType] - Remote stream type. This field is required when userId is not '*'.
1705
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1706
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1707
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1708
+ * @example
1709
+ * // Stop playing all remote users
1710
+ * await trtc.stopRemoteVideo({ userId: '*' });
1711
+ */
1712
+ stopRemoteVideo(config: StopRemoteVideoConfig): Promise<void>;
1713
+ /**
1714
+ * Mute a remote user and stop subscribing audio data from that user. Only effective for the current user, other users in the room can still hear the muted user's voice.<br>
1715
+ *
1716
+ * Note:
1717
+ * - By default, after entering the room, the SDK will automatically play remote audio. You can call this interface to mute or unmute remote users.
1718
+ * - If the parameter autoReceiveAudio = false is passed in when entering the room, remote audio will not be played automatically. When audio playback is required, you need to call this method (mute is passed in false) to play remote audio.
1719
+ * - This interface is effective before or after entering the room (enterRoom), and the mute state will be reset to false after exiting the room (exitRoom).
1720
+ * - If you want to continue subscribing audio data from the user but not play it, you can call setRemoteAudioVolume(userId, 0)
1721
+ * @param {string} userId - Remote user ID, '*' represents all users.
1722
+ * @param {boolean} mute - Whether to mute
1723
+ * @throws
1724
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1725
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1726
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1727
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1728
+ * @example
1729
+ * // Mute all remote users
1730
+ * await trtc.muteRemoteAudio('*', true);
1731
+ */
1732
+ muteRemoteAudio(userId: string, mute: boolean): Promise<void>;
1733
+ /**
1734
+ * Used to control the playback volume of remote audio.<br>
1735
+ *
1736
+ * - Not supported by iOS Safari
1737
+ * @param {string} userId - Remote user ID。'*' represents all remote users.
1738
+ * @param {number} volume - Volume, ranging from 0 to 100. The default value is 100.<br>
1739
+ * Since `v5.1.3+`, the volume can be set higher than 100.
1740
+ * @example
1741
+ * await trtc.setRemoteAudioVolume('123', 90);
1742
+ */
1743
+ setRemoteAudioVolume(userId: string, volume: number): void;
1744
+ startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1745
+ startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1746
+ updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1747
+ updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1748
+ stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1749
+ stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1750
+ /**
1751
+ * Enables or disables the volume callback.<br>
1752
+ *
1753
+ * - After enabling this function, whether someone is speaking in the room or not, the SDK will regularly throw the {@link module:EVENT.AUDIO_VOLUME TRTC.on(TRTC.EVENT.AUDIO_VOLUME)} event, which feedbacks the volume evaluation value of each user.<br>
1754
+ *
1755
+ * @param {number} [interval=2000] Used to set the time interval for triggering the volume callback event. The default is 2000(ms), and the minimum value is 100(ms). If set to less than or equal to 0, the volume callback will be turned off.
1756
+ * @param {boolean} [enableInBackground=false] For performance reasons, when the page switches to the background, the SDK will not throw volume callback events. If you need to receive volume callback events when the page is switched to the background, you can set this parameter to true.
1757
+ * @memberof TRTC
1758
+ * @example
1759
+ * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
1760
+ * event.result.forEach(({ userId, volume }) => {
1761
+ * const isMe = userId === ''; // When userId is an empty string, it represents the local microphone volume.
1762
+ * if (isMe) {
1763
+ * console.log(`my volume: ${volume}`);
1764
+ * } else {
1765
+ * console.log(`user: ${userId} volume: ${volume}`);
1766
+ * }
1767
+ * })
1768
+ * });
1769
+ *
1770
+ * // Enable volume callback and trigger the event every 1000ms
1771
+ * trtc.enableAudioVolumeEvaluation(1000);
1772
+ *
1773
+ * // To turn off the volume callback, pass in an interval value less than or equal to 0
1774
+ * trtc.enableAudioVolumeEvaluation(-1);
1775
+ */
1776
+ enableAudioVolumeEvaluation(interval?: number, enableInBackground?: boolean): void;
1777
+ /**
1778
+ * Listen to TRTC events<br><br>
1779
+ * For a detailed list of events, please refer to: {@link module:EVENT TRTC.EVENT}
1780
+ *
1781
+ * @param {string} eventName Event name
1782
+ * @param {function} handler Event callback function
1783
+ * @param {context} context Context
1784
+ * @memberof TRTC
1785
+ * @example
1786
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
1787
+ * // REMOTE_VIDEO_AVAILABLE event handler
1788
+ * });
1789
+ */
1790
+ on<T extends keyof TRTCEventTypes>(event: T, handler: (...args: TRTCEventTypes[T]) => void, context?: any): this;
1791
+ /**
1792
+ * Remove event listener<br>
1793
+ *
1794
+ * @param {string} eventName Event name. Passing in the wildcard '*' will remove all event listeners.
1795
+ * @param {function} handler Event callback function
1796
+ * @param {context} context Context
1797
+ * @memberof TRTC
1798
+ * @example
1799
+ * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, function peerJoinHandler(event) {
1800
+ * // REMOTE_USER_ENTER event handler
1801
+ * console.log('remote user enter');
1802
+ *
1803
+ * trtc.off(TRTC.EVENT.REMOTE_USER_ENTER, peerJoinHandler);
1804
+ * });
1805
+ *
1806
+ * // Remove all event listeners
1807
+ * trtc.off('*');
1808
+ */
1809
+ off<T extends keyof TRTCEventTypes>(event: T | '*', handler: T extends '*' ? never : (...args: TRTCEventTypes[T]) => void, context?: any): this;
1810
+ /**
1811
+ * Get audio track
1812
+ *
1813
+ * @returns {MediaStreamTrack?} Audio track
1814
+ * @param {Object|string} [config] If not passed, get the local microphone audioTrack
1815
+ * @param {string} [config.userId] If not passed or passed an empty string, get the local audioTrack. Pass the userId of the remote user to get the remote user's audioTrack.
1816
+ * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1817
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's microphone)(default)
1818
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing audio). Only works for local screen sharing audio because there is only one remote audioTrack, and there is no distinction between Main and Sub for remote audioTrack.
1819
+ * @memberof TRTC
1820
+ * @example
1821
+ * // Version before v5.4.3
1822
+ * trtc.getAudioTrack(); // Get local microphone audioTrack, captured by trtc.startLocalAudio()
1823
+ * trtc.getAudioTrack('remoteUserId'); // Get remote audioTrack
1824
+ *
1825
+ * // Since v5.4.3+, you can get local screen audioTrack by passing the streamType = TRTC.STREAM_TYPE_SUB
1826
+ * trtc.getAudioTrack({ streamType: TRTC.STREAM_TYPE_SUB });
1827
+ */
1828
+ getAudioTrack(configOrUserId?: {
1829
+ userId?: string;
1830
+ streamType?: TRTCStreamType;
1831
+ } | string): MediaStreamTrack | null;
1832
+ /**
1833
+ * Get video track
1834
+ *
1835
+ * @param {string} [config] If not passed, get the local camera videoTrack
1836
+ * @param {string} [config.userId] If not passed or passed an empty string, get the local videoTrack. Pass the userId of the remote user to get the remote user's videoTrack.
1837
+ * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1838
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's camera)(default)
1839
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing)
1840
+ * @returns {MediaStreamTrack|null} Video track
1841
+ * @memberof TRTC
1842
+ * @example
1843
+ * // Get local camera videoTrack
1844
+ * const videoTrack = trtc.getVideoTrack();
1845
+ * // Get local screen sharing videoTrack
1846
+ * const screenVideoTrack = trtc.getVideoTrack({ streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1847
+ * // Get remote user's main stream videoTrack
1848
+ * const remoteMainVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_MAIN });
1849
+ * // Get remote user's sub stream videoTrack
1850
+ * const remoteSubVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1851
+ */
1852
+ getVideoTrack(config?: {
1853
+ userId?: string;
1854
+ streamType?: TRTCStreamType;
1855
+ }): MediaStreamTrack | null;
1856
+ /**
1857
+ * Get video snapshot <br>
1858
+ * Notice: must play the video before it can obtain the snapshot. If there is no playback, an empty string will be returned.
1859
+ * @param {string} config.userId - Remote user ID
1860
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType
1861
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream
1862
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream
1863
+ * @since 5.4.0
1864
+ * @example
1865
+ * // get self main stream video frame
1866
+ * trtc.getVideoSnapshot()
1867
+ * // get self sub stream video frame
1868
+ * trtc.getVideoSnapshot({streamType:TRTC.TYPE.STREAM_TYPE_SUB})
1869
+ * // get remote user main stream video frame
1870
+ * trtc.getVideoSnapshot({userId: 'remote userId', streamType:TRTC.TYPE.STREAM_TYPE_MAIN})
1871
+ * @memberof TRTC
1872
+ */
1873
+ getVideoSnapshot(config?: VideoFrameConfig): string;
1874
+ setCurrentSpeaker(speakerId: string): void;
1875
+ /**
1876
+ * Send SEI Message <br>
1877
+ *
1878
+ * > The header of a video frame has a header block called SEI.
1879
+ * > The principle of this interface is to use the SEI to embed the custom data you want to send along with the video frame.
1880
+ * > SEI messages can accompany video frames all the way to the live CDN.
1881
+ *
1882
+ * Applicable scenarios: synchronization of lyrics, live answering questions, etc.
1883
+ *
1884
+ * When to call: call after {@link TRTC#startLocalVideo trtc.startLocalVideo} or {@link TRTC#startLocalScreen trtc.startLocalScreen} when set 'toSubStream' option to true successfully.
1885
+ *
1886
+ * Note:
1887
+ * 1. Maximum 1KB(Byte) sent in a single call, maximum 30 calls per second, maximum 8KB sent per second.
1888
+ * 2. Currently only support Chrome 86+, Edge 86+, Opera 72+ browsers.
1889
+ * 3. Since SEI is sent along with video frames, there is a possibility that video frames may be lost, and therefore SEI may be lost as well. The number of times it can be sent can be increased within the frequency limit, and the business side needs to do message de-duplication on the receiving side.
1890
+ * 4. SEI cannot be sent without trtc.startLocalVideo(or trtc.startLocalScreen when set 'toSubStream' option to true); SEI cannot be received without startRemoteVideo.
1891
+ * 5. Only H264 encoder is supported to send SEI.
1892
+ * 6. SEI sending and receiving is not supported for small streams for the time being.
1893
+ * @see {@link module:EVENT.SEI_MESSAGE TRTC.EVENT.SEI_MESSAGE}
1894
+ * @since v5.3.0
1895
+ * @param {ArrayBuffer} buffer SEI data to be sent
1896
+ * @param {Object=} options
1897
+ * @param {Number} options.seiPayloadType Set the SEI payload type. SDK uses the custom payloadType 243 by default, the business side can use this parameter to set the payloadType to the standard 5. When the business side uses the 5 payloadType, you need to follow the specification to make sure that the first 16 bytes of the `buffer` are the business side's customized uuid.
1898
+ * @param {Boolean} [options.toSubStream=false] Send SEI data to substream. Need call trtc.startLocalScreen first. Since v5.7.0+.
1899
+ * @example
1900
+ * // 1. enable SEI
1901
+ * const trtc = TRTC.create({
1902
+ * enableSEI: true
1903
+ * })
1904
+ *
1905
+ * // 2. send SEI
1906
+ * try {
1907
+ * await trtc.enterRoom({
1908
+ * userId: 'user_1',
1909
+ * roomId: 12345,
1910
+ * })
1911
+ * await trtc.startLocalVideo();
1912
+ * const unit8Array = new Uint8Array([1, 2, 3]);
1913
+ * trtc.sendSEIMessage(unit8Array.buffer);
1914
+ * } catch(error) {
1915
+ * console.warn(error);
1916
+ * }
1917
+ *
1918
+ * // 3. receive SEI
1919
+ * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
1920
+ * console.warn(`sei ${event.data} from ${event.userId}`);
1921
+ * })
1922
+ */
1923
+ sendSEIMessage(buffer: ArrayBuffer, options?: {
1924
+ seiPayloadType?: number;
1925
+ toSubStream?: boolean;
1926
+ }): void;
1927
+ /**
1928
+ * Send Custom Message to all remote users in the room. <br>
1929
+ *
1930
+ * Note:
1931
+ *
1932
+ * 1. Only {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} can call sendCustomMessage.
1933
+ * 2. You should call this api after {@link TRTC#enterRoom TRTC.enterRoom} successfully.
1934
+ * 3. The custom message will be sent in order and as reliably as possible, but it's possible to loss messages in a very bad network. The receiver will also receive the message in order.
1935
+ * @since v5.6.0
1936
+ * @see Listen for the event {@link module:EVENT.CUSTOM_MESSAGE TRTC.EVENT.CUSTOM_MESSAGE} to receive custom message.
1937
+ * @param {object} message
1938
+ * @param {number} message.cmdId message Id. Integer, range [1, 10]. You can set different cmdId for different types of messages to reduce the delay of transferring message.
1939
+ * @param {ArrayBuffer} message.data - message content. <br/>
1940
+ * - Maximum 1KB(Byte) sent in a single call.
1941
+ * - Maximum 30 calls per second
1942
+ * - Maximum 8KB sent per second.
1943
+ * @example
1944
+ * // send custom message
1945
+ * trtc.sendCustomMessage({
1946
+ * cmdId: 1,
1947
+ * data: new TextEncoder().encode('hello').buffer
1948
+ * });
1949
+ *
1950
+ * // receive custom message
1951
+ * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
1952
+ * // event.userId: remote userId.
1953
+ * // event.cmdId: message cmdId.
1954
+ * // event.seq: message sequence number.
1955
+ * // event.data: custom message data, type is ArrayBuffer.
1956
+ * console.log(`received custom msg from ${event.userId}, message: ${new TextDecoder().decode(event.data)}`)
1957
+ * })
1958
+ */
1959
+ sendCustomMessage(message: CustomMessageData): void;
1960
+ static EVENT: {
1961
+ readonly ERROR: "error";
1962
+ readonly AUTOPLAY_FAILED: "autoplay-failed";
1963
+ readonly KICKED_OUT: "kicked-out";
1964
+ readonly REMOTE_USER_ENTER: "remote-user-enter";
1965
+ readonly REMOTE_USER_EXIT: "remote-user-exit";
1966
+ readonly REMOTE_AUDIO_AVAILABLE: "remote-audio-available";
1967
+ readonly REMOTE_AUDIO_UNAVAILABLE: "remote-audio-unavailable";
1968
+ readonly REMOTE_VIDEO_AVAILABLE: "remote-video-available";
1969
+ readonly REMOTE_VIDEO_UNAVAILABLE: "remote-video-unavailable";
1970
+ readonly AUDIO_VOLUME: "audio-volume";
1971
+ readonly NETWORK_QUALITY: "network-quality";
1972
+ readonly CONNECTION_STATE_CHANGED: "connection-state-changed";
1973
+ readonly AUDIO_PLAY_STATE_CHANGED: "audio-play-state-changed";
1974
+ readonly VIDEO_PLAY_STATE_CHANGED: "video-play-state-changed";
1975
+ readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
1976
+ readonly DEVICE_CHANGED: "device-changed";
1977
+ readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
1978
+ readonly TRACK: "track";
1979
+ readonly STATISTICS: "statistics";
1980
+ readonly SEI_MESSAGE: "sei-message";
1981
+ readonly CUSTOM_MESSAGE: "custom-message";
1982
+ };
1983
+ static ERROR_CODE: {
1984
+ INVALID_PARAMETER: number;
1985
+ INVALID_OPERATION: number;
1986
+ ENV_NOT_SUPPORTED: number;
1987
+ DEVICE_ERROR: number;
1988
+ SERVER_ERROR: number;
1989
+ OPERATION_FAILED: number;
1990
+ OPERATION_ABORT: number;
1991
+ UNKNOWN_ERROR: number;
1992
+ };
1993
+ static TYPE: {
1994
+ readonly SCENE_LIVE: Scene.LIVE;
1995
+ readonly SCENE_RTC: Scene.RTC;
1996
+ readonly ROLE_ANCHOR: UserRole.ANCHOR;
1997
+ readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
1998
+ readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
1999
+ readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
2000
+ readonly AUDIO_PROFILE_STANDARD: "standard";
2001
+ readonly AUDIO_PROFILE_STANDARD_STEREO: "standard-stereo";
2002
+ readonly AUDIO_PROFILE_HIGH: "high";
2003
+ readonly AUDIO_PROFILE_HIGH_STEREO: "high-stereo";
2004
+ readonly QOS_PREFERENCE_SMOOTH: "smooth";
2005
+ readonly QOS_PREFERENCE_CLEAR: "clear";
2006
+ };
2007
+ static frameWorkType: number;
2008
+ /**
2009
+ * Set the log output level
2010
+ * <br>
2011
+ * It is recommended to set the DEBUG level during development and testing, which includes detailed prompt information.
2012
+ * The default output level is INFO, which includes the log information of the main functions of the SDK.
2013
+ *
2014
+ * @param {0-5} [level] Log output level 0: TRACE 1: DEBUG 2: INFO 3: WARN 4: ERROR 5: NONE
2015
+ * @param {boolean} [enableUploadLog=true] Whether to enable log upload, which is enabled by default. It is not recommended to turn it off, which will affect problem troubleshooting.
2016
+ * @example
2017
+ * // Output log levels above DEBUG
2018
+ * TRTC.setLogLevel(1);
2019
+ */
2020
+ static setLogLevel(level: LOG_LEVEL, enableUploadLog?: boolean): void;
2021
+ /**
2022
+ * Check if the TRTC Web SDK is supported by the current browser
2023
+ *
2024
+ * - Reference: {@tutorial 05-info-browser}.
2025
+ * @example
2026
+ * TRTC.isSupported().then((checkResult) => {
2027
+ * if(!checkResult.result) {
2028
+ * console.log('checkResult', checkResult.result, 'checkDetail', checkResult.detail);
2029
+ * // The SDK is not supported by the current browser, guide the user to use the latest version of Chrome browser.
2030
+ * }
2031
+ * });
2032
+ *
2033
+ * @returns {Promise.<object>} Promise returns the detection result
2034
+ * | Property | Type | Description |
2035
+ * |--------------------------------------------|---------|-------------------------------------|
2036
+ * | checkResult.result | boolean | Detection result |
2037
+ * | checkResult.detail.isBrowserSupported | boolean | Whether the current browser is supported by the SDK |
2038
+ * | checkResult.detail.isWebRTCSupported | boolean | Whether the current browser supports WebRTC |
2039
+ * | checkResult.detail.isWebCodecsSupported | boolean | Whether the current browser supports WebCodecs |
2040
+ * | checkResult.detail.isMediaDevicesSupported | boolean | Whether the current browser supports obtaining media devices and media streams |
2041
+ * | checkResult.detail.isScreenShareSupported | boolean | Whether the current browser supports screen sharing |
2042
+ * | checkResult.detail.isSmallStreamSupported | boolean | Whether the current browser supports small streams |
2043
+ * | checkResult.detail.isH264EncodeSupported | boolean | Whether the current browser supports H264 encoding for uplink |
2044
+ * | checkResult.detail.isH264DecodeSupported | boolean | Whether the current browser supports H264 decoding for downlink |
2045
+ * | checkResult.detail.isVp8EncodeSupported | boolean | Whether the current browser supports VP8 encoding for uplink |
2046
+ * | checkResult.detail.isVp8DecodeSupported | boolean | Whether the current browser supports VP8 decoding for downlink |
2047
+ */
2048
+ static isSupported(): Promise<any>;
2049
+ /**
2050
+ * Returns the list of camera devices
2051
+ * <br>
2052
+ * **Note**
2053
+ * - This interface does not support use under the http protocol, please use the https protocol to deploy your website. {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Privacy_and_security Privacy and security}
2054
+ * - You can call the browser's native interface [getCapabilities](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities) to get the maximum resolutions supported by the camera, frame rate, mobile devices to distinguish between front and rear cameras, etc. This interface supports Chrome 67+, Edge 79+, Safari 17+, Opera 54+.
2055
+ * @param {boolean} [requestPermission=true] `Since v5.6.3`. Whether to request permission to use the camera. If requestPermission is true, calling this method may temporarily open the camera to ensure that the camera list can be normally obtained, and the SDK will automatically stop the camera capture later.
2056
+ * @example
2057
+ * const cameraList = await TRTC.getCameraList();
2058
+ * if (cameraList[0] && cameraList[0].getCapabilities) {
2059
+ * const { width, height, frameRate, facingMode } = cameraList[0].getCapabilities();
2060
+ * console.log(width.max, height.max, frameRate.max);
2061
+ * if (facingMode) {
2062
+ * if (facingMode[0] === 'user') {
2063
+ * // front camera
2064
+ * } else if (facingMode[0] === 'environment') {
2065
+ * // rear camera
2066
+ * }
2067
+ * }
2068
+ * }
2069
+ * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
2070
+ */
2071
+ static getCameraList(requestPermission?: boolean): Promise<MediaDeviceInfo[]>;
2072
+ /**
2073
+ * Returns the list of microphone devices
2074
+ * <br>
2075
+ * **Note**
2076
+ * - This interface does not support use under the http protocol, please use the https protocol to deploy your website. {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Privacy_and_security Privacy and security}
2077
+ * - You can call the browser's native interface [getCapabilities](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities) to get information about the microphone's capabilities, e.g. the maximum number of channels supported, etc. This interface supports Chrome 67+, Edge 79+, Safari 17+, Opera 54+.
2078
+ * @param {boolean} [requestPermission=true] `Since v5.6.3`. Whether to request permission to use the microphone. If requestPermission is true, calling this method may temporarily open the microphone to ensure that the microphone list can be normally obtained, and the SDK will automatically stop the microphone capture later.
2079
+ * @example
2080
+ * const microphoneList = await TRTC.getMicrophoneList();
2081
+ * if (microphoneList[0] && microphoneList[0].getCapabilities) {
2082
+ * const { channelCount } = microphoneList[0].getCapabilities();
2083
+ * console.log(channelCount.max);
2084
+ * }
2085
+ * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
2086
+ */
2087
+ static getMicrophoneList(requestPermission?: boolean): Promise<MediaDeviceInfo[]>;
2088
+ /**
2089
+ * Returns the list of speaker devices. Only support PC browser, not support mobile browser.
2090
+ * <br>
2091
+ * @param {boolean} [requestPermission=true] `Since v5.6.3`. Whether to request permission to use the microphone. If requestPermission is true, calling this method may temporarily open the microphone to ensure that the microphone list can be normally obtained, and the SDK will automatically stop the microphone capture later.
2092
+ * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
2093
+ */
2094
+ static getSpeakerList(requestPermission?: boolean): Promise<MediaDeviceInfo[]>;
2095
+ /**
2096
+ * Set the current speaker for audio playback
2097
+ *
2098
+ * @param {string} speakerId Speaker ID
2099
+ */
2100
+ static setCurrentSpeaker(speakerId: string): Promise<void>;
1841
2101
  }
1842
2102
  export default TRTC