trtc-sdk-v5 5.4.1-beta.7 → 5.4.1

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