@xylink/xy-rtc-sdk 3.8.1 → 3.9.0

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 (43) hide show
  1. package/lib/action/index.d.ts +20 -5
  2. package/lib/enum/client.d.ts +15 -0
  3. package/lib/enum/contraints.d.ts +33 -96
  4. package/lib/enum/device.d.ts +1 -0
  5. package/lib/enum/errorCode.d.ts +58 -1
  6. package/lib/enum/index.d.ts +44 -16
  7. package/lib/index.d.ts +11 -8
  8. package/lib/main/client.d.ts +93 -63
  9. package/lib/main/deviceManager.d.ts +23 -4
  10. package/lib/main/helper.d.ts +2 -2
  11. package/lib/main/iauth.d.ts +14 -1
  12. package/lib/main/layoutManager.d.ts +29 -11
  13. package/lib/main/meeting.d.ts +71 -34
  14. package/lib/main/peer.d.ts +70 -121
  15. package/lib/main/qualityManager.d.ts +38 -9
  16. package/lib/main/stream.d.ts +237 -104
  17. package/lib/main/videoManager.d.ts +1 -9
  18. package/lib/tools/dbManager.d.ts +106 -0
  19. package/lib/tools/detect.d.ts +2 -2
  20. package/lib/tools/enum.d.ts +1 -1
  21. package/lib/tools/httpClient.d.ts +4 -4
  22. package/lib/tools/i18n.d.ts +1 -1
  23. package/lib/tools/logger.d.ts +75 -74
  24. package/lib/tools/logger.worker.d.ts +13 -0
  25. package/lib/tools/quality.d.ts +113 -0
  26. package/lib/tools/quality.worker.d.ts +13 -0
  27. package/lib/tools/queue.d.ts +38 -3
  28. package/lib/tools/template.d.ts +3 -3
  29. package/lib/tools/utils.d.ts +8 -0
  30. package/lib/type/base.d.ts +2 -2
  31. package/lib/type/client.d.ts +255 -150
  32. package/lib/type/device.d.ts +21 -15
  33. package/lib/type/index.d.ts +3 -0
  34. package/lib/type/layout.d.ts +18 -1
  35. package/lib/type/logger.d.ts +112 -0
  36. package/lib/type/meeting.d.ts +11 -2
  37. package/lib/type/peer.d.ts +20 -0
  38. package/lib/type/quality.d.ts +101 -0
  39. package/lib/type/stream.d.ts +332 -134
  40. package/lib/xyrtc.cjs.js +1 -1
  41. package/lib/xyrtc.umd.js +1 -1
  42. package/package.json +4 -4
  43. package/lib/tools/db.d.ts +0 -85
@@ -1,97 +1,96 @@
1
1
  /**
2
- * Logger 日志打印函数
2
+ * Logger日志库-v2
3
+ * 使用WebWorker作为输出和日志控制
3
4
  *
4
5
  * @authors Luo-jinghui (luojinghui424@gmail.com)
5
6
  * @date 2019-10-22 20:08:33
6
7
  */
