trtc-sdk-v5 5.5.2-beta.8 → 5.5.2-ktv

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