@xylink/xy-rtc-sdk 3.9.1-beta.6 → 3.10.0-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.
Files changed (56) hide show
  1. package/lib/action/index.d.ts +103 -20
  2. package/lib/enum/client.d.ts +1 -1
  3. package/lib/enum/{contraints.d.ts → constraints.d.ts} +6 -0
  4. package/lib/enum/device.d.ts +34 -0
  5. package/lib/enum/errorCode.d.ts +7 -1
  6. package/lib/enum/i18n.d.ts +6 -0
  7. package/lib/enum/index.d.ts +70 -12
  8. package/lib/enum/meeting.d.ts +4 -0
  9. package/lib/feature/index.d.ts +1 -0
  10. package/lib/feature/speaker.d.ts +61 -0
  11. package/lib/index.d.ts +13 -10
  12. package/lib/main/ability/const.d.ts +2 -0
  13. package/lib/main/ability/index.d.ts +31 -0
  14. package/lib/main/{iauth.d.ts → auth.d.ts} +8 -8
  15. package/lib/main/client.d.ts +203 -97
  16. package/lib/main/clientImplements.d.ts +99 -0
  17. package/lib/main/deviceManager.d.ts +150 -93
  18. package/lib/main/helper.d.ts +62 -9
  19. package/lib/main/layout/index.d.ts +377 -0
  20. package/lib/main/layout/template.d.ts +64 -0
  21. package/lib/main/meeting.d.ts +32 -26
  22. package/lib/main/peer.d.ts +3 -1
  23. package/lib/main/stream.d.ts +47 -21
  24. package/lib/main/videoManager.d.ts +95 -12
  25. package/lib/tools/{audioLevel.d.ts → analyser.d.ts} +11 -4
  26. package/lib/tools/browser.d.ts +60 -49
  27. package/lib/tools/httpClient.d.ts +27 -6
  28. package/lib/tools/index.d.ts +12 -5
  29. package/lib/tools/{logger.d.ts → log/logger.d.ts} +18 -7
  30. package/lib/tools/log/loggerManager.d.ts +69 -0
  31. package/lib/tools/promiseQueue.d.ts +45 -0
  32. package/lib/tools/queue.d.ts +12 -15
  33. package/lib/tools/resize.d.ts +62 -0
  34. package/lib/tools/snapshot.d.ts +31 -0
  35. package/lib/tools/socket.d.ts +99 -32
  36. package/lib/tools/template/index.d.ts +324 -0
  37. package/lib/tools/template/mobile.d.ts +9 -0
  38. package/lib/tools/utils.d.ts +13 -5
  39. package/lib/type/ability.d.ts +25 -0
  40. package/lib/type/analyser.d.ts +18 -0
  41. package/lib/type/{iauth.d.ts → auth.d.ts} +0 -7
  42. package/lib/type/base.d.ts +16 -0
  43. package/lib/type/client.d.ts +164 -150
  44. package/lib/type/device.d.ts +103 -31
  45. package/lib/type/index.d.ts +3 -1
  46. package/lib/type/layout.d.ts +198 -13
  47. package/lib/type/logger.d.ts +19 -1
  48. package/lib/type/meeting.d.ts +294 -10
  49. package/lib/type/socket.d.ts +60 -0
  50. package/lib/type/stream.d.ts +21 -13
  51. package/lib/xyrtc.cjs.js +1 -1
  52. package/lib/xyrtc.umd.js +1 -1
  53. package/package.json +7 -5
  54. package/lib/main/layoutManager.d.ts +0 -244
  55. package/lib/tools/template.d.ts +0 -21
  56. /package/lib/tools/{logger.worker.d.ts → log/logger.worker.d.ts} +0 -0
@@ -5,11 +5,11 @@
5
5
  * @author jinghui-luo、chengfei
6
6
  *
7
7
  * Created at : 2020-11-26 14:41:51
8
- * Last modified : 2023-04-24 14:38:52
8
+ * Last modified : 2023-11-09 10:05:07
9
9
  */
10
- import Logger from '../tools/logger';
10
+ import Logger from '../tools/log/logger';
11
11
  import Emitter from '../tools/emitter';
12
- import { IDeviceInfo, IDeviceList, ISelectedDevice, ICurrentPermission, PermissionType, DeviceKind, FacingMode } from '../type';
12
+ import { IDeviceInfo, IDeviceList, ICurrentPermission, PermissionType, FacingMode, DEVICE_KIND, IDeviceId, ISetSpecDevice } from '../type';
13
13
  /**
14
14
  * DeviceManager模块,用于管理枚举设备列表、监听设备变动、处理设备权限等功能
15
15
  *
@@ -18,166 +18,223 @@ import { IDeviceInfo, IDeviceList, ISelectedDevice, ICurrentPermission, Permissi
18
18
  */
