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