7
- /**
8
- * @value INFO 所有信息
9
- * @value DEBUG 所有调试信息
10
- * @value WARNING 所有警告信息
11
- * @value ERROR 所有错误信息
12
- * @value NONE 不打印任何信息
13
- */
14
- declare type TypeLogLevel = 'INFO' | 'DEBUG' | 'WARNING' | 'ERROR' | 'NONE';
15
- interface ILogLevel {
16
- INFO: 'INFO';
17
- DEBUG: 'DEBUG';
18
- WARNING: 'WARNING';
19
- ERROR: 'ERROR';
20
- NONE: 'NONE';
21
- }
22
- interface ILog {
23
- time: number;
24
- title: string;
25
- content: string;
26
- rest: any;
27
- }
8
+ import { LogLevel, ILoggerConfig, TLogLevel } from '../type';
28
9
  declare class Logger {
29
- /**
30
- * @member { DB } db indexDB数据库
10
+ private worker;
11
+ private isArrowUpload;
12
+ currentLevel: LogLevel;
13
+ config: ILoggerConfig;
14
+ isProgress: boolean;
15
+ isUpdateVersion: boolean;
16
+ taskPromiseMap: {
17
+ [key: string]: any;
18
+ };
19
+ constructor(config: ILoggerConfig);
20
+ /**
21
+ * 启动日志模块
22
+ *
23
+ * @param { ILoggerConfig? } config - Logger配置
24
+ * @param { boolean } enableClearTable - 是否清理表
25
+ * @returns { boolean }
31
26
  */
32
- private db;
27
+ start(enableClearTable?: boolean): true | "The log module is already enabled, please stop it first";
33
28
  /**
34
- * @member { boolean } isArrowUpload 是否运训上传日志到小鱼云服务器
29
+ * 接收WebWorker线程消息
30
+ *
31
+ * @param { any } msg - WebWorker消息
35
32
  */
36
- private isArrowUpload;
33
+ onMessage(msg: any): Promise<void>;
37
34
  /**
38
- * @member { boolean } isAddCache 是否允许缓存写入数据库失败的数据
35
+ * 停止日志模块
36
+ *
37
+ * @param { boolean } enabledUpdateIndex - 是否更新表
39
38
  */
40
- private isAddCache;
39
+ stop(enabledUpdateIndex?: boolean): void;
41
40
  /**
42
- * @member { ILogLevel } LogLevel 设置日志等级
41
+ * 监听WebWorker错误
42
+ *
43
+ * @param { AbstractWorker } this - worker实例
44
+ * @param { ErrorEvent } event - 错误内容
43
45
  */
44
- LogLevel: ILogLevel;
46
+ private onErrorWorker;
45
47
  /**
46
- * @member { string } currentLevel 设置当前日志等级
48
+ * 监听WebWorker消息错误
49
+ *
50
+ * @param { Worker } this - worker实例
51
+ * @param { MessageEvent<any> } event - 错误内容
47
52
  */
48
- currentLevel: string;
53
+ private onMessageErrorWorker;
49
54
  /**
50
- * @member { ILog[] } cacheData 缓存日志信息
55
+ * 缓存表的版本和索引位置
56
+ *
57
+ * @param { boolean } increase - 是否自增索引序列号
51
58
  */
52
- cacheData: ILog[];
53
- constructor();
54
- stopDB: () => void;
55
- openDB: () => void;
59
+ private updateTableIndex;
56
60
  /**
57
- * 如果db没有开启,那么需要初始话db,并清理之前的数据
61
+ * 获取可用的表名
58
62
  */
59
- initDB: () => Promise<void>;
63
+ private getTableIndex;
60
64
  /**
61
65
  * 设置日志等级
62
66
  *
63
- * @public
64
- * @param { TypeLogLevel } level 日志等级
67
+ * @param { LogLevel } level 日志等级
65
68
  */
66
- setLogLevel: (level: TypeLogLevel) => void;
69
+ setLogLevel: (level: TLogLevel) => void;
67
70
  /**
68
- * 写入数据库
71
+ * 设置Log Server服务器地址
69
72
  *
70
- * @param { string } title 日志key
71
- * @param { any } content 日志内容,必须是可序列化的数据
72
- * @param { any } rest 其他内容,同content
73
- * @param { any } nowTime 日志写入时间
73
+ * @public
74
+ * @param { string } logServer Log服务器地址
74
75
  */
75
- putLog: (title: string, content: any, rest: any, nowTime: any) => Promise<void>;
76
+ setLogServer: (logServer: string) => void;
76
77
  /**
77
- * 控制台输出debug信息,并写入日志
78
+ * 控制台输出INFO信息,并写入日志
78
79
  *
79
- * @public
80
80
  * @param { string } title 日志key
81
81
  * @param { any } content 日志内容,必须是可序列化的数据
82
82
  * @param { any[] } rest 其他内容,同content
83
83
  */
84
- debug(title?: string, content?: any, ...rest: any[]): void;
84
+ log(title: string, content?: any, ...rest: any[]): void;
85
85
  /**
86
- * 控制台输出log信息,并写入日志
87
- * 输出 INFO、WARNING、ERROR 级别的日志信息
86
+ * 控制台输出debug信息,并写入日志
88
87
  *
89
88
  * @public
90
89
  * @param { string } title 日志key
91
90
  * @param { any } content 日志内容,必须是可序列化的数据
92
91
  * @param { any[] } rest 其他内容,同content
93
92
  */
94
- log(title: string, content?: any, ...rest: any[]): void;
93
+ debug(title?: string, content?: any, ...rest: any[]): void;
95
94
  /**
96
95
  * 控制台输出warn信息,并写入日志
97
96
  * 输出 WARNING 和 ERROR 级别的日志信息
@@ -101,7 +100,7 @@ declare class Logger {
101
100
  * @param { any } content 日志内容,必须是可序列化的数据
102
101
  * @param { any[] } rest 其他内容,同content
103
102
  */
104
- warn(title: string, content?: any, ...rest: any[]): void;
103
+ warn(title?: string, content?: any, ...rest: any[]): void;
105
104
  /**
106
105
  * 控制台输出error信息,并写入日志
107
106
  * 输出 ERROR 级别的日志信息
@@ -113,39 +112,41 @@ declare class Logger {
113
112
  */
114
113
  error(title: any, content?: any, ...rest: any[]): void;
115
114
  /**
116
- * 允许日志上传
115
+ * 发送日志内容
117
116
  *
118
- * @public
117
+ * @param { any } message - 消息体
118
+ * @returns
119
119
  */
120
- enableLogUpload(): void;
120
+ sendLog(message: any): void;
121
121
  /**
122
- * 禁用日志上传
123
- *
124
- * @public
122
+ * 下载日志数据到本地
125
123
  */
126
- disableLogUpload(): void;
124
+ downloadLog: (fileName?: string | '') => Promise<unknown>;
127
125
  /**
128
- * 下载会议日志数据到本地
126
+ * 上传日志到小鱼Devops平台
129
127
  *
130
- * @public
128
+ * @param { string } name 上传文件名
129
+ * @param { string } account 上传账号
130
+ * @param { string } comments 上传时备注信息
131
+ * @returns { boolean } 上传结果
131
132
  */
132
- downloadLog: () => Promise<void>;
133
+ uploadLog(name?: string, account?: string, comments?: string): Promise<unknown>;
133
134
  /**
134
- * Upload sdk log file to devops
135
+ * 上传日志到小鱼Devops平台
135
136
  *
136
- * @public
137
137
  * @param { string } name 上传文件名
138
138
  * @param { string } account 上传账号
139
139
  * @param { string } comments 上传时备注信息
140
140
  * @returns { boolean } 上传结果
141
141
  */
142
- uploadLog(name?: string, account?: string, comments?: string): Promise<any>;
142
+ uploadLogProcess(config: any, blob: Blob): Promise<any>;
143
143
  /**
144
- * 设置Log Server服务器地址
145
- *
146
- * @public
147
- * @param { string } logServer Log服务器地址
144
+ * 允许日志上传
148
145
  */
149
- setLogServer: (logServer: string) => void;
146
+ enableLogUpload(): void;
147
+ /**
148
+ * 禁用日志上传
149
+ */
150
+ disableLogUpload(): void;
150
151
  }
