trtc-sdk-v5 5.7.1-beta.7 → 5.7.1-beta.9

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,1822 +1,1819 @@
1
- /// <reference path="./core.d.ts" />
1
+ /// <reference path="./core.d.ts" />
2
2
 
3
- declare type PluginWithAssets = {
4
- plugin: IPluginClass;
5
- assetsPath?: string;
6
- };
7
- declare interface TRTCOptions {
8
- plugins?: Array<IPluginClass>;
9
- enableSEI?: boolean;
10
- assetsPath?: string;
11
- }
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
- };
26
- }
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;
35
- }
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;
52
- }
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
- };
69
- }
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
- };
75
- }
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
- };
87
- }
88
- declare interface StopRemoteVideoConfig {
89
- userId: string;
90
- streamType?: TRTCStreamType;
91
- }
92
- declare interface LocalAudioConfig {
93
- publish?: boolean;
94
- mute?: boolean;
95
- option?: {
96
- microphoneId?: string;
97
- profile?: keyof typeof audioProfileMap;
98
- audioTrack?: MediaStreamTrack;
99
- captureVolume?: number;
100
- earMonitorVolume?: number;
101
- echoCancellation?: boolean;
102
- autoGainControl?: boolean;
103
- noiseSuppression?: boolean;
104
- };
105
- }
106
- declare interface UpdateLocalAudioConfig extends LocalAudioConfig {
107
- mute?: boolean;
108
- option?: {
109
- microphoneId?: string;
110
- audioTrack?: MediaStreamTrack;
111
- captureVolume?: number;
112
- earMonitorVolume?: number;
113
- echoCancellation?: boolean;
114
- autoGainControl?: boolean;
115
- noiseSuppression?: boolean;
116
- };
117
- }
118
- declare interface RemoteAudioConfig {
119
- userId: string;
120
- option?: {
121
- volume?: number;
122
- };
123
- }
124
- declare interface StopRemoteAudioConfig {
125
- userId: string;
126
- }
127
- declare const enum TRTCStreamType {
128
- Main = "main",
129
- Sub = "sub"
130
- }
131
- declare enum TRTCDeviceType {
132
- Camera = "camera",
133
- Microphone = "microphone",
134
- Speaker = "speaker"
135
- }
136
- declare enum TRTCDeviceAction {
137
- Remove = "remove",
138
- Add = "add",
139
- Active = "active"
140
- }
141
- declare interface RTCErrorParams {
142
- code: number;
143
- extraCode?: number;
144
- functionName?: string;
145
- fnName?: string;
146
- message?: string;
147
- messageParams?: any;
148
- originError?: Error | DOMException;
149
- }
150
- declare interface RTCErrorInterface {
151
- readonly name: string;
152
- readonly code: number;
153
- readonly extraCode?: number;
154
- readonly functionName?: string;
155
- readonly message?: string;
156
- readonly originError?: Error | DOMException;
157
- }
158
- declare interface ErrorMessageParams {
159
- key?: string;
160
- rule?: any;
161
- fnName?: string;
162
- fnParams?: any;
163
- value?: string | number | any;
164
- type?: string;
165
- deviceType?: string;
166
- error?: Error | DOMException | CoreError;
167
- }
168
- /**
169
- * **TRTC Constants**<br>
170
- * @module TYPE
171
- * @example
172
- * // Usage:
173
- * TRTC.TYPE.SCENE_LIVE
174
- */
175
- declare const TRTCType: {
176
- /**
177
- * Live streaming scene
178
- * @default 'live'
179
- * @memberof module:TYPE
180
- */
181
- readonly SCENE_LIVE: Scene.LIVE;
182
- /**
183
- * RTC scene
184
- * @default 'rtc'
185
- * @memberof module:TYPE
186
- */
187
- readonly SCENE_RTC: Scene.RTC;
188
- /**
189
- * Anchor role
190
- * @default 'anchor'
191
- * @memberof module:TYPE
192
- */
193
- readonly ROLE_ANCHOR: UserRole.ANCHOR;
194
- /**
195
- * Audience role
196
- * @default 'audience'
197
- * @memberof module:TYPE
198
- */
199
- readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
200
- /**
201
- * Main stream
202
- *
203
- * - TRTC has a main video stream (main stream) and an sub video stream (sub stream)
204
- * - The camera is published through the main stream, and the screen sharing is published through the sub stream.
205
- * - 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).
206
- * @default 'main'
207
- * @memberof module:TYPE
208
- */
209
- readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
210
- /**
211
- * Sub stream
212
- * @default 'sub'
213
- * @memberof module:TYPE
214
- */
215
- readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
216
- /**
217
- * Standard audio quality
218
- * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
219
- * | :--- | :--- | :--- | :--- |
220
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
221
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
222
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
223
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
224
- * @default 'standard'
225
- * @memberof module:TYPE
226
- */
227
- readonly AUDIO_PROFILE_STANDARD: "standard";
228
- /**
229
- * Standard stereo audio quality
230
- * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
231
- * | :--- | :--- | :--- | :--- |
232
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
233
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
234
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
235
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
236
- * @default 'standard-stereo'
237
- * @memberof module:TYPE
238
- */
239
- readonly AUDIO_PROFILE_STANDARD_STEREO: "standard-stereo";
240
- /**
241
- * High audio quality
242
- * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
243
- * | :--- | :--- | :--- | :--- |
244
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
245
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
246
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
247
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
248
- * @default 'high'
249
- * @memberof module:TYPE
250
- */
251
- readonly AUDIO_PROFILE_HIGH: "high";
252
- /**
253
- * High-quality stereo audio
254
- * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
255
- * | :--- | :--- | :--- | :--- |
256
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
257
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
258
- * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
259
- * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
260
- * @default 'high-stereo'
261
-
262
- * @memberof module:TYPE
263
- */
264
- readonly AUDIO_PROFILE_HIGH_STEREO: "high-stereo";
265
- /**
266
- * When the network is weak, the video encoding strategy takes 'smooth' first, i.e., the priority is to preserve frame rate.
267
- * <br>
268
- * Default 'smooth' first for camera, 'default' clear first for screen sharing
269
- * @default 'smooth'
270
- * @memberof module:TYPE
271
- */
272
- readonly QOS_PREFERENCE_SMOOTH: "smooth";
273
- /**
274
- * When the network is weak, the video encoding strategy takes 'clear' first, i.e., the priority is to preserve resolution.
275
- * <br>
276
- * Default 'smooth' first for camera, 'default' clear first for screen sharing
277
- * @default 'clear'
278
- * @memberof module:TYPE
279
- */
280
- readonly QOS_PREFERENCE_CLEAR: "clear";
281
- };
282
- declare interface AudioMixerOptions {
283
- id: string;
284
- url: string;
285
- loop?: boolean;
286
- volume?: number;
287
- }
288
- declare interface UpdateAudioMixerOptions {
289
- id: string;
290
- loop?: boolean;
291
- volume?: number;
292
- seekFrom?: number;
293
- operation?: 'pause' | 'resume' | 'stop';
294
- }
295
- declare interface StopAudioMixerOptions {
296
- id: string;
297
- }
298
- declare interface AIDenoiserOptions {
299
- assetsPath: string;
300
- sdkAppId: number;
301
- userId: string;
302
- userSig: string;
303
- }
304
- declare type PluginStartOptionsMap = {
305
- 'AudioMixer': AudioMixerOptions;
306
- 'AIDenoiser': AIDenoiserOptions;
307
- 'CDNStreaming': CDNStreamingOptions;
308
- 'VirtualBackground': VirtualBackgroundOptions;
309
- 'Watermark': WatermarkOptions;
310
- 'Beauty': BeautyOptions;
311
- 'BasicBeauty': BasicBeautyOptions;
312
- 'CrossRoom': StartCrossRoomOption;
313
- };
314
- declare type PluginUpdateOptionsMap = {
315
- 'AudioMixer': UpdateAudioMixerOptions;
316
- 'CDNStreaming': CDNStreamingOptions;
317
- 'VirtualBackground': UpdateVirtualBackgroundOptions;
318
- 'Beauty': UpdateBeautyOptions;
319
- 'BasicBeauty': BasicBeautyOptions;
320
- 'CrossRoom': UpdateCrossRoomOption;
321
- };
322
- declare type PluginStopOptionsMap = {
323
- 'AudioMixer': StopAudioMixerOptions;
324
- 'AIDenoiser': undefined;
325
- 'CDNStreaming': CDNStreamingOptions;
326
- 'VirtualBackground': undefined;
327
- 'Watermark': undefined;
328
- 'Beauty': undefined;
329
- 'BasicBeauty': undefined;
330
- 'CrossRoom': StopCrossRoomOption | undefined;
331
- };
332
- declare interface TRTCStatistics {
333
- rtt: number;
334
- downLoss: number;
335
- upLoss: number;
336
- bytesSent: number;
337
- bytesReceived: number;
338
- localStatistics: LocalStatistic;
339
- remoteStatistics: RemoteStatistic[];
340
- }
341
- interface LocalStatistic {
342
- audio: {
343
- bitrate: number;
344
- audioLevel: number;
345
- };
346
- video: {
347
- width: number;
348
- height: number;
349
- frameRate: number;
350
- bitrate: number;
351
- videoType: TRTCVideoType;
352
- }[];
353
- }
354
- declare enum TRTCVideoType {
355
- Big = "big",
356
- Small = "small",
357
- Sub = "sub"
358
- }
359
- interface RemoteStatistic {
360
- audio: {
361
- bitrate: number;
362
- audioLevel: number;
363
- };
364
- video: {
365
- width: number;
366
- height: number;
367
- frameRate: number;
368
- bitrate: number;
369
- videoType: TRTCVideoType;
370
- }[];
371
- userId: string;
372
- }
373
- declare interface VideoFrameConfig {
374
- userId?: string;
375
- streamType?: TRTCStreamType;
376
- }
3
+ declare type PluginWithAssets = {
4
+ plugin: IPlugin;
5
+ assetsPath?: string;
6
+ };
7
+ declare interface TRTCOptions {
8
+ plugins?: Array<IPlugin>;
9
+ enableSEI?: boolean;
10
+ assetsPath?: string;
11
+ }
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
+ };
26
+ }
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;
35
+ }
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;
52
+ }
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
+ };
69
+ }
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
+ };
75
+ }
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
+ };
87
+ }
88
+ declare interface StopRemoteVideoConfig {
89
+ userId: string;
90
+ streamType?: TRTCStreamType;
91
+ }
92
+ declare interface LocalAudioConfig {
93
+ publish?: boolean;
94
+ mute?: boolean;
95
+ option?: {
96
+ microphoneId?: string;
97
+ profile?: keyof typeof audioProfileMap;
98
+ audioTrack?: MediaStreamTrack;
99
+ captureVolume?: number;
100
+ earMonitorVolume?: number;
101
+ echoCancellation?: boolean;
102
+ autoGainControl?: boolean;
103
+ noiseSuppression?: boolean;
104
+ };
105
+ }
106
+ declare interface UpdateLocalAudioConfig extends LocalAudioConfig {
107
+ mute?: boolean;
108
+ option?: {
109
+ microphoneId?: string;
110
+ audioTrack?: MediaStreamTrack;
111
+ captureVolume?: number;
112
+ earMonitorVolume?: number;
113
+ echoCancellation?: boolean;
114
+ autoGainControl?: boolean;
115
+ noiseSuppression?: boolean;
116
+ };
117
+ }
118
+ declare interface RemoteAudioConfig {
119
+ userId: string;
120
+ option?: {
121
+ volume?: number;
122
+ };
123
+ }
124
+ declare interface StopRemoteAudioConfig {
125
+ userId: string;
126
+ }
127
+ declare const enum TRTCStreamType {
128
+ Main = "main",
129
+ Sub = "sub"
130
+ }
131
+ declare enum TRTCDeviceType {
132
+ Camera = "camera",
133
+ Microphone = "microphone",
134
+ Speaker = "speaker"
135
+ }
136
+ declare enum TRTCDeviceAction {
137
+ Remove = "remove",
138
+ Add = "add",
139
+ Active = "active"
140
+ }
141
+ declare interface RTCErrorParams {
142
+ code: number;
143
+ extraCode?: number;
144
+ functionName?: string;
145
+ fnName?: string;
146
+ message?: string;
147
+ messageParams?: any;
148
+ originError?: Error | DOMException;
149
+ }
150
+ declare interface RTCErrorInterface {
151
+ readonly name: string;
152
+ readonly code: number;
153
+ readonly extraCode?: number;
154
+ readonly functionName?: string;
155
+ readonly message?: string;
156
+ readonly originError?: Error | DOMException;
157
+ }
158
+ declare interface ErrorMessageParams {
159
+ key?: string;
160
+ rule?: any;
161
+ fnName?: string;
162
+ fnParams?: any;
163
+ value?: string | number | any;
164
+ type?: string;
165
+ deviceType?: string;
166
+ error?: Error | DOMException | CoreError;
167
+ }
168
+ /**
169
+ * **TRTC Constants**<br>
170
+ * @module TYPE
171
+ * @example
172
+ * // Usage:
173
+ * TRTC.TYPE.SCENE_LIVE
174
+ */
175
+ declare const TRTCType: {
176
+ /**
177
+ * Live streaming scene
178
+ * @default 'live'
179
+ * @memberof module:TYPE
180
+ */
181
+ readonly SCENE_LIVE: Scene.LIVE;
182
+ /**
183
+ * RTC scene
184
+ * @default 'rtc'
185
+ * @memberof module:TYPE
186
+ */
187
+ readonly SCENE_RTC: Scene.RTC;
188
+ /**
189
+ * Anchor role
190
+ * @default 'anchor'
191
+ * @memberof module:TYPE
192
+ */
193
+ readonly ROLE_ANCHOR: UserRole.ANCHOR;
194
+ /**
195
+ * Audience role
196
+ * @default 'audience'
197
+ * @memberof module:TYPE
198
+ */
199
+ readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
200
+ /**
201
+ * Main stream
202
+ *
203
+ * - TRTC has a main video stream (main stream) and an sub video stream (sub stream)
204
+ * - The camera is published through the main stream, and the screen sharing is published through the sub stream.
205
+ * - 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).
206
+ * @default 'main'
207
+ * @memberof module:TYPE
208
+ */
209
+ readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
210
+ /**
211
+ * Sub stream
212
+ * @default 'sub'
213
+ * @memberof module:TYPE
214
+ */
215
+ readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
216
+ /**
217
+ * Standard audio quality
218
+ * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
219
+ * | :--- | :--- | :--- | :--- |
220
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
221
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
222
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
223
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
224
+ * @default 'standard'
225
+ * @memberof module:TYPE
226
+ */
227
+ readonly AUDIO_PROFILE_STANDARD: "standard";
228
+ /**
229
+ * Standard stereo audio quality
230
+ * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
231
+ * | :--- | :--- | :--- | :--- |
232
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
233
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
234
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
235
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
236
+ * @default 'standard-stereo'
237
+ * @memberof module:TYPE
238
+ */
239
+ readonly AUDIO_PROFILE_STANDARD_STEREO: "standard-stereo";
240
+ /**
241
+ * High audio quality
242
+ * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
243
+ * | :--- | :--- | :--- | :--- |
244
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
245
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
246
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
247
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
248
+ * @default 'high'
249
+ * @memberof module:TYPE
250
+ */
251
+ readonly AUDIO_PROFILE_HIGH: "high";
252
+ /**
253
+ * High-quality stereo audio
254
+ * | Audio Profile | Sampling Rate | Channel | Bitrate (kbps) |
255
+ * | :--- | :--- | :--- | :--- |
256
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD | 48000 | Mono| 40 |
257
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH | 48000 | Mono| 128 |
258
+ * | TRTC.TYPE.AUDIO_PROFILE_STANDARD_STEREO | 48000 | Stereo| 64 |
259
+ * | TRTC.TYPE.AUDIO_PROFILE_HIGH_STEREO | 48000 | Stereo| 192 |
260
+ * @default 'high-stereo'
261
+
262
+ * @memberof module:TYPE
263
+ */
264
+ readonly AUDIO_PROFILE_HIGH_STEREO: "high-stereo";
265
+ /**
266
+ * When the network is weak, the video encoding strategy takes 'smooth' first, i.e., the priority is to preserve frame rate.
267
+ * <br>
268
+ * Default 'smooth' first for camera, 'default' clear first for screen sharing
269
+ * @default 'smooth'
270
+ * @memberof module:TYPE
271
+ */
272
+ readonly QOS_PREFERENCE_SMOOTH: "smooth";
273
+ /**
274
+ * When the network is weak, the video encoding strategy takes 'clear' first, i.e., the priority is to preserve resolution.
275
+ * <br>
276
+ * Default 'smooth' first for camera, 'default' clear first for screen sharing
277
+ * @default 'clear'
278
+ * @memberof module:TYPE
279
+ */
280
+ readonly QOS_PREFERENCE_CLEAR: "clear";
281
+ };
282
+ declare interface AudioMixerOptions {
283
+ id: string;
284
+ url: string;
285
+ loop?: boolean;
286
+ volume?: number;
287
+ }
288
+ declare interface UpdateAudioMixerOptions {
289
+ id: string;
290
+ loop?: boolean;
291
+ volume?: number;
292
+ seekFrom?: number;
293
+ operation?: 'pause' | 'resume' | 'stop';
294
+ }
295
+ declare interface StopAudioMixerOptions {
296
+ id: string;
297
+ }
298
+ declare interface AIDenoiserOptions {
299
+ assetsPath: string;
300
+ sdkAppId: number;
301
+ userId: string;
302
+ userSig: string;
303
+ }
304
+ declare type PluginStartOptionsMap = {
305
+ 'AudioMixer': AudioMixerOptions;
306
+ 'AIDenoiser': AIDenoiserOptions;
307
+ 'CDNStreaming': CDNStreamingOptions;
308
+ 'VirtualBackground': VirtualBackgroundOptions;
309
+ 'Watermark': WatermarkOptions;
310
+ 'Beauty': BeautyOptions;
311
+ 'BasicBeauty': BasicBeautyOptions;
312
+ };
313
+ declare type PluginUpdateOptionsMap = {
314
+ 'AudioMixer': UpdateAudioMixerOptions;
315
+ 'CDNStreaming': CDNStreamingOptions;
316
+ 'VirtualBackground': UpdateVirtualBackgroundOptions;
317
+ 'Beauty': UpdateBeautyOptions;
318
+ 'BasicBeauty': BasicBeautyOptions;
319
+ };
320
+ declare type PluginStopOptionsMap = {
321
+ 'AudioMixer': StopAudioMixerOptions;
322
+ 'AIDenoiser': undefined;
323
+ 'CDNStreaming': CDNStreamingOptions;
324
+ 'VirtualBackground': undefined;
325
+ 'Watermark': undefined;
326
+ 'Beauty': undefined;
327
+ 'BasicBeauty': undefined;
328
+ };
329
+ declare interface TRTCStatistics {
330
+ rtt: number;
331
+ downLoss: number;
332
+ upLoss: number;
333
+ bytesSent: number;
334
+ bytesReceived: number;
335
+ localStatistics: LocalStatistic;
336
+ remoteStatistics: RemoteStatistic[];
337
+ }
338
+ interface LocalStatistic {
339
+ audio: {
340
+ bitrate: number;
341
+ audioLevel: number;
342
+ };
343
+ video: {
344
+ width: number;
345
+ height: number;
346
+ frameRate: number;
347
+ bitrate: number;
348
+ videoType: TRTCVideoType;
349
+ }[];
350
+ }
351
+ declare enum TRTCVideoType {
352
+ Big = "big",
353
+ Small = "small",
354
+ Sub = "sub"
355
+ }
356
+ interface RemoteStatistic {
357
+ audio: {
358
+ bitrate: number;
359
+ audioLevel: number;
360
+ };
361
+ video: {
362
+ width: number;
363
+ height: number;
364
+ frameRate: number;
365
+ bitrate: number;
366
+ videoType: TRTCVideoType;
367
+ }[];
368
+ userId: string;
369
+ }
370
+ declare interface VideoFrameConfig {
371
+ userId?: string;
372
+ streamType?: TRTCStreamType;
373
+ }
377
374
 
