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

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