151
152
  export default Logger;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * XYLink WebRTC SDK Logger Webworker
3
+ *
4
+ * @authors Luo-jinghui (luojinghui424@gmail.com)
5
+ *
6
+ * Created at : 2023-04-24 14:16:27
7
+ * Last modified : 2023-05-17 16:31:59
8
+ */
9
+ declare const _default: {
10
+ new (scriptURL: string | URL, options?: WorkerOptions | undefined): Worker;
11
+ prototype: Worker;
12
+ } & (new () => Worker);
13
+ export default _default;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * WebRTC SDK Quality Manager
3
+ *
4
+ * Created at : 2023-04-27 15:27:15
5
+ * Last modified : 2023-05-18 19:35:24
6
+ */
7
+ import { IInternals, IWorkerVideoReceiver, IVideoReceiverMessage, IQualityConfig } from '../type';
8
+ declare class Quality {
9
+ currentInternals: IInternals;
10
+ nextInternals: IInternals;
11
+ private bytesReceivedSecond;
12
+ private bytesSentSecond;
13
+ private packetsSentSecondSum;
14
+ private packetsSentLostSecondSum;
15
+ private packetsReceivedSecondSum;
16
+ private packetsReceivedLostSecondSum;
17
+ private audioPacketsReceivedSecondSum;
18
+ private audioPacketsReceivedLostSecondSum;
19
+ private videoCodec;
20
+ private audioCodec;
21
+ private bytesSent;
22
+ private bytesReceived;
23
+ private config;
24
+ private currentLogInterval;
25
+ private currentReportInterval;
26
+ private onMessage;
27
+ constructor(onMessage: (eventData: any) => void);
28
+ /**
29
+ * 设置Quality配置
30
+ *
31
+ * @param { IQualityConfig } config - Quality模块配置
32
+ */
33
+ setConfig(config: IQualityConfig): void;
34
+ /**
35
+ * 重置默认数据
36
+ */
37
+ private initInternals;
38
+ /**
39
+ * 第一步:处理视频接收器数据
40
+ *
41
+ * @param { IWorkerVideoReceiver[] } senderStatsList - 原始质量数据
42
+ */
43
+ statsVideoReceiver(data: IVideoReceiverMessage): void;
44
+ /**
45
+ * 第二步:处理音频Audio接收器数据
46
+ *
47
+ * @param { IWorkerVideoReceiver[] } senderStatsList - 原始质量数据
48
+ */
49
+ statsAudioReceiver(receiverList: IWorkerVideoReceiver[]): void;
50
+ /**
51
+ * 第三步:处理音频/视频发送器数据
52
+ *
53
+ * @param { IWorkerVideoReceiver[] } senderStatsList - 原始质量数据
54
+ */
55
+ statsSender(senderStatsList: IWorkerVideoReceiver[]): void;
56
+ /**
57
+ * 通过Worker发送最终的质量统计数据
58
+ */
59
+ private sendInternals;
60
+ /**
61
+ * 计算丢包率
62
+ *
63
+ * @param { number } sum - 包总数
64
+ * @param { number } lost - 丢失包的数量
65
+ * @returns { number } - 丢包率
66
+ */
67
+ private getLost;
68
+ /**
69
+ * 获取sender的发送数据
70
+ *
71
+ * @param { any[] } statsList - RTCStatsReport字典里面所有的统计数据
72
+ * @param { IStreamConfig } streamConfig - 流配置
73
+ * @returns { ISender } - 自定义统计数据内容
74
+ */
75
+ private getSenderStatus;
76
+ /**
77
+ * 获取视频接收质量数据
78
+ *
79
+ * @param { any[] } statsList - RTCStatsReport字典里面所有的统计数据
80
+ * @param { ILayout } layoutItem layout布局数据
81
+ * @returns { IReceiver } 接收端的统计数据
82
+ * @returns { IReceiver }
83
+ */
84
+ private getReceiverStatus;
85
+ /**
86
+ * 计算音频接收质量数据
87
+ *
88
+ * @param { any[] } statsList - RTCStatsReport字典里面所有的统计数据
89
+ * @param { string } trackId - 轨道ID
90
+ * @returns { IReceiver }
91
+ */
92
+ private getReceiverAudioTrackStatus;
93
+ /**
94
+ * 计算音量值, 显示0-100
95
+ *
96
+ * @param { number } audioLevel - 音量数据
97
+ * @returns { number }
98
+ */
99
+ private calcAudioLevel;
100
+ /**
101
+ * 计算速率
102
+ *
103
+ * @private
104
+ * @param { RTCStatsReport } report 上一次RTCStatsReport值
105
+ * @param { string } accumulativeMetric key
106
+ * @param { string } samplesMetric timeLong
107
+ * @param { number } bitsRate bite转换值
108
+ * @param { number } timeRatio 事件单位
109
+ * @param { any } dataOrigin 上一次的数据
110
+ */
111
+ private rateBytesCalculator;
112
+ }
113
+ export default Quality;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * XYLink WebRTC SDK Quality Webworker
3
+ *
4
+ * @authors Luo-jinghui (luojinghui424@gmail.com)
5
+ *
6
+ * Created at : 2023-04-24 14:16:27
7
+ * Last modified : 2023-05-10 18:48:22
8
+ */
9
+ declare const _default: {
10
+ new (scriptURL: string | URL, options?: WorkerOptions | undefined): Worker;
11
+ prototype: Worker;
12
+ } & (new () => Worker);
13
+ export default _default;
@@ -1,10 +1,45 @@
1
- declare type AsyncFn<T> = (...args: any[]) => Promise<T>;
2
- declare type Fn = (...args: any) => void;
1
+ /**
2
+ * XYLink WebRTC SDK Queue Task Lib
3
+ *
4
+ * Created at : 2023-04-19 09:46:28
5
+ * Last modified : 2023-04-25 16:54:44
6
+ */
7
+ type AsyncFn<T> = (...args: any[]) => Promise<T>;
3
8
  declare class Queue<T> {
4
9
  private isRunning;
10
+ private taskCompletedCB;
5
11
  private waitingQueue;
6
12
  constructor();
13
+ /**
14
+ * 监听任务执行完成状态
15
+ *
16
+ * @param { (() => void) | null } callback - 任务结束回调
17
+ */
18
+ onTaskCompleted(callback: () => void): void;
19
+ /**
20
+ * 添加同步任务
21
+ *
22
+ * @param { AsyncFn<T> } task - 同步任务函数
23
+ * @returns { Promise<T> }
24
+ */
7
25
  addTask(task: AsyncFn<T>): Promise<T>;
8
- execute(task: AsyncFn<T>, resolve: Fn, reject: Fn): void;
26
+ /**
27
+ * 执行同步任务队列
28
+ *
29
+ * @param { AsyncFn<T> } task - 同步任务函数
30
+ * @param { Fn } resolve - Resolve函数
31
+ * @param { Fn } reject - Reject函数
32
+ */
33
+ private execute;
34
+ /**
35
+ * 获取执行中的任务数量
36
+ *
37
+ * @returns { number }
38
+ */
39
+ taskLength(): number;
40
+ /**
41
+ * 清空任务队列
42
+ */
43
+ clear(): void;
9
44
  }