19
19
  declare class DeviceManager extends Emitter {
20
20
  private navigator;
21
- private currentDeviceList;
22
- private nextDeviceList;
23
- private currentUsedDevice;
21
+ logger: Logger;
22
+ isNewLogger: boolean;
24
23
  private currentPermission;
25
24
  private permissionCameraStatus;
26
25
  private permissionPhoneStatus;
27
- logger: Logger;
28
- isNewLogger: boolean;
26
+ private previousDeviceList;
27
+ private currentDeviceList;
28
+ private fullDeviceList;
29
+ private systemDefaultDevice;
30
+ private cacheDefaultDeviceId;
31
+ private specifiedDevice;
32
+ private usedDeviceId;
33
+ private systemDefaultDeviceId;
34
+ private specifiedDefaultDeviceId;
35
+ private onDeviceChangeEvent;
36
+ private onUpdateFullDeviceList;
29
37
  constructor(logger?: Logger);
30
38
  /**
31
39
  * 获取设备权限数据
32
40
  */
33
41
  getDevicePermission(): ICurrentPermission;
34
42
  /**
35
- * 获取当前设备列表
36
- * @returns
43
+ * 初始化设备列表和设备权限状态及监听事件
44
+ *
45
+ * 调用时机:MakeCall时调用、当前实例被创建时
37
46
  */
38
- getNextDeviceList(): IDeviceList;
47
+ initDeviceAndPermission(): Promise<void>;
39
48
  /**
40
- * 设置当前正在使用的设备信息
41
- * 1. 此信息可能从stream中获取
49
+ * 计算并缓存系统默认、指定设备两种类型设备的默认值
42
50
  *
43
- * @param devices 设备数据
51
+ * @param { DEVICE_KIND } kind - 设备类型
44
52
  */
45
- setCurrentUsedDevice(currentDevice: ISelectedDevice): Promise<void>;
53
+ calculateDefaultDevice(kind: DEVICE_KIND): void;
46
54
  /**
47
- * 设置当前正在使用的设备信息
48
- * 切换设备时,需重新设置此值,为下次diffDevice 使用
49
- * @param type
50
- * @param deviceId
55
+ * 计算并缓存系统默认、指定设备两种类型设备的默认值
56
+ *
57
+ * @param { IDefaultDeviceIdParams } params - 初始化参数
58
+ * @returns { systemDefaultDevice, specifiedDefaultDevice } - 默认设备、指定默认设备的值
51
59
  */
52
- setCurrentUsedDeviceByType(type: DeviceKind, deviceId: string): void;
60
+ private getDefaultDeviceImpl;
53
61
  /**
54
- * 设置输出设备
62
+ * Diff新旧设备列表,寻找到可用的默认设备
55
63
  *
56
- * @param element video元素节点
57
- * @param outputDeviceId 设备id
64
+ * 如果是新增设备,则diff设备列表,找到第一个最新的设备
65
+ *
66
+ * @param { IDeviceInfo[] } preDeviceList - 上一次的设备列表
67
+ * @param { IDeviceInfo[] } curDeviceList - 最新的设备列表
68
+ * @return { IDeviceInfo | null } 默认设备
69
+ */
70
+ private diffDefaultDevice;
71
+ /**
72
+ * 获取默认设备ID数据
73
+ * 区分两种类型:如用户选择系统默设备,则获取系统默认设备,如果是指定设备,则根据指定设备获取对应分配的设备
58
74
  */
59
- setAudioOutputDevice(element: any, outputDeviceId: string): void;
75
+ getDefaultDeviceId(): IDeviceId;
60
76
  /**
61
- * 向外提供权限信息
77
+ * 缓存用户选择的设备数据,也可用作判断用户是否选择:默认系统设备
78
+ * 注意:如果用户设置的DeviceID不存在,也会持久缓存,不会做设备真实性校验
79
+ *
80
+ * @param { ISetSpecDevice } params - 需要指定的设备信息
62
81
  */
63
- emmitDevices(): Promise<void>;
82
+ setSpecifiedDeviceId(params: ISetSpecDevice): void;
64
83
  /**
65
- * 初始化构造器函数
84
+ * 通过采集到的Stream,获取到真实的DeviceId,并更新到设备列表
85
+ *
86
+ * @param { IDeviceId } usedDeviceId - 增量的设备ID信息
66
87
  */
67
- init(): Promise<void>;
88
+ updateUsedDeviceId(usedDeviceId: IDeviceId): Promise<void>;
68
89
  /**
69
- * 销毁设备管理器实例
90
+ * 获取指定ID对应的真实DeviceId值
91
+ *
92
+ * @param { IDeviceInfo[] } deviceList - 全量设备列表
93
+ * @param { string } deviceId - 指定设备ID
94
+ * @param { string } defaultId - 默认设备ID
95
+ * @returns { string } 设备ID
70
96
  */
71
- destroy(): void;
97
+ private getReallyDeviceIdById;
72
98
  /**
73
- * 获取设备列表
99
+ * 获取指定ID对应的真实DeviceId值
74
100
  *
75
- * @private
76
- * @returns { IDeviceList } list
101
+ * @param { DEVICE_KIND } kind - 设备类型
102
+ * @param { string } deviceId - 指定设备ID
103
+ * @returns { string } 设备ID
77
104
  */
78
- private getPrivateDevices;
105
+ getReallyDeviceId(kind: DEVICE_KIND, deviceId: string): string;
79
106
  /**
80
- * 获取设备列表数据
107
+ * 更新全量设备列表
81
108
  */
82
- getDevices(): Promise<IDeviceList>;
109
+ updateFullDeviceList(): Promise<void>;
83
110
  /**
84
- * 设置当前麦克风/摄像头权限
111
+ * 设置输出设备
85
112
  *
86
- * @param { ICurrentPermission } permission - 新的权限状态
113
+ * @param { * } element - Audio元素节点
114
+ * @param { string } deviceId - 切换的设备ID,可能包含DEFAULT设备
87
115
  */
88
- setPermission(permission: ICurrentPermission): void;
116
+ setAudioOutputDevice(element: any, deviceId: string): Promise<void>;
89
117
  /**
90
- * 通过采集能力更新设备权限
118
+ * 获取基础设备列表
119
+ * 注意:不包含DEFAULT系统默认设备,会在最后一步合并
91
120
  *
92
- * @param { PermissionType } video - 摄像头权限
93
- * @param { PermissionType } audio - 麦克风权限
121
+ * @returns { Promise<IDeviceList> } 过滤无效后的基础设备列表
94
122
  */
95
- updateDevicePermission(video: PermissionType, audio: PermissionType): void;
123
+ private createBaseDeviceList;
96
124
  /**
97
- * 【私有方法】
98
- * 向外提供权限信息
125
+ * 获取基础的设备列表
126
+ *
127
+ * @return { Promise<IDeviceList> } 设备列表
99
128
  */
100
- private emmitPermission;
129
+ getOriginDeviceList(): Promise<IDeviceList>;
101
130
  /**
102
- * 【私有方法】
103
- * 查询权限接口
131
+ * 过滤虚拟设备和通讯设备
104
132
  *
105
- * @param type 需要检测的设备类型 'microphone' | 'camera'
133
+ * @param { IDeviceList } deviceList - 设备列表
106
134
  */
107
- private query;
135
+ private filterInvalidDevice;
108
136
  /**
109
- * 【私有方法】
110
- * 监听权限变更
137
+ * 过滤默认设备,并将默认设备对应的真实设备找到并缓存
111
138
  *
112
- * @param e 回调权限数据
139
+ * @param { IDeviceList } deviceList - 设备列表
113
140
  */
114
- private handlePermissionCameraStateChanged;
141
+ private filterDefaultDevice;
115
142
  /**
116
- * 【私有方法】
117
- * 监听权限变更
143
+ * 追加系统默认设备选项
144
+ */
145
+ private appendSystemDefaultDevice;
146
+ /**
147
+ * 缓存默认设备对应的真实设备数据
148
+ * 从BaseDeviceList中寻找到default设备对应的真实设备
118
149
  *
119
- * @param e 回调权限数据
150
+ * @param { IDeviceInfo } defaultDevice - 默认设备
151
+ * @param { IDeviceInfo[] } deviceList - 设备列表
120
152
  */
121
- private handlePermissionPhoneStateChanged;
153
+ private setDefaultDevice;
154
+ /**
155
+ * 更新最新的设备列表中的选中状态(isSelected),元配置数据(originLabel, originDeviceId)
156
+ */
157
+ private updateFullDeviceListStatus;
158
+ /**
159
+ * 通过DeviceId获取设备详情信息
160
+ *
161
+ * @param { IDeviceInfo[] } devices - 全量设备列表
162
+ * @param { string } deviceId - 设备ID
163
+ * @returns { IDeviceInfo | null } 设备信息
164
+ */
165
+ private getDeviceByDeviceId;
122
166
  /**
123
- * 获取摄像头和麦克风权限方法,初始化时直接调用
167
+ * 通过对比,获取到即将切换的设备数据
124
168
  *
125
- * TODO:兼容方式通过获取devices设备去检测是否授予了权限
126
- * TODO:可以通过looping的形式检测,后续在处理
169
+ * @returns { ISelectedDevice } 即将切换的设备
127
170
  */
128
- getPermission(): Promise<ICurrentPermission>;
171
+ private createNextDevice;
172
+ /**
173
+ * 更新计算系统默认和指定默认设备数据
174
+ */
175
+ private updateDefaultDeviceId;
176
+ /**
177
+ * 创建全量设备列表
178
+ */
179
+ private createFullDeviceList;
180
+ /**
181
+ * 设备变化监听函数
182
+ */
183
+ private onDeviceChange;
184
+ /**
185
+ * 初始化设备监听函数
186
+ */
187
+ private initDeviceEvent;
188
+ /**
189
+ * 移除设备监听函数
190
+ */
191
+ private removeDeviceEvent;
129
192
  /**
130
193
  * 获取手机前置/后置摄像头
131
194
  *
132
- * @param { FacingMode } type
195
+ * @param { FacingMode } type - 摄像头类型,可选:FRONT、BACK,分辨是前置摄像头还是后置摄像头
133
196
  * @returns { IDeviceInfo } 摄像头信息
134
197
  */
135
198
  getCameraDeviceByMode(type: FacingMode): Promise<IDeviceInfo>;
136
199
  /**
137
- * 【私有方法】
138
- * 如果有音频设备插入,则选取最新设备
139
- * 如果有音频设备拔出,则选默认设备
140
- * 如果有音频设备进行切换,则以切换为主
200
+ * 设置当前麦克风/摄像头权限
141
201
  *
142
- * @param preList
143
- * @param nextList
202
+ * @param { ICurrentPermission } permission - 新的权限状态
144
203
  */
145
- private diffAudioDevice;
204
+ setDevicePermission(permission: ICurrentPermission): void;
146
205
  /**
147
- * 【私有方法】
148
- * 获取最新的摄像头设备数据
149
- * 1. 默认采用新加入的摄像头设备
150
- * 2. 如果当前使用的设备被拔出,采用第0个设备数据
206
+ * 通过采集能力更新设备权限
207
+ *
208
+ * @param { PermissionType } video - 摄像头权限
209
+ * @param { PermissionType } audio - 麦克风权限
210
+ */
211
+ updateDevicePermission(video: PermissionType, audio: PermissionType): void;
212
+ /**
213
+ * 查询权限接口
151
214
  *
152
- * @param preVideoInList 上一次的摄像头列表数据
153
- * @param nextVideoInList 设备变化后的摄像头列表数据
215
+ * @param { 'microphone' | 'camera' } type - 需要检测的设备类型
154
216
  */
155
- private diffVideoDevice;
217
+ private query;
156
218
  /**
157
- * 【私有方法】
158
- * 通过和最新的设备数据对比,得到设备差异
159
- * 用于切换到最新的设备
219
+ * 监听权限变更
160
220
  *
161
- * @param currentDevices 当前设备列表
162
- * @param nextDevices 设备变化后的列表
221
+ * @param { * } e - 权限变动事件
163
222
  */
164
- private diffDevices;
223
+ private handlePermissionCameraStateChanged;
165
224
  /**
166
225
  * 【私有方法】
167
- * 设备变化监听函数
168
- * 1. detail: 最新的设备列表数据
169
- * 2. nextDevice: 需要切换的设备数据
226
+ * 监听权限变更
227
+ *
228
+ * @param e 回调权限数据
170
229
  */
171
- private mediaDevicesChange;
230
+ private handlePermissionPhoneStateChanged;
172
231
  /**
173
- * 【私有方法】
174
- * 初始化设备监听函数
232
+ * 初始化摄像头和麦克风权限和监听事件
175
233
  */
176
- private initDeviceEvent;
234
+ bindDevicePermissionEvent(): Promise<void>;
177
235
  /**
178
- * 【私有方法】
179
- * 移除设备监听函数
236
+ * 销毁设备管理器实例
180
237
  */
181
- private removeDeviceEvent;
238
+ destroy(): void;
182
239
  }
