@xylink/xy-rtc-sdk 4.0.3 → 4.0.5

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 (148) hide show
  1. package/action/ability.d.ts +0 -1
  2. package/action/api.d.ts +15 -1
  3. package/action/auth.d.ts +3 -4
  4. package/action/base.d.ts +2 -3
  5. package/action/config.d.ts +2 -3
  6. package/action/control.d.ts +3 -4
  7. package/action/enterprise.d.ts +4 -5
  8. package/action/http.d.ts +2 -3
  9. package/action/index.d.ts +9 -10
  10. package/action/index.type.d.ts +0 -1
  11. package/action/log.d.ts +1 -2
  12. package/action/meeting.d.ts +17 -4
  13. package/enum/client.d.ts +0 -1
  14. package/enum/constraints.d.ts +0 -1
  15. package/enum/errorCode/server.d.ts +0 -1
  16. package/enum/errorCode/signal.d.ts +0 -1
  17. package/enum/index.d.ts +8 -1
  18. package/enum/meeting.d.ts +0 -1
  19. package/enum/polling.d.ts +0 -1
  20. package/export/tools.d.ts +17 -0
  21. package/feature/artboard/index.d.ts +10 -4
  22. package/feature/audioPCM/index.d.ts +29 -0
  23. package/feature/contentPreserver/index.d.ts +38 -0
  24. package/feature/customMessage/index.d.ts +1 -2
  25. package/feature/edu/index.d.ts +1 -2
  26. package/feature/edu/index.type.d.ts +0 -1
  27. package/feature/im/index.d.ts +2 -3
  28. package/feature/query/index.d.ts +2 -3
  29. package/feature/speaker/index.d.ts +2 -3
  30. package/feature/speaker/index.type.d.ts +0 -1
  31. package/feature/translation/index.d.ts +34 -0
  32. package/feature/vep/index.d.ts +56 -0
  33. package/feature/vep/index.type.d.ts +139 -0
  34. package/index.d.ts +11 -9
  35. package/interface/clientInterface.type.d.ts +11 -12
  36. package/interface/contentTrackInterface.type.d.ts +0 -1
  37. package/interface/event.type.d.ts +10 -2
  38. package/interface/extension.type.d.ts +10 -0
  39. package/interface/processor.type.d.ts +9 -0
  40. package/interface/videoAudioTrackInterface.type.d.ts +2 -3
  41. package/main/ability/const.d.ts +0 -1
  42. package/main/ability/index.d.ts +1 -2
  43. package/main/auth/index.d.ts +9 -17
  44. package/main/auth/index.type.d.ts +0 -1
  45. package/main/auth/rule.d.ts +9 -0
  46. package/main/client/clientBase.d.ts +10 -3
  47. package/main/client/clientState.d.ts +1 -2
  48. package/main/client/index.d.ts +66 -47
  49. package/main/client/rule.d.ts +19 -0
  50. package/main/device/index.d.ts +12 -5
  51. package/main/device/index.type.d.ts +22 -0
  52. package/main/helper/i18n.d.ts +0 -1
  53. package/main/helper/index.d.ts +9 -2
  54. package/main/layout/index.d.ts +11 -5
  55. package/main/layout/index.type.d.ts +2 -3
  56. package/main/layout/polling.d.ts +2 -3
  57. package/main/layout/state.d.ts +3 -4
  58. package/main/layout/template/index.d.ts +0 -1
  59. package/main/layout/template/manager.d.ts +0 -1
  60. package/main/layout/template/mobile.d.ts +0 -1
  61. package/main/layout/template/polling.d.ts +0 -1
  62. package/main/media/index.d.ts +4 -5
  63. package/main/media/index.type.d.ts +0 -1
  64. package/main/meeting/control.d.ts +1 -2
  65. package/main/meeting/control.type.d.ts +0 -1
  66. package/main/meeting/index.d.ts +8 -3
  67. package/main/meeting/rule.d.ts +3 -0
  68. package/main/meeting/verify.d.ts +1 -2
  69. package/main/peer/index.d.ts +37 -9
  70. package/main/peer/index.type.d.ts +24 -1
  71. package/main/peer/state.d.ts +4 -0
  72. package/main/plugin/audioPCM/audio-processor.worklet.d.ts +1 -0
  73. package/main/plugin/audioPCM/index.d.ts +31 -0
  74. package/main/plugin/audioPCM/index.type.d.ts +29 -0
  75. package/main/plugin/audioPCM/processor.d.ts +68 -0
  76. package/main/plugin/contentPreserver/index.d.ts +30 -0
  77. package/main/plugin/contentPreserver/index.type.d.ts +69 -0
  78. package/main/plugin/contentPreserver/processor.d.ts +127 -0
  79. package/main/plugin/index.d.ts +1 -2
  80. package/main/plugin/index.type.d.ts +21 -0
  81. package/main/quality/index.d.ts +0 -1
  82. package/main/quality/report.d.ts +2 -2
  83. package/main/render/audioManager.d.ts +45 -0
  84. package/main/render/index.d.ts +27 -11
  85. package/main/render/index.type.d.ts +2 -6
  86. package/main/render/videoManager.d.ts +36 -3
  87. package/main/render/videoManager.type.d.ts +10 -0
  88. package/main/roster/index.d.ts +41 -2
  89. package/main/server/index.d.ts +3 -4
  90. package/main/server/index.type.d.ts +2 -0
  91. package/main/signal/index.d.ts +1 -2
  92. package/main/socket/index.d.ts +2 -3
  93. package/main/stream/index.d.ts +9 -9
  94. package/main/track/baseTrack.d.ts +4 -5
  95. package/main/track/contentTrack.d.ts +80 -6
  96. package/main/track/customContentTrack.d.ts +2 -3
  97. package/main/track/customVideoAudioTrack.d.ts +2 -3
  98. package/main/track/helper.d.ts +1 -13
  99. package/main/track/videoAudioCapture.d.ts +1 -2
  100. package/main/track/videoAudioTrack.d.ts +88 -13
  101. package/main/vom/config.d.ts +9 -0
  102. package/main/vom/index.d.ts +5 -2
  103. package/package.json +6 -3
  104. package/tools/analyser/index.d.ts +0 -1
  105. package/tools/analyser/manager.d.ts +1 -2
  106. package/tools/config.d.ts +0 -1
  107. package/tools/log/db.d.ts +0 -1
  108. package/tools/log/logger.d.ts +0 -1
  109. package/tools/log/logger.worker.d.ts +1 -1
  110. package/tools/log/loggerManager.d.ts +1 -2
  111. package/tools/socket/socket.d.ts +2 -3
  112. package/tools/socket/socketManager.d.ts +2 -3
  113. package/tools/utils.d.ts +4 -125
  114. package/type/ability.d.ts +3 -1
  115. package/type/analyser.d.ts +0 -1
  116. package/type/base.d.ts +5 -5
  117. package/type/capture.d.ts +0 -1
  118. package/type/client.d.ts +9 -48
  119. package/type/index.d.ts +1 -0
  120. package/type/layout.d.ts +1 -2
  121. package/type/meeting.d.ts +4 -5
  122. package/type/quality.d.ts +1 -2
  123. package/type/stream.d.ts +11 -4
  124. package/type/subtitle.d.ts +86 -0
  125. package/type/track.d.ts +12 -4
  126. package/xyrtc.js +15952 -14725
  127. package/tools/data/list.d.ts +0 -87
  128. package/tools/data/map.d.ts +0 -17
  129. package/tools/detector/browser.d.ts +0 -114
  130. package/tools/detector/index.d.ts +0 -187
  131. package/tools/detector/index.type.d.ts +0 -51
  132. package/tools/detector/stream.d.ts +0 -77
  133. package/tools/detector/stream.type.d.ts +0 -56
  134. package/tools/emitter.d.ts +0 -42
  135. package/tools/frame/index.d.ts +0 -36
  136. package/tools/frame/index.type.d.ts +0 -1
  137. package/tools/index.d.ts +0 -72
  138. package/tools/pressure/index.d.ts +0 -26
  139. package/tools/pressure/index.type.d.ts +0 -22
  140. package/tools/queue/async.d.ts +0 -45
  141. package/tools/queue/queue.type.d.ts +0 -10
  142. package/tools/queue/sync.d.ts +0 -36
  143. package/tools/resize.d.ts +0 -64
  144. package/tools/snapshot/index.d.ts +0 -23
  145. package/tools/snapshot/index.type.d.ts +0 -38
  146. package/tools/store.d.ts +0 -47
  147. package/tools/verify.d.ts +0 -14
  148. package/tools/window.d.ts +0 -31
