@xylink/xy-rtc-sdk 3.9.11-private.6 → 4.0.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 (124) hide show
  1. package/README.MD +36 -13
  2. package/lib/action/index.d.ts +106 -36
  3. package/lib/enum/analyser.d.ts +7 -0
  4. package/lib/enum/client.d.ts +8 -2
  5. package/lib/enum/constraints.d.ts +51 -0
  6. package/lib/enum/device.d.ts +28 -0
  7. package/lib/enum/errorCode.d.ts +8 -2
  8. package/lib/enum/i18n.d.ts +6 -0
  9. package/lib/enum/index.d.ts +90 -7
  10. package/lib/enum/meeting.d.ts +4 -0
  11. package/lib/enum/polling.d.ts +2 -11
  12. package/lib/feature/customMessage/index.d.ts +29 -0
  13. package/lib/feature/edu/index.d.ts +34 -0
  14. package/lib/feature/edu/index.type.d.ts +29 -0
  15. package/lib/feature/index.d.ts +3 -0
  16. package/lib/feature/speaker/index.d.ts +81 -0
  17. package/lib/feature/speaker/index.type.d.ts +17 -0
  18. package/lib/index.d.ts +84 -31
  19. package/lib/interface/baseModule.type.d.ts +9 -0
  20. package/lib/interface/clientInterface.type.d.ts +128 -0
  21. package/lib/interface/contentTrackInterface.type.d.ts +15 -0
  22. package/lib/interface/event.type.d.ts +444 -0
  23. package/lib/interface/videoAudioTrackInterface.type.d.ts +17 -0
  24. package/lib/main/ability/const.d.ts +5 -0
  25. package/lib/main/ability/index.d.ts +37 -0
  26. package/lib/main/{iauth.d.ts → auth/index.d.ts} +34 -26
  27. package/lib/main/client.d.ts +643 -637
  28. package/lib/main/clientBase.d.ts +40 -0
  29. package/lib/main/clientState.d.ts +56 -0
  30. package/lib/main/device/index.d.ts +272 -0
  31. package/lib/main/device/index.type.d.ts +204 -0
  32. package/lib/main/helper/index.d.ts +118 -0
  33. package/lib/main/helper/index.type.d.ts +12 -0
  34. package/lib/main/layout/index.d.ts +74 -108
  35. package/lib/main/layout/index.type.d.ts +282 -0
  36. package/lib/main/layout/polling.d.ts +17 -13
  37. package/lib/main/layout/state.d.ts +163 -0
  38. package/lib/main/layout/template.d.ts +3 -3
  39. package/lib/main/media/index.d.ts +177 -0
  40. package/lib/main/media/index.type.d.ts +29 -0
  41. package/lib/main/meeting/control.d.ts +107 -0
  42. package/lib/main/meeting/control.type.d.ts +24 -0
  43. package/lib/main/{meeting.d.ts → meeting/index.d.ts} +58 -28
  44. package/lib/main/meeting/verify.d.ts +70 -0
  45. package/lib/main/meeting/verify.type.d.ts +12 -0
  46. package/lib/main/peer.d.ts +67 -19
  47. package/lib/main/plugin/index.d.ts +28 -0
  48. package/lib/{tools/quality.d.ts → main/quality/index.d.ts} +2 -2
  49. package/lib/{tools → main/quality}/quality.worker.d.ts +1 -1
  50. package/lib/main/{qualityManager.d.ts → quality/report.d.ts} +11 -5
  51. package/lib/main/render/index.d.ts +116 -0
  52. package/lib/main/render/index.type.d.ts +36 -0
  53. package/lib/main/render/videoManager.d.ts +190 -0
  54. package/lib/main/render/videoManager.type.d.ts +66 -0
  55. package/lib/main/roster/index.d.ts +39 -0
  56. package/lib/main/server/index.d.ts +79 -0
  57. package/lib/main/server/index.type.d.ts +21 -0
  58. package/lib/main/signal/index.d.ts +15 -0
  59. package/lib/main/socket/index.d.ts +95 -0
  60. package/lib/main/stream/index.d.ts +182 -0
  61. package/lib/main/track/baseTrack.d.ts +178 -0
  62. package/lib/main/track/contentTrack.d.ts +168 -0
  63. package/lib/main/track/customContentTrack.d.ts +18 -0
  64. package/lib/main/track/customVideoAudioTrack.d.ts +18 -0
  65. package/lib/main/track/helper.d.ts +53 -0
  66. package/lib/main/track/videoAudioCapture.d.ts +90 -0
  67. package/lib/main/track/videoAudioTrack.d.ts +273 -0
  68. package/lib/main/vom/index.d.ts +44 -0
  69. package/lib/main/vom/index.type.d.ts +1 -0
  70. package/lib/tools/analyser.d.ts +53 -0
  71. package/lib/tools/analyserManager.d.ts +55 -0
  72. package/lib/tools/dbManager.d.ts +12 -1
  73. package/lib/tools/{browser.d.ts → detectBrowser/index.d.ts} +53 -5
  74. package/lib/tools/detectStream/index.d.ts +84 -0
  75. package/lib/tools/detectStream/index.type.d.ts +56 -0
  76. package/lib/tools/detectTool/index.d.ts +191 -0
  77. package/lib/tools/detectTool/index.type.d.ts +51 -0
  78. package/lib/tools/emitter.d.ts +27 -6
  79. package/lib/tools/enum.d.ts +1 -1
  80. package/lib/tools/httpClient.d.ts +23 -6
  81. package/lib/tools/i18n.d.ts +1 -1
  82. package/lib/tools/index.d.ts +5 -5
  83. package/lib/tools/{logger.d.ts → log/logger.d.ts} +59 -29
  84. package/lib/tools/{logger.worker.d.ts → log/logger.worker.d.ts} +1 -1
  85. package/lib/tools/log/loggerManager.d.ts +70 -0
  86. package/lib/tools/pressure/index.d.ts +33 -0
  87. package/lib/tools/pressure/index.type.d.ts +22 -0
  88. package/lib/tools/promiseQueue.d.ts +51 -0
  89. package/lib/tools/queue.d.ts +12 -15
  90. package/lib/tools/resize.d.ts +65 -0
  91. package/lib/tools/snapshot.d.ts +31 -0
  92. package/lib/tools/socket.d.ts +109 -32
  93. package/lib/tools/template/index.d.ts +3 -3
  94. package/lib/tools/template/mobile.d.ts +1 -1
  95. package/lib/tools/template/polling.d.ts +1 -1
  96. package/lib/tools/utils.d.ts +22 -19
  97. package/lib/tools/verify.d.ts +7 -0
  98. package/lib/type/ability.d.ts +25 -0
  99. package/lib/type/analyser.d.ts +43 -0
  100. package/lib/type/{iauth.d.ts → auth.d.ts} +22 -29
  101. package/lib/type/base.d.ts +41 -33
  102. package/lib/type/capture.d.ts +9 -0
  103. package/lib/type/client.d.ts +404 -498
  104. package/lib/type/index.d.ts +26 -2
  105. package/lib/type/layout.d.ts +25 -49
  106. package/lib/type/logger.d.ts +37 -12
  107. package/lib/type/meeting.d.ts +266 -27
  108. package/lib/type/peer.d.ts +24 -1
  109. package/lib/type/polling.d.ts +1 -49
  110. package/lib/type/quality.d.ts +16 -6
  111. package/lib/type/socket.d.ts +42 -0
  112. package/lib/type/stream.d.ts +154 -116
  113. package/lib/type/track.d.ts +139 -0
  114. package/lib/xyrtc.cjs.js +1 -1
  115. package/lib/xyrtc.umd.js +1 -1
  116. package/package.json +11 -3
  117. package/lib/enum/contraints.d.ts +0 -50
  118. package/lib/main/deviceManager.d.ts +0 -185
  119. package/lib/main/helper.d.ts +0 -79
  120. package/lib/main/stream.d.ts +0 -396
  121. package/lib/main/videoManager.d.ts +0 -57
  122. package/lib/tools/audioLevel.d.ts +0 -23
  123. package/lib/tools/detect.d.ts +0 -43
  124. package/lib/type/device.d.ts +0 -83