10
45
  export default Queue;
@@ -4,7 +4,7 @@
4
4
  * @authors Luo-jinghui (luojinghui424@gmail.com)
5
5
  * @date 2019-10-24 20:41:38
6
6
  */
7
- import { ITypeTemplate, ITemplate, TEMPLATE_TYPE, ITemplateObj } from '../type';
7
+ import { ITypeTemplate, ITemplate, TemplateType, ITemplateObj } from '../type';
8
8
  export declare const RATE = 0.5625;
9
9
  export declare const HIDE_POSITION: number[];
10
10
  export declare const SPEAKER_TEMPLATE: ITypeTemplate;
@@ -15,7 +15,7 @@ export declare const TEMPLATE: ITemplate;
15
15
  /**
16
16
  * forceLayout模版
17
17
  *
18
- * @param { TEMPLATE_TYPE } type - 模版类型
18
+ * @param { TemplateType } type - 模版类型
19
19
  * @returns
20
20
  */
21
- export declare const FORCE_LAYOUT_TEMPLATE: (type: TEMPLATE_TYPE) => ITemplateObj;
21
+ export declare const FORCE_LAYOUT_TEMPLATE: (type: TemplateType) => ITemplateObj;
@@ -62,6 +62,9 @@ export declare const getMeetingStatus: (success: boolean, code?: string, msg?: s
62
62
  };