183
240
  export default DeviceManager;
@@ -1,13 +1,10 @@
1
1
  /**
2
2
  * Common Helper Function Lib
3
3
  *
4
- * @author jinghui-Luo
5
- * @email luojinghui424@gmail.com
6
- *
7
4
  * Created at : 2021-01-09 14:45:46
8
- * Last modified : 2023-05-16 18:54:50
5
+ * Last modified : 2023-09-25 14:32:59
9
6
  */
10
- import { ILayout, IVideoManagerState, IRotationInfoTotalItem } from '../type';
7
+ import { ILayout, IVideoManagerState, IRotationInfoTotalItem, IRosterIdInfo, IRotateStyle, DEVICE_KIND } from '../type';
11
8
  export declare const getLayoutItemState: (item: ILayout | ILayout, stream: MediaStream | null, vmState: IVideoManagerState) => "REQUEST" | "NORMAL" | "MUTE" | "AUDIO_TEL" | "AUDIO_ONLY" | "AUDIO_CONTENT";
12
9
  /**
13
10
  * Get video real display size and rotate of transform infos
@@ -25,11 +22,11 @@ export declare const getVideoInfoByRotation: (width: number, height: number, con
25
22
  /**
26
23
  * 通过旋转信息配合画面容器计算应该旋转的角度和宽高
27
24
  *
28
- * @param item rotateInfo 设备旋转item,通过rotate-info接口回调获取
29
- * @param containerWidth 当前参会者画面容器的宽度
30
- * @param containerHeight 当前参会者画面容器的高度
25
+ * @param { IRotationInfoTotalItem } rotationInfo - rotateInfo 设备旋转item,通过rotate-info接口回调获取
26
+ * @param { number } containerWidth - 当前参会者画面容器的宽度
27
+ * @param { number } containerHeight - 当前参会者画面容器的高度
31
28
  */
