trtc-sdk-v5 5.5.2 → 5.5.3-beta.1

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