@@ -1,7 +1,6 @@
1
- import { AutoState } from '../../type/polling';
2
- import { Gap } from '../../type/layout';
3
1
  import { XYLayoutState } from '../render/videoManager.type';
4
-
2
+ import { Gap } from '../../type/layout';
3
+ import { AutoState } from '../../type/polling';
5
4
  /**
6
5
  * 设备类型
7
6
  *
@@ -1,7 +1,6 @@
1
- import { default as Client } from '../client';
2
- import { ICustomizedLayout, ILayout, IRoster, PollingState } from '../../type/index';
3
1
  import { default as LayoutManager } from './index';
4
-
2
+ import { ICustomizedLayout, ILayout, IRoster, PollingState } from '../../type/index';
3
+ import { default as Client } from '../client';
5
4
  export default class Polling {
6
5
  pollingMessage: ICustomizedLayout | null;
7
6
  private pollingIntervalTimer;
@@ -1,8 +1,7 @@
1
- import { ContentTemplateMode, LayoutConfig, TemplateMode } from '../../type/index';
2
- import { default as Client } from '../client';
3
- import { default as LayoutManager } from './index';
4
1
  import { XYBaseModule } from '../../interface/baseModule.type';
5
-
2
+ import { default as LayoutManager } from './index';
3
+ import { default as Client } from '../client';
4
+ import { ContentTemplateMode, LayoutConfig, TemplateMode } from '../../type/index';
6
5
  export declare class XYLayoutManagerState implements XYBaseModule {
7
6
  private client;
8
7
  private logger;
@@ -1,5 +1,4 @@
1
1
  import { ITemplate, TemplateType, VideoQuality, StreamResolutionLevel, TemplateInfos, Gap } from '../../../type/index';
2
-
3
2
  export * from './mobile';
4
3
  export declare const RATE = 0.5625;
5
4
  export declare const HIDE_POSITION: number[];
@@ -1,5 +1,4 @@
1
1
  import { TemplateInfo, TemplateParams } from '../../../type/index';
2
-
3
2
  declare class TemplateManager {
4
3
  private templates;
5
4
  private commonTemplates;
@@ -1,4 +1,3 @@
1
1
  import { ITemplate } from '../../../type/index';
2
-
3
2
  export declare const COMMON_MOBILE_VERTICAL_TEMPLATE: ITemplate;
4
3
  export declare const COMMON_MOBILE_HORIZONTAL_TEMPLATE: ITemplate;
@@ -1,3 +1,2 @@
1
1
  import { Template } from '../../../type/index';
2
-
3
2
  export declare const POLLING_TEMPLATE: Template;
@@ -1,8 +1,7 @@
1
- import { XYLayoutRosters } from './index.type';
2
- import { ICustomMessageConfig, ICustomStreamTrack, IReturnResult, IRoster, IRotationInfoTotalItem, ISpeakerInfo, Key, SpeakersInfoItem, XYBaseModule, XYWebRxAudioStatus } from '../../type/index';
3
- import { XYSpeaker } from '../../feature/index';
4
1
  import { default as XYRTCClient } from '../client';
5
-
2
+ import { XYSpeaker } from '../../feature/index';
3
+ import { ICustomMessageConfig, ICustomStreamTrack, IReturnResult, IRoster, IRotationInfoTotalItem, ISpeakerInfo, Key, SpeakersInfoItem, XYBaseModule, XYWebRxAudioStatus } from '../../type/index';
4
+ import { XYLayoutRosters } from './index.type';
6
5
  export declare class XYMediaManager implements XYBaseModule {
7
6
  private client;
8
7
  private logger;
@@ -57,7 +56,7 @@ export declare class XYMediaManager implements XYBaseModule {
57
56
  */