32
- export declare const getLayoutRotateInfo: (item: IRotationInfoTotalItem, containerWidth: number, containerHeight: number) => {};
29
+ export declare const getLayoutRotateInfo: (rotationInfo: IRotationInfoTotalItem, containerWidth: number, containerHeight: number) => IRotateStyle | null;
33
30
  /**
34
31
  * 获取可支持的编解码
35
32
  *
@@ -49,3 +46,59 @@ export declare const detectLocator: ({ extId, clientId, clientSecret, httpServer
49
46
  clientSecret: string;
50
47
  httpServer?: string | undefined;
51
48
  }) => Promise<string>;
49
+ /**
50
+ * 生成用户唯一ID值
51
+ *
52
+ * @param { string } callUri - callUri或者endpointId值
53
+ * @param { number | string } mediagroupid - mid,多分组通道,常见:0代表people,1代表content,会控喊话有>10值
54
+ * @return { string } 唯一ID
55
+ */
56
+ export declare const getRosterId: (callUri?: string, mediagroupid?: number | string) => string;
57
+ /**
58
+ * 切割RosterId,获取endpointId和mediagroupId信息
59
+ *
60
+ * @param { string } rosterId - 唯一ID
61
+ * @return { IRosterIdInfo } 切割后的数据
62
+ */
63
+ export declare const getRosterIdInfo: (rosterId: string) => IRosterIdInfo;
64
+ /**
65
+ * 通过participantId和mediagroupId获取用户的UniquePd值?
66
+ *
67
+ * @param { string } participantId - 小鱼设计的唯一用户ID,迁会后自动创建新的Pid子段;
68
+ * @param { string } mediagroupId - 多分组通道ID
69
+ * @returns { string } 创建的ID值
70
+ */
71
+ export declare const getUniquePid: (participantId: string | number, mediagroupId: string | number) => string;
72
+ /**
73
+ * 基于生成的UniquePid值获取participantId和mediagroupId
74
+ *
75
+ * @param { string } partId - UniquePid值
76
+ * @returns
77
+ */
78
+ export declare const getUniquePidInfo: (partId: string) => {
79
+ participantId: string;
80
+ mediagroupId: string;
81
+ };
82
+ /**
83
+ * 获取副屏渲染ID
84
+ *
85
+ * @param { string } viewId - 视图容器节点ID
86
+ * @returns { string }
87
+ */
88
+ export declare const getSlaveId: (viewId: string) => string;
89
+ /**
90
+ * 生成设备唯一Key
91
+ *
92
+ * @param { string } deviceId - 设备ID
93
+ * @param { boolean } isDefault - 是否是默认设备
94
+ * @param { DEVICE_KIND } kind - 设备类型
95
+ * @returns { string } 设备唯一Key
96
+ */
97
+ export declare const getDeviceUniKey: (deviceId: string, isDefault: boolean, kind: DEVICE_KIND) => string;
98
+ /**
99
+ * 根据名称及相应规则获得对应的名称头像
100
+ *
101
+ * @param { string } displayName - layout名称
102
+ * @returns { string } - 名称头像 文字内容
103
+ */
104
+ export declare const getTextAvatar: (displayName: string) => string;