@@ -0,0 +1,70 @@
1
+ /**
2
+ * 校验模块,包含校验会议、会议密码等
3
+ *
4
+ * Created at : 2024-05-13 14:43:44
5
+ * Last modified : 2024-07-12 16:03:31
6
+ */
7
+ import { IReturnResult, XYBaseModule, XYCheckNumberParams } from '../../type/index';
8
+ import XYRTCClient from '../client';
9
+ export declare class Verify implements XYBaseModule {
10
+ private client;
11
+ private logger;
12
+ private action;
13
+ private meetingVerified;
14
+ constructor(client: XYRTCClient);
15
+ destroy(): void;
16
+ /**
17
+ * 校验会议室号
18
+ *
19
+ * @private
20
+ * @param { XYCheckNumberParams } params - 校验会议号参数
21
+ * @property { string } confNumber - 会议号
22
+ * @property { string } password - 会议密码
23
+ * @returns { Promise<IReturnResult> } - 结果
24
+ */
25
+ checkMeetingNumber(params: XYCheckNumberParams): Promise<IReturnResult>;
26
+ /**
27
+ * 校验会议室密码
28
+ *
29
+ * @param { XYCheckNumberParams } params - 呼叫的会议信息
30
+ * @property { string } params.confNumber - 会议号
31
+ * @property { string } params.password - 会议密码
32
+ * @returns { Promise<IReturnResult> } - 结果
33
+ */
34
+ checkMeetingPassword(params: XYCheckNumberParams): Promise<IReturnResult>;
35
+ /**
36
+ * 检查会议室类型是否支持
37
+ *
38
+ * @param { string } deviceType - 会议室类型
39
+ * @returns { boolean } - 是否支持呼叫
40
+ */
41
+ private isSupportedCall;
42
+ /**
43
+ * 处理密码验证逻辑
44
+ *
45
+ * @param { string } confNumber - 会议号
46
+ * @param { string } password - 密码
47
+ * @param { string | number } hideId - 是否是隐身入会模式
48
+ * @returns
49
+ */
50
+ private handlePasswordValidation;
51
+ /**
52
+ * 完成会议室校验,上报会议室信息
53
+ *
54
+ * @returns { Promise<IReturnResult> } - 校验结果
55
+ */
56
+ private completeMeetingVerify;
57
+ /**
58
+ * 校验会议室前置任务
59
+ *
60
+ * @returns { Promise<IReturnResult> } - 校验结果
61
+ */
62
+ private preVerifyTasks;
63
+ /**
64
+ * 校验会控主持密码
65
+ *
66
+ * @param { string } pwd - 会控密码
67
+ * @returns { Promise<IReturnResult> } - 校验结果
68
+ */
69
+ verifyControlPassword(pwd: string): Promise<IReturnResult>;
70
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 会议号和密码参数
3
+ *
4
+ * @param { string } confNumber - 必填,会议号
5
+ * @param { string } password - 可选,会议入会密码
6
+ * @param { string } __hideId - 可选,隐身ID
7
+ */
8
+ export interface XYCheckNumberParams {
9
+ confNumber: string;
10
+ password?: string;
11
+ __hideId?: string | number | undefined;
12
+ }
@@ -4,14 +4,13 @@
4
4
  * @authors Luo-jinghui (luojinghui424@gmail.com)
5
5
  * @date 2019-10-25 18:53:01
6
6
  */
7
- import { IInvite, IStreamSender, ICandidate, PushType, ISenderMap, PeerState, ICEState } from '../type';
7
+ import { IStreamSender, ICandidate, PushType, ISenderMap, PeerState, ICEState } from '../type/index';
8
8
  import Client from './client';
9
- import Logger from '../tools/logger';
10
- import Stream from './stream';
9
+ import Logger from '../tools/log/logger';
10
+ import VideoAudioTrack from './track/videoAudioTrack';
11
+ import ContentTrack from './track/contentTrack';
11
12
  /**
12
- * Peer模块,用于管理 P2P 连接和内部事件
13
- *
14
- * @class Peer
13
+ * Peer模块,用于管理 P2S 连接和内部事件
15
14
  */
16
15
  export default class Peer {
17
16
  private connectTimer;
@@ -19,12 +18,10 @@ export default class Peer {
19
18
  client: Client;
20
19
  peerConnection: RTCPeerConnection | null;
21
20
  logger: Logger;
22
- invite: IInvite;
23
21
  connectState: {
24
22
  peer: PeerState;
25
23
  ice: ICEState;
26
24
  };
27
- stream: Stream;
28
25
  streamSenders: IStreamSender[];
29
26
  senderMap: ISenderMap;
30
27
  private senderTimer;
@@ -36,8 +33,12 @@ export default class Peer {
36
33
  private firstCallState;
37
34
  private peerCallState;
38
35
  private isReceivedTrackMsg;
36
+ private isCreatedOffer;
37
+ private isReceivedAnswer;
38
+ private contentTrackSize;
39
39
  private detectTrackMsgTimer;
40
- constructor(client: Client, stream: Stream, isRenew?: boolean);
40
+ private candidateList;
41
+ constructor(client: Client, isRenew?: boolean);
41
42
  /**
42
43
  * 初始化质量统计WebWorker模块
43
44
  */
@@ -46,20 +47,24 @@ export default class Peer {
46
47
  * 初始化Peer模块
47
48
  * 1. 创建PeerConnection
48
49
  * 2. 初始化监听事件
49
- *
50
- * @private
51
50
  */
52
51
  private init;
53
52
  /**
54
53
  * 向Client发送消息
55
54
  *
56
55
  * @private
57
- * @param { string } type 消息Key
58
- * @param { string } code 状态码
59
- * @param { string } msg 消息内容
60
- * @param { any } detail 消息数据
56
+ * @param { XYClientEventKey } type - 消息Key
57
+ * @param { string } code - 状态码
58
+ * @param { string } msg - 消息内容
59
+ * @param { any } detail - 消息数据
61
60
  */
62
61
  private sendEmmit;
62
+ /**
63
+ * 获取Peer是否连接成功
64
+ *
65
+ * @returns { boolean } - 是否连接成功
66
+ */
67
+ getPeerConnectionStatus(): boolean;
63
68
  /**
64
69
  * 停止状态检查定时器,重置重连状态
65
70
  */
@@ -79,12 +84,26 @@ export default class Peer {
79
84
  * 监听peer连接状态,Timeout:40s
80
85
  */
81
86
  private initTimer;
87
+ /**
88
+ * 处理各种与媒体协商失败报错异常
89
+ * 处理方式:上报结果并退会
90
+ *
91
+ * @param { string } code - 错误码
92
+ */
93
+ private handlePeerConnectError;
82
94
  /**
83
95
  * ice协商回调事件
84
96
  *
85
97
  * @private
86
98
  */
87
99
  private onHandleNegotiationNeeded;
100
+ /**
101
+ * 修改SDP内容
102
+ *
103
+ * @param { string } sdp - offer sdp报文信息
104
+ * @returns { string } - 修改后的报文
105
+ */
106
+ private appendExtmap;
88
107
  /**
89
108
  * 创建offer,并针对stream设置初始带宽
90
109
  *
@@ -105,11 +124,17 @@ export default class Peer {
105
124
  * 处理candidate消息
106
125
  *
107
126
  * @public
108
- * @param { ICandidate } body candidate消息内容
127
+ * @param { ICandidate } body - candidate消息内容
109
128
  */
110
129
  handleCandidate(body: ICandidate): Promise<void>;
111
130
  /**
112
- * 响应offer
131
+ * 缓存协商的Candidate节点信息
132
+ *
133
+ * @param { string } candidate - ICE Candidate协商节点信息
134
+ */
135
+ private cacheCandidateData;
136
+ /**
137
+ * 响应Answer
113
138
  *
114
139
  * @public
115
140
  * @param { RTCSessionDescriptionInit } answer answerSDP内容,设置到peerConnection上
@@ -141,8 +166,21 @@ export default class Peer {
141
166
  * @param { Event } e - ICE状态回调事件
142
167
  */
143
168
  private onHandleConnectionStateChange;
169
+ /**
170
+ * 统一处理WebRTC PeerConnection连接状态事件
171
+ */
144
172
  private peerStateChange;
173
+ /**
174
+ * WebRTC ICE探测错误事件监听
175
+ *
176
+ * @param { Event } e - 错误信息
177
+ */
145
178
  onHandleIcecandidateerror(e: Event): void;
179
+ /**
180
+ * WebRTC ICE协商事件
181
+ *
182
+ * @param { any } ice - ICE报文
183
+ */
146
184
  private onHandleIcecandidate;
147
185
  /**
148
186
  * Peer已经连接成功
@@ -159,7 +197,7 @@ export default class Peer {
159
197
  /**
160
198
  * 关闭PeerConnection连接、销毁状态
161
199
  */
162
- close(): void;
200
+ destroy(): void;
163
201
  /**
164
202
  * Push people and content tracks of stream
165
203
  *
@@ -167,7 +205,7 @@ export default class Peer {
167
205
  * @param { Stream } stream - Stream Library
168
206
  * @param { PushType } pushType - 推送类型,All全推送、Video只推送video、Audio只推送audio、Content只推送content video流
169
207
  */
170
- publish(stream: Stream, pushType: PushType): void;
208
+ publish(track: VideoAudioTrack | ContentTrack, pushType: PushType): void;
171
209
  /**
172
210
  * people and content sender status
173
211
  *
@@ -219,6 +257,16 @@ export default class Peer {
219
257
  * @param { RTCRtpTransceiverDirection } direction 指定添加到peer上的方向
220
258
  */
221
259
  private streamConfigProcessor;
260
+ /**
261
+ * 计算一组StreamConfig中Track面积最小的尺寸信息
262
+ *
263
+ * @param { IStreamConfig[] } streamConfigList - An array of `IStreamConfig` objects
264
+ */
265
+ private calculateContentTrackSize;
266
+ /**
267
+ * 重置ContentTrack尺寸信息
268
+ */
269
+ resetContentTrackSize(): void;
222
270
  /**
223
271
  * 添加Track轨道数据
224
272
  *
@@ -0,0 +1,28 @@
1
+ /**
2
+ * WebRTC SDK AI Plugin Lib
3
+ *
4
+ * Created at : 2024-05-14 14:54:33
5
+ * Last modified : 2024-05-14 15:21:59
6
+ */
7
+ import XYRTCClient from '../client';
8
+ import { XYBaseModule } from '../../type/index';
9
+ export declare class XYPlugin implements XYBaseModule {
10
+ private logger;
11
+ private plugin;
12
+ constructor(client: XYRTCClient);
13
+ /**
14
+ * 获取所有可用的插件
15
+ * @returns { array } - 插件列表
16
+ */
17
+ getPlugin(): any[];
18
+ /**
19
+ * 销毁插件
20
+ */
21
+ destroy(): void;
22
+ /**
23
+ * 注册Web AI插件
24
+ *
25
+ * @param { Array } plugins - 插件列表
26
+ */
27
+ registerPlugins(plugins: any[]): void;
28
+ }
@@ -2,9 +2,9 @@
2
2
  * WebRTC SDK Quality Manager
3
3
  *
4
4
  * Created at : 2023-04-27 15:27:15
5
- * Last modified : 2024-03-06 11:33:44
5
+ * Last modified : 2024-04-23 19:03:09
6
6
  */
7
- import { IInternals, IWorkerVideoReceiver, IVideoReceiverMessage, IQualityConfig } from '../type';
7
+ import { IInternals, IWorkerVideoReceiver, IVideoReceiverMessage, IQualityConfig } from '../../type/index';
8
8
  declare class Quality {
9
9
  currentInternals: IInternals;
10
10
  nextInternals: IInternals;
@@ -4,7 +4,7 @@
4
4
  * @authors Luo-jinghui (luojinghui424@gmail.com)
5
5
  *
6
6
  * Created at : 2023-04-24 14:16:27
7
- * Last modified : 2023-05-10 18:48:22
7
+ * Last modified : 2024-06-06 16:01:56
8
8
  */
9
9
  declare const _default: {
10
10
  new (scriptURL: string | URL, options?: WorkerOptions | undefined): Worker;
@@ -1,6 +1,6 @@
1
- import Client from './client';
2
- import { IConfInfo, IInternals } from '../type';
3
- declare class QualityManager {
1
+ import Client from '../client';
2
+ import { IConfInfo, IInternals, XYBaseModule } from '../../type/index';
3
+ declare class XYQualityReport implements XYBaseModule {
4
4
  private client;
5
5
  private reportDataTime;
6
6
  private meetingQualityData;
@@ -30,7 +30,7 @@ declare class QualityManager {
30
30
  *
31
31
  * @private
32
32
  */
33
- stopReportData(): void;
33
+ destroy(): void;
34
34
  /**
35
35
  * 清除网络信号统计定时器
36
36
  *
@@ -65,5 +65,11 @@ declare class QualityManager {
65
65
  * @returns { number } level 计算得到的网络信号等级
66
66
  */
67
67
  private calcNetQualityLevel;
68
+ /**
69
+ * Internals统计数据-期望带宽
70
+ *
71
+ * @param { IInternals } internals - 统计数据
72
+ */
73
+ getNewInternals(internals: IInternals): IInternals;
68
74
  }
69
- export default QualityManager;
75
+ export default XYQualityReport;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * XY WebRTC SDK Render Manager
3
+ *
4
+ * Created at : 2024-05-14 16:46:01
5
+ * Last modified : 2024-07-09 19:38:25
6
+ */
7
+ import XYRTCClient from '../client';
8
+ import VideoManager from './videoManager';
9
+ import { IAudioRenders, XYVideoRendererMap, XYBaseModule } from '../../type/index';
10
+ export declare class XYRender implements XYBaseModule {
11
+ private client;
12
+ private logger;
13
+ private slaveVideoManagers;
14
+ private audioManagers;
15
+ private videoManagerMap;
16
+ constructor(client: XYRTCClient);
17
+ getVideoManagerMap(): XYVideoRendererMap;
18
+ getAudioManagers(): IAudioRenders;
19
+ destroy(): void;
20
+ /**
21
+ * 设置画面渲染元素并播放Video画面
22
+ *
23
+ * @param { string } id - 参会者Layout Id
24
+ * @param { string } wrapEleId - 包裹video组件的容器ID字段
25
+ */
26
+ setVideoRenderer(id: string, wrapEleId: string): void;
27
+ /**
28
+ * 设置画面渲染元素并播放Video画面
29
+ *
30
+ * @param { string } layoutId - 参会者Layout Id
31
+ * @param { string } wrapEleId - 包裹video组件的容器ID字段
32
+ */
33
+ setSlaveVideoRenderer(layoutId: string, wrapEleId: string): import("../../type/index").IReturnResult;
34
+ /**
35
+ * videoManagers 移除key对应的元素
36
+ *
37
+ * @param { string } id - 参会者Layout Id
38
+ */
39
+ removeVideoRenderer(id: string): void;
40
+ /**
41
+ * 【副屏渲染】移除副屏渲染信息
42
+ * 如果layoutId和viewId没有填写,则清空所有的副屏渲染配置数据
43
+ *
44
+ * @param { string } rosterId - 参会者Layout Id
45
+ * @param { string } viewId 包裹video组件的元素id,此元素一定要提供宽高信息,内部会基于此宽高信息计算video的旋转信息
46
+ */
47
+ removeSlaveVideoRenderer(layoutId?: string, viewId?: string): void;
48
+ /**
49
+ * 重新播放Video画面组件
50
+ *
51
+ * @param { string[]? } idList - Layout Id 列表,如果为空值,则播放所有画面
52
+ */
53
+ playVideo(idList?: string[]): Promise<void>;
54
+ /**
55
+ * 播放本地视频
56
+ */
57
+ playLocalVideo(): Promise<void>;
58
+ /**
59
+ * 重新播放音频
60
+ */
61
+ playAudio(): Promise<void>;
62
+ /**
63
+ * 提供Audio元素信息,用于播放音频流
64
+ *
65
+ * @param { string } streamId - mediaStream流ID
66
+ * @param { HTMLAudioElement } ele - audio元素
67
+ */
68
+ setAudioRenderer(streamId: string, ele: HTMLAudioElement): Promise<void>;
69
+ /**
70
+ * 移除对应的AudioRender
71
+ *
72
+ * @param { string } id - MediaStream的Id字段
73
+ */
74
+ removeAudioRender(key: string): void;
75
+ /**
76
+ * Video组件状态变更回调事件
77
+ *
78
+ * @param { string } id - 参会者Layout Id
79
+ */
80
+ private onVideoStatusChange;
81
+ /**
82
+ * Video组件播放错误回调事件
83
+ *
84
+ * @param { string } id - 参会者Layout Id
85
+ * @param { Error } data - 播放错误数据
86
+ */
87
+ private onVideoPlayError;
88
+ /**
89
+ * 更新本地LocalTrack状态
90
+ *
91
+ * @param { string } id - Layout Id
92
+ */
93
+ updateLocalTrack(id: string): void;
94
+ /**
95
+ * 通过Layout ID创建并获取Video管理器
96
+ *
97
+ * @param { string } id - Layout Id
98
+ * @param { boolean } isContent - 是否是Content内容
99
+ * @return { VideoManager } - 视频管理器
100
+ */
101
+ getVideoManagerById(id: string, isContent: boolean): VideoManager;
102
+ /**
103
+ * 清理失效的 video manager 数据
104
+ */
105
+ clearInvalidVideoManagers(): void;
106
+ /**
107
+ * 【内部方法】停止轮询时,清理无效的 videoManager 数据
108
+ *
109
+ * @param { string[] } monitoryList - callUri list 数据
110
+ */
111
+ clearVideoManagersUseMonitorList(monitoryList: string[]): void;
112
+ /**
113
+ * 清楚所有的音频管理器
114
+ */
115
+ private clearAudioManagers;
116
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * XYRender Lib Type Defined
3
+ *
4
+ * Created at : 2024-06-04 11:51:02
5
+ * Last modified : 2024-06-04 16:00:23
6
+ */
7
+ import VideoManager from '../render/videoManager';
8
+ export type XYVideoRendererMap = Map<string, VideoManager>;
9
+ export type IAudioRenders = {
10
+ [key: string]: {
11
+ ele: any;
12
+ };
13
+ };
14
+ /**
15
+ * 管理所有的Video Managers
16
+ *
17
+ * @param { string } obj.key - Layout Id,参会者唯一ID
18
+ * @param { VideoManager } obj.value - VideoManager模块
19
+ */
20
+ export type IVideoRenders = {
21
+ [key: string]: VideoManager & {
22
+ match?: boolean;
23
+ };
24
+ };
25
+ /**
26
+ * 音视频播放异常信息
27
+ *
28
+ * @param { 'video' | 'audio' } type - 媒体类型
29
+ * @param { string } key - 关键ID信息,可能是layoutId或者streamId
30
+ * @param { any } error - 详细错误信息
31
+ */
32
+ export interface XYPlayFailedInfo {
33
+ type: 'video' | 'audio';
34
+ key: string;
35
+ error: any;
36
+ }
@@ -0,0 +1,190 @@
1
+ /**
2
+ * XYLink WebRTC Video Manager Lib
3
+ *
4
+ * Created at : 2020-12-18 16:54:15
5
+ * Last modified : 2024-06-05 18:14:48
6
+ */
7
+ import Logger from '../../tools/log/logger';
8
+ import { IRotationInfoTotalItem, XYVideoState, XYLayoutState, ILayout, XYLayoutStateResult } from '../../type/index';
9
+ declare class VideoManager {
10
+ private logger;
11
+ private key;
12
+ private wrapEleId;
13
+ videoEle: HTMLVideoElement | null;
14
+ videoState: XYVideoState;
15
+ private loadState;
16
+ private streamState;
17
+ private layoutState;
18
+ private stream;
19
+ private streamId;
20
+ private streamTimerCountDown;
21
+ private isContent;
22
+ private isMatch;
23
+ private cacheLayout;
24
+ private isNormalPlay;
25
+ private streamStatusTimer;
26
+ private videoStateChangeCallBack;
27
+ private videoPlayErrorCallBack;
28
+ constructor(logger?: Logger, isContent?: boolean);
29
+ getLayoutState(): XYLayoutState;
30
+ getIsMatch(): boolean;
31
+ /**
32
+ * 切换是否处理当前数据
33
+ *
34
+ * @param { boolean } is - 真假值
35
+ * @returns { boolean } - 结果
36
+ */
37
+ setIsMatch(is: boolean): boolean;
38
+ /**
39
+ * 设置当前Video对应的MediaStream流
40
+ *
41
+ * @param { string } key - 参会者唯一ID,由layout中的id得到
42
+ * @param { MediaStream | null } stream - MediaStream or null
43
+ */
44
+ setVideoMediaStream(key: string, stream: MediaStream | null): void;
45
+ /**
46
+ * 【副流渲染】绑定Stream数据
47
+ *
48
+ * @param { MediaStream | null } stream - MediaStream or null
49
+ */
50
+ setSlaveVideoStream(stream: MediaStream | null): Promise<void>;
51
+ /**
52
+ * 获取MediaStream流上的所有Track数据
53
+ *
54
+ * @returns { MediaStreamTrack[] } - 轨道数据
55
+ */
56
+ getVideoTracks(): MediaStreamTrack[];
57
+ /**
58
+ * 重新绑定Track Event事件监听,发送最新的视频状态
59
+ */
60
+ updateLocalTrack(): void;
61
+ /**
62
+ * 【副流渲染】计算新容器Video的旋转角度和宽高信息
63
+ *
64
+ * @param { IRotationInfoTotalItem | undefined } rotateInfo - RotationInfo信息
65
+ * @param { boolean } isLocal - 是否是Local设备
66
+ * @param { boolean | undefined } localMirror - 是否是本地镜像设置
67
+ */
68
+ setVideoRotationStyle(rotateInfo: IRotationInfoTotalItem | undefined, isLocal: boolean, localMirror: boolean | undefined): void;
69
+ /**
70
+ * 绑定视频渲染容器,增加事件监听,并通过Video元素播放最新的MediaStream数据
71
+ *
72
+ * @param { string } viewId 包裹video组件的元素id,此元素一定要提供宽高信息,内部会基于此宽高信息计算video的旋转信息
73
+ */
74
+ private initVideoSource;
75
+ /**
76
+ * 创建Video元素
77
+ *
78
+ * @param { HTMLElement } container - 容器节点信息
79
+ * @returns { HTMLVideoElement }
80
+ */
81
+ private createVideoElement;
82
+ /**
83
+ * 绑定Video元素的视频流数据,并播放
84
+ *
85
+ * @param { string } streamId - MediaStream Id数据
86
+ */
87
+ private setSrcObject;
88
+ /**
89
+ * 初始化Video元素播放事件
90
+ *
91
+ * @param { HTMLVideoElement } videoEle - video元素
92
+ */
93
+ private initEventListener;
94
+ /**
95
+ * 移除绑定Video事件
96
+ *
97
+ * @param { HTMLVideoElement } videoEle - Video元素
98
+ */
99
+ private removeEventListener;
100
+ /**
101
+ * 绑定Track事件
102
+ *
103
+ * @param { MediaStream | null } stream - 流数据
104
+ */
105
+ private initStreamTrackEventListener;
106
+ /**
107
+ * 移除绑定Track事件
108
+ */
109
+ private removeStreamTrackEventListener;
110
+ /**
111
+ * Video元素是否绑定Stream数据
112
+ *
113
+ * @returns { boolean }
114
+ */
115
+ private isHaveSrcObject;
116
+ /**
117
+ *
118
+ * 设置用户信息和渲染画面的视图信息,创建Video元素用于渲染画面
119
+ *
120
+ * @param { string } id - 用户唯一ID,通过layout事件获取
121
+ * @param { string } wrapEleId - 渲染画面的视图容器ID
122
+ */
123
+ setSource(id: string, wrapEleId: string): void;
124
+ /**
125
+ * 【副流渲染】设置用户信息和渲染画面的视图信息,创建Video元素用于渲染画面
126
+ *
127
+ * @param { string } id - 用户唯一ID,通过layout事件获取
128
+ * @param { string } viewId - 渲染画面的视图容器ID
129
+ */
130
+ setSlaveSource(id: string, viewId: string): void;
131
+ /**
132
+ * 销毁当前实例数据
133
+ */
134
+ destroy(): void;
135
+ /**
136
+ * 设置Video状态变更回调函数
137
+ *
138
+ * @param { function } cb - 事件回调函数
139
+ */
140
+ setVideoStatusChange(cb: (key: string) => void): void;
141
+ /**
142
+ * 设置Video播放失败回调函数
143
+ *
144
+ * @param { function } cb - 事件回调函数
145
+ */
146
+ setVideoPlayError(cb: <T>(key: string, data: T) => void): void;
147
+ /**
148
+ * MediaStreamTrack结束事件
149
+ */
150
+ private onEnded;
151
+ /**
152
+ * MediaStreamTrack无流事件
153
+ * mute到unmute的变换可能会很迅速,所以3s以内的变换可以使用freeze替代
154
+ */
155
+ private onMute;
156
+ /**
157
+ * MediaStreamTrack有流事件
158
+ */
159
+ private onUnmute;
160
+ /**
161
+ * video元素加载流事件
162
+ */
163
+ private onWaiting;
164
+ /**
165
+ * video元素可以播放事件
166
+ */
167
+ private onCanPlay;
168
+ /**
169
+ * 清理定时器
170
+ */
171
+ private clearTrackStatusTimer;
172
+ /**
173
+ * 发送Video状态变更事件
174
+ */
175
+ private sendVideoStatus;
176
+ /**
177
+ * 合并计算最新的Layout显示状态
178
+ *
179
+ * @param { ILayout } layout - 当前Layout Item数据
180
+ * @returns { XYLayoutState } - 最新的Layout状态
181
+ */
182
+ calculateLayoutState(layout?: ILayout): XYLayoutStateResult;
183
+ /**
184
+ * 推送VM事件消息
185
+ *
186
+ * @param { string } key - 事件Key
187
+ */
188
+ private emmit;
189
+ }
190
+ export default VideoManager;