trtc-sdk-v5 5.5.2-beta.2 → 5.5.2-beta.4

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