@tencentcloud/tuiroom-engine-electron 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts ADDED
@@ -0,0 +1,1092 @@
1
+ import TIM from "tim-js-sdk";
2
+ import TRTCCloud, { TRTCDeviceInfo, TRTCScreenCaptureSourceInfo } from 'trtc-electron-sdk';
3
+ import { TUIRoomInfo, TUIVideoStreamType, TUIVideoProfile, TUIAudioProfile, TUIRole, TUIRoomEvents, TUIRoomType, TUISeatInfo, TUIRequestCallback } from './types';
4
+ export * from './types';
5
+ export { TRTCDeviceType, TRTCDeviceState, TRTCDeviceInfo, TRTCVideoMirrorType, TRTCVideoRotation, TRTCVideoFillMode, TRTCVideoStreamType, TRTCScreenCaptureSourceType, TRTCScreenCaptureSourceInfo, Rect, TRTCVideoEncParam, TRTCVideoResolution, TRTCVideoResolutionMode, TRTCScreenCaptureProperty } from 'trtc-electron-sdk';
6
+ /**
7
+ * TUIRoomEngine 提供了音视频房间的能力
8
+ *
9
+ * @class TUIRoomEngine
10
+ */
11
+ declare class TUIRoomEngine {
12
+ static className: string;
13
+ private static isReady;
14
+ private roomEngineWASM;
15
+ private static userId;
16
+ private static sdkAppId;
17
+ private static Module;
18
+ private logger;
19
+ private roomId;
20
+ static setModule(Module: any): void;
21
+ static once(event: string, func: Function): void;
22
+ constructor();
23
+ /**
24
+ * @private
25
+ * 调用 TUIRoomEngineWASM 的静态方法
26
+ */
27
+ private static JSCallNativeFunctionPromise;
28
+ /**
29
+ * @private
30
+ * 调用 TUIRoomEngineWASM 的异步方法
31
+ * @param funcName
32
+ * @param args
33
+ */
34
+ private JSCallNativeFunctionPromise;
35
+ /**
36
+ * 初始化 TUIRoomEngine
37
+ *
38
+ * @param {object} options
39
+ * @param {number} options.sdkAppId sdkAppId <br>
40
+ * 在 [实时音视频控制台](https://console.cloud.tencent.com/trtc) 单击 **应用管理** > **创建应用** 创建新应用之后,即可在 **应用信息** 中获取 sdkAppId 信息。
41
+ * @param {string} options.userId 用户ID <br>
42
+ * 建议限制长度为32字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。
43
+ * @param {string} options.userSig userSig 签名 <br>
44
+ * 计算 userSig 的方式请参考 [UserSig 相关](https://cloud.tencent.com/document/product/647/17275)。
45
+ * @returns {Promise<void>}
46
+ *
47
+ * @example
48
+ * // 初始化 TUIRoomEngine
49
+ * await TUIRoomEngine.init({
50
+ * sdkAppId: 0, // 填写您申请的 sdkAppId
51
+ * userId: '', // 填写您业务对应的 userId
52
+ * userSig: '', // 填写服务器或本地计算的 userSig
53
+ * })
54
+ */
55
+ static init(options: {
56
+ sdkAppId: number;
57
+ userId: string;
58
+ userSig: string;
59
+ tim?: TIM;
60
+ }): Promise<void>;
61
+ /**
62
+ * 设置当前用户基本信息(用户名、用户头像)
63
+ *
64
+ * @param {object} options
65
+ * @param {string} options.userName 用户名,必填
66
+ * @param {string} options.avatarUrl 用户头像,必填
67
+ * @returns {Promise<void>}
68
+ *
69
+ * @example
70
+ * // 设置当前用户用户名及用户头像
71
+ * await TUIRoomEngine.setSelfInfo({
72
+ * userName: '', // 填写您的新用户名
73
+ * avatarUrl: '', // 填写您的新头像地址
74
+ * })
75
+ */
76
+ static setSelfInfo(options: {
77
+ userName: string;
78
+ avatarUrl: string;
79
+ }): Promise<void>;
80
+ /**
81
+ * 主持人创建房间,调用 createRoom 的用户为房间的所有者。创建房间时可设置房间 Id, 房间名称,以及房间是否允许加入用户开启音视频,发送消息等功能。
82
+ *
83
+ * @param {object} options
84
+ * @param {string} options.roomId 房间 Id,必填, roomId 限制长度为64字节,且仅支持以下范围的字符集:<br>
85
+ * - 大小写英文字母(a-zA-Z)
86
+ * - 数字(0-9)
87
+ * - 空格 ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | ~ ,
88
+ * @param {string} [options.name] 房间名称,必填,且不能为空字符串
89
+ * @param {TUIRoomType} [options.roomType] 房间类型, 必填 <br>
90
+ * 教育及会议场景设置房间类型为 TUIRoomType.kGroup,直播场景设置房间类型为 TUIRoomType.kOpen;
91
+ * @param {number=} options.maxSeatCount 最大麦位数量 <br>
92
+ * roomType 为 TUIRoomType.kGroup (教育及会议场景) 时,maxSeatCount 值不做限制;
93
+ * roomType 为 TUIRoomType.kOpen (直播场景) 时,maxSeatCount 最大限制为 16;
94
+ * @param {boolean=} [options.enableAudio=true] 是否允许加入用户打开音频
95
+ * @param {boolean=} [options.enableVideo=true] 是否允许加入用户打开视频
96
+ * @param {boolean=} [options.enableMessage=true] 是否允许加入用户发送消息
97
+ * @param {boolean=} [options.enableSeatControl=false] 是否开启麦位控制
98
+ * @returns {Promise<void>}
99
+ *
100
+ * @example
101
+ * const roomEngine = new TUIRoomEngine();
102
+ * await roomEngine.createRoom({
103
+ * roomId: '12345', // 填入您的房间 Id, 注意房间 Id 要求为字符串类型
104
+ * name: 'Test Room', // 填入您的房间名称, 房间名称默认为 roomId,最长 30 字节
105
+ * roomType: TUIRoomType.kGroup, // 设置房间类型为 TUIRoomType.kGroup 类型
106
+ * enableAudio: true, // 设置是否允许加入用户打开音频
107
+ * enableVideo: true, // 设置是否允许加入用户打开视频
108
+ * enableMessage: true, // 设置是否允许加入用户发送消息
109
+ * });
110
+ */
111
+ createRoom(options: {
112
+ roomId: string;
113
+ name: string;
114
+ roomType: TUIRoomType;
115
+ maxSeatCount?: number;
116
+ enableAudio?: boolean;
117
+ enableVideo?: boolean;
118
+ enableMessage?: boolean;
119
+ enableSeatControl?: boolean;
120
+ }): Promise<void>;
121
+ /**
122
+ * 进入房间接口
123
+ * @param {object} options
124
+ * @param {string} options.roomId 房间号,字符串类型
125
+ * @returns {Promise<TUIRoomInfo>} roomInfo
126
+ * 该接口返回当前房间信息
127
+ *
128
+ * @example
129
+ * const roomEngine = new TUIRoomEngine();
130
+ * const roomInfo = await roomEngine.enterRoom({
131
+ * roomId: '12345',
132
+ * });
133
+ */
134
+ enterRoom(options: {
135
+ roomId: string;
136
+ }): Promise<TUIRoomInfo>;
137
+ /**
138
+ * 销毁房间接口,销毁房间必须由房间所有者发起,销毁房间之后房间不可进入
139
+ * @returns {Promise<void>}
140
+ *
141
+ * @example
142
+ * const roomEngine = new TUIRoomEngine();
143
+ * await roomEngine.destroyRoom();
144
+ */
145
+ destroyRoom(): Promise<void>;
146
+ /**
147
+ * 离开房间接口,用户在执行 enterRoom 之后可通过 exitRoom 离开房间
148
+ * @returns {Promise<void>}
149
+ *
150
+ * @example
151
+ * const roomEngine = new TUIRoomEngine();
152
+ * await roomEngine.exitRoom();
153
+ */
154
+ exitRoom(): Promise<void>;
155
+ /**
156
+ * 获取房间信息
157
+ * @returns {Promise<TUIRoomInfo>} roomInfo
158
+ * 该接口返回房间信息
159
+ *
160
+ * @example
161
+ * const roomEngine = new TUIRoomEngine();
162
+ * const roomInfo = roomEngine.getRoomInfo();
163
+ */
164
+ getRoomInfo(): Promise<TUIRoomInfo>;
165
+ /**
166
+ * 更新房间信息, 只有房间所有者有权限更新房间信息
167
+ */
168
+ /**
169
+ * 主持人更新房间信息,注意仅房间所有者有权限更新房间信息
170
+ * @param {object} roomInfo 主持人更新房间的信息
171
+ * @param {string} roomInfo.name 更新房间的名字
172
+ * @param {true} roomInfo.enableVideo 更新房间是否允许其他用户开启摄像头
173
+ * @param {true} roomInfo.enableAudio 更新房间是否允许其他用户开启麦克风
174
+ * @param {true} roomInfo.enableMessage 更新房间是否允许其他用户发送消息
175
+ * @param {true} roomInfo.enableSeatControl 更新房间是否进行麦位控制<br/>
176
+ * 注意:enableSeatControl 设置为 true 时为举手发言模式,enableSeatControl 设置为 false 时为自由发言模式。
177
+ * @param {true} roomInfo.maxSeatCount 更新房间麦位最大值<br/>
178
+ * - roomType 为 TUIRoomType.kGroup (教育及会议场景) 时,maxSeatCount 值不做限制;
179
+ * - roomType 为 TUIRoomType.kOpen (直播场景) 时,maxSeatCount 最大限制为 16;
180
+ * @returns {Promise<void>}
181
+ *
182
+ * @example
183
+ * const roomEngine = new TUIRoomEngine();
184
+ * await roomEngine.createRoom({ roomId: '12345' });
185
+ * await roomEngine.updateRoomInfo({ name: '新的名字', enableVideo: true });
186
+ */
187
+ updateRoomInfo(options: {
188
+ name?: string;
189
+ enableVideo?: boolean;
190
+ enableAudio?: boolean;
191
+ enableMessage?: boolean;
192
+ enableSeatControl?: boolean;
193
+ maxSeatCount?: number;
194
+ }): Promise<void>;
195
+ /**
196
+ * 获取当前房间用户列表,注意该接口一次拉取的用户列表量最大为 100 个
197
+ *
198
+ * @param {object=} options 获取用户列表的参数
199
+ * @param {number=} options.nextSequence 偏移量,默认从 0 开始拉取用户<br/>
200
+ * @return {Promise<object>} result
201
+ * result.nextSequence 下一次拉取群组用户的偏移量,如果 nextSequence 为 0 则代表 userList 全部拉下来了
202
+ * result.userInfoList 本次拉取的 userList
203
+ *
204
+ * @example
205
+ * const roomEngine = new TUIRoomEngine();
206
+ * let result;
207
+ * const userList = [];
208
+ * do {
209
+ * result = await roomEngine.getUserList();
210
+ * userList
211
+ * } while (result.nextSequence !== 0)
212
+ */
213
+ getUserList(options?: {
214
+ nextSequence?: Number;
215
+ }): Promise<object>;
216
+ /**
217
+ * 获取用户的详细信息
218
+ *
219
+ * @param {object} options 获取用户信息的参数
220
+ * @param {string} options.userId 根据 userId 获取该用户的详细信息
221
+ * @returns Promise<TUIUserInfo> userInfo
222
+ * 该接口返回指定用户的用户信息
223
+ *
224
+ * @example
225
+ * const roomEngine = new TUIRoomEngine();
226
+ * const userInfo = await roomEngine.getUserInfo({
227
+ * userId: 'user_12345',
228
+ * });
229
+ */
230
+ getUserInfo(options: {
231
+ userId: string;
232
+ }): Promise<any>;
233
+ private JSCallNativeRequestFunctionPromise;
234
+ /**
235
+ * 麦下用户可调用 takeSeat 成为麦上用户,仅麦上用户可发布本地音视频流。<br/>
236
+ * 当 roomInfo.enableSeatControl 为 true 时,普通用户调用 takeSeat 方法需要等待主持人/管理员的同意后成为麦上用户。<br/>
237
+ * 当 roomInfo.enableSeatControl 为 false 时,普通用户调用 takeSeat 方法成功后即为麦上用户。<br/>
238
+ * 主持人&管理员调用 takeSeat 成功后即为麦上用户。<br/>
239
+ * 麦上用户的变更通过 TUIRoomEvents.onSeatListChanged 通知所有用户。<br/>
240
+ * @param {object} options 获取麦位的参数
241
+ * @param {number} options.seatIndex 麦位 index, 无麦位序号时设置为 -1
242
+ * @param {number} options.timeout 超时时间。若 timeout 设置为 0,则无超时时间
243
+ * @param {Function} options.requestCallback 请求回调,用来通知发起方请求被接受/拒绝/取消/超时/错误的回调
244
+ * @returns {Promise<number>} <br/>
245
+ * 当 roomIno.enableSeatControl 为 true,普通用户调用该接口时返回 requestId,普通用户可使用该 requestId 调用 cancelRequest 接口取消上麦请求。
246
+ *
247
+ * @example
248
+ * const roomEngine = new TUIRoomEngine();
249
+ *
250
+ * // 情景一:主持人/管理员上麦
251
+ * // 情景二:当 roomInfo.enableSeatControl 为 false 时,普通用户上麦
252
+ * await roomEngine.takeSeat({
253
+ * seatIndex: -1,
254
+ * timeout: 0,
255
+ * });
256
+ *
257
+ * // 情景三:当 roomInfo.enableSeatControl 为 true 时,普通用户上麦
258
+ * const requestId = await roomEngine.instance?.takeSeat({
259
+ * seatIndex: -1,
260
+ * timeout: 0,
261
+ * requestCallback: ({ requestCallbackType, requestId, userId, code, message }) => {
262
+ * switch (requestCallbackType) {
263
+ * case TUIRequestCallbackType.kRequestAccepted:
264
+ * // 请求被接受
265
+ * break;
266
+ * case TUIRequestCallbackType.kRequestRejected:
267
+ * // 请求被拒绝
268
+ * break;
269
+ * case TUIRequestCallbackType.kRequestCancelled:
270
+ * // 请求已取消
271
+ * break;
272
+ * case TUIRequestCallbackType.kRequestTimeout:
273
+ * // 请求超时
274
+ * break;
275
+ * case TUIRequestCallbackType.kRequestError:
276
+ * // 请求错误
277
+ * break;
278
+ * default:
279
+ * break;
280
+ * }
281
+ * },
282
+ * });
283
+ */
284
+ takeSeat(options: {
285
+ seatIndex: number;
286
+ timeout: number;
287
+ requestCallback?: (callbackInfo: TUIRequestCallback) => void;
288
+ }): Promise<number>;
289
+ /**
290
+ * 离开麦位
291
+ * @returns {Promise<void>}
292
+ *
293
+ * @example
294
+ * const roomEngine = new TUIRoomEngine();
295
+ * await roomEngine.leaveSeat();
296
+ */
297
+ leaveSeat(): Promise<void>;
298
+ /**
299
+ * 获取麦位列表
300
+ * @returns {Promise<TUISeatInfo[]>}
301
+ *
302
+ * @example
303
+ * const roomEngine = new TUIRoomEngine();
304
+ * const seatList = await roomEngine.getSeatList();
305
+ * ;
306
+ */
307
+ getSeatList(): Promise<TUISeatInfo[]>;
308
+ /**
309
+ * 请求远端用户打开摄像头
310
+ * @param {object} options 请求远端用户打开摄像头的参数
311
+ * @param {string} options.userId 用户 Id
312
+ * @param {number} options.timeout 超时时间。若 timeout 设置为 0 ,则无超时时间
313
+ * @param {Function} 请求回调,用来通知发起方请求被接受/拒绝/取消/超时/错误的回调
314
+ * @return {Promise<number>} <br/>
315
+ * 该接口返回 requestId,用户可使用该 requestId 调用 cancelRequest 接口取消请求
316
+ *
317
+ * @example
318
+ * const roomEngine = new TUIRoomEngine();
319
+ * const requestId = roomEngine.requestToOpenRemoteCamera({
320
+ * userId: 'user_1234',
321
+ * timeout: 0,
322
+ * requestCallback: ({ requestCallbackType, requestId, userId, code, message }) => {
323
+ * switch (requestCallbackType) {
324
+ * case TUIRequestCallbackType.kRequestAccepted:
325
+ * // 请求被接受
326
+ * break;
327
+ * case TUIRequestCallbackType.kRequestRejected:
328
+ * // 请求被拒绝
329
+ * break;
330
+ * case TUIRequestCallbackType.kRequestCancelled:
331
+ * // 请求已取消
332
+ * break;
333
+ * case TUIRequestCallbackType.kRequestTimeout:
334
+ * // 请求超时
335
+ * break;
336
+ * case TUIRequestCallbackType.kRequestError:
337
+ * // 请求错误
338
+ * break;
339
+ * default:
340
+ * break;
341
+ * }
342
+ * },
343
+ * });
344
+ */
345
+ requestToOpenRemoteCamera(options: {
346
+ userId: string;
347
+ timeout: number;
348
+ requestCallback?: (callbackInfo: TUIRequestCallback) => void;
349
+ }): Promise<number>;
350
+ /**
351
+ * 关闭远端用户摄像头
352
+ *
353
+ * @param {object} options 关闭远端用户摄像头的参数
354
+ * @param {string} options.userId 用户 Id
355
+ * @returns {Promise<void>}
356
+ *
357
+ * @example
358
+ * const roomEngine = new TUIRoomEngine();
359
+ * await roomEngine.closeRemoteCamera({
360
+ * userId: 'user_1234',
361
+ * });
362
+ */
363
+ closeRemoteCamera(options: {
364
+ userId: string;
365
+ }): Promise<void>;
366
+ /**
367
+ * 请求远端用户打开麦克风
368
+ *
369
+ * @param {object} options 请求远端用户打开麦克风的参数
370
+ * @param {string} options.userId 用户 Id
371
+ * @param {number} options.timeout 超时时间,设置为 0 时,无超时时间
372
+ * @param {Function} options.requestCallback 请求回调,用来通知发起方请求被接受/拒绝/取消/超时/错误的回调
373
+ * @returns {Promise<number>} <br/>
374
+ * 该接口返回 requestId,用户可使用该 requestId 调用 cancelRequest 接口取消请求
375
+ *
376
+ * @example
377
+ * const roomEngine = new TUIRoomEngine();
378
+ * const requestId = await roomEngine.requestToOpenRemoteMicrophone({
379
+ * userId: 'user_1234',
380
+ * timeout: 0,
381
+ * requestCallback: ({ requestCallbackType, requestId, userId, code, message }) => {
382
+ * switch (requestCallbackType) {
383
+ * case TUIRequestCallbackType.kRequestAccepted:
384
+ * // 请求被接受
385
+ * break;
386
+ * case TUIRequestCallbackType.kRequestRejected:
387
+ * // 请求被拒绝
388
+ * break;
389
+ * case TUIRequestCallbackType.kRequestCancelled:
390
+ * // 请求已取消
391
+ * break;
392
+ * case TUIRequestCallbackType.kRequestTimeout:
393
+ * // 请求超时
394
+ * break;
395
+ * case TUIRequestCallbackType.kRequestError:
396
+ * // 请求错误
397
+ * break;
398
+ * default:
399
+ * break;
400
+ * }
401
+ * },
402
+ * });
403
+ */
404
+ requestToOpenRemoteMicrophone(options: {
405
+ userId: string;
406
+ timeout: number;
407
+ requestCallback?: (callbackInfo: TUIRequestCallback) => void;
408
+ }): Promise<number>;
409
+ /**
410
+ * 关闭远端用户麦克风
411
+ *
412
+ * @param {object} options 关闭远端用户麦克风, 仅房间主持人和管理员可调用此方法
413
+ * @param {string} options.userId 用户 Id
414
+ * @returns {Promise<void>}
415
+ *
416
+ * @example
417
+ * const roomEngine = new TUIRoomEngine();
418
+ * await roomEngine.closeRemoteMicrophone({
419
+ * userId: 'user_1234',
420
+ * });
421
+ */
422
+ closeRemoteMicrophone(options: {
423
+ userId: string;
424
+ }): Promise<void>;
425
+ /**
426
+ * 停止远端用户屏幕分享
427
+ *
428
+ * @param {object} options 停止远端用户屏幕分享, 仅房间主持人和管理员可调用此方法
429
+ * @param {string} options.userId 用户 Id
430
+ * @returns {Promise<void>}
431
+ *
432
+ * @example
433
+ * const roomEngine = new TUIRoomEngine();
434
+ * await roomEngine.stopRemoteScreenSharing({
435
+ * userId: 'user_1234',
436
+ * });
437
+ */
438
+ stopRemoteScreenSharing(options: {
439
+ userId: string;
440
+ }): Promise<void>;
441
+ /**
442
+ * 邀请其他人上麦
443
+ * @param {object} options 邀请其他人上麦的参数
444
+ * @param {number} options.seatIndex 麦位 index
445
+ * @param {string} options.userId 用户 Id
446
+ * @param {number} options.timeout 超时时间,设置为 0 时,无超时时间
447
+ * @param {Function} options.requestCallback 请求回调,用来通知发起方请求被接受/拒绝/取消/超时/错误的回调
448
+ * @returns {Promise<number>} <br/>
449
+ * 该接口返回 requestId,用户可使用该 requestId 调用 cancelRequest 接口取消请求
450
+ *
451
+ * @example
452
+ * const roomEngine = new TUIRoomEngine();
453
+ * const requestId = await roomEngine.requestRemoteUserOnSeat({
454
+ * seatIndex: 0,
455
+ * userId: 'user_1234',
456
+ * timeout: 0,
457
+ * requestCallback: ({ requestCallbackType, requestId, userId, code, message }) => {
458
+ * switch (requestCallbackType) {
459
+ * case TUIRequestCallbackType.kRequestAccepted:
460
+ * // 请求被接受
461
+ * break;
462
+ * case TUIRequestCallbackType.kRequestRejected:
463
+ * // 请求被拒绝
464
+ * break;
465
+ * case TUIRequestCallbackType.kRequestCancelled:
466
+ * // 请求已取消
467
+ * break;
468
+ * case TUIRequestCallbackType.kRequestTimeout:
469
+ * // 请求超时
470
+ * break;
471
+ * case TUIRequestCallbackType.kRequestError:
472
+ * // 请求错误
473
+ * break;
474
+ * default:
475
+ * break;
476
+ * }
477
+ * },
478
+ * });
479
+ */
480
+ requestRemoteUserOnSeat(options: {
481
+ seatIndex: number;
482
+ userId: string;
483
+ timeout: number;
484
+ requestCallback?: (callbackInfo: TUIRequestCallback) => void;
485
+ }): Promise<number>;
486
+ /**
487
+ * 要求其他人下麦
488
+ * @param {object} options 要求其他人下麦的参数
489
+ * @param {number} options.seatIndex 麦位 index
490
+ * @param {string} options.userId 用户 Id
491
+ * @returns {Promise<void>}
492
+ *
493
+ * @example
494
+ * const roomEngine = new TUIRoomEngine();
495
+ * await roomEngine.kickRemoteUserOffSeat({
496
+ * seatIndex: 0,
497
+ * userId: 'user_1234',
498
+ * });
499
+ */
500
+ kickRemoteUserOffSeat(options: {
501
+ seatIndex: number;
502
+ userId: string;
503
+ }): Promise<void>;
504
+ /**
505
+ * 取消已经发出的请求
506
+ * @param {object} options 取消已经发出请求的参数
507
+ * @param {number} options.requestId 请求 Id
508
+ * @returns {Promise<void>}
509
+ *
510
+ * @example
511
+ * const roomEngine = new TUIRoomEngine();
512
+ * await roomEngine.cancelRequest({
513
+ * requestId: 0, // 请使用实际 requestId
514
+ * });
515
+ */
516
+ cancelRequest(options: {
517
+ requestId: number;
518
+ }): Promise<void>;
519
+ /**
520
+ * 回复远端用户的请求
521
+ * @param {object} options 回复远端用户的请求的参数
522
+ * @param {number} options.requestId 请求 Id
523
+ * @param {boolean} options.agree 是否同意
524
+ * @returns {Promise<void>}
525
+ *
526
+ * @example
527
+ * const roomEngine = new TUIRoomEngine();
528
+ *
529
+ * // 同意远端的请求
530
+ * await roomEngine.responseRemoteRequest({
531
+ * requestId: 0, // 请使用实际 requestId
532
+ * agree: true,
533
+ * });
534
+ *
535
+ * // 拒绝远端的请求
536
+ * await roomEngine.responseRemoteRequest({
537
+ * requestId: 0, // 请使用实际 requestId
538
+ * agree: false,
539
+ * });
540
+ */
541
+ responseRemoteRequest(options: {
542
+ requestId: number;
543
+ agree: boolean;
544
+ }): Promise<any>;
545
+ /**
546
+ * 设置本地流的渲染位置
547
+ * @param {object} options 设置本地流的渲染位置的参数
548
+ * @param {TUIVideoStreamType} options.streamType 本地流类型
549
+ * @param {string} options.view streamType 对应的流渲染的 div 元素的 id
550
+ * @returns {Promise<void>}
551
+ *
552
+ * @example
553
+ * const roomEngine = new TUIRoomEngine();
554
+ *
555
+ * // 设置本地摄像头流的播放区域为 id 是 'preview-camera' 的 div 元素
556
+ * await roomEngine.setLocalRenderView({
557
+ * streamType: TUIVideoStreamType.kCameraStream,
558
+ * view: 'preview-camera',
559
+ * });
560
+ *
561
+ * // 设置本地屏幕分享流的播放区域为 id 是 'preview-screen' 的 div 元素
562
+ * await roomEngine.setLocalRenderView({
563
+ * streamType: TUIVideoStreamType.kScreenStream,
564
+ * view: 'preview-screen',
565
+ * });
566
+ */
567
+ setLocalRenderView(options: {
568
+ streamType: TUIVideoStreamType;
569
+ view: string;
570
+ }): Promise<void>;
571
+ /**
572
+ * 打开本地摄像头,开始视频流采集
573
+ * @returns {Promise<void>}
574
+ *
575
+ * @example
576
+ * const roomEngine = new TUIRoomEngine();
577
+ * await roomEngine.setLocalRenderView({
578
+ * streamType: TUIVideoStreamType.kScreenStream,
579
+ * view: 'preview-screen',
580
+ * });
581
+ * await roomEngine.openLocalCamera();
582
+ */
583
+ openLocalCamera(): Promise<void>;
584
+ /**
585
+ * 关闭本地摄像头
586
+ * @returns {Promise<void>}
587
+ *
588
+ * @example
589
+ * const roomEngine = new TUIRoomEngine();
590
+ * await roomEngine.closeLocalCamera();
591
+ */
592
+ closeLocalCamera(): Promise<void>;
593
+ /**
594
+ * 打开本地麦克风, 开始采集音频流
595
+ * @returns {Promise<void>}
596
+ *
597
+ * @example
598
+ * const roomEngine = new TUIRoomEngine();
599
+ * await roomEngine.openLocalMicrophone();
600
+ */
601
+ openLocalMicrophone(): Promise<void>;
602
+ /**
603
+ * 关闭本地麦克风, 停止采集音频流
604
+ * @returns {Promise<void>}
605
+ *
606
+ * @example
607
+ * const roomEngine = new TUIRoomEngine();
608
+ * await roomEngine.closeLocalMicrophone();
609
+ */
610
+ closeLocalMicrophone(): Promise<void>;
611
+ /**
612
+ * 设置本地视频的参数
613
+ * @param {object} options 设置本地视频的参数
614
+ * @param {TUIVideoProfile} options.videoProfile
615
+ *
616
+ * - 清晰 TUIVideoProfile.kLowDefinition <br/>
617
+ * - 标清 TUIVideoProfile.kStandardDefinition <br/>
618
+ * - 高清 TUIVideoProfile.kHighDefinition <br/>
619
+ * - 超清 TUIVideoProfile.kSuperDefinition <br/>
620
+ *
621
+ * @returns {Promise<void>}
622
+ *
623
+ * @example
624
+ * const roomEngine = new TUIRoomEngine();
625
+ * await roomEngine.setLocalVideoProfile({
626
+ * videoProfile: TUIVideoProfile.kHighDefinition,
627
+ * });
628
+ */
629
+ setLocalVideoProfile(options: {
630
+ videoProfile: TUIVideoProfile;
631
+ }): Promise<void>;
632
+ /**
633
+ * 设置本地音频的参数<br/>
634
+ * 注意:该方法需要在 openLocalMicrophone 之前进行设置,否则不会生效。
635
+ * @param {object} options 设置本地音频的参数
636
+ * @param {TUIAudioProfile} options.audioProfile
637
+ *
638
+ * - TUIAudioProfile.kAudioProfileSpeech:语言模式;采样率:16k<br/>
639
+ * - TUIAudioProfile.kAudioProfileDefault:标准模式(或者默认模式);采样率:48k<br/>
640
+ * - TUIAudioProfile.kAudioProfileMusic:音乐模式;采样率:48k
641
+ *
642
+ * @returns {Promise<void>}
643
+ *
644
+ * @example
645
+ * const roomEngine = new TUIRoomEngine();
646
+ * await roomEngine.setLocalAudioProfile({
647
+ * audioProfile: TUIAudioProfile.kAudioProfileSpeech,
648
+ * });
649
+ */
650
+ setLocalAudioProfile(options: {
651
+ audioProfile: TUIAudioProfile;
652
+ }): Promise<void>;
653
+ /**
654
+ * 开始向远端推本地视频流
655
+ * @returns {Promise<void>}
656
+ *
657
+ * @example
658
+ * const roomEngine = new TUIRoomEngine();
659
+ * await roomEngine.startPushLocalVideo();
660
+ */
661
+ startPushLocalVideo(): Promise<void>;
662
+ /**
663
+ * 停止向远端推本地视频流
664
+ * @returns {Promise<void>}
665
+ *
666
+ * @example
667
+ * const roomEngine = new TUIRoomEngine();
668
+ * await roomEngine.startPushLocalVideo();
669
+ */
670
+ stopPushLocalVideo(): Promise<void>;
671
+ /**
672
+ * 开始向远端推本地音频流
673
+ * @returns {Promise<void>}
674
+ *
675
+ * @example
676
+ * const roomEngine = new TUIRoomEngine();
677
+ * await roomEngine.startPushLocalAudio();
678
+ */
679
+ startPushLocalAudio(): Promise<void>;
680
+ /**
681
+ * 停止向远端推本地音频流
682
+ * @returns {Promise<void>}
683
+ *
684
+ * @example
685
+ * const roomEngine = new TUIRoomEngine();
686
+ * await roomEngine.stopPushLocalAudio();
687
+ */
688
+ stopPushLocalAudio(): Promise<void>;
689
+ /**
690
+ * 设置远端流渲染的区域
691
+ *
692
+ * @param {object} options 设设置远端流渲染区域的参数
693
+ * @param {string} options.userId 用户 Id
694
+ * @param {TUIVideoStreamType} options.streamType 用户流类型
695
+ * @param {string} options.view 播放远端用户流的 div 元素的 id
696
+ * @returns {Promise<void>}
697
+ *
698
+ * @example
699
+ * const roomEngine = new TUIRoomEngine();
700
+ *
701
+ * // 设置远端用户视频流在 id 为 'remote_preview_camera' 的区域播放
702
+ * roomEngine.setRemoteRenderView({
703
+ * userId: 'user_1234',
704
+ * streamType: TUIVideoStreamType.kCameraStream,
705
+ * view: 'remote_preview_camera',
706
+ * });
707
+ *
708
+ * // 设置远端用户屏幕分享流在 id 为 'remote_preview_screen' 的区域播放
709
+ * roomEngine.setRemoteRenderView({
710
+ * userId: 'user_1234',
711
+ * streamType: TUIVideoStreamType.kScreenStream,
712
+ * view: 'remote_preview_screen',
713
+ * });
714
+ */
715
+ setRemoteRenderView(options: {
716
+ userId: string;
717
+ streamType: TUIVideoStreamType;
718
+ view: string;
719
+ }): Promise<void>;
720
+ /**
721
+ * 开始播放远端用户视频流
722
+ *
723
+ * @param {object} options 开始播放远端用户视频流的参数
724
+ * @param {string} options.userId 用户 Id
725
+ * @param {TUIVideoStreamType} options.streamType 用户流类型
726
+ * @returns {Promise<void>}
727
+ *
728
+ * @example
729
+ * const roomEngine = new TUIRoomEngine();
730
+ * await roomEngine.startPlayRemoteVideo({
731
+ * userId: 'user_1234',
732
+ * streamType: TUIVideoStreamType.kCameraStream,
733
+ * });
734
+ */
735
+ startPlayRemoteVideo(options: {
736
+ userId: string;
737
+ streamType: TUIVideoStreamType;
738
+ }): Promise<void>;
739
+ /**
740
+ * 停止播放远端用户视频流
741
+ *
742
+ * @param {object} options 停止播放远端用户视频流的参数
743
+ * @param {string} options.userId 用户 Id
744
+ * @param {TUIVideoStreamType} options.streamType 用户流类型<br/>
745
+ *
746
+ * - TUIVideoStreamType.kCameraStream 视频流<br/>
747
+ * - TUIVideoStreamType.kScreenStream 屏幕分享流<br/>
748
+ * - TUIVideoStreamType.kCameraStreamLow 低清视频流
749
+ *
750
+ * @returns {Promise<void>}
751
+ *
752
+ * @example
753
+ * const roomEngine = new TUIRoomEngine();
754
+ * await roomEngine.stopPlayRemoteVideo({
755
+ * userId: 'user_1234',
756
+ * streamType: TUIVideoStreamType.kCameraStream,
757
+ * });
758
+ */
759
+ stopPlayRemoteVideo(options: {
760
+ userId: string;
761
+ streamType: TUIVideoStreamType;
762
+ }): Promise<void>;
763
+ /**
764
+ * 改变用户的角色,仅主持人可调用该接口
765
+ * @param {object} options 改变用户的角色,仅主持人可调用该接口的参数
766
+ * @param {string} options.userId 用户 Id
767
+ * @param {TUIRole} options.role 用户角色
768
+ * @returns {Promise<void>}
769
+ *
770
+ * @example
771
+ * const roomEngine = new TUIRoomEngine();
772
+ * // 将房间移交给用户 user_1234
773
+ * await roomEngine.changeUserRole({
774
+ * userId: 'user_1234',
775
+ * role: TUIRole.kRoomOwner,
776
+ * });
777
+ */
778
+ changeUserRole(options: {
779
+ userId: string;
780
+ role: TUIRole;
781
+ }): Promise<void>;
782
+ /**
783
+ * 禁止远端用户发送消息,仅主持人和管理员可调用该接口
784
+ * @param {object} options
785
+ * @param {string} options.userId 远端用户 userId
786
+ * @param {number} options.duration 禁止时长,单位秒。如设为 1000,则表示从现在起禁言该用户 1000 秒
787
+ * @returns {Promise<void>}
788
+ *
789
+ * @example
790
+ * const roomEngine = new TUIRoomEngine();
791
+ * await roomEngine.muteRemoteUser({
792
+ * userId: 'user_1234',
793
+ * duration: 1000,
794
+ * });
795
+ */
796
+ muteRemoteUser(options: {
797
+ userId: string;
798
+ duration: number;
799
+ }): Promise<void>;
800
+ /**
801
+ * 取消禁止远端用户发送消息,仅主持人和管理员可调用该接口
802
+ * @param {object} options
803
+ * @param {string} options.userId 远端用户 userId
804
+ * @returns {Promise<void>}
805
+ *
806
+ * @example
807
+ * const roomEngine = new TUIRoomEngine();
808
+ * await roomEngine.unmuteRemoteUser({
809
+ * userId: 'user_1234',
810
+ * });
811
+ */
812
+ unmuteRemoteUser(options: {
813
+ userId: string;
814
+ }): Promise<void>;
815
+ /**
816
+ * 将用户踢出房间,仅主持人和管理员可调用该接口
817
+ * @param {object} options
818
+ * @param {string} options.userId 用户 Id
819
+ * @returns {Promise<void>}
820
+ *
821
+ * @example
822
+ * const roomEngine = new TUIRoomEngine();
823
+ * await roomEngine.kickOutRemoteUser({
824
+ * userId: 'user_1234',
825
+ * });
826
+ */
827
+ kickOutRemoteUser(options: {
828
+ userId: string;
829
+ }): Promise<void>;
830
+ /**
831
+ * 发送文本消息
832
+ * @param {object} options
833
+ * @param {string} options.messageText 文本消息内容
834
+ * @returns {Promise<void>}
835
+ *
836
+ * @example
837
+ * const roomEngine = new TUIRoomEngine();
838
+ * await roomEngine.sendTextMessage({
839
+ * messageText: 'hello, everyone',
840
+ * });
841
+ */
842
+ sendTextMessage(options: {
843
+ messageText: string;
844
+ }): Promise<void>;
845
+ /**
846
+ * 发送自定义消息
847
+ * @param {object} options
848
+ * @param {string} options.messageText 自定义消息内容
849
+ * @returns {Promise<void>}
850
+ *
851
+ * @example
852
+ * const roomEngine = new TUIRoomEngine();
853
+ * await roomEngine.sendCustomMessage({
854
+ * messageText: '{ data:'', description: ''}',
855
+ * });
856
+ */
857
+ sendCustomMessage(options: {
858
+ messageText: string;
859
+ }): Promise<void>;
860
+ /**
861
+ * 开始屏幕共享
862
+ * @param {object=} options
863
+ * @param {boolean=} [options.screenAudio=false] web 端屏幕共享是否可选共享系统声音, screenAudio 默认值为 false
864
+ * @returns {Promise<void>}
865
+ *
866
+ * @example
867
+ * const roomEngine = new TUIRoomEngine();
868
+ * // 设置本地屏幕分享流的播放区域为 id 是 'preview-screen' 的 div 元素, 可以不设置
869
+ * await roomEngine.setLocalRenderView({
870
+ * streamType: TUIVideoStreamType.kScreenStream,
871
+ * view: 'preview-screen',
872
+ * });
873
+ * // example 1: 开始屏幕分享
874
+ * await roomEngine.startScreenSharing();
875
+ * // example 2: 开始屏幕分享(可采集系统音频)
876
+ * await roomEngine.startScreenSharing({ screenAudio: true });
877
+ */
878
+ startScreenSharing(options?: {
879
+ screenAudio?: boolean;
880
+ }): Promise<void>;
881
+ /**
882
+ * 停止屏幕共享
883
+ * @returns {Promise<void>}
884
+ *
885
+ * @example
886
+ * const roomEngine = new TUIRoomEngine();
887
+ * await roomEngine.stopScreenSharing();
888
+ */
889
+ stopScreenSharing(): Promise<void>;
890
+ /**
891
+ * 开始屏幕共享 Electron
892
+ * @param {string} targetId 分享窗口 id, 可从 getScreenSharingTarget 获取
893
+ * @returns {Promise<void>}
894
+ *
895
+ * @example
896
+ * const roomEngine = new TUIRoomEngine();
897
+ * await roomEngine.startScreenSharingElectron('xxx');
898
+ *
899
+ */
900
+ startScreenSharingElectron(targetId: string): Promise<void>;
901
+ /**
902
+ * 停止屏幕共享 Electron
903
+ * @returns {Promise<void>}
904
+ *
905
+ * @example
906
+ * const roomEngine = new TUIRoomEngine();
907
+ * await roomEngine.stopScreenSharingElectron();
908
+ */
909
+ stopScreenSharingElectron(): Promise<void>;
910
+ /**
911
+ * 获取屏幕分享列表 Electron
912
+ * @returns {Promise<void>}
913
+ *
914
+ * @example
915
+ * const roomEngine = new TUIRoomEngine();
916
+ * const screenList = await roomEngine.getScreenSharingTarget();
917
+ */
918
+ getScreenSharingTarget(): Promise<Array<TRTCScreenCaptureSourceInfo>>;
919
+ /**
920
+ * 切换屏幕分享窗口 Electron
921
+ * @param {string} targetId 分享窗口 id, 可从 getScreenSharingTarget 获取
922
+ *
923
+ * @returns {Promise<void>}
924
+ *
925
+ * @example
926
+ * const roomEngine = new TUIRoomEngine();
927
+ * await roomEngine.selectScreenSharingTarget('xxx');
928
+ */
929
+ selectScreenSharingTarget(targetId: string): Promise<void>;
930
+ /**
931
+ * 监听 roomEngine 的事件
932
+ * @param event TUIRoomEvents
933
+ * @param func function
934
+ * @returns {void}
935
+ *
936
+ * @example
937
+ * const roomEngine = new TUIRoomEngine();
938
+ * roomEngine.on(event, func);
939
+ */
940
+ on(event: TUIRoomEvents, func: Function): void;
941
+ private setObserver;
942
+ /**
943
+ * 取消监听 roomEngine 的事件
944
+ * @param event TUIRoomEvents
945
+ * @param func function
946
+ * @returns {void}
947
+ *
948
+ * @example
949
+ * const roomEngine = new TUIRoomEngine();
950
+ * roomEngine.off(event, func);
951
+ */
952
+ off(event: String, func: Function): void;
953
+ private handleTrtcCloudBindEvent;
954
+ /**
955
+ * 获取摄像头设备列表<br>
956
+ * @returns {Promise<TRTCDeviceInfo[]>} 摄像头列表
957
+ * @example
958
+ * const roomEngine = new TUIRoomEngine();
959
+ * const cameralist = await roomEngine.getCameraDevicesList();
960
+ * for (i = 0; i < cameralist.length; i++) {
961
+ * var camera = cameralist[i];
962
+ * console.info("camera deviceName: " + camera.deviceName + " deviceId:" + camera.deviceId);
963
+ * }
964
+ */
965
+ getCameraDevicesList(): Promise<any>;
966
+ /**
967
+ * 获取麦克风设备列表<br>
968
+ * @returns {Promise<TRTCDeviceInfo[]>} 麦克风列表
969
+ * @example
970
+ * const roomEngine = new TUIRoomEngine();
971
+ * const micList = await roomEngine.getMicDevicesList();
972
+ * for (i = 0; i < micList.length; i++) {
973
+ * var mic = micList[i];
974
+ * console.info("mic deviceName: " + mic.deviceName + " deviceId:" + mic.deviceId);
975
+ * }
976
+ */
977
+ getMicDevicesList(): Promise<any>;
978
+ /**
979
+ * 获取扬声器设备列表<br>
980
+ * @returns {Promise<TRTCDeviceInfo[]>} 扬声器列表
981
+ * @example
982
+ * const roomEngine = new TUIRoomEngine();
983
+ * const speakerList = await roomEngine.getSpeakerDevicesList();
984
+ * for (i = 0; i < speakerList.length; i++) {
985
+ * var speaker = speakerList[i];
986
+ * console.info("speaker deviceName: " + speaker.deviceName + " deviceId:" + speaker.deviceId);
987
+ * }
988
+ */
989
+ getSpeakerDevicesList(): Promise<any>;
990
+ /**
991
+ * 设置要使用的摄像头设备<br>
992
+ * @param {Object} options
993
+ * @param {String} options.deviceId - 从 getCameraDevicesList 中得到的设备 ID
994
+ * @returns {Promise<void>}
995
+ * @example
996
+ * const roomEngine = new TUIRoomEngine();
997
+ * await roomEngine.setCurrentCameraDevice({ deviceId: '' });
998
+ */
999
+ setCurrentCameraDevice(options: {
1000
+ deviceId: string;
1001
+ }): Promise<void>;
1002
+ /**
1003
+ * 设置要使用的麦克风设备<br>
1004
+ * @param {Object} options
1005
+ * @param {String} options.deviceId - 从 getMicDevicesList 中得到的设备 ID
1006
+ * @returns {Promise<void>}
1007
+ * @example
1008
+ * const roomEngine = new TUIRoomEngine();
1009
+ * await roomEngine.setCurrentMicDevice({ deviceId: '' });
1010
+ */
1011
+ setCurrentMicDevice(options: {
1012
+ deviceId: string;
1013
+ }): Promise<void>;
1014
+ /**
1015
+ * 设置要使用的扬声器设备<br>
1016
+ * @param {Object} options
1017
+ * @param {String} options.deviceId - 从 getSpeakerDevicesList 中得到的设备 ID
1018
+ * @returns {Promise<void>}
1019
+ * @example
1020
+ * const roomEngine = new TUIRoomEngine();
1021
+ * await roomEngine.setCurrentSpeakerDevice({ deviceId: '' });
1022
+ */
1023
+ setCurrentSpeakerDevice(options: {
1024
+ deviceId: string;
1025
+ }): Promise<void>;
1026
+ /**
1027
+ * 获取当前正在使用的摄像头设备
1028
+ * @returns {TRTCDeviceInfo} 设备信息,能获取设备 ID 和设备名称
1029
+ * @example
1030
+ * const roomEngine = new TUIRoomEngine();
1031
+ * const currentCameraDevice = roomEngine.getCurrentCameraDevice();
1032
+ */
1033
+ getCurrentCameraDevice(): TRTCDeviceInfo;
1034
+ /**
1035
+ * 获取当前正在使用的麦克风设备
1036
+ * @returns {TRTCDeviceInfo} 设备信息,能获取设备 ID 和设备名称
1037
+ * @example
1038
+ * const roomEngine = new TUIRoomEngine();
1039
+ * const currentMicDevice = roomEngine.getCurrentMicDevice();
1040
+ */
1041
+ getCurrentMicDevice(): TRTCDeviceInfo;
1042
+ /**
1043
+ * 获取当前正在使用的扬声器设备
1044
+ * @returns {TRTCDeviceInfo} 设备信息,能获取设备 ID 和设备名称
1045
+ * @example
1046
+ * const roomEngine = new TUIRoomEngine();
1047
+ * const currentSpeakerDevice = roomEngine.getCurrentSpeakerDevice();
1048
+ */
1049
+ getCurrentSpeakerDevice(): TRTCDeviceInfo;
1050
+ /**
1051
+ * 开始进行摄像头测试
1052
+ * @param {string} view 显示摄像头测试的视频区域, 传入的 view 为承载预览画面 div 元素的 id
1053
+ * @returns {Promise<void>}
1054
+ *
1055
+ * @example
1056
+ * const roomEngine = new TUIRoomEngine();
1057
+ * await roomEngine.startCameraDeviceTest({ view: 'test-preview' });
1058
+ */
1059
+ startCameraDeviceTest(options: {
1060
+ view: string;
1061
+ }): Promise<void>;
1062
+ /**
1063
+ * 停止摄像头测试
1064
+ * @returns {void}
1065
+ * @example
1066
+ * const roomEngine = new TUIRoomEngine();
1067
+ * await roomEngine.stopCameraDeviceTest();
1068
+ */
1069
+ stopCameraDeviceTest(): Promise<void>;
1070
+ /**
1071
+ * 获取 trtcCloud 实例
1072
+ * @returns {TRTCCloud} trtcCloud
1073
+ * web 端 trtcCloud 能力请查看:https://web.sdk.qcloud.com/trtc/webrtc/trtcCloud/doc/TRTCCloud.html
1074
+ *
1075
+ * @example
1076
+ * const roomEngine = new TUIRoomEngine();
1077
+ * const trtcCloud = roomEngine.getTRTCCloud();
1078
+ */
1079
+ getTRTCCloud(): TRTCCloud;
1080
+ /**
1081
+ * 获取 tim 实例
1082
+ * @returns {TIM} tim
1083
+ * web 端 tim 能力请查看:https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html
1084
+ *
1085
+ * @example
1086
+ * const roomEngine = new TUIRoomEngine();
1087
+ * const trtcCloud = roomEngine.getTIM();
1088
+ */
1089
+ getTIM(): any;
1090
+ destroy(): void;
1091
+ }
1092
+ export default TUIRoomEngine;