63
63
  };
64
64
  export declare const hideKeyInfo: (data: any, key: string | string[]) => any;
65
+ /**
66
+ * 判断值类型
67
+ */
65
68
  export declare const TYPEOF: {
66
69
  isNumber(num: any): boolean;
67
70
  isObject(obj: any): boolean;
@@ -69,4 +72,9 @@ export declare const TYPEOF: {
69
72
  isString(str: any): boolean;
70
73
  isBoolean(str: any): boolean;
71
74
  isUndefined(str: any): boolean;
75
+ isLetter(val: any): boolean;
76
+ isChinese(val: any): boolean;
77
+ isNumberText(val: any): boolean;
78
+ isSpecialChar(val: any): boolean;
79
+ isWhiteSpace(val: any): boolean;
72
80
  };
@@ -14,7 +14,7 @@ export interface IStatus {
14
14
  * 国际化,目前只支持 英文、中文、繁体
15
15
  *
16
16
  */
17
- export declare type TLocale = 'en_US' | 'zh_CN' | 'zh_TW';
17
+ export type TLocale = 'en_US' | 'zh_CN' | 'zh_TW';
18
18
  /**
19
19
  * 是否支持入会
20
20
  */
@@ -80,4 +80,4 @@ export interface IReturnResult {
80
80
  msg: string;
81
81
  detail: any;
82
82
  }
83
- export declare type Key = string | number;
83
+ export type Key = string | number;