58
57
  handleRosterMessage(data: any): void;
59
58
  /**
60
- * 对媒体下发的roster信息进行排序,发布
59
+ * 对媒体下发的roster信息进行排序,推送数据
61
60
  */
62
61
  sendOriginOrderRosterMessage(): void;
63
62
  /**
@@ -1,5 +1,4 @@
1
1
  import { ILayoutRoster } from '../../type/index';
2
-
3
2
  /**
4
3
  * 请流结果数据结构
5
4
  */
@@ -1,6 +1,5 @@
1
- import { OriginalNotification, OriginalRealTimeNotification, IReturnResult, ISubTitle, IEPMessage, IWaitingState, IMeetingControl, IRecordStatusNotification, IRecordingStateChanged, XYBaseModule } from '../../type/index';
2
1
  import { default as XYRTCClient } from '../client';
3
-
2
+ import { OriginalNotification, OriginalRealTimeNotification, IReturnResult, ISubTitle, IEPMessage, IWaitingState, IMeetingControl, IRecordStatusNotification, IRecordingStateChanged, XYBaseModule } from '../../type/index';
4
3
  export declare class XYMeetingControl implements XYBaseModule {
5
4
  private client;
6
5
  private logger;
@@ -1,5 +1,4 @@
1
1
  import { EVENT_TYPE } from '../../type/index';
2
-
3
2
  /**
4
3
  * 信令上报原始的消息
5
4
  *
@@ -1,7 +1,6 @@
1
- import { XYConferencePropertiesMessage, XYEnterpriseInfo, XYUicustomization } from './index.type';
2
- import { default as Client } from '../client';
3
1
  import { IConferenceInfo, IRecordPermission, IExportUserInfo, ILayout, IMediaConfig, IReqInfo, IEnterpriseConfig, LayoutAvatarType, TLayoutMap, InviteInfo, MEETING_DIRECTION, IVideoProfile, IMeetingControl, FocusViewAction } from '../../type/index';
4
-
2
+ import { default as Client } from '../client';
3
+ import { XYConferencePropertiesMessage, XYEnterpriseInfo, XYUicustomization } from './index.type';
5
4
  declare class Meeting {
6
5
  private client;
7
6
  private logger;
@@ -27,6 +26,12 @@ declare class Meeting {
27
26
  getEnterpriseConfig(): IEnterpriseConfig;
28
27
  getLayoutAvatarType(): LayoutAvatarType;
29
28
  getMeetingControlInfo(): IMeetingControl | null;
29
+ /**
30
+ * 清空已退会的终端头像
31
+ *
32
+ * @param { string[] } rosterIds - rosterId列表
33
+ */
34
+ clearLayoutAvatar(rosterIds: string[]): void;
30
35
  /**
31
36
  * 设置会控消息
32
37
  *
@@ -0,0 +1,3 @@
1
+ import { Rule } from '@xylink/xy-toolkit';
2
+ declare const checkMeetingPasswordRule: Record<string, Rule>;
3
+ export { checkMeetingPasswordRule };
@@ -1,6 +1,5 @@
1
- import { default as XYRTCClient } from '../client';
2
1
  import { IReturnResult, XYBaseModule, XYCheckNumberParams } from '../../type/index';
3
-
2
+ import { default as XYRTCClient } from '../client';
4
3
  export declare class Verify implements XYBaseModule {
5
4
  private client;
6
5
  private logger;
@@ -1,13 +1,13 @@
1
- import { default as ContentTrack } from '../track/contentTrack';
2
- import { default as VideoAudioTrack } from '../track/videoAudioTrack';
3
- import { default as Logger } from '../../tools/log/logger';
1
+ import { IStreamSender, ICandidate, PushType, ISenderMap, XYConnectState, XYStreamParameterConfig, XYRTCSessionDescriptionInit } from '../../type/index';
4
2
  import { default as Client } from '../client';
5
- import { IStreamSender, ICandidate, PushType, ISenderMap, XYConnectState } from '../../type/index';
6
-
3
+ import { default as Logger } from '../../tools/log/logger';
4
+ import { default as VideoAudioTrack } from '../track/videoAudioTrack';
5
+ import { default as ContentTrack } from '../track/contentTrack';
6
+ import { State } from './state';
7
7
  /**
8
8
  * Peer模块,用于管理 P2P(媒体Server) 连接和内部事件
9
9
  */
10
- export default class Peer {
10
+ export default class Peer extends State {
11
11
  private connectTimer;
12
12
  private connectCount;
13
13
  client: Client;
@@ -30,6 +30,7 @@ export default class Peer {
30
30
  private contentTrackSize;
31
31
  private detectTrackMsgTimer;
32
32
  private candidateList;
33
+ private offerKey;
33
34
  constructor(client: Client, isRenew?: boolean);
34
35
  /**
35
36
  * 初始化质量统计WebWorker模块
@@ -70,6 +71,10 @@ export default class Peer {
70
71
  * 清理Track回调检测器定时器
71
72
  */
72
73
  private stopDetectTrackMsgTimer;
74
+ /**
75
+ * 获取最终协商成功的候选地址对
76
+ */
77
+ private getCandidatePairs;
73
78
  /**
74
79
  * 监听PeerConnection连接状态
75
80
  */
@@ -142,9 +147,9 @@ export default class Peer {
142
147
  * 响应Answer
143
148
  *
144
149
  * @public
145
- * @param { RTCSessionDescriptionInit } answer answerSDP内容,设置到peerConnection上
150
+ * @param { XYRTCSessionDescriptionInit } answer answerSDP内容,设置到peerConnection上
146
151
  */
147
- handleAnswer(answer: RTCSessionDescriptionInit): Promise<void>;
152
+ handleAnswer(answer: XYRTCSessionDescriptionInit): Promise<void>;
148
153
  /**
149
154
  * 对Track轨道进行动态带宽调整、帧率调整
150
155
  *
@@ -156,7 +161,7 @@ export default class Peer {
156
161
  setParameters(trackId: string, encodingParams: {
157
162
  bandwidth: number;
158
163
  frameRate?: number;
159
- } | undefined, isIncreaseBase: boolean | undefined, stream: MediaStream | null): Promise<void>;
164
+ } | undefined, isIncreaseBase: boolean | undefined, stream: MediaStream | null, config?: XYStreamParameterConfig): Promise<void>;
160
165
  /**
161
166
  * ICE Connection status change
162
167
  *
@@ -281,6 +286,10 @@ export default class Peer {
281
286
  * @param { IStreamConfig } streamConfig 自定义Stream流配置
282
287
  */
283
288
  private addTrackProcessor;
289
+ /**
290
+ * 设置Content流默认带宽
291
+ */
292
+ private setDefaultBandwidth;
284
293
  /**
285
294
  * 设置编解码器
286
295
  * 兼容:chrome:67+、edge:79、safari:13.1、firefox:不支持
@@ -293,6 +302,25 @@ export default class Peer {
293
302
  * 缓存浏览器支持所有可用的编解码器配置信息
294
303
  */
295
304
  private setSupportCodec;
305
+ /**
306
+ * 按照顺序排序
307
+ * 注意此处使用sort函数,会修改原函数
308
+ */
309
+ private sortCodecs;
310
+ /**
311
+ * 过滤不符合优先级规则的视频编解码器
312
+ *
313
+ * packetization-mode解释:
314
+ * packetization-mode=0 代表单一 NALU 传输模式,部分 WebRTC 设备可能不支持。
315
+ * packetization-mode=1 是 WebRTC 更推荐的模式,因为它支持分片并提高适应性。
316
+ * profile-level-id解释:
317
+ * 42001f(Baseline Profile)
318
+ * 42e01f(Constrained Baseline Profile)
319
+ * 4d001f(Main Profile)
320
+ * 640034(High Profile)
321
+ * 建议优先 42e01f(Constrained Baseline),因为它适用于大多数移动设备和 WebRTC 兼容客户端
322
+ */
323
+ private filterVideoCodecs;
296
324
  /**
297
325
  * 替换Sender发送器中的Track数据
298
326
  *
@@ -1,5 +1,4 @@
1
1
  import { PeerState, ICEState } from '../../type/index';
2
-
3
2
  /**
4
3
  * 接口表示Peer的连接状态,包括当前的Peer状态和ICE状态。
5
4
  * 用于跟踪Peer连接和ICE协商过程的状态。
@@ -8,3 +7,27 @@ export interface XYConnectState {
8
7
  peer: PeerState;
9
8
  ice: ICEState;
10
9
  }
10
+ /**
11
+ * 编码优先级
12
+ *
13
+ * @param MAINTAIN_FRAMERATE maintain-framerate - 帧率优先
14
+ * @param MAINTAIN_RESOLUTION maintain-resolution - 分辨率优先
15
+ * @param BALANCED balanced - 平衡
16
+ */
17
+ export declare enum XYDegradationPreference {
18
+ MAINTAIN_FRAMERATE = "maintain-framerate",
19
+ MAINTAIN_RESOLUTION = "maintain-resolution",
20
+ BALANCED = "balanced"
21
+ }
22
+ /**
23
+ * 流参数配置
24
+ */
25
+ export interface XYStreamParameterConfig {
26
+ degradationPreference?: XYDegradationPreference;
27
+ }
28
+ /**
29
+ * 对端Answer报文
30
+ */
31
+ export interface XYRTCSessionDescriptionInit extends RTCSessionDescriptionInit {
32
+ offerKey?: string;
33
+ }
@@ -0,0 +1,4 @@
1
+ import { IStreamConfig } from '../../type/index';
2
+ export declare class State {
3
+ protected cacheContentStreamConfig: IStreamConfig[];
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import { PluginType } from '../index.type';
2
+ import { XYAudioPCMProcessor } from './processor';
3
+ import { XYAudioPCMOptions } from './index.type';
4
+ import { XYPluginIF } from '../../../interface/extension.type';
5
+ export declare class XYAudioPCMExtension implements XYPluginIF<XYAudioPCMProcessor> {
6
+ private version;
7
+ private name;
8
+ private processType;
9
+ constructor();
10
+ init(): void;
11
+ getVersion(): string;
12
+ getPluginType(): PluginType;
13
+ getPluginName(): string;
14
+ /**
15
+ * 销毁插件
16
+ */
17
+ destroy(): void;
18
+ /**
19
+ * 检测浏览器是否支持插件
20
+ *
21
+ * @returns { boolean } - 是否支持插件
22
+ */
23
+ isSupportExtension(): boolean;
24
+ /**
25
+ * 创建处理器
26
+ *
27
+ * @param { XYAudioPCMOptions } config - 插件配置项
28
+ * @returns { XYContentSnapshotProcessor | null } - 返回处理器实例
29
+ */
30
+ createProcessor(config?: XYAudioPCMOptions): XYAudioPCMProcessor | null;
31
+ }
@@ -0,0 +1,29 @@
1
+ export interface XYAudioParamDescriptor {
2
+ name: string;
3
+ defaultValue?: number;
4
+ minValue?: number;
5
+ maxValue?: number;
6
+ automationRate?: 'a-rate' | 'k-rate';
7
+ }
8
+ /**
9
+ * Audio PCM Options 配置项
10
+ *
11
+ * @param { number } targetSampleRate - 目标采样率
12
+ * @param { number } reportInterval - 上报间隔
13
+ * @param { (result:XYAudioPCMData) => void } onData - PCM数据回调函数
14
+ * @param { (error: any) => void } onError - 错误回调函数
15
+ */
16
+ export interface XYAudioPCMOptions {
17
+ targetSampleRate?: number;
18
+ reportInterval?: number;
19
+ onData?: (result: XYAudioPCMData) => void;
20
+ onError?: (error: any) => void;
21
+ }
22
+ /**
23
+ * Audio PCM Data 数据
24
+ *
25
+ * @param { Float32Array } data - PCM数据
26
+ */
27
+ export interface XYAudioPCMData {
28
+ data: Float32Array;
29
+ }
@@ -0,0 +1,68 @@
1
+ import { XYAudioPCMOptions } from './index.type';
2
+ import { XYAudioPCMExtension } from '.';
3
+ import { XYProcessorIF } from '../../../interface/processor.type';
4
+ import { IProcessTrack } from '../../../type/track';
5
+ /**
6
+ * PCM音频处理器类, 使用AudioWorklet实时处理MediaStream中的音频数据
7
+ */
8
+ declare class XYAudioPCMProcessor implements XYProcessorIF {
9
+ private pluginInstance;
10
+ /** 用于处理音频的AudioWorklet节点 */
11
+ private workletNode;
12
+ /** 用于处理Web Audio API操作的音频上下文 */
13
+ private audioContext;
14
+ /** 插件状态 */
15
+ private enablePlugin;
16
+ /** 音频流 */
17
+ private audioStream;
18
+ /** 配置项 */
19
+ private config;
20
+ /** 回调函数 */
21
+ private onData?;
22
+ private onError?;
23
+ static isSupportAudioContext(): boolean;
24
+ /**
25
+ * 构造函数
26
+ * @param config 配置项
27
+ */
28
+ constructor(config: XYAudioPCMOptions | undefined, pluginInstance: XYAudioPCMExtension);
29
+ getProcessorType(): import('../index.type').PluginType;
30
+ setOptions(config: XYAudioPCMOptions): void;
31
+ /**
32
+ * 启用插件
33
+ *
34
+ * @returns { Promise<boolean> } - 返回Promise对象
35
+ */
36
+ enable(): Promise<boolean>;
37
+ /**
38
+ * 禁用插件
39
+ *
40
+ * @returns { Promise<boolean> } - 返回Promise对象
41
+ */
42
+ disable(): Promise<boolean>;
43
+ private setReportEnabled;
44
+ /**
45
+ * 获取插件状态
46
+ */
47
+ getEnablePluginState(): boolean;
48
+ private initEvent;
49
+ /**
50
+ * 开始处理音频数据
51
+ * 初始化AudioContext和AudioWorklet,建立音频处理管道
52
+ * @throws 如果音频流未激活或处理失败
53
+ */
54
+ process(processTrack: IProcessTrack): Promise<IProcessTrack>;
55
+ /**
56
+ * 销毁音频处理器
57
+ *
58
+ * 使用场景:当不再需要音频处理器时,调用此方法清理资源
59
+ * 调用时机:处理器实例需要销毁时
60
+ */
61
+ destroy(): void;
62
+ /**
63
+ * 清理音频处理资源
64
+ * 断开AudioWorklet连接并关闭AudioContext
65
+ */
66
+ private cleanup;
67
+ }
68
+ export { XYAudioPCMProcessor };
@@ -0,0 +1,30 @@
1
+ import { PluginType, XYContentPreserverOptions } from './index.type';
2
+ import { XYContentPreserverProcessor } from './processor';
3
+ import { XYPluginIF } from '../../../interface/extension.type';
4
+ export declare class XYContentPreserverExtension implements XYPluginIF<XYContentPreserverProcessor> {
5
+ private version;
6
+ private name;
7
+ private processType;
8
+ constructor();
9
+ init(): void;
10
+ getVersion(): string;
11
+ getPluginType(): PluginType;
12
+ getPluginName(): string;
13
+ /**
14
+ * 销毁插件
15
+ */
16
+ destroy(): void;
17
+ /**
18
+ * 检测浏览器是否支持插件
19
+ *
20
+ * @returns { boolean } - 是否支持插件
21
+ */
22
+ isSupportExtension(): boolean;
23
+ /**
24
+ * 创建处理器
25
+ *
26
+ * @param { XYContentPreserverOptions } config - 插件配置项
27
+ * @returns { XYContentPreserverProcessor | null } - 返回处理器实例
28
+ */
29
+ createProcessor(config?: XYContentPreserverOptions): XYContentPreserverProcessor | null;
30
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Plugin Types
3
+ *
4
+ * @summary short description for the file
5
+ * @author JingHui Luo <luojinghui424@gmail.com>
6
+ *
7
+ * Created at : 2023-11-17 11:37:03
8
+ * Last modified : 2024-11-15 16:28:12
9
+ */
10
+ /**
11
+ * 插件类型
12
+ *
13
+ * @property VIDEO_INPUT - 视频输入
14
+ * @property AUDIO_INPUT - 音频输入
15
+ * @property CONTENT_INPUT - 内容输入
16
+ */
17
+ export declare enum PluginType {
18
+ VIDEO_INPUT = "VIDEO_INPUT",
19
+ AUDIO_INPUT = "AUDIO_INPUT",
20
+ CONTENT_INPUT = "CONTENT_INPUT"
21
+ }
22
+ /**
23
+ * 内容快照类型
24
+ *
25
+ * @property TEXT - 文本
26
+ * @property IMAGE - 图片
27
+ */
28
+ export declare enum ContentPreserverType {
29
+ TEXT = "TEXT",
30
+ IMAGE = "IMAGE"
31
+ }
32
+ /**
33
+ * Content Preserver Options 配置项
34
+ *
35
+ * @param { ContentPreserverType } type - 内容快照类型
36
+ * @param { string } content - 快照显示的内容
37
+ * @param { number[] } position - 位置
38
+ * @param { number } size - 大小
39
+ * @param { string } color - 颜色
40
+ */
41
+ export interface XYContentPreserverOptions {
42
+ type?: ContentPreserverType;
43
+ content?: string;
44
+ position?: number[];
45
+ size?: number;
46
+ color?: string;
47
+ }
48
+ /**
49
+ * 自定义Track
50
+ *
51
+ * @param { MediaStreamTrack } track - 媒体轨道
52
+ * @param { number } width - 轨道宽度
53
+ * @param { number } height - 轨道高度
54
+ */
55
+ export interface IProcessTrack {
56
+ track: MediaStreamTrack;
57
+ width: number;
58
+ height: number;
59
+ }
60
+ /**
61
+ * 最后一帧视频帧数据
62
+ *
63
+ * @property { VideoFrame } videoFrame - 最后一帧视频帧数据
64
+ * @property { ReadableStreamDefaultReader } reader - 视频轨道的可读流读取器
65
+ */
66
+ export interface XYLastFrameData {
67
+ videoFrame: VideoFrame;
68
+ reader: ReadableStreamDefaultReader<any>;
69
+ }
@@ -0,0 +1,127 @@
1
+ import { IProcessTrack, XYContentPreserverOptions } from './index.type';
2
+ import { XYContentPreserverExtension } from './index';
3
+ import { XYProcessorIF } from '../../../interface/processor.type';
4
+ export declare class XYContentPreserverProcessor implements XYProcessorIF {
5
+ private canvas;
6
+ private canvasContext;
7
+ private options;
8
+ private enablePlugin;
9
+ private trackWidth;
10
+ private trackHeight;
11
+ private trackGenerator;
12
+ private pluginInstance;
13
+ private isPause;
14
+ private cacheBitmap;
15
+ private isCacheCanvas;
16
+ private cacheVideoTrack;
17
+ private transformController;
18
+ private detectInterval;
19
+ private createLastVideoFrame;
20
+ private isProcessorEnded;
21
+ private debounceDelay;
22
+ private detectIntervalGap;
23
+ constructor(config: XYContentPreserverOptions | undefined, pluginInstance: XYContentPreserverExtension);
24
+ getProcessorType(): import('./index.type').PluginType;
25
+ /**
26
+ * 销毁处理器实例
27
+ *
28
+ * 使用场景:当不再需要内容快照处理器时,调用此方法清理资源
29
+ * 调用时机:处理器实例需要销毁时
30
+ */
31
+ destroy(): void;
32
+ /**
33
+ * 清除检测定时器
34
+ */
35
+ private clearDetectInterval;
36
+ /**
37
+ * 初始化离线画布
38
+ */
39
+ private initOfflineCanvas;
40
+ /**
41
+ * 移除选项
42
+ */
43
+ removeOptions(): void;
44
+ /**
45
+ * 设置选项
46
+ *
47
+ * @param { XYContentPreserverOptions } option - 插件配置项
48
+ * @returns { Promise<boolean> } - 返回Promise对象
49
+ */
50
+ setOptions(option?: XYContentPreserverOptions): Promise<boolean>;
51
+ /**
52
+ * 启用插件
53
+ *
54
+ * @returns { Promise<boolean> } - 返回Promise对象
55
+ */
56
+ enable(): Promise<boolean>;
57
+ /**
58
+ * 禁用插件
59
+ *
60
+ * @returns { Promise<boolean> } - 返回Promise对象
61
+ */
62
+ disable(): Promise<boolean>;
63
+ /**
64
+ * 获取插件状态
65
+ */
66
+ getEnablePluginState(): boolean;
67
+ /**
68
+ * 暂停处理器
69
+ */
70
+ pause(): void;
71
+ /**
72
+ * 恢复处理器
73
+ */
74
+ resume(): void;
75
+ /**
76
+ * 当TransformStream freeze触发时,启动定时器接管转换流,每隔1000ms进行补帧操作
77
+ */
78
+ private createLastVideoFrameWrap;
79
+ /**
80
+ * 从视频轨道创建视频帧
81
+ *
82
+ * @return { Promise<XYLastFrameData> } - 返回最后一帧视频帧数据和读取器
83
+ */
84
+ private createVideoFrameFromVideoTrack;
85
+ /**
86
+ * 清除并缓存新的视频轨道
87
+ *
88
+ * @param { MediaStreamTrack } track - 视频轨道
89
+ */
90
+ private clearAndCacheVideoTrack;
91
+ /**
92
+ * 处理视频流
93
+ *
94
+ * @param { IProcessTrack } processTrack - 处理视频流
95
+ * @returns { Promise<IProcessTrack> } - 返回加工处理过后的 MediaStreamTrack 轨道数据
96
+ */
97
+ process(processTrack: IProcessTrack): Promise<IProcessTrack>;
98
+ /**
99
+ * 转换视频流
100
+ *
101
+ * @param { VideoFrame } videoFrame - 视频帧
102
+ * @param { TransformStreamDefaultController<VideoFrame> } controller - 转换流控制器
103
+ */
104
+ transformStream(videoFrame: VideoFrame, controller: TransformStreamDefaultController<VideoFrame>): Promise<void>;
105
+ /**
106
+ * 创建下一个视频帧
107
+ *
108
+ * @param { number } videoTimestamp - 视频帧时间戳
109
+ */
110
+ private createNextVideoFrame;
111
+ /**
112
+ * 创建暂停内容快照
113
+ */
114
+ private createContentPreserver;
115
+ /**
116
+ * 创建缓存位图
117
+ */
118
+ private createCacheBitmap;
119
+ /**
120
+ * 处理视频帧,将视频帧绘制到离线画布上
121
+ */
122
+ private addVideoEffectToFrame;
123
+ /**
124
+ * 清除离线画布
125
+ */
126
+ private clearRect;
127
+ }
@@ -1,6 +1,5 @@
1
- import { XYBaseModule } from '../../type/index';
2
1
  import { default as XYRTCClient } from '../client';
3
-
2
+ import { XYBaseModule } from '../../type/index';
4
3
  export declare class XYPlugin implements XYBaseModule {
5
4
  private logger;
6
5
  private plugin;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Plugin Types
3
+ *
4
+ * @summary short description for the file
5
+ * @author JingHui Luo <luojinghui424@gmail.com>
6
+ *
7
+ * Created at : 2023-11-17 11:37:03
8
+ * Last modified : 2025-03-07 16:19:14
9
+ */
10
+ /**
11
+ * 插件类型
12
+ *
13
+ * @property VIDEO_INPUT - 视频输入
14
+ * @property AUDIO_INPUT - 音频输入
15
+ * @property CONTENT_INPUT - 内容输入
16
+ */
17
+ export declare enum PluginType {
18
+ VIDEO_INPUT = "VIDEO_INPUT",
19
+ AUDIO_INPUT = "AUDIO_INPUT",
20
+ CONTENT_INPUT = "CONTENT_INPUT"
21
+ }