378
- /**
379
- * @typedef TRTCStatistics TRTC statistics
380
- * @property {number} rtt The round-trip time from SDK to TRTC server(SDK -> TRTC server -> SDK). Unit: ms.
381
- * @property {number} upLoss Uplink loss rate from SDK to TRTC server. Unit: %
382
- * @property {number} downLoss Downlink loss rate from TRTC server to SDK. Unit: %
383
- * @property {number} bytesSent Total bytes sent, including signaling data and media data. Unit: bytes.
384
- * @property {number} bytesReceived Total bytes received, including signaling data and media data. Unit: bytes.
385
- * @property {TRTCLocalStatistics} localStatistics Local statistics.
386
- * @property {TRTCRemoteStatistics[]} remoteStatistics Remote statistics.
387
- */
388
- /**
389
- * Local statistics
390
- * @typedef TRTCLocalStatistics
391
- * @property {TRTCAudioStatistic} audio Local audio statistics
392
- * @property {TRTCVideoStatistic[]} video Local video statistics
393
- */
394
- /**
395
- * Remote statistics.
396
- * @typedef TRTCRemoteStatistics
397
- * @property {string} userId The userId of remote user
398
- * @property {TRTCAudioStatistic} audio Remote audio statistics
399
- * @property {TRTCVideoStatistic[]} video Remote video statistics
400
- */
401
- /**
402
- * Audio statistics
403
- * @typedef TRTCAudioStatistic
404
- * @property {number} bitrate Audio bitrate. Unit: kbps
405
- * @property {number} audioLevel Audio level. Value: float from 0 to 1.
406
- */
407
- /** Video statistics
408
- * @typedef TRTCVideoStatistic
409
- * @property {number} bitrate Video bitrate. Unit: kbps
410
- * @property {number} width Video width
411
- * @property {number} height Video height
412
- * @property {number} frameRate Video frameRate
413
- * @property {'big'|'small'|'sub'} videoType Video type: big, small, sub.
414
- */
415
- /**
416
- * **TRTC Event List**<br>
417
- * <br>
418
- * Listen to specific events through {@link TRTC#on trtc.on(TRTC.EVENT.XXX)}. You can use these events to manage the room user list, manage user stream state, and perceive network state. The following is a detailed introduction to the events.
419
- * > !
420
- * > - Events need to be listened to before they are triggered, so that you can receive the corresponding event notifications. Therefore, it is recommended to complete event listening before entering the room, so as to ensure that no event notifications are missed.
421
- * @module EVENT
422
- * @example
423
- * // Usage:
424
- * trtc.on(TRTC.EVENT.ERROR, () => {});
425
- */
426
- declare const TRTCEvent: {
427
- /**
428
- * Error event, non-API call error, SDK throws when an unrecoverable error occurs during operation.
429
- *
430
- * - Error code (error.code): {@link module:ERROR_CODE.OPERATION_FAILED ErrorCode.OPERATION_FAILED}
431
- * - Possible extended error codes (error.extraCode): 5501, 5502
432
- * @default 'error'
433
- * @memberof module:EVENT
434
- * @see {@link RtcError RtcError}
435
- * @e
436
- * @example
437
- *
438
- * trtc.on(TRTC.EVENT.ERROR, error => {
439
- * console.error('trtc error observed: ' + error);
440
- * const errorCode = error.code;
441
- * const extraCode = error.extraCode;
442
- * });
443
- */
444
- readonly ERROR: "error";
445
- /**
446
- * @description Automatic playback failed, refer to {@tutorial 21-advanced-auto-play-policy}
447
- * @default 'autoplay-failed'
448
- * @memberof module:EVENT
449
- * @example
450
- * trtc.on(TRTC.EVENT.AUTOPLAY_FAILED, event => {
451
- * // Guide user to click the page, SDK will resume playback automatically when user click the page.
452
- * // Since v5.1.3+, you can get userId on this event.
453
- * console.log(event.userId);
454
- * });
455
- */
456
- readonly AUTOPLAY_FAILED: "autoplay-failed";
457
- /**
458
- * @description Kicked out of the room for some reason, including:<br>
459
- * - 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.
460
- * - 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.
461
- * - Users with the same userId who enter the same room with the same audience role may not receive this event.
462
- * - banned: kicked out by the administrator using [Server API - RemoveUser](https://trtc.io/document/34267/34268).
463
- * - room_disband: kicked out by the administrator using [Server API - DismissRoom](https://trtc.io/document/34267/34269).
464
- * @default 'kicked-out'
465
- * @memberof module:EVENT
466
- * @example
467
- *
468
- * trtc.on(TRTC.EVENT.KICKED_OUT, event => {
469
- * console.log(event.reason)
470
- * });
471
- */
472
- readonly KICKED_OUT: "kicked-out";
473
- /**
474
- * Remote user enters the room event.
475
- *
476
- * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
477
- * - 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.
478
- * @default 'remote-user-enter'
479
- * @memberof module:EVENT
480
- * @example
481
- *
482
- * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, event => {
483
- * const userId = event.userId;
484
- * });
485
- */
486
- readonly REMOTE_USER_ENTER: "remote-user-enter";
487
- /**
488
- * Remote user exits the room event.
489
- *
490
- * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
491
- * - 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.
492
- * @default 'remote-user-exit'
493
- * @memberof module:EVENT
494
- * @example
495
- *
496
- * trtc.on(TRTC.EVENT.REMOTE_USER_EXIT, event => {
497
- * const userId = event.userId;
498
- * });
499
- */
500
- readonly REMOTE_USER_EXIT: "remote-user-exit";
501
- /**
502
- * 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)
503
- *
504
- * - 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".
505
- * - 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.
506
- * - 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()}.
507
- * - 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.
508
- * @default 'remote-audio-available'
509
- * @memberof module:EVENT
510
- * @example
511
- * // Listen before entering the room
512
- * trtc.on(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE, event => {
513
- * const userId = event.userId;
514
- * });
515
- */
516
- readonly REMOTE_AUDIO_AVAILABLE: "remote-audio-available";
517
- /**
518
- * Remote user stops publishing audio. You will receive this notification when the remote user turns off the microphone.
519
- *
520
- * @default 'remote-audio-unavailable'
521
- * @memberof module:EVENT
522
- * @example
523
- * // Listen before entering the room
524
- * trtc.on(TRTC.EVENT.REMOTE_AUDIO_UNAVAILABLE, event => {
525
- * const userId = event.userId;
526
- *
527
- * });
528
- */
529
- readonly REMOTE_AUDIO_UNAVAILABLE: "remote-audio-unavailable";
530
- /**
531
- * 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)
532
- *
533
- * - 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".
534
- * @see {@link module:TYPE.STREAM_TYPE_MAIN STREAM_TYPE_MAIN}
535
- * @see {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB}
536
- * @default 'remote-video-available'
537
- * @memberof module:EVENT
538
- * @example
539
- * // Listen before entering the room
540
- * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
541
- * const userId = event.userId;
542
- * const streamType = event.streamType;
543
- * trtc.startRemoteVideo({userId, streamType, view});
544
- * });
545
- */
546
- readonly REMOTE_VIDEO_AVAILABLE: "remote-video-available";
547
- /**
548
- * Remote user stops publishing video. You will receive this notification when the remote user turns off the camera.
549
- * @default 'remote-video-unavailable'
550
- * @memberof module:EVENT
551
- * @example
552
- * // Listen before entering the room
553
- * trtc.on(TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE, event => {
554
- * const userId = event.userId;
555
- * const streamType = event.streamType;
556
- * // At this point, the SDK will automatically stop playing, and there is no need to call stopRemoteVideo.
557
- * });
558
- */
559
- readonly REMOTE_VIDEO_UNAVAILABLE: "remote-video-unavailable";
560
- /**
561
- * @description Volume event<br>
562
- * 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>
563
- * **Note**
564
- * - 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.
565
- * - The event.result will be sorted from large to small according to the volume size.
566
- * - When userId is an empty string, it represents the volume of the local microphone.
567
- * - volume is a positive integer with a value of 0-100.
568
- * @default 'audio-volume'
569
- * @memberof module:EVENT
570
- * @example
571
- * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
572
- * event.result.forEach(({ userId, volume }) => {
573
- * const isMe = userId === ''; // When userId is an empty string, it represents the volume of the local microphone.
574
- * if (isMe) {
575
- * console.log(`my volume: ${volume}`);
576
- * } else {
577
- * console.log(`user: ${userId} volume: ${volume}`);
578
- * }
579
- * })
580
- * });
581
- *
582
- * // Enable volume callback and trigger the event every 1000ms
583
- * trtc.enableAudioVolumeEvaluation(1000);
584
- */
585
- readonly AUDIO_VOLUME: "audio-volume";
586
- /**
587
- * @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.
588
- * - The uplink network quality (uplinkNetworkQuality) refers to the network situation of uploading local streams (uplink connection network quality from SDK to Tencent Cloud)
589
- * - 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)
590
- *
591
- * The enumeration values and meanings are shown in the following table:
592
- * | Value | Meaning |
593
- * | :--- | :---- |
594
- * | 0 | Network state is unknown, indicating that the current trtc instance has not established an uplink/downlink connection |
595
- * | 1 | Network state is excellent |
596
- * | 2 | Network state is good |
597
- * | 3 | Network state is average |
598
- * | 4 | Network state is poor |
599
- * | 5 | Network state is very poor |
600
- * | 6 | Network connection is disconnected<br/>Note: If the downlink network quality is this value, it means that all downlink connections have been disconnected |
601
- * - uplinkRTT, uplinkLoss are the uplink RTT (ms) and uplink packet loss rate.
602
- * - downlinkRTT, downlinkLoss are the average RTT (ms) and average packet loss rate of all downlink connections.
603
- *
604
- * **Note**
605
- * - 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.
606
- *
607
- * @default 'network-quality'
608
- * @memberof module:EVENT
609
- * @example
610
- * trtc.on(TRTC.EVENT.NETWORK_QUALITY, event => {
611
- * console.log(`network-quality, uplinkNetworkQuality:${event.uplinkNetworkQuality}, downlinkNetworkQuality: ${event.downlinkNetworkQuality}`)
612
- * console.log(`uplink rtt:${event.uplinkRTT} loss:${event.uplinkLoss}`)
613
- * console.log(`downlink rtt:${event.downlinkRTT} loss:${event.downlinkLoss}`)
614
- * })
615
- */
616
- readonly NETWORK_QUALITY: "network-quality";
617
- /**
618
- * @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>
619
- * - 'DISCONNECTED': Connection disconnected
620
- * - 'CONNECTING': Connecting
621
- * - 'CONNECTED': Connected
622
- *
623
- * Meanings of different state changes:
624
- *
625
- * - DISCONNECTED -> CONNECTING: Trying to establish a connection, triggered when calling the enter room interface or when the SDK automatically reconnects.
626
- * - CONNECTING -> DISCONNECTED: Connection establishment failed, triggered when calling the exit room interface to interrupt the connection or when the connection fails after SDK retries.
627
- * - CONNECTING -> CONNECTED: Connection established successfully, triggered when the connection is successful.
628
- * - CONNECTED -> DISCONNECTED: Connection interrupted, triggered when calling the exit room interface or when the connection is disconnected due to network anomalies.
629
- *
630
- * Suggestion: You can listen to this event and display different UIs in different states to remind users of the current connection state.
631
- *
632
- * @default 'connection-state-changed'
633
- * @memberof module:EVENT
634
- * @example
635
- * trtc.on(TRTC.CONNECTION_STATE_CHANGED, event => {
636
- * const prevState = event.prevState;
637
- * const curState = event.state;
638
- * });
639
- */
640
- readonly CONNECTION_STATE_CHANGED: "connection-state-changed";
641
- /**
642
- * @description Audio playback state change event
643
- *
644
- * 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.
645
- *
646
- * event.state The value is as follows:
647
- * - 'PLAYING': start playing
648
- * - event.reason is 'playing' or 'unmute'.
649
- * - 'PAUSED': pause playback
650
- * - When event.reason is 'pause', it is triggered by the pause event of the \<audio\> element. The following situations will trigger:
651
- * - Call the HTMLMediaElement.pause interface.
652
- * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
653
- * - 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.
654
- * - 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.
655
- * - 'STOPPED': stop playing
656
- * - event.reason is 'ended'.
657
- *
658
- * event.reason The reason for the state change, the value is as follows:
659
- * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
660
- * - '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}
661
- * - '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}
662
- * - 'ended': The audio track has been closed
663
- * - 'pause': Playback paused
664
- * @default 'audio-play-state-changed'
665
- * @memberof module:EVENT
666
- * @example
667
- * trtc.on(TRTC.EVENT.AUDIO_PLAY_STATE_CHANGED, event => {
668
- * console.log(`${event.userId} player is ${event.state} because of ${event.reason}`);
669
- * });
670
- */
671
- readonly AUDIO_PLAY_STATE_CHANGED: "audio-play-state-changed";
672
- /**
673
- * @description Video playback state change event
674
- *
675
- * 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.
676
- *
677
- * 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}
678
- *
679
- * event.state The value is as follows:
680
- * - 'PLAYING': start playing
681
- * - event.reason is 'playing' or 'unmute'.
682
- * - 'PAUSED': pause playback
683
- * - When event.reason is 'pause', it is triggered by the pause event of the \<video\> element. The following situations will trigger:
684
- * - Call the HTMLMediaElement.pause interface.
685
- * - After successful playback, the view container for playing the video is removed from the DOM.
686
- * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
687
- * - 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.
688
- * - 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.
689
- * - 'STOPPED': stop playing
690
- * - event.reason is 'ended'.
691
- *
692
- * event.reason The reason for the state change, the value is as follows:
693
- * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
694
- * - '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}
695
- * - '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}
696
- * - 'ended': The video track has been closed
697
- * - 'pause': Playback paused
698
- * @default 'video-play-state-changed'
699
- * @memberof module:EVENT
700
- * @example
701
- * trtc.on(TRTC.EVENT.VIDEO_PLAY_STATE_CHANGED, event => {
702
- * console.log(`${event.userId} ${event.streamType} video player is ${event.state} because of ${event.reason}`);
703
- * });
704
- */
705
- readonly VIDEO_PLAY_STATE_CHANGED: "video-play-state-changed";
706
- /**
707
- * @description Notification event for local screen sharing stop, only valid for local screen sharing streams.
708
- * @default 'screen-share-stopped'
709
- * @memberof module:EVENT
710
- * @example
711
- * trtc.on(TRTC.EVENT.SCREEN_SHARE_STOPPED, () => {
712
- * console.log('screen sharing was stopped');
713
- * });
714
- */
715
- readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
716
- /**
717
- * @description Notification event for device changes such as camera and microphone.
718
- * - event.device is a [MediaDeviceInfo](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) object with properties:
719
- * - deviceId: device ID
720
- * - label: device description information
721
- * - groupId: device group ID
722
- * - event.type value: `'camera'|'microphone'|'speaker'`
723
- * - event.action value:
724
- * - 'add' device has been added.
725
- * - 'remove' device has been removed.
726
- * - 'active' device has been activated, for example: after startLocalVideo is successful, this event will be triggered.
727
- * @default 'device-changed'
728
- * @memberof module:EVENT
729
- * @example
730
- * trtc.on(TRTC.EVENT.DEVICE_CHANGED, (event) => {
731
- * console.log(`${event.type}(${event.device.label}) ${event.action}`);
732
- * });
733
- */
734
- readonly DEVICE_CHANGED: "device-changed";
735
- /**
736
- * @description Publish state change event.
737
- * - event.mediaType media type, value: `'audio'|'video'|'screen'`.
738
- * - event.state current publish state, value:
739
- * - `'starting'` trying to publish stream
740
- * - `'started'` publish stream succeeded
741
- * - `'stopped'` publish stream stopped, see event.reason field for the reason
742
- * - event.prevState the publish state at the last event trigger, with the same type as event.state.
743
- * - event.reason the reason for the publish state to become `'stopped'`, value:
744
- * - `'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.
745
- * - `'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.
746
- * - `'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.
747
- * - event.error error information when event.reason is `'error'`.
748
- * @default 'publish-state-changed'
749
- * @memberof module:EVENT
750
- * @example
751
- * trtc.on(TRTC.EVENT.PUBLISH_STATE_CHANGED, (event) => {
752
- * console.log(`${event.mediaType} ${event.state} ${event.reason}`);
753
- * });
754
- */
755
- readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
756
- /**
757
- * @since v5.3.0
758
- * @description a new MediaStreamTrack object received.
759
- * @default 'track'
760
- * @memberof module:EVENT
761
- * @example
762
- * trtc.on(TRTC.EVENT.TRACK, event => {
763
- * // userId === '' means event.track is a local track, otherwise it's a remote track
764
- * const isLocal = event.userId === '';
765
- * // Usually the sub stream is a screen-sharing video stream.
766
- * const isSubStream = event.streamType === TRTC.TYPE.STREAM_TYPE_SUB;
767
- * const mediaStreamTrack = event.track;
768
- * const kind = event.track.kind; // audio or video
769
- * })
770
- */
771
- readonly TRACK: "track";
772
- /**
773
- * @description TRTC statistics.<br>
774
- *
775
- * - SDK will fires this event once every 2s.
776
- * - You can get the network quality, statistics of audio and video from this event. For detailed parameter description, please refer to {@link TRTCStatistics}.
777
- * @default 'statistics'
778
- * @since v5.2.0
779
- * @memberof module:EVENT
780
- * @example
781
- * trtc.on(TRTC.EVENT.STATISTICS, statistics => {
782
- * console.warn(statistics.rtt, statistics.upLoss, statistics.downLoss);
783
- * })
784
- */
785
- readonly STATISTICS: "statistics";
786
- /**
787
- * @since v5.3.0
788
- * @description SEI message received<br>
789
- * @default 'sei-message'
790
- * @memberof module:EVENT
791
- * @example
792
- * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
793
- * console.log(`received sei message from ${event.userId}, data: ${event.data}, streamType: ${event.streamType}`)
794
- * })
795
- */
796
- readonly SEI_MESSAGE: "sei-message";
797
- /**
798
- * @since v5.6.0
799
- * @description received a new custom message.
800
- * @default 'custom-message'
801
- * @memberof module:EVENT
802
- * @example
803
- * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
804
- * // event.userId: remote userId.
805
- * // event.cmdId: message cmdId.
806
- * // event.seq: message sequence number.
807
- * // event.data: custom message data, type is ArrayBuffer.
808
- * })
809
- */
810
- readonly CUSTOM_MESSAGE: "custom-message";
811
- };
812
- declare interface TRTCEventTypes {
813
- [TRTCEvent.ERROR]: [RtcError];
814
- [TRTCEvent.AUTOPLAY_FAILED]: [{
815
- userId: string;
816
- }];
817
- [TRTCEvent.KICKED_OUT]: [{
818
- reason: Exclude<BannedReason, 'user_time_out'>;
819
- }];
820
- [TRTCEvent.REMOTE_USER_ENTER]: [{
821
- userId: string;
822
- }];
823
- [TRTCEvent.REMOTE_USER_EXIT]: [{
824
- userId: string;
825
- }];
826
- [TRTCEvent.REMOTE_AUDIO_AVAILABLE]: [{
827
- userId: string;
828
- }];
829
- [TRTCEvent.REMOTE_AUDIO_UNAVAILABLE]: [{
830
- userId: string;
831
- }];
832
- [TRTCEvent.REMOTE_VIDEO_AVAILABLE]: [{
833
- userId: string;
834
- streamType: TRTCStreamType;
835
- }];
836
- [TRTCEvent.REMOTE_VIDEO_UNAVAILABLE]: [{
837
- userId: string;
838
- streamType: TRTCStreamType;
839
- }];
840
- [TRTCEvent.AUDIO_VOLUME]: [{
841
- result: {
842
- userId: string;
843
- volume: number;
844
- }[];
845
- }];
846
- [TRTCEvent.NETWORK_QUALITY]: [NetworkQuality];
847
- [TRTCEvent.CONNECTION_STATE_CHANGED]: [{
848
- prevState: ConnectionState;
849
- state: ConnectionState;
850
- }];
851
- [TRTCEvent.AUDIO_PLAY_STATE_CHANGED]: [{
852
- userId: string;
853
- state: PlayerState;
854
- reason: string;
855
- }];
856
- [TRTCEvent.VIDEO_PLAY_STATE_CHANGED]: [{
857
- userId: string;
858
- streamType: TRTCStreamType;
859
- state: PlayerState;
860
- reason: string;
861
- }];
862
- [TRTCEvent.SCREEN_SHARE_STOPPED]: [];
863
- [TRTCEvent.DEVICE_CHANGED]: [{
864
- type: TRTCDeviceType;
865
- action: TRTCDeviceAction;
866
- device: DeviceInfo;
867
- }];
868
- [TRTCEvent.PUBLISH_STATE_CHANGED]: [
869
- {
870
- mediaType: 'audio' | 'video' | 'screen';
871
- state: 'started' | 'stopped' | 'starting';
872
- prevState: 'started' | 'stopped' | 'starting';
873
- reason?: 'timeout' | 'error' | 'api-call';
874
- error?: RtcError;
875
- }
876
- ];
877
- [TRTCEvent.SEI_MESSAGE]: [{
878
- data: Uint8Array;
879
- userId: string;
880
- streamType: TRTCStreamType;
881
- }];
882
- [TRTCEvent.STATISTICS]: [statistics: TRTCStatistics];
883
- [TRTCEvent.TRACK]: [{
884
- userId: string;
885
- streamType?: TRTCStreamType;
886
- track: MediaStreamTrack;
887
- }];
888
- [TRTCEvent.CUSTOM_MESSAGE]: [CustomMessage];
889
- }
375
+ /**
376
+ * @typedef TRTCStatistics TRTC statistics
377
+ * @property {number} rtt The round-trip time from SDK to TRTC server(SDK -> TRTC server -> SDK). Unit: ms.
378
+ * @property {number} upLoss Uplink loss rate from SDK to TRTC server. Unit: %
379
+ * @property {number} downLoss Downlink loss rate from TRTC server to SDK. Unit: %
380
+ * @property {number} bytesSent Total bytes sent, including signaling data and media data. Unit: bytes.
381
+ * @property {number} bytesReceived Total bytes received, including signaling data and media data. Unit: bytes.
382
+ * @property {TRTCLocalStatistics} localStatistics Local statistics.
383
+ * @property {TRTCRemoteStatistics[]} remoteStatistics Remote statistics.
384
+ */
385
+ /**
386
+ * Local statistics
387
+ * @typedef TRTCLocalStatistics
388
+ * @property {TRTCAudioStatistic} audio Local audio statistics
389
+ * @property {TRTCVideoStatistic[]} video Local video statistics
390
+ */
391
+ /**
392
+ * Remote statistics.
393
+ * @typedef TRTCRemoteStatistics
394
+ * @property {string} userId The userId of remote user
395
+ * @property {TRTCAudioStatistic} audio Remote audio statistics
396
+ * @property {TRTCVideoStatistic[]} video Remote video statistics
397
+ */
398
+ /**
399
+ * Audio statistics
400
+ * @typedef TRTCAudioStatistic
401
+ * @property {number} bitrate Audio bitrate. Unit: kbps
402
+ * @property {number} audioLevel Audio level. Value: float from 0 to 1.
403
+ */
404
+ /** Video statistics
405
+ * @typedef TRTCVideoStatistic
406
+ * @property {number} bitrate Video bitrate. Unit: kbps
407
+ * @property {number} width Video width
408
+ * @property {number} height Video height
409
+ * @property {number} frameRate Video frameRate
410
+ * @property {'big'|'small'|'sub'} videoType Video type: big, small, sub.
411
+ */
412
+ /**
413
+ * **TRTC Event List**<br>
414
+ * <br>
415
+ * Listen to specific events through {@link TRTC#on trtc.on(TRTC.EVENT.XXX)}. You can use these events to manage the room user list, manage user stream state, and perceive network state. The following is a detailed introduction to the events.
416
+ * > !
417
+ * > - Events need to be listened to before they are triggered, so that you can receive the corresponding event notifications. Therefore, it is recommended to complete event listening before entering the room, so as to ensure that no event notifications are missed.
418
+ * @module EVENT
419
+ * @example
420
+ * // Usage:
421
+ * trtc.on(TRTC.EVENT.ERROR, () => {});
422
+ */
423
+ declare const TRTCEvent: {
424
+ /**
425
+ * Error event, non-API call error, SDK throws when an unrecoverable error occurs during operation.
426
+ *
427
+ * - Error code (error.code): {@link module:ERROR_CODE.OPERATION_FAILED ErrorCode.OPERATION_FAILED}
428
+ * - Possible extended error codes (error.extraCode): 5501, 5502
429
+ * @default 'error'
430
+ * @memberof module:EVENT
431
+ * @see {@link RtcError RtcError}
432
+ * @e
433
+ * @example
434
+ *
435
+ * trtc.on(TRTC.EVENT.ERROR, error => {
436
+ * console.error('trtc error observed: ' + error);
437
+ * const errorCode = error.code;
438
+ * const extraCode = error.extraCode;
439
+ * });
440
+ */
441
+ readonly ERROR: "error";
442
+ /**
443
+ * @description Automatic playback failed, refer to {@tutorial 21-advanced-auto-play-policy}
444
+ * @default 'autoplay-failed'
445
+ * @memberof module:EVENT
446
+ * @example
447
+ * trtc.on(TRTC.EVENT.AUTOPLAY_FAILED, event => {
448
+ * // Guide user to click the page, SDK will resume playback automatically when user click the page.
449
+ * // Since v5.1.3+, you can get userId on this event.
450
+ * console.log(event.userId);
451
+ * });
452
+ */
453
+ readonly AUTOPLAY_FAILED: "autoplay-failed";
454
+ /**
455
+ * @description Kicked out of the room for some reason, including:<br>
456
+ * - 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.
457
+ * - 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.
458
+ * - Users with the same userId who enter the same room with the same audience role may not receive this event.
459
+ * - banned: kicked out by the administrator using [Server API - RemoveUser](https://trtc.io/document/34267/34268).
460
+ * - room_disband: kicked out by the administrator using [Server API - DismissRoom](https://trtc.io/document/34267/34269).
461
+ * @default 'kicked-out'
462
+ * @memberof module:EVENT
463
+ * @example
464
+ *
465
+ * trtc.on(TRTC.EVENT.KICKED_OUT, event => {
466
+ * console.log(event.reason)
467
+ * });
468
+ */
469
+ readonly KICKED_OUT: "kicked-out";
470
+ /**
471
+ * Remote user enters the room event.
472
+ *
473
+ * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
474
+ * - 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.
475
+ * @default 'remote-user-enter'
476
+ * @memberof module:EVENT
477
+ * @example
478
+ *
479
+ * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, event => {
480
+ * const userId = event.userId;
481
+ * });
482
+ */
483
+ readonly REMOTE_USER_ENTER: "remote-user-enter";
484
+ /**
485
+ * Remote user exits the room event.
486
+ *
487
+ * - In `rtc` mode, all users will receive the notification of entering and exiting the room of the other user.
488
+ * - 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.
489
+ * @default 'remote-user-exit'
490
+ * @memberof module:EVENT
491
+ * @example
492
+ *
493
+ * trtc.on(TRTC.EVENT.REMOTE_USER_EXIT, event => {
494
+ * const userId = event.userId;
495
+ * });
496
+ */
497
+ readonly REMOTE_USER_EXIT: "remote-user-exit";
498
+ /**
499
+ * 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)
500
+ *
501
+ * - 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".
502
+ * - 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.
503
+ * - 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()}.
504
+ * - 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.
505
+ * @default 'remote-audio-available'
506
+ * @memberof module:EVENT
507
+ * @example
508
+ * // Listen before entering the room
509
+ * trtc.on(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE, event => {
510
+ * const userId = event.userId;
511
+ * });
512
+ */
513
+ readonly REMOTE_AUDIO_AVAILABLE: "remote-audio-available";
514
+ /**
515
+ * Remote user stops publishing audio. You will receive this notification when the remote user turns off the microphone.
516
+ *
517
+ * @default 'remote-audio-unavailable'
518
+ * @memberof module:EVENT
519
+ * @example
520
+ * // Listen before entering the room
521
+ * trtc.on(TRTC.EVENT.REMOTE_AUDIO_UNAVAILABLE, event => {
522
+ * const userId = event.userId;
523
+ *
524
+ * });
525
+ */
526
+ readonly REMOTE_AUDIO_UNAVAILABLE: "remote-audio-unavailable";
527
+ /**
528
+ * 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)
529
+ *
530
+ * - 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".
531
+ * @see {@link module:TYPE.STREAM_TYPE_MAIN STREAM_TYPE_MAIN}
532
+ * @see {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB}
533
+ * @default 'remote-video-available'
534
+ * @memberof module:EVENT
535
+ * @example
536
+ * // Listen before entering the room
537
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
538
+ * const userId = event.userId;
539
+ * const streamType = event.streamType;
540
+ * trtc.startRemoteVideo({userId, streamType, view});
541
+ * });
542
+ */
543
+ readonly REMOTE_VIDEO_AVAILABLE: "remote-video-available";
544
+ /**
545
+ * Remote user stops publishing video. You will receive this notification when the remote user turns off the camera.
546
+ * @default 'remote-video-unavailable'
547
+ * @memberof module:EVENT
548
+ * @example
549
+ * // Listen before entering the room
550
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE, event => {
551
+ * const userId = event.userId;
552
+ * const streamType = event.streamType;
553
+ * // At this point, the SDK will automatically stop playing, and there is no need to call stopRemoteVideo.
554
+ * });
555
+ */
556
+ readonly REMOTE_VIDEO_UNAVAILABLE: "remote-video-unavailable";
557
+ /**
558
+ * @description Volume event<br>
559
+ * 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>
560
+ * **Note**
561
+ * - 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.
562
+ * - The event.result will be sorted from large to small according to the volume size.
563
+ * - When userId is an empty string, it represents the volume of the local microphone.
564
+ * - volume is a positive integer with a value of 0-100.
565
+ * @default 'audio-volume'
566
+ * @memberof module:EVENT
567
+ * @example
568
+ * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
569
+ * event.result.forEach(({ userId, volume }) => {
570
+ * const isMe = userId === ''; // When userId is an empty string, it represents the volume of the local microphone.
571
+ * if (isMe) {
572
+ * console.log(`my volume: ${volume}`);
573
+ * } else {
574
+ * console.log(`user: ${userId} volume: ${volume}`);
575
+ * }
576
+ * })
577
+ * });
578
+ *
579
+ * // Enable volume callback and trigger the event every 1000ms
580
+ * trtc.enableAudioVolumeEvaluation(1000);
581
+ */
582
+ readonly AUDIO_VOLUME: "audio-volume";
583
+ /**
584
+ * @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.
585
+ * - The uplink network quality (uplinkNetworkQuality) refers to the network situation of uploading local streams (uplink connection network quality from SDK to Tencent Cloud)
586
+ * - 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)
587
+ *
588
+ * The enumeration values and meanings are shown in the following table:
589
+ * | Value | Meaning |
590
+ * | :--- | :---- |
591
+ * | 0 | Network state is unknown, indicating that the current trtc instance has not established an uplink/downlink connection |
592
+ * | 1 | Network state is excellent |
593
+ * | 2 | Network state is good |
594
+ * | 3 | Network state is average |
595
+ * | 4 | Network state is poor |
596
+ * | 5 | Network state is very poor |
597
+ * | 6 | Network connection is disconnected<br/>Note: If the downlink network quality is this value, it means that all downlink connections have been disconnected |
598
+ * - uplinkRTT, uplinkLoss are the uplink RTT (ms) and uplink packet loss rate.
599
+ * - downlinkRTT, downlinkLoss are the average RTT (ms) and average packet loss rate of all downlink connections.
600
+ *
601
+ * **Note**
602
+ * - 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.
603
+ *
604
+ * @default 'network-quality'
605
+ * @memberof module:EVENT
606
+ * @example
607
+ * trtc.on(TRTC.EVENT.NETWORK_QUALITY, event => {
608
+ * console.log(`network-quality, uplinkNetworkQuality:${event.uplinkNetworkQuality}, downlinkNetworkQuality: ${event.downlinkNetworkQuality}`)
609
+ * console.log(`uplink rtt:${event.uplinkRTT} loss:${event.uplinkLoss}`)
610
+ * console.log(`downlink rtt:${event.downlinkRTT} loss:${event.downlinkLoss}`)
611
+ * })
612
+ */
613
+ readonly NETWORK_QUALITY: "network-quality";
614
+ /**
615
+ * @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>
616
+ * - 'DISCONNECTED': Connection disconnected
617
+ * - 'CONNECTING': Connecting
618
+ * - 'CONNECTED': Connected
619
+ *
620
+ * Meanings of different state changes:
621
+ *
622
+ * - DISCONNECTED -> CONNECTING: Trying to establish a connection, triggered when calling the enter room interface or when the SDK automatically reconnects.
623
+ * - CONNECTING -> DISCONNECTED: Connection establishment failed, triggered when calling the exit room interface to interrupt the connection or when the connection fails after SDK retries.
624
+ * - CONNECTING -> CONNECTED: Connection established successfully, triggered when the connection is successful.
625
+ * - CONNECTED -> DISCONNECTED: Connection interrupted, triggered when calling the exit room interface or when the connection is disconnected due to network anomalies.
626
+ *
627
+ * Suggestion: You can listen to this event and display different UIs in different states to remind users of the current connection state.
628
+ *
629
+ * @default 'connection-state-changed'
630
+ * @memberof module:EVENT
631
+ * @example
632
+ * trtc.on(TRTC.CONNECTION_STATE_CHANGED, event => {
633
+ * const prevState = event.prevState;
634
+ * const curState = event.state;
635
+ * });
636
+ */
637
+ readonly CONNECTION_STATE_CHANGED: "connection-state-changed";
638
+ /**
639
+ * @description Audio playback state change event
640
+ *
641
+ * 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.
642
+ *
643
+ * event.state The value is as follows:
644
+ * - 'PLAYING': start playing
645
+ * - event.reason is 'playing' or 'unmute'.
646
+ * - 'PAUSED': pause playback
647
+ * - When event.reason is 'pause', it is triggered by the pause event of the \<audio\> element. The following situations will trigger:
648
+ * - Call the HTMLMediaElement.pause interface.
649
+ * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
650
+ * - 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.
651
+ * - 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.
652
+ * - 'STOPPED': stop playing
653
+ * - event.reason is 'ended'.
654
+ *
655
+ * event.reason The reason for the state change, the value is as follows:
656
+ * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
657
+ * - '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}
658
+ * - '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}
659
+ * - 'ended': The audio track has been closed
660
+ * - 'pause': Playback paused
661
+ * @default 'audio-play-state-changed'
662
+ * @memberof module:EVENT
663
+ * @example
664
+ * trtc.on(TRTC.EVENT.AUDIO_PLAY_STATE_CHANGED, event => {
665
+ * console.log(`${event.userId} player is ${event.state} because of ${event.reason}`);
666
+ * });
667
+ */
668
+ readonly AUDIO_PLAY_STATE_CHANGED: "audio-play-state-changed";
669
+ /**
670
+ * @description Video playback state change event
671
+ *
672
+ * 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.
673
+ *
674
+ * 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}
675
+ *
676
+ * event.state The value is as follows:
677
+ * - 'PLAYING': start playing
678
+ * - event.reason is 'playing' or 'unmute'.
679
+ * - 'PAUSED': pause playback
680
+ * - When event.reason is 'pause', it is triggered by the pause event of the \<video\> element. The following situations will trigger:
681
+ * - Call the HTMLMediaElement.pause interface.
682
+ * - After successful playback, the view container for playing the video is removed from the DOM.
683
+ * - When event.reason is 'mute'. See event {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event | MediaStreamTrack.mute_event}
684
+ * - 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.
685
+ * - 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.
686
+ * - 'STOPPED': stop playing
687
+ * - event.reason is 'ended'.
688
+ *
689
+ * event.reason The reason for the state change, the value is as follows:
690
+ * - 'playing': start playing, see event {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playing_event | HTMLMediaElement.playing_event}
691
+ * - '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}
692
+ * - '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}
693
+ * - 'ended': The video track has been closed
694
+ * - 'pause': Playback paused
695
+ * @default 'video-play-state-changed'
696
+ * @memberof module:EVENT
697
+ * @example
698
+ * trtc.on(TRTC.EVENT.VIDEO_PLAY_STATE_CHANGED, event => {
699
+ * console.log(`${event.userId} ${event.streamType} video player is ${event.state} because of ${event.reason}`);
700
+ * });
701
+ */
702
+ readonly VIDEO_PLAY_STATE_CHANGED: "video-play-state-changed";
703
+ /**
704
+ * @description Notification event for local screen sharing stop, only valid for local screen sharing streams.
705
+ * @default 'screen-share-stopped'
706
+ * @memberof module:EVENT
707
+ * @example
708
+ * trtc.on(TRTC.EVENT.SCREEN_SHARE_STOPPED, () => {
709
+ * console.log('screen sharing was stopped');
710
+ * });
711
+ */
712
+ readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
713
+ /**
714
+ * @description Notification event for device changes such as camera and microphone.
715
+ * - event.device is a [MediaDeviceInfo](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) object with properties:
716
+ * - deviceId: device ID
717
+ * - label: device description information
718
+ * - groupId: device group ID
719
+ * - event.type value: `'camera'|'microphone'|'speaker'`
720
+ * - event.action value:
721
+ * - 'add' device has been added.
722
+ * - 'remove' device has been removed.
723
+ * - 'active' device has been activated, for example: after startLocalVideo is successful, this event will be triggered.
724
+ * @default 'device-changed'
725
+ * @memberof module:EVENT
726
+ * @example
727
+ * trtc.on(TRTC.EVENT.DEVICE_CHANGED, (event) => {
728
+ * console.log(`${event.type}(${event.device.label}) ${event.action}`);
729
+ * });
730
+ */
731
+ readonly DEVICE_CHANGED: "device-changed";
732
+ /**
733
+ * @description Publish state change event.
734
+ * - event.mediaType media type, value: `'audio'|'video'|'screen'`.
735
+ * - event.state current publish state, value:
736
+ * - `'starting'` trying to publish stream
737
+ * - `'started'` publish stream succeeded
738
+ * - `'stopped'` publish stream stopped, see event.reason field for the reason
739
+ * - event.prevState the publish state at the last event trigger, with the same type as event.state.
740
+ * - event.reason the reason for the publish state to become `'stopped'`, value:
741
+ * - `'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.
742
+ * - `'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.
743
+ * - `'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.
744
+ * - event.error error information when event.reason is `'error'`.
745
+ * @default 'publish-state-changed'
746
+ * @memberof module:EVENT
747
+ * @example
748
+ * trtc.on(TRTC.EVENT.PUBLISH_STATE_CHANGED, (event) => {
749
+ * console.log(`${event.mediaType} ${event.state} ${event.reason}`);
750
+ * });
751
+ */
752
+ readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
753
+ /**
754
+ * @since v5.3.0
755
+ * @description a new MediaStreamTrack object received.
756
+ * @default 'track'
757
+ * @memberof module:EVENT
758
+ * @example
759
+ * trtc.on(TRTC.EVENT.TRACK, event => {
760
+ * // userId === '' means event.track is a local track, otherwise it's a remote track
761
+ * const isLocal = event.userId === '';
762
+ * // Usually the sub stream is a screen-sharing video stream.
763
+ * const isSubStream = event.streamType === TRTC.TYPE.STREAM_TYPE_SUB;
764
+ * const mediaStreamTrack = event.track;
765
+ * const kind = event.track.kind; // audio or video
766
+ * })
767
+ */
768
+ readonly TRACK: "track";
769
+ /**
770
+ * @description TRTC statistics.<br>
771
+ *
772
+ * - SDK will fires this event once every 2s.
773
+ * - You can get the network quality, statistics of audio and video from this event. For detailed parameter description, please refer to {@link TRTCStatistics}.
774
+ * @default 'statistics'
775
+ * @since v5.2.0
776
+ * @memberof module:EVENT
777
+ * @example
778
+ * trtc.on(TRTC.EVENT.STATISTICS, statistics => {
779
+ * console.warn(statistics.rtt, statistics.upLoss, statistics.downLoss);
780
+ * })
781
+ */
782
+ readonly STATISTICS: "statistics";
783
+ /**
784
+ * @since v5.3.0
785
+ * @description SEI message received<br>
786
+ * @default 'sei-message'
787
+ * @memberof module:EVENT
788
+ * @example
789
+ * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
790
+ * console.log(`received sei message from ${event.userId}, data: ${event.data}, streamType: ${event.streamType}`)
791
+ * })
792
+ */
793
+ readonly SEI_MESSAGE: "sei-message";
794
+ /**
795
+ * @since v5.6.0
796
+ * @description received a new custom message.
797
+ * @default 'custom-message'
798
+ * @memberof module:EVENT
799
+ * @example
800
+ * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
801
+ * // event.userId: remote userId.
802
+ * // event.cmdId: message cmdId.
803
+ * // event.seq: message sequence number.
804
+ * // event.data: custom message data, type is ArrayBuffer.
805
+ * })
806
+ */
807
+ readonly CUSTOM_MESSAGE: "custom-message";
808
+ };
809
+ declare interface TRTCEventTypes {
810
+ [TRTCEvent.ERROR]: [RtcError];
811
+ [TRTCEvent.AUTOPLAY_FAILED]: [{
812
+ userId: string;
813
+ }];
814
+ [TRTCEvent.KICKED_OUT]: [{
815
+ reason: Exclude<BannedReason, 'user_time_out'>;
816
+ }];
817
+ [TRTCEvent.REMOTE_USER_ENTER]: [{
818
+ userId: string;
819
+ }];
820
+ [TRTCEvent.REMOTE_USER_EXIT]: [{
821
+ userId: string;
822
+ }];
823
+ [TRTCEvent.REMOTE_AUDIO_AVAILABLE]: [{
824
+ userId: string;
825
+ }];
826
+ [TRTCEvent.REMOTE_AUDIO_UNAVAILABLE]: [{
827
+ userId: string;
828
+ }];
829
+ [TRTCEvent.REMOTE_VIDEO_AVAILABLE]: [{
830
+ userId: string;
831
+ streamType: TRTCStreamType;
832
+ }];
833
+ [TRTCEvent.REMOTE_VIDEO_UNAVAILABLE]: [{
834
+ userId: string;
835
+ streamType: TRTCStreamType;
836
+ }];
837
+ [TRTCEvent.AUDIO_VOLUME]: [{
838
+ result: {
839
+ userId: string;
840
+ volume: number;
841
+ }[];
842
+ }];
843
+ [TRTCEvent.NETWORK_QUALITY]: [NetworkQuality];
844
+ [TRTCEvent.CONNECTION_STATE_CHANGED]: [{
845
+ prevState: ConnectionState;
846
+ state: ConnectionState;
847
+ }];
848
+ [TRTCEvent.AUDIO_PLAY_STATE_CHANGED]: [{
849
+ userId: string;
850
+ state: PlayerState;
851
+ reason: string;
852
+ }];
853
+ [TRTCEvent.VIDEO_PLAY_STATE_CHANGED]: [{
854
+ userId: string;
855
+ streamType: TRTCStreamType;
856
+ state: PlayerState;
857
+ reason: string;
858
+ }];
859
+ [TRTCEvent.SCREEN_SHARE_STOPPED]: [];
860
+ [TRTCEvent.DEVICE_CHANGED]: [{
861
+ type: TRTCDeviceType;
862
+ action: TRTCDeviceAction;
863
+ device: DeviceInfo;
864
+ }];
865
+ [TRTCEvent.PUBLISH_STATE_CHANGED]: [
866
+ {
867
+ mediaType: 'audio' | 'video' | 'screen';
868
+ state: 'started' | 'stopped' | 'starting';
869
+ prevState: 'started' | 'stopped' | 'starting';
870
+ reason?: 'timeout' | 'error' | 'api-call';
871
+ error?: RtcError;
872
+ }
873
+ ];
874
+ [TRTCEvent.SEI_MESSAGE]: [{
875
+ data: Uint8Array;
876
+ userId: string;
877
+ streamType: TRTCStreamType;
878
+ }];
879
+ [TRTCEvent.STATISTICS]: [statistics: TRTCStatistics];
880
+ [TRTCEvent.TRACK]: [{
881
+ userId: string;
882
+ streamType?: TRTCStreamType;
883
+ track: MediaStreamTrack;
884
+ }];
885
+ [TRTCEvent.CUSTOM_MESSAGE]: [CustomMessage];
886
+ }
890
887
  class TRTC extends EventEmitter<TRTCEventTypes> {
891
- /**
892
- * Create a TRTC object for implementing functions such as entering a room, previewing, publishing, and subscribing streams.<br>
893
- *
894
- * **Note:**
895
- * - You must create a TRTC object first and call its methods and listen to its events to implement various functions required by the business.
896
- * @example
897
- * // Create a TRTC object
898
- * const trtc = TRTC.create();
899
- *
900
- * @returns {TRTC} TRTC object
901
- */
902
- static create(options?: TRTCOptions): TRTC;
903
- /**
904
- * @private
905
- * 注册插件 <br>
906
- *
907
- * @example
908
- * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
909
- * trtc.use({ plugin: VirtualBackground });
910
- *
911
- * @example
912
- * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
913
- * trtc.use({ plugin: VirtualBackground, assetsPath: './js/assets/' });
914
- *
915
- * @example
916
- * // 简写使用
917
- * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
918
- * trtc.use(VirtualBackground);
919
- */
920
- use(pluginObject: PluginWithAssets | IPluginClass): void;
921
- _use(pluginClass: IPluginClass, assetsPath?: string): void;
922
- /**
923
- * @typedef TurnServer
924
- * @property {string} url TURN server url
925
- * @property {string=} username TURN server auth user name
926
- * @property {string=} credential TURN server password
927
- * @property {string=} [credentialType=password] TURN server verify password type
928
- */
929
- /**
930
- * @typedef ProxyServer
931
- * @property {string} [websocketProxy] websocket service proxy
932
- * @property {string} [loggerProxy] log service agent
933
- * @property {TurnServer[]} [turnServer] media data transmission agent
934
- * @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>
935
- * 'relay' forces the connection through the TURN server.
936
- */
937
- /**
938
- * Enter a video call room.<br>
939
- * - 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.
940
- * - 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.
941
- * - By default, the SDK automatically plays remote audio. You need to call {@link TRTC#startRemoteVideo startRemoteVideo()} to play remote video.
942
- *
943
- * @param {object} options Enter room parameters
944
- * @param {number} options.sdkAppId sdkAppId <br>
945
- * 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).
946
- * @param {string} options.userId User ID <br>
947
- * 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.
948
- * @param {string} options.userSig UserSig signature <br>
949
- * Please refer to [UserSig related](https://www.tencentcloud.com/document/product/647/35166) for the calculation method of userSig.
950
- * @param {number=} options.roomId
951
- * the value must be an integer between 1 and 4294967294<br>
952
- * <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>
953
- * @param {string=} options.strRoomId
954
- * String type room id, the length is limited to 64 bytes, and only supports the following characters:
955
- * - Uppercase and lowercase English letters (a-zA-Z)
956
- * - Numbers (0-9)
957
- * - Space ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | ~ ,
958
- * <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>
959
- * @param {string} [options.scene] Application scene, currently supports the following two scenes:
960
- * - {@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}.
961
- * - {@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.
962
- * @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:
963
- * - {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} (default) Anchor
964
- * - {@link module:TYPE.ROLE_AUDIENCE TRTC.TYPE.ROLE_AUDIENCE} Audience
965
- * 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.
966
- * @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.
967
- * @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.
968
- * - 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).
969
- * @param {boolean} [options.enableAutoPlayDialog] Whether to enable the SDK's automatic playback failure dialog box, default: true.
970
- * - 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.
971
- * - Can be set to false in order to turn off. Refer to {@tutorial 21-advanced-auto-play-policy}.
972
- * @param {string|ProxyServer} [options.proxy] proxy config. Refer to {@tutorial 34-advanced-proxy}.
973
- * @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=).
974
- * @throws
975
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
976
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
977
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
978
- * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
979
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
980
- * @example
981
- * const trtc = TRTC.create();
982
- * await trtc.enterRoom({ roomId: 8888, sdkAppId, userId, userSig });
983
- */
984
- enterRoom(params: EnterRoomConfig): Promise<void>;
985
- /**
986
- * Exit the current audio and video call room.
987
- * - 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.
988
- * - 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.
989
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
990
- * @memberof TRTC
991
- * @example
992
- * await trtc.exitRoom();
993
- */
994
- exitRoom(): Promise<void>;
995
- /**
996
- * Switches the user role, only effective in TRTC.TYPE.SCENE_LIVE interactive live streaming mode.
997
- *
998
- * In interactive live streaming mode, a user may need to switch between "audience" and "anchor".
999
- * You can determine the role through the role field in {@link TRTC#enterRoom enterRoom()}, or switch roles after entering the room through switchRole.
1000
- * - 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.
1001
- * - 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.
1002
- * > !
1003
- * > - This interface can only be called after entering the room successfully.
1004
- * > - 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.
1005
- * @param {string} role User role
1006
- * - 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.
1007
- * - 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.
1008
- * @param {object} [option]
1009
- * @param {string} [option.privateMapKey] `Since v5.3.0+` <br>
1010
- * The privateMapKey may expire after a timeout, so you can use this parameter to update the privateMapKey.
1011
- * @throws
1012
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1013
- * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1014
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1015
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1016
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1017
- * @memberof TRTC
1018
- * @example
1019
- * // After entering the room successfully
1020
- * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, audience switches to anchor
1021
- * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR);
1022
- * // Switch from audience role to anchor role and start streaming
1023
- * await trtc.startLocalVideo();
1024
- *
1025
- * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, anchor switches to audience
1026
- * await trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE);
1027
- * @example
1028
- * // Since v5.3.0+
1029
- * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR, { privateMapKey: 'your new privateMapKey' });
1030
- */
1031
- switchRole(role: UserRole, option?: {
1032
- privateMapKey?: string;
1033
- latencyLevel?: number;
1034
- }): Promise<void>;
1035
- /**
1036
- * Destroy the TRTC instance <br/>
1037
- *
1038
- * 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.
1039
- *
1040
- * Note:
1041
- * - The trtc instance after destruction cannot be used again.
1042
- * - 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.
1043
- *
1044
- * @example
1045
- * // When the call is over
1046
- * await trtc.exitRoom();
1047
- * // If the trtc is no longer needed, destroy the trtc and release the reference.
1048
- * trtc.destroy();
1049
- * trtc = null;
1050
- * @throws {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1051
- * @memberof TRTC
1052
- */
1053
- destroy(): void;
1054
- /**
1055
- * Start collecting audio from the local microphone and publish it to the current room.
1056
- * - When to call: can be called before or after entering the room, cannot be called repeatedly.
1057
- * - 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.
1058
- *
1059
- * @param {object} [config] - Configuration item
1060
- * @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}.
1061
- * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1062
- * @param {object} [config.option] - Local audio options
1063
- * @param {string} [config.option.microphoneId]- Specify which microphone to use
1064
- * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1065
- * @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+.
1066
- * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1067
- * @param {string} [config.option.profile] - Audio encoding configuration, default {@link module:TYPE.AUDIO_PROFILE_STANDARD TRTC.TYPE.AUDIO_PROFILE_STANDARD}
1068
- * @throws
1069
- * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1070
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1071
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1072
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1073
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1074
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1075
- * @example
1076
- * // Collect the default microphone and publish
1077
- * await trtc.startLocalAudio();
1078
- * @example
1079
- * // The following is a code example for testing microphone volume, which can be used for microphone volume detection.
1080
- * trtc.enableAudioVolumeEvaluation();
1081
- * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => { });
1082
- * // No need to publish audio for testing microphone
1083
- * await trtc.startLocalAudio({ publish: false });
1084
- * // After the test is completed, turn off the microphone
1085
- * await trtc.stopLocalAudio();
1086
- * @memberof TRTC
1087
- */
1088
- startLocalAudio(config?: LocalAudioConfig): Promise<void>;
1089
- /**
1090
- * Update the configuration of the local microphone.
1091
- * - When to call: This interface needs to be called after {@link TRTC#startLocalAudio startLocalAudio()} is successful and can be called multiple times.
1092
- * - This method uses incremental update: only update the passed parameters, and keep the parameters that are not passed unchanged.
1093
- * @param {object} [config]
1094
- * @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}.
1095
- * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1096
- * @param {object} [config.option] - Local audio configuration
1097
- * @param {string} [config.option.microphoneId] - Specify which microphone to use to switch microphones.
1098
- * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1099
- * @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+.
1100
- * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1101
- * @throws
1102
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1103
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1104
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1105
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1106
- * @example
1107
- * // Switch microphone
1108
- * const microphoneList = await TRTC.getMicrophoneList();
1109
- * if (microphoneList[1]) {
1110
- * await trtc.updateLocalAudio({ option: { microphoneId: microphoneList[1].deviceId }});
1111
- * }
1112
- * @memberof TRTC
1113
- */
1114
- updateLocalAudio(config: UpdateLocalAudioConfig): Promise<void>;
1115
- /**
1116
- * Stop collecting and publishing the local microphone.
1117
- * - If you just want to mute the microphone, please use updateLocalAudio({ mute: true }). Refer to: {@tutorial 15-basic-dynamic-add-video}.
1118
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1119
- * @example
1120
- * await trtc.stopLocalAudio();
1121
- */
1122
- stopLocalAudio(): Promise<void>;
1123
- /**
1124
- * @typedef {object|string} VideoProfile - Configuration for local video stream
1125
- *
1126
- * Video configuration parameters, can use preset values in string format or custom resolution and other parameters
1127
- * | Video Profile | Resolution (Width x Height) | Frame Rate (fps) | Bitrate (kbps) | Remarks |
1128
- * | :--- | :--- | :--- | :--- | :--- |
1129
- * | 120p | 160 x 120 | 15 | 200 ||
1130
- * | 180p | 320 x 180 | 15 | 350 ||
1131
- * | 240p | 320 x 240 | 15 | 400 ||
1132
- * | 360p | 640 x 360 | 15 | 800 ||
1133
- * | 480p | 640 x 480 | 15 | 900 ||
1134
- * | 720p | 1280 x 720 | 15 | 1500 ||
1135
- * | 1080p | 1920 x 1080 | 15 | 2000 ||
1136
- * | 1440p | 2560 x 1440 | 30 | 4860 ||
1137
- * | 4K | 3840 x 2160 | 30 | 9000 ||
1138
- * @property {number} width - Video width
1139
- * @property {number} height - Video height
1140
- * @property {number} frameRate - Video frame rate
1141
- * @property {number} bitrate - Video bitrate
1142
- * @example
1143
- * const config = {
1144
- * option: {
1145
- * profile: '480p',
1146
- * },
1147
- * }
1148
- * await trtc.startLocalVideo(config);
1149
- * @example
1150
- * const config = {
1151
- * option: {
1152
- * profile: {
1153
- * width: 640,
1154
- * height: 480,
1155
- * frameRate: 15,
1156
- * bitrate: 900,
1157
- * }
1158
- * }
1159
- * }
1160
- * await trtc.startLocalVideo(config);
1161
- */
1162
- /**
1163
- * 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.
1164
- * - When to call: can be called before or after entering the room, but cannot be called repeatedly.
1165
- * - 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.
1166
-
1167
- * @param {object} [config]
1168
- * @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.
1169
- * @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}.
1170
- * @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}.
1171
- * @param {object} [config.option] - Local video configuration
1172
- * @param {string} [config.option.cameraId] - Specify which camera to use for switching cameras.
1173
- * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera.
1174
- * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1175
- * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
1176
- * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
1177
- * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
1178
- * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
1179
- * - false: Boolean value, represents no mirroring.
1180
- *
1181
- * <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>
1182
- * @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.
1183
- * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main video.
1184
- * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1185
- * @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})
1186
- * @throws
1187
- * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1188
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1189
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1190
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1191
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1192
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1193
- * @example
1194
- * // Preview and publish the camera
1195
- * await trtc.startLocalVideo({
1196
- * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1197
- * });
1198
- * @example
1199
- * // Preview the camera without publishing. Can be used for camera testing.
1200
- * const config = {
1201
- * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1202
- * publish: false // Do not publish the camera
1203
- * }
1204
- * await trtc.startLocalVideo(config);
1205
- * // Call updateLocalVideo when you need to publish the video
1206
- * await trtc.updateLocalVideo({ publish:true });
1207
- * @example
1208
- * // Use a specified camera.
1209
- * const cameraList = await TRTC.getCameraList();
1210
- * if (cameraList[0]) {
1211
- * await trtc.startLocalVideo({
1212
- * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1213
- * option: {
1214
- * cameraId: cameraList[0].deviceId,
1215
- * }
1216
- * });
1217
- * }
1218
- *
1219
- * // use front camera on mobile device.
1220
- * await trtc.startLocalVideo({ view, option: { useFrontCamera: true }});
1221
- * // use rear camera on mobile device.
1222
- * await trtc.startLocalVideo({ view, option: { useFrontCamera: false }});
1223
- * @memberof TRTC
1224
- */
1225
- startLocalVideo(config?: LocalVideoConfig): Promise<void>;
1226
- /**
1227
- * Update the local camera configuration.
1228
- * - This interface needs to be called after {@link TRTC#startLocalVideo startLocalVideo()} is successful.
1229
- * - This interface can be called multiple times.
1230
- * - This method uses incremental update: only updates the passed-in parameters, and keeps the parameters that are not passed in unchanged.
1231
- * @param {object} [config]
1232
- * @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.
1233
- * @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}.
1234
- * @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}.
1235
- * @param {object} [config.option] - Local video configuration
1236
- * @param {string} [config.option.cameraId] - Specify which camera to use
1237
- * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera
1238
- * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1239
- * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
1240
- * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
1241
- * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
1242
- * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
1243
- * - false: Boolean value, represents no mirroring.
1244
- * @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
1245
- * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main stream
1246
- * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1247
- * @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})
1248
- * @throws
1249
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1250
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1251
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1252
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1253
- * @example
1254
- * // Switch camera
1255
- * const cameraList = await TRTC.getCameraList();
1256
- * if (cameraList[1]) {
1257
- * await trtc.updateLocalVideo({ option: { cameraId: cameraList[1].deviceId }});
1258
- * }
1259
- * @example
1260
- * // Stop publishing video, but keep local preview
1261
- * await trtc.updateLocalVideo({ publish:false });
1262
- * @memberof TRTC
1263
- */
1264
- updateLocalVideo(config: LocalVideoConfig): Promise<void>;
1265
- /**
1266
- * Stop capturing, previewing, and publishing the local camera.
1267
- * - 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>
1268
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1269
- * @example
1270
- * await trtc.stopLocalVideo();
1271
- */
1272
- stopLocalVideo(): Promise<void>;
1273
- /**
1274
- * @typedef {object|string} ScreenShareProfile - Screen sharing resolution, bit rate, and frame rate configuration
1275
- * Screen sharing configuration parameters, can use preset values or custom resolution and other parameters
1276
- * | Screen Profile | Resolution (width x height) | Frame Rate (fps) | Bitrate (kbps) |
1277
- * | :--- | :--- | :--- | :--- |
1278
- * | 480p | 640 x 480 | 5 | 900 |
1279
- * | 480p_2 | 640 x 480 | 30 | 1000 |
1280
- * | 720p | 1280 x 720 | 5 | 1200 |
1281
- * | 720p_2 | 1280 x 720 | 30 | 3000 |
1282
- * | 1080p | 1920 x 1080 | 5 | 1600 |
1283
- * | 1080p_2 | 1920 x 1080 | 30 | 4000 |
1284
- * - The default resolution for screen sharing is `1080p`.
1285
- * - If the above profiles do not meet your business needs, you can also specify custom resolution, frame rate, and bitrate.
1286
-
1287
- * @property {number} width - Screen sharing width
1288
- * @property {number} height - Screen sharing height
1289
- * @property {number} frameRate - Screen sharing frame rate
1290
- * @property {number} bitrate - Screen sharing bitrate
1291
- * @example
1292
- * const config = {
1293
- * option: {
1294
- * profile: '720p',
1295
- * },
1296
- * }
1297
- * await trtc.startScreenShare(config);
1298
- */
1299
- /**
1300
- * Start screen sharing.
1301
- *
1302
- * - 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}.
1303
- * @param {object} [config]
1304
- * @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.
1305
- * @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}.
1306
- * @param {object} [config.option] - Screen sharing configuration
1307
- * @param {boolean} [config.option.systemAudio] - Whether to capture system audio. The default is false.
1308
- * @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.
1309
- * @param {ScreenShareProfile} [config.option.profile] - Screen sharing encoding configuration.
1310
- * @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})
1311
- * @param {HTMLElement} [config.option.captureElement] - Capture screen from the specified element of current tab. Available on Chrome 104+.
1312
- * @param {'current-tab' | 'tab' | 'window' | 'monitor'} [config.option.preferDisplaySurface='monitor'] - The prefer display surface for screen sharing. Available on Chrome 94+.
1313
- * - The default is monitor, which means that monitor capture will be displayed first in the Screen Sharing Capture pre-checkbox。
1314
- * - If you fill in 'current-tab', the pre-checkbox will only show the current page.
1315
- * @throws
1316
- * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1317
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1318
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1319
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1320
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1321
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1322
- * @example
1323
- * // Start screen sharing
1324
- * await trtc.startScreenShare();
1325
- * @memberof TRTC
1326
- */
1327
- startScreenShare(config?: ScreenShareConfig): Promise<void>;
1328
- /**
1329
- * Update screen sharing configuration
1330
- * - This interface needs to be called after {@link TRTC#startScreenShare startScreenShare()} is successful.
1331
- * - This interface can be called multiple times.
1332
- * - This method uses incremental update: only update the passed-in parameters, and keep the parameters that are not passed-in unchanged.
1333
- * @param {object} [config]
1334
- * @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.
1335
- * @param {boolean} [config.publish=true] - Whether to publish screen sharing to the room
1336
- * @param {object} [config.option] - Screen sharing configuration
1337
- * @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.
1338
- * @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})
1339
- * @throws
1340
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1341
- * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1342
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1343
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1344
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1345
- * @example
1346
- * // Stop screen sharing, but keep the local preview of screen sharing
1347
- * await trtc.updateScreenShare({ publish:false });
1348
- * @memberof TRTC
1349
- */
1350
- updateScreenShare(config: UpdateScreenShareConfig): Promise<void>;
1351
- /**
1352
- * Stop screen sharing.
1353
-
1354
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1355
- * @example
1356
- * await trtc.stopScreenShare();
1357
- */
1358
- stopScreenShare(): Promise<void>;
1359
- /**
1360
- * Play remote video
1361
- *
1362
- * - When to call: Call after receiving the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE TRTC.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE)} event.
1363
- * @param {object} [config]
1364
- * @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.
1365
- * @param {string} config.userId - Remote user ID
1366
- * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1367
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1368
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1369
- * @param {object} [config.option] - Remote video configuration
1370
- * @param {boolean} [config.option.small] - Whether to subscribe small streams
1371
- * @param {boolean} [config.option.mirror] - Whether to enable mirror
1372
- * @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.
1373
- * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1374
- * @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}.
1375
- * @throws
1376
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1377
- * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1378
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1379
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1380
- * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1381
- * @example
1382
- * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, ({ userId, streamType }) => {
1383
- * // You need to place the video container in the DOM in advance, and it is recommended to use `${userId}_${streamType}` as the element id.
1384
- * trtc.startRemoteVideo({ userId, streamType, view: `${userId}_${streamType}` });
1385
- * })
1386
- * @memberof TRTC
1387
- */
1388
- startRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1389
- /**
1390
- * Update remote video playback configuration<br>
1391
- * - This method should be called after {@link TRTC#startRemoteVideo startRemoteVideo} is successful.
1392
- * - This method can be called multiple times.
1393
- * - This method uses incremental updates, so only the configuration items that need to be updated need to be passed in.
1394
- * @param {object} [config]
1395
- * @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.
1396
- * @param {string} config.userId - Remote user ID
1397
- * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1398
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1399
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1400
- * @param {object} [config.option] - Remote video configuration
1401
- * @param {boolean} [config.option.small] - Whether to subscribe small streams. Refer to: {@tutorial 27-advanced-small-stream}.
1402
- * @param {boolean} [config.option.mirror] - Whether to enable mirror
1403
- * @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.
1404
- * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1405
- * @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}.
1406
- * @throws
1407
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1408
- * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1409
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1410
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1411
- * @example
1412
- * const config = {
1413
- * view: document.getElementById(userId),
1414
- * userId,
1415
- * }
1416
- * await trtc.updateRemoteVideo(config);
1417
- * @memberof TRTC
1418
- */
1419
- updateRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1420
- /**
1421
- * Used to stop remote video playback.<br>
1422
- * @param {object} config - Remote video configuration
1423
- * @param {string} config.userId - Remote user ID, '*' represents all users.
1424
- * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} [config.streamType] - Remote stream type. This field is required when userId is not '*'.
1425
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1426
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1427
- * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1428
- * @example
1429
- * // Stop playing all remote users
1430
- * await trtc.stopRemoteVideo({ userId: '*' });
1431
- */
1432
- stopRemoteVideo(config: StopRemoteVideoConfig): Promise<void>;
1433
- /**
1434
- * 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>
1435
- *
1436
- * Note:
1437
- * - By default, after entering the room, the SDK will automatically play remote audio. You can call this interface to mute or unmute remote users.
1438
- * - 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.
1439
- * - 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).
1440
- * - If you want to continue subscribing audio data from the user but not play it, you can call setRemoteAudioVolume(userId, 0)
1441
- * @param {string} userId - Remote user ID, '*' represents all users.
1442
- * @param {boolean} mute - Whether to mute
1443
- * @throws
1444
- * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1445
- * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1446
- * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1447
- * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1448
- * @example
1449
- * // Mute all remote users
1450
- * await trtc.muteRemoteAudio('*', true);
1451
- */
1452
- muteRemoteAudio(userId: string, mute: boolean): Promise<void>;
1453
- /**
1454
- * Used to control the playback volume of remote audio.<br>
1455
- *
1456
- * - Not supported by iOS Safari
1457
- * @param {string} userId - Remote user ID。'*' represents all remote users.
1458
- * @param {number} volume - Volume, ranging from 0 to 100. The default value is 100.<br>
1459
- * Since `v5.1.3+`, the volume can be set higher than 100.
1460
- * @example
1461
- * await trtc.setRemoteAudioVolume('123', 90);
1462
- */
1463
- setRemoteAudioVolume(userId: string, volume: number): void;
1464
- startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1465
- startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1466
- updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1467
- updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1468
- stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1469
- stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1470
- /**
1471
- * Enables or disables the volume callback.<br>
1472
- *
1473
- * - 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>
1474
- *
1475
- * @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.
1476
- * @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.
1477
- * @memberof TRTC
1478
- * @example
1479
- * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
1480
- * event.result.forEach(({ userId, volume }) => {
1481
- * const isMe = userId === ''; // When userId is an empty string, it represents the local microphone volume.
1482
- * if (isMe) {
1483
- * console.log(`my volume: ${volume}`);
1484
- * } else {
1485
- * console.log(`user: ${userId} volume: ${volume}`);
1486
- * }
1487
- * })
1488
- * });
1489
- *
1490
- * // Enable volume callback and trigger the event every 1000ms
1491
- * trtc.enableAudioVolumeEvaluation(1000);
1492
- *
1493
- * // To turn off the volume callback, pass in an interval value less than or equal to 0
1494
- * trtc.enableAudioVolumeEvaluation(-1);
1495
- */
1496
- enableAudioVolumeEvaluation(interval?: number, enableInBackground?: boolean): void;
1497
- /**
1498
- * Listen to TRTC events<br><br>
1499
- * For a detailed list of events, please refer to: {@link module:EVENT TRTC.EVENT}
1500
- *
1501
- * @param {string} eventName Event name
1502
- * @param {function} handler Event callback function
1503
- * @param {context} context Context
1504
- * @memberof TRTC
1505
- * @example
1506
- * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
1507
- * // REMOTE_VIDEO_AVAILABLE event handler
1508
- * });
1509
- */
1510
- on<T extends keyof TRTCEventTypes>(event: T, handler: (...args: TRTCEventTypes[T]) => void, context?: any): this;
1511
- /**
1512
- * Remove event listener<br>
1513
- *
1514
- * @param {string} eventName Event name. Passing in the wildcard '*' will remove all event listeners.
1515
- * @param {function} handler Event callback function
1516
- * @param {context} context Context
1517
- * @memberof TRTC
1518
- * @example
1519
- * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, function peerJoinHandler(event) {
1520
- * // REMOTE_USER_ENTER event handler
1521
- * console.log('remote user enter');
1522
- *
1523
- * trtc.off(TRTC.EVENT.REMOTE_USER_ENTER, peerJoinHandler);
1524
- * });
1525
- *
1526
- * // Remove all event listeners
1527
- * trtc.off('*');
1528
- */
1529
- off<T extends keyof TRTCEventTypes>(event: T | '*', handler: T extends '*' ? never : (...args: TRTCEventTypes[T]) => void, context?: any): this;
1530
- /**
1531
- * Get audio track
1532
- *
1533
- * @returns {MediaStreamTrack?} Audio track
1534
- * @param {Object|string} [config] If not passed, get the local microphone audioTrack
1535
- * @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.
1536
- * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1537
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's microphone)(default)
1538
- * - {@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.
1539
- * @memberof TRTC
1540
- * @example
1541
- * // Version before v5.4.3
1542
- * trtc.getAudioTrack(); // Get local microphone audioTrack, captured by trtc.startLocalAudio()
1543
- * trtc.getAudioTrack('remoteUserId'); // Get remote audioTrack
1544
- *
1545
- * // Since v5.4.3+, you can get local screen audioTrack by passing the streamType = TRTC.STREAM_TYPE_SUB
1546
- * trtc.getAudioTrack({ streamType: TRTC.STREAM_TYPE_SUB });
1547
- */
1548
- getAudioTrack(configOrUserId?: {
1549
- userId?: string;
1550
- streamType?: TRTCStreamType;
1551
- } | string): MediaStreamTrack | null;
1552
- /**
1553
- * Get video track
1554
- *
1555
- * @param {string} [config] If not passed, get the local camera videoTrack
1556
- * @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.
1557
- * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1558
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's camera)(default)
1559
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing)
1560
- * @returns {MediaStreamTrack|null} Video track
1561
- * @memberof TRTC
1562
- * @example
1563
- * // Get local camera videoTrack
1564
- * const videoTrack = trtc.getVideoTrack();
1565
- * // Get local screen sharing videoTrack
1566
- * const screenVideoTrack = trtc.getVideoTrack({ streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1567
- * // Get remote user's main stream videoTrack
1568
- * const remoteMainVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_MAIN });
1569
- * // Get remote user's sub stream videoTrack
1570
- * const remoteSubVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1571
- */
1572
- getVideoTrack(config?: {
1573
- userId?: string;
1574
- streamType?: TRTCStreamType;
1575
- }): MediaStreamTrack | null;
1576
- /**
1577
- * Get video snapshot <br>
1578
- * Notice: must play the video before it can obtain the snapshot. If there is no playback, an empty string will be returned.
1579
- * @param {string} config.userId - Remote user ID
1580
- * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType
1581
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream
1582
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream
1583
- * @since 5.4.0
1584
- * @example
1585
- * // get self main stream video frame
1586
- * trtc.getVideoSnapshot()
1587
- * // get self sub stream video frame
1588
- * trtc.getVideoSnapshot({streamType:TRTC.TYPE.STREAM_TYPE_SUB})
1589
- * // get remote user main stream video frame
1590
- * trtc.getVideoSnapshot({userId: 'remote userId', streamType:TRTC.TYPE.STREAM_TYPE_MAIN})
1591
- * @memberof TRTC
1592
- */
1593
- getVideoSnapshot(config?: VideoFrameConfig): string;
1594
- setCurrentSpeaker(speakerId: string): void;
1595
- /**
1596
- * Send SEI Message <br>
1597
- *
1598
- * > The header of a video frame has a header block called SEI.
1599
- * > The principle of this interface is to use the SEI to embed the custom data you want to send along with the video frame.
1600
- * > SEI messages can accompany video frames all the way to the live CDN.
1601
- *
1602
- * Applicable scenarios: synchronization of lyrics, live answering questions, etc.
1603
- *
1604
- * When to call: call after {@link TRTC#startLocalVideo trtc.startLocalVideo} or {@link TRTC#startLocalScreen trtc.startLocalScreen} when set 'toSubStream' option to true successfully.
1605
- *
1606
- * Note:
1607
- * 1. Maximum 1KB(Byte) sent in a single call, maximum 30 calls per second, maximum 8KB sent per second.
1608
- * 2. Currently only support Chrome 86+, Edge 86+, Opera 72+ browsers.
1609
- * 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.
1610
- * 4. SEI cannot be sent without trtc.startLocalVideo(or trtc.startLocalScreen when set 'toSubStream' option to true); SEI cannot be received without startRemoteVideo.
1611
- * 5. Only H264 encoder is supported to send SEI.
1612
- * 6. SEI sending and receiving is not supported for small streams for the time being.
1613
- * @see {@link module:EVENT.SEI_MESSAGE TRTC.EVENT.SEI_MESSAGE}
1614
- * @since v5.3.0
1615
- * @param {ArrayBuffer} buffer SEI data to be sent
1616
- * @param {Object=} options
1617
- * @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.
1618
- * @param {Boolean} [options.toSubStream=false] Send SEI data to substream. Need call trtc.startLocalScreen first. Since v5.7.0+.
1619
- * @example
1620
- * // 1. enable SEI
1621
- * const trtc = TRTC.create({
1622
- * enableSEI: true
1623
- * })
1624
- *
1625
- * // 2. send SEI
1626
- * try {
1627
- * await trtc.enterRoom({
1628
- * userId: 'user_1',
1629
- * roomId: 12345,
1630
- * })
1631
- * await trtc.startLocalVideo();
1632
- * const unit8Array = new Uint8Array([1, 2, 3]);
1633
- * trtc.sendSEIMessage(unit8Array.buffer);
1634
- * } catch(error) {
1635
- * console.warn(error);
1636
- * }
1637
- *
1638
- * // 3. receive SEI
1639
- * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
1640
- * console.warn(`sei ${event.data} from ${event.userId}`);
1641
- * })
1642
- */
1643
- sendSEIMessage(buffer: ArrayBuffer, options?: {
1644
- seiPayloadType?: number;
1645
- toSubStream?: boolean;
1646
- }): void;
1647
- /**
1648
- * Send Custom Message to all remote users in the room. <br>
1649
- *
1650
- * Note:
1651
- *
1652
- * 1. Only {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} can call sendCustomMessage.
1653
- * 2. You should call this api after {@link TRTC#enterRoom TRTC.enterRoom} successfully.
1654
- * 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.
1655
- * @since v5.6.0
1656
- * @see Listen for the event {@link module:EVENT.CUSTOM_MESSAGE TRTC.EVENT.CUSTOM_MESSAGE} to receive custom message.
1657
- * @param {object} message
1658
- * @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.
1659
- * @param {ArrayBuffer} message.data - message content. <br/>
1660
- * - Maximum 1KB(Byte) sent in a single call.
1661
- * - Maximum 30 calls per second
1662
- * - Maximum 8KB sent per second.
1663
- * @example
1664
- * // send custom message
1665
- * trtc.sendCustomMessage({
1666
- * cmdId: 1,
1667
- * data: new TextEncoder().encode('hello').buffer
1668
- * });
1669
- *
1670
- * // receive custom message
1671
- * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
1672
- * // event.userId: remote userId.
1673
- * // event.cmdId: message cmdId.
1674
- * // event.seq: message sequence number.
1675
- * // event.data: custom message data, type is ArrayBuffer.
1676
- * console.log(`received custom msg from ${event.userId}, message: ${new TextDecoder().decode(event.data)}`)
1677
- * })
1678
- */
1679
- sendCustomMessage(message: CustomMessageData): void;
1680
- static EVENT: {
1681
- readonly ERROR: "error";
1682
- readonly AUTOPLAY_FAILED: "autoplay-failed";
1683
- readonly KICKED_OUT: "kicked-out";
1684
- readonly REMOTE_USER_ENTER: "remote-user-enter";
1685
- readonly REMOTE_USER_EXIT: "remote-user-exit";
1686
- readonly REMOTE_AUDIO_AVAILABLE: "remote-audio-available";
1687
- readonly REMOTE_AUDIO_UNAVAILABLE: "remote-audio-unavailable";
1688
- readonly REMOTE_VIDEO_AVAILABLE: "remote-video-available";
1689
- readonly REMOTE_VIDEO_UNAVAILABLE: "remote-video-unavailable";
1690
- readonly AUDIO_VOLUME: "audio-volume";
1691
- readonly NETWORK_QUALITY: "network-quality";
1692
- readonly CONNECTION_STATE_CHANGED: "connection-state-changed";
1693
- readonly AUDIO_PLAY_STATE_CHANGED: "audio-play-state-changed";
1694
- readonly VIDEO_PLAY_STATE_CHANGED: "video-play-state-changed";
1695
- readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
1696
- readonly DEVICE_CHANGED: "device-changed";
1697
- readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
1698
- readonly TRACK: "track";
1699
- readonly STATISTICS: "statistics";
1700
- readonly SEI_MESSAGE: "sei-message";
1701
- readonly CUSTOM_MESSAGE: "custom-message";
1702
- };
1703
- static ERROR_CODE: {
1704
- INVALID_PARAMETER: number;
1705
- INVALID_OPERATION: number;
1706
- ENV_NOT_SUPPORTED: number;
1707
- DEVICE_ERROR: number;
1708
- SERVER_ERROR: number;
1709
- OPERATION_FAILED: number;
1710
- OPERATION_ABORT: number;
1711
- UNKNOWN_ERROR: number;
1712
- };
1713
- static TYPE: {
1714
- readonly SCENE_LIVE: Scene.LIVE;
1715
- readonly SCENE_RTC: Scene.RTC;
1716
- readonly ROLE_ANCHOR: UserRole.ANCHOR;
1717
- readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
1718
- readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
1719
- readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
1720
- readonly AUDIO_PROFILE_STANDARD: "standard";
1721
- readonly AUDIO_PROFILE_STANDARD_STEREO: "standard-stereo";
1722
- readonly AUDIO_PROFILE_HIGH: "high";
1723
- readonly AUDIO_PROFILE_HIGH_STEREO: "high-stereo";
1724
- readonly QOS_PREFERENCE_SMOOTH: "smooth";
1725
- readonly QOS_PREFERENCE_CLEAR: "clear";
1726
- };
1727
- static frameWorkType: number;
1728
- /**
1729
- * Set the log output level
1730
- * <br>
1731
- * It is recommended to set the DEBUG level during development and testing, which includes detailed prompt information.
1732
- * The default output level is INFO, which includes the log information of the main functions of the SDK.
1733
- *
1734
- * @param {0-5} [level] Log output level 0: TRACE 1: DEBUG 2: INFO 3: WARN 4: ERROR 5: NONE
1735
- * @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.
1736
- * @example
1737
- * // Output log levels above DEBUG
1738
- * TRTC.setLogLevel(1);
1739
- */
1740
- static setLogLevel(level: LOG_LEVEL, enableUploadLog?: boolean): void;
1741
- /**
1742
- * Check if the TRTC Web SDK is supported by the current browser
1743
- *
1744
- * - Reference: {@tutorial 05-info-browser}.
1745
- * @example
1746
- * TRTC.isSupported().then((checkResult) => {
1747
- * if(!checkResult.result) {
1748
- * console.log('checkResult', checkResult.result, 'checkDetail', checkResult.detail);
1749
- * // The SDK is not supported by the current browser, guide the user to use the latest version of Chrome browser.
1750
- * }
1751
- * });
1752
- *
1753
- * @returns {Promise.<object>} Promise returns the detection result
1754
- * | Property | Type | Description |
1755
- * |--------------------------------------------|---------|-------------------------------------|
1756
- * | checkResult.result | boolean | Detection result |
1757
- * | checkResult.detail.isBrowserSupported | boolean | Whether the current browser is supported by the SDK |
1758
- * | checkResult.detail.isWebRTCSupported | boolean | Whether the current browser supports WebRTC |
1759
- * | checkResult.detail.isWebCodecsSupported | boolean | Whether the current browser supports WebCodecs |
1760
- * | checkResult.detail.isMediaDevicesSupported | boolean | Whether the current browser supports obtaining media devices and media streams |
1761
- * | checkResult.detail.isScreenShareSupported | boolean | Whether the current browser supports screen sharing |
1762
- * | checkResult.detail.isSmallStreamSupported | boolean | Whether the current browser supports small streams |
1763
- * | checkResult.detail.isH264EncodeSupported | boolean | Whether the current browser supports H264 encoding for uplink |
1764
- * | checkResult.detail.isH264DecodeSupported | boolean | Whether the current browser supports H264 decoding for downlink |
1765
- * | checkResult.detail.isVp8EncodeSupported | boolean | Whether the current browser supports VP8 encoding for uplink |
1766
- * | checkResult.detail.isVp8DecodeSupported | boolean | Whether the current browser supports VP8 decoding for downlink |
1767
- */
1768
- static isSupported(): Promise<any>;
1769
- /**
1770
- * Returns the list of camera devices
1771
- * <br>
1772
- * **Note**
1773
- * - 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}
1774
- * - 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+.
1775
- * @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.
1776
- * @example
1777
- * const cameraList = await TRTC.getCameraList();
1778
- * if (cameraList[0] && cameraList[0].getCapabilities) {
1779
- * const { width, height, frameRate, facingMode } = cameraList[0].getCapabilities();
1780
- * console.log(width.max, height.max, frameRate.max);
1781
- * if (facingMode) {
1782
- * if (facingMode[0] === 'user') {
1783
- * // front camera
1784
- * } else if (facingMode[0] === 'environment') {
1785
- * // rear camera
1786
- * }
1787
- * }
1788
- * }
1789
- * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1790
- */
1791
- static getCameraList(requestPermission?: boolean): Promise<DeviceInfo[]>;
1792
- /**
1793
- * Returns the list of microphone devices
1794
- * <br>
1795
- * **Note**
1796
- * - 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}
1797
- * - 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+.
1798
- * @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.
1799
- * @example
1800
- * const microphoneList = await TRTC.getMicrophoneList();
1801
- * if (microphoneList[0] && microphoneList[0].getCapabilities) {
1802
- * const { channelCount } = microphoneList[0].getCapabilities();
1803
- * console.log(channelCount.max);
1804
- * }
1805
- * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1806
- */
1807
- static getMicrophoneList(requestPermission?: boolean): Promise<DeviceInfo[]>;
1808
- /**
1809
- * Returns the list of speaker devices. Only support PC browser, not support mobile browser.
1810
- * <br>
1811
- * @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.
1812
- * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1813
- */
1814
- static getSpeakerList(requestPermission?: boolean): Promise<DeviceInfo[]>;
1815
- /**
1816
- * Set the current speaker for audio playback
1817
- *
1818
- * @param {string} speakerId Speaker ID
1819
- */
1820
- static setCurrentSpeaker(speakerId: string): Promise<void>;
1821
- }
888
+ /**
889
+ * Create a TRTC object for implementing functions such as entering a room, previewing, publishing, and subscribing streams.<br>
890
+ *
891
+ * **Note:**
892
+ * - You must create a TRTC object first and call its methods and listen to its events to implement various functions required by the business.
893
+ * @example
894
+ * // Create a TRTC object
895
+ * const trtc = TRTC.create();
896
+ *
897
+ * @returns {TRTC} TRTC object
898
+ */
899
+ static create(options?: TRTCOptions): TRTC;
900
+ /**
901
+ * @private
902
+ * 注册插件 <br>
903
+ *
904
+ * @example
905
+ * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
906
+ * trtc.use({ plugin: VirtualBackground });
907
+ *
908
+ * @example
909
+ * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
910
+ * trtc.use({ plugin: VirtualBackground, assetsPath: './js/assets/' });
911
+ *
912
+ * @example
913
+ * // 简写使用
914
+ * import { VirtualBackground } from 'trtc-sdk-v5/plugins/video-effect/virtual-background';
915
+ * trtc.use(VirtualBackground);
916
+ */
917
+ use(pluginObject: PluginWithAssets | IPlugin): void;
918
+ _use(pluginClass: IPlugin, assetsPath?: string): void;
919
+ /**
920
+ * @typedef TurnServer
921
+ * @property {string} url TURN server url
922
+ * @property {string=} username TURN server auth user name
923
+ * @property {string=} credential TURN server password
924
+ * @property {string=} [credentialType=password] TURN server verify password type
925
+ */
926
+ /**
927
+ * @typedef ProxyServer
928
+ * @property {string} [websocketProxy] websocket service proxy
929
+ * @property {string} [loggerProxy] log service agent
930
+ * @property {TurnServer[]} [turnServer] media data transmission agent
931
+ * @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>
932
+ * 'relay' forces the connection through the TURN server.
933
+ */
934
+ /**
935
+ * Enter a video call room.<br>
936
+ * - 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.
937
+ * - 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.
938
+ * - By default, the SDK automatically plays remote audio. You need to call {@link TRTC#startRemoteVideo startRemoteVideo()} to play remote video.
939
+ *
940
+ * @param {object} options Enter room parameters
941
+ * @param {number} options.sdkAppId sdkAppId <br>
942
+ * 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).
943
+ * @param {string} options.userId User ID <br>
944
+ * 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.
945
+ * @param {string} options.userSig UserSig signature <br>
946
+ * Please refer to [UserSig related](https://www.tencentcloud.com/document/product/647/35166) for the calculation method of userSig.
947
+ * @param {number=} options.roomId
948
+ * the value must be an integer between 1 and 4294967294<br>
949
+ * <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>
950
+ * @param {string=} options.strRoomId
951
+ * String type room id, the length is limited to 64 bytes, and only supports the following characters:
952
+ * - Uppercase and lowercase English letters (a-zA-Z)
953
+ * - Numbers (0-9)
954
+ * - Space ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | ~ ,
955
+ * <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>
956
+ * @param {string} [options.scene] Application scene, currently supports the following two scenes:
957
+ * - {@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}.
958
+ * - {@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.
959
+ * @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:
960
+ * - {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} (default) Anchor
961
+ * - {@link module:TYPE.ROLE_AUDIENCE TRTC.TYPE.ROLE_AUDIENCE} Audience
962
+ * 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.
963
+ * @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.
964
+ * @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.
965
+ * - 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).
966
+ * @param {boolean} [options.enableAutoPlayDialog] Whether to enable the SDK's automatic playback failure dialog box, default: true.
967
+ * - 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.
968
+ * - Can be set to false in order to turn off. Refer to {@tutorial 21-advanced-auto-play-policy}.
969
+ * @param {string|ProxyServer} [options.proxy] proxy config. Refer to {@tutorial 34-advanced-proxy}.
970
+ * @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=).
971
+ * @throws
972
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
973
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
974
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
975
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
976
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
977
+ * @example
978
+ * const trtc = TRTC.create();
979
+ * await trtc.enterRoom({ roomId: 8888, sdkAppId, userId, userSig });
980
+ */
981
+ enterRoom(params: EnterRoomConfig): Promise<void>;
982
+ /**
983
+ * Exit the current audio and video call room.
984
+ * - 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.
985
+ * - 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.
986
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
987
+ * @memberof TRTC
988
+ * @example
989
+ * await trtc.exitRoom();
990
+ */
991
+ exitRoom(): Promise<void>;
992
+ /**
993
+ * Switches the user role, only effective in TRTC.TYPE.SCENE_LIVE interactive live streaming mode.
994
+ *
995
+ * In interactive live streaming mode, a user may need to switch between "audience" and "anchor".
996
+ * You can determine the role through the role field in {@link TRTC#enterRoom enterRoom()}, or switch roles after entering the room through switchRole.
997
+ * - 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.
998
+ * - 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.
999
+ * > !
1000
+ * > - This interface can only be called after entering the room successfully.
1001
+ * > - 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.
1002
+ * @param {string} role User role
1003
+ * - 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.
1004
+ * - 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.
1005
+ * @param {object} [option]
1006
+ * @param {string} [option.privateMapKey] `Since v5.3.0+` <br>
1007
+ * The privateMapKey may expire after a timeout, so you can use this parameter to update the privateMapKey.
1008
+ * @throws
1009
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1010
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1011
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1012
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1013
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1014
+ * @memberof TRTC
1015
+ * @example
1016
+ * // After entering the room successfully
1017
+ * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, audience switches to anchor
1018
+ * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR);
1019
+ * // Switch from audience role to anchor role and start streaming
1020
+ * await trtc.startLocalVideo();
1021
+ *
1022
+ * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, anchor switches to audience
1023
+ * await trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE);
1024
+ * @example
1025
+ * // Since v5.3.0+
1026
+ * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR, { privateMapKey: 'your new privateMapKey' });
1027
+ */
1028
+ switchRole(role: UserRole, option?: {
1029
+ privateMapKey?: string;
1030
+ latencyLevel?: number;
1031
+ }): Promise<void>;
1032
+ /**
1033
+ * Destroy the TRTC instance <br/>
1034
+ *
1035
+ * 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.
1036
+ *
1037
+ * Note:
1038
+ * - The trtc instance after destruction cannot be used again.
1039
+ * - 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.
1040
+ *
1041
+ * @example
1042
+ * // When the call is over
1043
+ * await trtc.exitRoom();
1044
+ * // If the trtc is no longer needed, destroy the trtc and release the reference.
1045
+ * trtc.destroy();
1046
+ * trtc = null;
1047
+ * @throws {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1048
+ * @memberof TRTC
1049
+ */
1050
+ destroy(): void;
1051
+ /**
1052
+ * Start collecting audio from the local microphone and publish it to the current room.
1053
+ * - When to call: can be called before or after entering the room, cannot be called repeatedly.
1054
+ * - 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.
1055
+ *
1056
+ * @param {object} [config] - Configuration item
1057
+ * @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}.
1058
+ * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1059
+ * @param {object} [config.option] - Local audio options
1060
+ * @param {string} [config.option.microphoneId]- Specify which microphone to use
1061
+ * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1062
+ * @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+.
1063
+ * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1064
+ * @param {string} [config.option.profile] - Audio encoding configuration, default {@link module:TYPE.AUDIO_PROFILE_STANDARD TRTC.TYPE.AUDIO_PROFILE_STANDARD}
1065
+ * @throws
1066
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1067
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1068
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1069
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1070
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1071
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1072
+ * @example
1073
+ * // Collect the default microphone and publish
1074
+ * await trtc.startLocalAudio();
1075
+ * @example
1076
+ * // The following is a code example for testing microphone volume, which can be used for microphone volume detection.
1077
+ * trtc.enableAudioVolumeEvaluation();
1078
+ * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => { });
1079
+ * // No need to publish audio for testing microphone
1080
+ * await trtc.startLocalAudio({ publish: false });
1081
+ * // After the test is completed, turn off the microphone
1082
+ * await trtc.stopLocalAudio();
1083
+ * @memberof TRTC
1084
+ */
1085
+ startLocalAudio(config?: LocalAudioConfig): Promise<void>;
1086
+ /**
1087
+ * Update the configuration of the local microphone.
1088
+ * - When to call: This interface needs to be called after {@link TRTC#startLocalAudio startLocalAudio()} is successful and can be called multiple times.
1089
+ * - This method uses incremental update: only update the passed parameters, and keep the parameters that are not passed unchanged.
1090
+ * @param {object} [config]
1091
+ * @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}.
1092
+ * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1093
+ * @param {object} [config.option] - Local audio configuration
1094
+ * @param {string} [config.option.microphoneId] - Specify which microphone to use to switch microphones.
1095
+ * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1096
+ * @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+.
1097
+ * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1098
+ * @throws
1099
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1100
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1101
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1102
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1103
+ * @example
1104
+ * // Switch microphone
1105
+ * const microphoneList = await TRTC.getMicrophoneList();
1106
+ * if (microphoneList[1]) {
1107
+ * await trtc.updateLocalAudio({ option: { microphoneId: microphoneList[1].deviceId }});
1108
+ * }
1109
+ * @memberof TRTC
1110
+ */
1111
+ updateLocalAudio(config: UpdateLocalAudioConfig): Promise<void>;
1112
+ /**
1113
+ * Stop collecting and publishing the local microphone.
1114
+ * - If you just want to mute the microphone, please use updateLocalAudio({ mute: true }). Refer to: {@tutorial 15-basic-dynamic-add-video}.
1115
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1116
+ * @example
1117
+ * await trtc.stopLocalAudio();
1118
+ */
1119
+ stopLocalAudio(): Promise<void>;
1120
+ /**
1121
+ * @typedef {object|string} VideoProfile - Configuration for local video stream
1122
+ *
1123
+ * Video configuration parameters, can use preset values in string format or custom resolution and other parameters
1124
+ * | Video Profile | Resolution (Width x Height) | Frame Rate (fps) | Bitrate (kbps) | Remarks |
1125
+ * | :--- | :--- | :--- | :--- | :--- |
1126
+ * | 120p | 160 x 120 | 15 | 200 ||
1127
+ * | 180p | 320 x 180 | 15 | 350 ||
1128
+ * | 240p | 320 x 240 | 15 | 400 ||
1129
+ * | 360p | 640 x 360 | 15 | 800 ||
1130
+ * | 480p | 640 x 480 | 15 | 900 ||
1131
+ * | 720p | 1280 x 720 | 15 | 1500 ||
1132
+ * | 1080p | 1920 x 1080 | 15 | 2000 ||
1133
+ * | 1440p | 2560 x 1440 | 30 | 4860 ||
1134
+ * | 4K | 3840 x 2160 | 30 | 9000 ||
1135
+ * @property {number} width - Video width
1136
+ * @property {number} height - Video height
1137
+ * @property {number} frameRate - Video frame rate
1138
+ * @property {number} bitrate - Video bitrate
1139
+ * @example
1140
+ * const config = {
1141
+ * option: {
1142
+ * profile: '480p',
1143
+ * },
1144
+ * }
1145
+ * await trtc.startLocalVideo(config);
1146
+ * @example
1147
+ * const config = {
1148
+ * option: {
1149
+ * profile: {
1150
+ * width: 640,
1151
+ * height: 480,
1152
+ * frameRate: 15,
1153
+ * bitrate: 900,
1154
+ * }
1155
+ * }
1156
+ * }
1157
+ * await trtc.startLocalVideo(config);
1158
+ */
1159
+ /**
1160
+ * 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.
1161
+ * - When to call: can be called before or after entering the room, but cannot be called repeatedly.
1162
+ * - 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.
1163
+
1164
+ * @param {object} [config]
1165
+ * @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.
1166
+ * @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}.
1167
+ * @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}.
1168
+ * @param {object} [config.option] - Local video configuration
1169
+ * @param {string} [config.option.cameraId] - Specify which camera to use for switching cameras.
1170
+ * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera.
1171
+ * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1172
+ * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
1173
+ * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
1174
+ * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
1175
+ * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
1176
+ * - false: Boolean value, represents no mirroring.
1177
+ *
1178
+ * <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>
1179
+ * @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.
1180
+ * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main video.
1181
+ * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1182
+ * @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})
1183
+ * @throws
1184
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1185
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1186
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1187
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1188
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1189
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1190
+ * @example
1191
+ * // Preview and publish the camera
1192
+ * await trtc.startLocalVideo({
1193
+ * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1194
+ * });
1195
+ * @example
1196
+ * // Preview the camera without publishing. Can be used for camera testing.
1197
+ * const config = {
1198
+ * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1199
+ * publish: false // Do not publish the camera
1200
+ * }
1201
+ * await trtc.startLocalVideo(config);
1202
+ * // Call updateLocalVideo when you need to publish the video
1203
+ * await trtc.updateLocalVideo({ publish:true });
1204
+ * @example
1205
+ * // Use a specified camera.
1206
+ * const cameraList = await TRTC.getCameraList();
1207
+ * if (cameraList[0]) {
1208
+ * await trtc.startLocalVideo({
1209
+ * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1210
+ * option: {
1211
+ * cameraId: cameraList[0].deviceId,
1212
+ * }
1213
+ * });
1214
+ * }
1215
+ *
1216
+ * // use front camera on mobile device.
1217
+ * await trtc.startLocalVideo({ view, option: { useFrontCamera: true }});
1218
+ * // use rear camera on mobile device.
1219
+ * await trtc.startLocalVideo({ view, option: { useFrontCamera: false }});
1220
+ * @memberof TRTC
1221
+ */
1222
+ startLocalVideo(config?: LocalVideoConfig): Promise<void>;
1223
+ /**
1224
+ * Update the local camera configuration.
1225
+ * - This interface needs to be called after {@link TRTC#startLocalVideo startLocalVideo()} is successful.
1226
+ * - This interface can be called multiple times.
1227
+ * - This method uses incremental update: only updates the passed-in parameters, and keeps the parameters that are not passed in unchanged.
1228
+ * @param {object} [config]
1229
+ * @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.
1230
+ * @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}.
1231
+ * @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}.
1232
+ * @param {object} [config.option] - Local video configuration
1233
+ * @param {string} [config.option.cameraId] - Specify which camera to use
1234
+ * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera
1235
+ * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1236
+ * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
1237
+ * - 'view': You see yourself as a mirror image, and the other person sees you as a non-mirror image.
1238
+ * - 'publish': The other person sees you as a mirror image, and you see yourself as a non-mirror image.
1239
+ * - 'both': You see yourself as a mirror image, and the other person sees you as a mirror image.
1240
+ * - false: Boolean value, represents no mirroring.
1241
+ * @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
1242
+ * @param {string | VideoProfile} [config.option.profile] - Video encoding parameters for the main stream
1243
+ * @param {string | boolean | VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1244
+ * @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})
1245
+ * @throws
1246
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1247
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1248
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1249
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1250
+ * @example
1251
+ * // Switch camera
1252
+ * const cameraList = await TRTC.getCameraList();
1253
+ * if (cameraList[1]) {
1254
+ * await trtc.updateLocalVideo({ option: { cameraId: cameraList[1].deviceId }});
1255
+ * }
1256
+ * @example
1257
+ * // Stop publishing video, but keep local preview
1258
+ * await trtc.updateLocalVideo({ publish:false });
1259
+ * @memberof TRTC
1260
+ */
1261
+ updateLocalVideo(config: LocalVideoConfig): Promise<void>;
1262
+ /**
1263
+ * Stop capturing, previewing, and publishing the local camera.
1264
+ * - 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>
1265
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1266
+ * @example
1267
+ * await trtc.stopLocalVideo();
1268
+ */
1269
+ stopLocalVideo(): Promise<void>;
1270
+ /**
1271
+ * @typedef {object|string} ScreenShareProfile - Screen sharing resolution, bit rate, and frame rate configuration
1272
+ * Screen sharing configuration parameters, can use preset values or custom resolution and other parameters
1273
+ * | Screen Profile | Resolution (width x height) | Frame Rate (fps) | Bitrate (kbps) |
1274
+ * | :--- | :--- | :--- | :--- |
1275
+ * | 480p | 640 x 480 | 5 | 900 |
1276
+ * | 480p_2 | 640 x 480 | 30 | 1000 |
1277
+ * | 720p | 1280 x 720 | 5 | 1200 |
1278
+ * | 720p_2 | 1280 x 720 | 30 | 3000 |
1279
+ * | 1080p | 1920 x 1080 | 5 | 1600 |
1280
+ * | 1080p_2 | 1920 x 1080 | 30 | 4000 |
1281
+ * - The default resolution for screen sharing is `1080p`.
1282
+ * - If the above profiles do not meet your business needs, you can also specify custom resolution, frame rate, and bitrate.
1283
+
1284
+ * @property {number} width - Screen sharing width
1285
+ * @property {number} height - Screen sharing height
1286
+ * @property {number} frameRate - Screen sharing frame rate
1287
+ * @property {number} bitrate - Screen sharing bitrate
1288
+ * @example
1289
+ * const config = {
1290
+ * option: {
1291
+ * profile: '720p',
1292
+ * },
1293
+ * }
1294
+ * await trtc.startScreenShare(config);
1295
+ */
1296
+ /**
1297
+ * Start screen sharing.
1298
+ *
1299
+ * - 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}.
1300
+ * @param {object} [config]
1301
+ * @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.
1302
+ * @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}.
1303
+ * @param {object} [config.option] - Screen sharing configuration
1304
+ * @param {boolean} [config.option.systemAudio] - Whether to capture system audio. The default is false.
1305
+ * @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.
1306
+ * @param {ScreenShareProfile} [config.option.profile] - Screen sharing encoding configuration.
1307
+ * @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})
1308
+ * @param {HTMLElement} [config.option.captureElement] - Capture screen from the specified element of current tab. Available on Chrome 104+.
1309
+ * @param {'current-tab' | 'tab' | 'window' | 'monitor'} [config.option.preferDisplaySurface='monitor'] - The prefer display surface for screen sharing. Available on Chrome 94+.
1310
+ * - The default is monitor, which means that monitor capture will be displayed first in the Screen Sharing Capture pre-checkbox。
1311
+ * - If you fill in 'current-tab', the pre-checkbox will only show the current page.
1312
+ * @throws
1313
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1314
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1315
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1316
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1317
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1318
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1319
+ * @example
1320
+ * // Start screen sharing
1321
+ * await trtc.startScreenShare();
1322
+ * @memberof TRTC
1323
+ */
1324
+ startScreenShare(config?: ScreenShareConfig): Promise<void>;
1325
+ /**
1326
+ * Update screen sharing configuration
1327
+ * - This interface needs to be called after {@link TRTC#startScreenShare startScreenShare()} is successful.
1328
+ * - This interface can be called multiple times.
1329
+ * - This method uses incremental update: only update the passed-in parameters, and keep the parameters that are not passed-in unchanged.
1330
+ * @param {object} [config]
1331
+ * @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.
1332
+ * @param {boolean} [config.publish=true] - Whether to publish screen sharing to the room
1333
+ * @param {object} [config.option] - Screen sharing configuration
1334
+ * @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.
1335
+ * @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})
1336
+ * @throws
1337
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1338
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1339
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1340
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1341
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1342
+ * @example
1343
+ * // Stop screen sharing, but keep the local preview of screen sharing
1344
+ * await trtc.updateScreenShare({ publish:false });
1345
+ * @memberof TRTC
1346
+ */
1347
+ updateScreenShare(config: UpdateScreenShareConfig): Promise<void>;
1348
+ /**
1349
+ * Stop screen sharing.
1350
+
1351
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1352
+ * @example
1353
+ * await trtc.stopScreenShare();
1354
+ */
1355
+ stopScreenShare(): Promise<void>;
1356
+ /**
1357
+ * Play remote video
1358
+ *
1359
+ * - When to call: Call after receiving the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE TRTC.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE)} event.
1360
+ * @param {object} [config]
1361
+ * @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.
1362
+ * @param {string} config.userId - Remote user ID
1363
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1364
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1365
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1366
+ * @param {object} [config.option] - Remote video configuration
1367
+ * @param {boolean} [config.option.small] - Whether to subscribe small streams
1368
+ * @param {boolean} [config.option.mirror] - Whether to enable mirror
1369
+ * @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.
1370
+ * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1371
+ * @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}.
1372
+ * @throws
1373
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1374
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1375
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1376
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1377
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1378
+ * @example
1379
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, ({ userId, streamType }) => {
1380
+ * // You need to place the video container in the DOM in advance, and it is recommended to use `${userId}_${streamType}` as the element id.
1381
+ * trtc.startRemoteVideo({ userId, streamType, view: `${userId}_${streamType}` });
1382
+ * })
1383
+ * @memberof TRTC
1384
+ */
1385
+ startRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1386
+ /**
1387
+ * Update remote video playback configuration<br>
1388
+ * - This method should be called after {@link TRTC#startRemoteVideo startRemoteVideo} is successful.
1389
+ * - This method can be called multiple times.
1390
+ * - This method uses incremental updates, so only the configuration items that need to be updated need to be passed in.
1391
+ * @param {object} [config]
1392
+ * @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.
1393
+ * @param {string} config.userId - Remote user ID
1394
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1395
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1396
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1397
+ * @param {object} [config.option] - Remote video configuration
1398
+ * @param {boolean} [config.option.small] - Whether to subscribe small streams. Refer to: {@tutorial 27-advanced-small-stream}.
1399
+ * @param {boolean} [config.option.mirror] - Whether to enable mirror
1400
+ * @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.
1401
+ * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1402
+ * @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}.
1403
+ * @throws
1404
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1405
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1406
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1407
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1408
+ * @example
1409
+ * const config = {
1410
+ * view: document.getElementById(userId),
1411
+ * userId,
1412
+ * }
1413
+ * await trtc.updateRemoteVideo(config);
1414
+ * @memberof TRTC
1415
+ */
1416
+ updateRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1417
+ /**
1418
+ * Used to stop remote video playback.<br>
1419
+ * @param {object} config - Remote video configuration
1420
+ * @param {string} config.userId - Remote user ID, '*' represents all users.
1421
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} [config.streamType] - Remote stream type. This field is required when userId is not '*'.
1422
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1423
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1424
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1425
+ * @example
1426
+ * // Stop playing all remote users
1427
+ * await trtc.stopRemoteVideo({ userId: '*' });
1428
+ */
1429
+ stopRemoteVideo(config: StopRemoteVideoConfig): Promise<void>;
1430
+ /**
1431
+ * 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>
1432
+ *
1433
+ * Note:
1434
+ * - By default, after entering the room, the SDK will automatically play remote audio. You can call this interface to mute or unmute remote users.
1435
+ * - 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.
1436
+ * - 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).
1437
+ * - If you want to continue subscribing audio data from the user but not play it, you can call setRemoteAudioVolume(userId, 0)
1438
+ * @param {string} userId - Remote user ID, '*' represents all users.
1439
+ * @param {boolean} mute - Whether to mute
1440
+ * @throws
1441
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1442
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1443
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1444
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1445
+ * @example
1446
+ * // Mute all remote users
1447
+ * await trtc.muteRemoteAudio('*', true);
1448
+ */
1449
+ muteRemoteAudio(userId: string, mute: boolean): Promise<void>;
1450
+ /**
1451
+ * Used to control the playback volume of remote audio.<br>
1452
+ *
1453
+ * - Not supported by iOS Safari
1454
+ * @param {string} userId - Remote user ID。'*' represents all remote users.
1455
+ * @param {number} volume - Volume, ranging from 0 to 100. The default value is 100.<br>
1456
+ * Since `v5.1.3+`, the volume can be set higher than 100.
1457
+ * @example
1458
+ * await trtc.setRemoteAudioVolume('123', 90);
1459
+ */
1460
+ setRemoteAudioVolume(userId: string, volume: number): void;
1461
+ startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1462
+ startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1463
+ updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1464
+ updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1465
+ stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1466
+ stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1467
+ /**
1468
+ * Enables or disables the volume callback.<br>
1469
+ *
1470
+ * - 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>
1471
+ *
1472
+ * @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.
1473
+ * @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.
1474
+ * @memberof TRTC
1475
+ * @example
1476
+ * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
1477
+ * event.result.forEach(({ userId, volume }) => {
1478
+ * const isMe = userId === ''; // When userId is an empty string, it represents the local microphone volume.
1479
+ * if (isMe) {
1480
+ * console.log(`my volume: ${volume}`);
1481
+ * } else {
1482
+ * console.log(`user: ${userId} volume: ${volume}`);
1483
+ * }
1484
+ * })
1485
+ * });
1486
+ *
1487
+ * // Enable volume callback and trigger the event every 1000ms
1488
+ * trtc.enableAudioVolumeEvaluation(1000);
1489
+ *
1490
+ * // To turn off the volume callback, pass in an interval value less than or equal to 0
1491
+ * trtc.enableAudioVolumeEvaluation(-1);
1492
+ */
1493
+ enableAudioVolumeEvaluation(interval?: number, enableInBackground?: boolean): void;
1494
+ /**
1495
+ * Listen to TRTC events<br><br>
1496
+ * For a detailed list of events, please refer to: {@link module:EVENT TRTC.EVENT}
1497
+ *
1498
+ * @param {string} eventName Event name
1499
+ * @param {function} handler Event callback function
1500
+ * @param {context} context Context
1501
+ * @memberof TRTC
1502
+ * @example
1503
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
1504
+ * // REMOTE_VIDEO_AVAILABLE event handler
1505
+ * });
1506
+ */
1507
+ on<T extends keyof TRTCEventTypes>(event: T, handler: (...args: TRTCEventTypes[T]) => void, context?: any): this;
1508
+ /**
1509
+ * Remove event listener<br>
1510
+ *
1511
+ * @param {string} eventName Event name. Passing in the wildcard '*' will remove all event listeners.
1512
+ * @param {function} handler Event callback function
1513
+ * @param {context} context Context
1514
+ * @memberof TRTC
1515
+ * @example
1516
+ * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, function peerJoinHandler(event) {
1517
+ * // REMOTE_USER_ENTER event handler
1518
+ * console.log('remote user enter');
1519
+ *
1520
+ * trtc.off(TRTC.EVENT.REMOTE_USER_ENTER, peerJoinHandler);
1521
+ * });
1522
+ *
1523
+ * // Remove all event listeners
1524
+ * trtc.off('*');
1525
+ */
1526
+ off<T extends keyof TRTCEventTypes>(event: T | '*', handler: T extends '*' ? never : (...args: TRTCEventTypes[T]) => void, context?: any): this;
1527
+ /**
1528
+ * Get audio track
1529
+ *
1530
+ * @returns {MediaStreamTrack?} Audio track
1531
+ * @param {Object|string} [config] If not passed, get the local microphone audioTrack
1532
+ * @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.
1533
+ * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1534
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's microphone)(default)
1535
+ * - {@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.
1536
+ * @memberof TRTC
1537
+ * @example
1538
+ * // Version before v5.4.3
1539
+ * trtc.getAudioTrack(); // Get local microphone audioTrack, captured by trtc.startLocalAudio()
1540
+ * trtc.getAudioTrack('remoteUserId'); // Get remote audioTrack
1541
+ *
1542
+ * // Since v5.4.3+, you can get local screen audioTrack by passing the streamType = TRTC.STREAM_TYPE_SUB
1543
+ * trtc.getAudioTrack({ streamType: TRTC.STREAM_TYPE_SUB });
1544
+ */
1545
+ getAudioTrack(configOrUserId?: {
1546
+ userId?: string;
1547
+ streamType?: TRTCStreamType;
1548
+ } | string): MediaStreamTrack | null;
1549
+ /**
1550
+ * Get video track
1551
+ *
1552
+ * @param {string} [config] If not passed, get the local camera videoTrack
1553
+ * @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.
1554
+ * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1555
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's camera)(default)
1556
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing)
1557
+ * @returns {MediaStreamTrack|null} Video track
1558
+ * @memberof TRTC
1559
+ * @example
1560
+ * // Get local camera videoTrack
1561
+ * const videoTrack = trtc.getVideoTrack();
1562
+ * // Get local screen sharing videoTrack
1563
+ * const screenVideoTrack = trtc.getVideoTrack({ streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1564
+ * // Get remote user's main stream videoTrack
1565
+ * const remoteMainVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_MAIN });
1566
+ * // Get remote user's sub stream videoTrack
1567
+ * const remoteSubVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1568
+ */
1569
+ getVideoTrack(config?: {
1570
+ userId?: string;
1571
+ streamType?: TRTCStreamType;
1572
+ }): MediaStreamTrack | null;
1573
+ /**
1574
+ * Get video snapshot <br>
1575
+ * Notice: must play the video before it can obtain the snapshot. If there is no playback, an empty string will be returned.
1576
+ * @param {string} config.userId - Remote user ID
1577
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType
1578
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream
1579
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream
1580
+ * @since 5.4.0
1581
+ * @example
1582
+ * // get self main stream video frame
1583
+ * trtc.getVideoSnapshot()
1584
+ * // get self sub stream video frame
1585
+ * trtc.getVideoSnapshot({streamType:TRTC.TYPE.STREAM_TYPE_SUB})
1586
+ * // get remote user main stream video frame
1587
+ * trtc.getVideoSnapshot({userId: 'remote userId', streamType:TRTC.TYPE.STREAM_TYPE_MAIN})
1588
+ * @memberof TRTC
1589
+ */
1590
+ getVideoSnapshot(config?: VideoFrameConfig): string;
1591
+ setCurrentSpeaker(speakerId: string): void;
1592
+ /**
1593
+ * Send SEI Message <br>
1594
+ *
1595
+ * > The header of a video frame has a header block called SEI.
1596
+ * > The principle of this interface is to use the SEI to embed the custom data you want to send along with the video frame.
1597
+ * > SEI messages can accompany video frames all the way to the live CDN.
1598
+ *
1599
+ * Applicable scenarios: synchronization of lyrics, live answering questions, etc.
1600
+ *
1601
+ * When to call: call after {@link TRTC#startLocalVideo trtc.startLocalVideo} or {@link TRTC#startLocalScreen trtc.startLocalScreen} when set 'toSubStream' option to true successfully.
1602
+ *
1603
+ * Note:
1604
+ * 1. Maximum 1KB(Byte) sent in a single call, maximum 30 calls per second, maximum 8KB sent per second.
1605
+ * 2. Currently only support Chrome 86+, Edge 86+, Opera 72+ browsers.
1606
+ * 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.
1607
+ * 4. SEI cannot be sent without trtc.startLocalVideo(or trtc.startLocalScreen when set 'toSubStream' option to true); SEI cannot be received without startRemoteVideo.
1608
+ * 5. Only H264 encoder is supported to send SEI.
1609
+ * 6. SEI sending and receiving is not supported for small streams for the time being.
1610
+ * @see {@link module:EVENT.SEI_MESSAGE TRTC.EVENT.SEI_MESSAGE}
1611
+ * @since v5.3.0
1612
+ * @param {ArrayBuffer} buffer SEI data to be sent
1613
+ * @param {Object=} options
1614
+ * @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.
1615
+ * @param {Boolean} [options.toSubStream=false] Send SEI data to substream. Need call trtc.startLocalScreen first. Since v5.7.0+.
1616
+ * @example
1617
+ * // 1. enable SEI
1618
+ * const trtc = TRTC.create({
1619
+ * enableSEI: true
1620
+ * })
1621
+ *
1622
+ * // 2. send SEI
1623
+ * try {
1624
+ * await trtc.enterRoom({
1625
+ * userId: 'user_1',
1626
+ * roomId: 12345,
1627
+ * })
1628
+ * await trtc.startLocalVideo();
1629
+ * const unit8Array = new Uint8Array([1, 2, 3]);
1630
+ * trtc.sendSEIMessage(unit8Array.buffer);
1631
+ * } catch(error) {
1632
+ * console.warn(error);
1633
+ * }
1634
+ *
1635
+ * // 3. receive SEI
1636
+ * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
1637
+ * console.warn(`sei ${event.data} from ${event.userId}`);
1638
+ * })
1639
+ */
1640
+ sendSEIMessage(buffer: ArrayBuffer, options?: {
1641
+ seiPayloadType?: number;
1642
+ toSubStream?: boolean;
1643
+ }): void;
1644
+ /**
1645
+ * Send Custom Message to all remote users in the room. <br>
1646
+ *
1647
+ * Note:
1648
+ *
1649
+ * 1. Only {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} can call sendCustomMessage.
1650
+ * 2. You should call this api after {@link TRTC#enterRoom TRTC.enterRoom} successfully.
1651
+ * 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.
1652
+ * @since v5.6.0
1653
+ * @see Listen for the event {@link module:EVENT.CUSTOM_MESSAGE TRTC.EVENT.CUSTOM_MESSAGE} to receive custom message.
1654
+ * @param {object} message
1655
+ * @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.
1656
+ * @param {ArrayBuffer} message.data - message content. <br/>
1657
+ * - Maximum 1KB(Byte) sent in a single call.
1658
+ * - Maximum 30 calls per second
1659
+ * - Maximum 8KB sent per second.
1660
+ * @example
1661
+ * // send custom message
1662
+ * trtc.sendCustomMessage({
1663
+ * cmdId: 1,
1664
+ * data: new TextEncoder().encode('hello').buffer
1665
+ * });
1666
+ *
1667
+ * // receive custom message
1668
+ * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
1669
+ * // event.userId: remote userId.
1670
+ * // event.cmdId: message cmdId.
1671
+ * // event.seq: message sequence number.
1672
+ * // event.data: custom message data, type is ArrayBuffer.
1673
+ * console.log(`received custom msg from ${event.userId}, message: ${new TextDecoder().decode(event.data)}`)
1674
+ * })
1675
+ */
1676
+ sendCustomMessage(message: CustomMessageData): void;
1677
+ static EVENT: {
1678
+ readonly ERROR: "error";
1679
+ readonly AUTOPLAY_FAILED: "autoplay-failed";
1680
+ readonly KICKED_OUT: "kicked-out";
1681
+ readonly REMOTE_USER_ENTER: "remote-user-enter";
1682
+ readonly REMOTE_USER_EXIT: "remote-user-exit";
1683
+ readonly REMOTE_AUDIO_AVAILABLE: "remote-audio-available";
1684
+ readonly REMOTE_AUDIO_UNAVAILABLE: "remote-audio-unavailable";
1685
+ readonly REMOTE_VIDEO_AVAILABLE: "remote-video-available";
1686
+ readonly REMOTE_VIDEO_UNAVAILABLE: "remote-video-unavailable";
1687
+ readonly AUDIO_VOLUME: "audio-volume";
1688
+ readonly NETWORK_QUALITY: "network-quality";
1689
+ readonly CONNECTION_STATE_CHANGED: "connection-state-changed";
1690
+ readonly AUDIO_PLAY_STATE_CHANGED: "audio-play-state-changed";
1691
+ readonly VIDEO_PLAY_STATE_CHANGED: "video-play-state-changed";
1692
+ readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
1693
+ readonly DEVICE_CHANGED: "device-changed";
1694
+ readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
1695
+ readonly TRACK: "track";
1696
+ readonly STATISTICS: "statistics";
1697
+ readonly SEI_MESSAGE: "sei-message";
1698
+ readonly CUSTOM_MESSAGE: "custom-message";
1699
+ };
1700
+ static ERROR_CODE: {
1701
+ INVALID_PARAMETER: number;
1702
+ INVALID_OPERATION: number;
1703
+ ENV_NOT_SUPPORTED: number;
1704
+ DEVICE_ERROR: number;
1705
+ SERVER_ERROR: number;
1706
+ OPERATION_FAILED: number;
1707
+ OPERATION_ABORT: number;
1708
+ UNKNOWN_ERROR: number;
1709
+ };
1710
+ static TYPE: {
1711
+ readonly SCENE_LIVE: Scene.LIVE;
1712
+ readonly SCENE_RTC: Scene.RTC;
1713
+ readonly ROLE_ANCHOR: UserRole.ANCHOR;
1714
+ readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
1715
+ readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
1716
+ readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
1717
+ readonly AUDIO_PROFILE_STANDARD: "standard";
1718
+ readonly AUDIO_PROFILE_STANDARD_STEREO: "standard-stereo";
1719
+ readonly AUDIO_PROFILE_HIGH: "high";
1720
+ readonly AUDIO_PROFILE_HIGH_STEREO: "high-stereo";
1721
+ readonly QOS_PREFERENCE_SMOOTH: "smooth";
1722
+ readonly QOS_PREFERENCE_CLEAR: "clear";
1723
+ };
1724
+ static frameWorkType: number;
1725
+ /**
1726
+ * Set the log output level
1727
+ * <br>
1728
+ * It is recommended to set the DEBUG level during development and testing, which includes detailed prompt information.
1729
+ * The default output level is INFO, which includes the log information of the main functions of the SDK.
1730
+ *
1731
+ * @param {0-5} [level] Log output level 0: TRACE 1: DEBUG 2: INFO 3: WARN 4: ERROR 5: NONE
1732
+ * @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.
1733
+ * @example
1734
+ * // Output log levels above DEBUG
1735
+ * TRTC.setLogLevel(1);
1736
+ */
1737
+ static setLogLevel(level: LOG_LEVEL, enableUploadLog?: boolean): void;
1738
+ /**
1739
+ * Check if the TRTC Web SDK is supported by the current browser
1740
+ *
1741
+ * - Reference: {@tutorial 05-info-browser}.
1742
+ * @example
1743
+ * TRTC.isSupported().then((checkResult) => {
1744
+ * if(!checkResult.result) {
1745
+ * console.log('checkResult', checkResult.result, 'checkDetail', checkResult.detail);
1746
+ * // The SDK is not supported by the current browser, guide the user to use the latest version of Chrome browser.
1747
+ * }
1748
+ * });
1749
+ *
1750
+ * @returns {Promise.<object>} Promise returns the detection result
1751
+ * | Property | Type | Description |
1752
+ * |--------------------------------------------|---------|-------------------------------------|
1753
+ * | checkResult.result | boolean | Detection result |
1754
+ * | checkResult.detail.isBrowserSupported | boolean | Whether the current browser is supported by the SDK |
1755
+ * | checkResult.detail.isWebRTCSupported | boolean | Whether the current browser supports WebRTC |
1756
+ * | checkResult.detail.isWebCodecsSupported | boolean | Whether the current browser supports WebCodecs |
1757
+ * | checkResult.detail.isMediaDevicesSupported | boolean | Whether the current browser supports obtaining media devices and media streams |
1758
+ * | checkResult.detail.isScreenShareSupported | boolean | Whether the current browser supports screen sharing |
1759
+ * | checkResult.detail.isSmallStreamSupported | boolean | Whether the current browser supports small streams |
1760
+ * | checkResult.detail.isH264EncodeSupported | boolean | Whether the current browser supports H264 encoding for uplink |
1761
+ * | checkResult.detail.isH264DecodeSupported | boolean | Whether the current browser supports H264 decoding for downlink |
1762
+ * | checkResult.detail.isVp8EncodeSupported | boolean | Whether the current browser supports VP8 encoding for uplink |
1763
+ * | checkResult.detail.isVp8DecodeSupported | boolean | Whether the current browser supports VP8 decoding for downlink |
1764
+ */
1765
+ static isSupported(): Promise<any>;
1766
+ /**
1767
+ * Returns the list of camera devices
1768
+ * <br>
1769
+ * **Note**
1770
+ * - 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}
1771
+ * - 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+.
1772
+ * @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.
1773
+ * @example
1774
+ * const cameraList = await TRTC.getCameraList();
1775
+ * if (cameraList[0] && cameraList[0].getCapabilities) {
1776
+ * const { width, height, frameRate, facingMode } = cameraList[0].getCapabilities();
1777
+ * console.log(width.max, height.max, frameRate.max);
1778
+ * if (facingMode) {
1779
+ * if (facingMode[0] === 'user') {
1780
+ * // front camera
1781
+ * } else if (facingMode[0] === 'environment') {
1782
+ * // rear camera
1783
+ * }
1784
+ * }
1785
+ * }
1786
+ * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1787
+ */
1788
+ static getCameraList(requestPermission?: boolean): Promise<DeviceInfo[]>;
1789
+ /**
1790
+ * Returns the list of microphone 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 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+.
1795
+ * @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.
1796
+ * @example
1797
+ * const microphoneList = await TRTC.getMicrophoneList();
1798
+ * if (microphoneList[0] && microphoneList[0].getCapabilities) {
1799
+ * const { channelCount } = microphoneList[0].getCapabilities();
1800
+ * console.log(channelCount.max);
1801
+ * }
1802
+ * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1803
+ */
1804
+ static getMicrophoneList(requestPermission?: boolean): Promise<DeviceInfo[]>;
1805
+ /**
1806
+ * Returns the list of speaker devices. Only support PC browser, not support mobile browser.
1807
+ * <br>
1808
+ * @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.
1809
+ * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1810
+ */
1811
+ static getSpeakerList(requestPermission?: boolean): Promise<DeviceInfo[]>;
1812
+ /**
1813
+ * Set the current speaker for audio playback
1814
+ *
1815
+ * @param {string} speakerId Speaker ID
1816
+ */
1817
+ static setCurrentSpeaker(speakerId: string): Promise<void>;
1818
+ }
1822
1819
  export default TRTC