@xylink/xy-rtc-sdk 4.0.3 → 4.0.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 (79) hide show
  1. package/action/index.d.ts +1 -1
  2. package/enum/index.d.ts +8 -0
  3. package/export/tools.d.ts +18 -0
  4. package/feature/artboard/index.d.ts +7 -0
  5. package/feature/audioPCM/index.d.ts +30 -0
  6. package/feature/contentPreserver/index.d.ts +39 -0
  7. package/feature/im/index.d.ts +1 -1
  8. package/index.d.ts +7 -4
  9. package/interface/clientInterface.type.d.ts +6 -6
  10. package/interface/event.type.d.ts +10 -2
  11. package/interface/extension.type.d.ts +11 -0
  12. package/interface/processor.type.d.ts +10 -0
  13. package/interface/videoAudioTrackInterface.type.d.ts +2 -2
  14. package/main/auth/index.d.ts +8 -15
  15. package/main/auth/rule.d.ts +10 -0
  16. package/main/client/clientBase.d.ts +9 -1
  17. package/main/client/index.d.ts +13 -18
  18. package/main/client/rule.d.ts +20 -0
  19. package/main/device/index.d.ts +12 -4
  20. package/main/device/index.type.d.ts +22 -0
  21. package/main/helper/index.d.ts +8 -0
  22. package/main/layout/index.d.ts +7 -0
  23. package/main/meeting/rule.d.ts +4 -0
  24. package/main/peer/index.d.ts +34 -5
  25. package/main/peer/index.type.d.ts +24 -0
  26. package/main/peer/state.d.ts +5 -0
  27. package/main/plugin/audioPCM/audio-processor.worklet.d.ts +1 -0
  28. package/main/plugin/audioPCM/index.d.ts +32 -0
  29. package/main/plugin/audioPCM/index.type.d.ts +29 -0
  30. package/main/plugin/audioPCM/processor.d.ts +69 -0
  31. package/main/plugin/contentPreserver/index.d.ts +31 -0
  32. package/main/plugin/contentPreserver/index.type.d.ts +69 -0
  33. package/main/plugin/contentPreserver/processor.d.ts +128 -0
  34. package/main/plugin/index.type.d.ts +21 -0
  35. package/main/quality/report.d.ts +1 -0
  36. package/main/render/audioManager.d.ts +46 -0
  37. package/main/render/index.d.ts +26 -9
  38. package/main/render/index.type.d.ts +2 -5
  39. package/main/render/videoManager.d.ts +36 -2
  40. package/main/render/videoManager.type.d.ts +10 -0
  41. package/main/server/index.type.d.ts +2 -0
  42. package/main/stream/index.d.ts +3 -2
  43. package/main/track/baseTrack.d.ts +1 -1
  44. package/main/track/contentTrack.d.ts +78 -3
  45. package/main/track/helper.d.ts +1 -13
  46. package/main/track/videoAudioTrack.d.ts +85 -9
  47. package/main/vom/config.d.ts +10 -0
  48. package/main/vom/index.d.ts +4 -0
  49. package/package.json +4 -1
  50. package/tools/log/logger.worker.d.ts +1 -1
  51. package/tools/socket/socket.d.ts +1 -1
  52. package/tools/utils.d.ts +4 -124
  53. package/type/base.d.ts +5 -5
  54. package/type/client.d.ts +3 -1
  55. package/type/stream.d.ts +8 -0
  56. package/type/track.d.ts +12 -3
  57. package/xyrtc.js +14572 -12426
  58. package/tools/data/list.d.ts +0 -87
  59. package/tools/data/map.d.ts +0 -17
  60. package/tools/detector/browser.d.ts +0 -114
  61. package/tools/detector/index.d.ts +0 -187
  62. package/tools/detector/index.type.d.ts +0 -51
  63. package/tools/detector/stream.d.ts +0 -77
  64. package/tools/detector/stream.type.d.ts +0 -56
  65. package/tools/emitter.d.ts +0 -42
  66. package/tools/frame/index.d.ts +0 -36
  67. package/tools/frame/index.type.d.ts +0 -1
  68. package/tools/index.d.ts +0 -72
  69. package/tools/pressure/index.d.ts +0 -26
  70. package/tools/pressure/index.type.d.ts +0 -22
  71. package/tools/queue/async.d.ts +0 -45
  72. package/tools/queue/queue.type.d.ts +0 -10
  73. package/tools/queue/sync.d.ts +0 -36
  74. package/tools/resize.d.ts +0 -64
  75. package/tools/snapshot/index.d.ts +0 -23
  76. package/tools/snapshot/index.type.d.ts +0 -38
  77. package/tools/store.d.ts +0 -47
  78. package/tools/verify.d.ts +0 -14
  79. package/tools/window.d.ts +0 -31
@@ -1,13 +1,14 @@
1
+ import { State } from './state';
1
2
  import { default as ContentTrack } from '../track/contentTrack';
2
3
  import { default as VideoAudioTrack } from '../track/videoAudioTrack';
3
4
  import { default as Logger } from '../../tools/log/logger';
4
5
  import { default as Client } from '../client';
5
- import { IStreamSender, ICandidate, PushType, ISenderMap, XYConnectState } from '../../type/index';
6
+ import { IStreamSender, ICandidate, PushType, ISenderMap, XYConnectState, XYStreamParameterConfig, XYRTCSessionDescriptionInit } from '../../type/index';
6
7
 
7
8
  /**
8
9
  * Peer模块,用于管理 P2P(媒体Server) 连接和内部事件
9
10
  */
10
- export default class Peer {
11
+ export default class Peer extends State {
11
12
  private connectTimer;
12
13
  private connectCount;
13
14
  client: Client;
@@ -30,6 +31,7 @@ export default class Peer {
30
31
  private contentTrackSize;
31
32
  private detectTrackMsgTimer;
32
33
  private candidateList;
34
+ private offerKey;
33
35
  constructor(client: Client, isRenew?: boolean);
34
36
  /**
35
37
  * 初始化质量统计WebWorker模块
@@ -70,6 +72,10 @@ export default class Peer {
70
72
  * 清理Track回调检测器定时器
71
73
  */
72
74
  private stopDetectTrackMsgTimer;
75
+ /**
76
+ * 获取最终协商成功的候选地址对
77
+ */
78
+ private getCandidatePairs;
73
79
  /**
74
80
  * 监听PeerConnection连接状态
75
81
  */
@@ -142,9 +148,9 @@ export default class Peer {
142
148
  * 响应Answer
143
149
  *
144
150
  * @public
145
- * @param { RTCSessionDescriptionInit } answer answerSDP内容,设置到peerConnection上
151
+ * @param { XYRTCSessionDescriptionInit } answer answerSDP内容,设置到peerConnection上
146
152
  */
147
- handleAnswer(answer: RTCSessionDescriptionInit): Promise<void>;
153
+ handleAnswer(answer: XYRTCSessionDescriptionInit): Promise<void>;
148
154
  /**
149
155
  * 对Track轨道进行动态带宽调整、帧率调整
150
156
  *
@@ -156,7 +162,7 @@ export default class Peer {
156
162
  setParameters(trackId: string, encodingParams: {
157
163
  bandwidth: number;
158
164
  frameRate?: number;
159
- } | undefined, isIncreaseBase: boolean | undefined, stream: MediaStream | null): Promise<void>;
165
+ } | undefined, isIncreaseBase: boolean | undefined, stream: MediaStream | null, config?: XYStreamParameterConfig): Promise<void>;
160
166
  /**
161
167
  * ICE Connection status change
162
168
  *
@@ -281,6 +287,10 @@ export default class Peer {
281
287
  * @param { IStreamConfig } streamConfig 自定义Stream流配置
282
288
  */
283
289
  private addTrackProcessor;
290
+ /**
291
+ * 设置Content流默认带宽
292
+ */
293
+ private setDefaultBandwidth;
284
294
  /**
285
295
  * 设置编解码器
286
296
  * 兼容:chrome:67+、edge:79、safari:13.1、firefox:不支持
@@ -293,6 +303,25 @@ export default class Peer {
293
303
  * 缓存浏览器支持所有可用的编解码器配置信息
294
304
  */
295
305
  private setSupportCodec;
306
+ /**
307
+ * 按照顺序排序
308
+ * 注意此处使用sort函数,会修改原函数
309
+ */
310
+ private sortCodecs;
311
+ /**
312
+ * 过滤不符合优先级规则的视频编解码器
313
+ *
314
+ * packetization-mode解释:
315
+ * packetization-mode=0 代表单一 NALU 传输模式,部分 WebRTC 设备可能不支持。
316
+ * packetization-mode=1 是 WebRTC 更推荐的模式,因为它支持分片并提高适应性。
317
+ * profile-level-id解释:
318
+ * 42001f(Baseline Profile)
319
+ * 42e01f(Constrained Baseline Profile)
320
+ * 4d001f(Main Profile)
321
+ * 640034(High Profile)
322
+ * 建议优先 42e01f(Constrained Baseline),因为它适用于大多数移动设备和 WebRTC 兼容客户端
323
+ */
324
+ private filterVideoCodecs;
296
325
  /**
297
326
  * 替换Sender发送器中的Track数据
298
327
  *
@@ -8,3 +8,27 @@ export interface XYConnectState {
8
8
  peer: PeerState;
9
9
  ice: ICEState;
10
10
  }
11
+ /**
12
+ * 编码优先级
13
+ *
14
+ * @param MAINTAIN_FRAMERATE maintain-framerate - 帧率优先
15
+ * @param MAINTAIN_RESOLUTION maintain-resolution - 分辨率优先
16
+ * @param BALANCED balanced - 平衡
17
+ */
18
+ export declare enum XYDegradationPreference {
19
+ MAINTAIN_FRAMERATE = "maintain-framerate",
20
+ MAINTAIN_RESOLUTION = "maintain-resolution",
21
+ BALANCED = "balanced"
22
+ }
23
+ /**
24
+ * 流参数配置
25
+ */
26
+ export interface XYStreamParameterConfig {
27
+ degradationPreference?: XYDegradationPreference;
28
+ }
29
+ /**
30
+ * 对端Answer报文
31
+ */
32
+ export interface XYRTCSessionDescriptionInit extends RTCSessionDescriptionInit {
33
+ offerKey?: string;
34
+ }
@@ -0,0 +1,5 @@
1
+ import { IStreamConfig } from '../../type/index';
2
+
3
+ export declare class State {
4
+ protected cacheContentStreamConfig: IStreamConfig[];
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { XYPluginIF } from '../../../interface/extension.type';
2
+ import { XYAudioPCMOptions } from './index.type';
3
+ import { XYAudioPCMProcessor } from './processor';
4
+ import { PluginType } from '../index.type';
5
+
6
+ export declare class XYAudioPCMExtension implements XYPluginIF<XYAudioPCMProcessor> {
7
+ private version;
8
+ private name;
9
+ private processType;
10
+ constructor();
11
+ init(): void;
12
+ getVersion(): string;
13
+ getPluginType(): PluginType;
14
+ getPluginName(): string;
15
+ /**
16
+ * 销毁插件
17
+ */
18
+ destroy(): void;
19
+ /**
20
+ * 检测浏览器是否支持插件
21
+ *
22
+ * @returns { boolean } - 是否支持插件
23
+ */
24
+ isSupportExtension(): boolean;
25
+ /**
26
+ * 创建处理器
27
+ *
28
+ * @param { XYAudioPCMOptions } config - 插件配置项
29
+ * @returns { XYContentSnapshotProcessor | null } - 返回处理器实例
30
+ */
31
+ createProcessor(config?: XYAudioPCMOptions): XYAudioPCMProcessor | null;
32
+ }
@@ -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,69 @@
1
+ import { IProcessTrack } from '../../../type/track';
2
+ import { XYProcessorIF } from '../../../interface/processor.type';
3
+ import { XYAudioPCMExtension } from '.';
4
+ import { XYAudioPCMOptions } from './index.type';
5
+
6
+ /**
7
+ * PCM音频处理器类, 使用AudioWorklet实时处理MediaStream中的音频数据
8
+ */
9
+ declare class XYAudioPCMProcessor implements XYProcessorIF {
10
+ private pluginInstance;
11
+ /** 用于处理音频的AudioWorklet节点 */
12
+ private workletNode;
13
+ /** 用于处理Web Audio API操作的音频上下文 */
14
+ private audioContext;
15
+ /** 插件状态 */
16
+ private enablePlugin;
17
+ /** 音频流 */
18
+ private audioStream;
19
+ /** 配置项 */
20
+ private config;
21
+ /** 回调函数 */
22
+ private onData?;
23
+ private onError?;
24
+ static isSupportAudioContext(): boolean;
25
+ /**
26
+ * 构造函数
27
+ * @param config 配置项
28
+ */
29
+ constructor(config: XYAudioPCMOptions | undefined, pluginInstance: XYAudioPCMExtension);
30
+ getProcessorType(): import('../index.type').PluginType;
31
+ setOptions(config: XYAudioPCMOptions): void;
32
+ /**
33
+ * 启用插件
34
+ *
35
+ * @returns { Promise<boolean> } - 返回Promise对象
36
+ */
37
+ enable(): Promise<boolean>;
38
+ /**
39
+ * 禁用插件
40
+ *
41
+ * @returns { Promise<boolean> } - 返回Promise对象
42
+ */
43
+ disable(): Promise<boolean>;
44
+ private setReportEnabled;
45
+ /**
46
+ * 获取插件状态
47
+ */
48
+ getEnablePluginState(): boolean;
49
+ private initEvent;
50
+ /**
51
+ * 开始处理音频数据
52
+ * 初始化AudioContext和AudioWorklet,建立音频处理管道
53
+ * @throws 如果音频流未激活或处理失败
54
+ */
55
+ process(processTrack: IProcessTrack): Promise<IProcessTrack>;
56
+ /**
57
+ * 销毁音频处理器
58
+ *
59
+ * 使用场景:当不再需要音频处理器时,调用此方法清理资源
60
+ * 调用时机:处理器实例需要销毁时
61
+ */
62
+ destroy(): void;
63
+ /**
64
+ * 清理音频处理资源
65
+ * 断开AudioWorklet连接并关闭AudioContext
66
+ */
67
+ private cleanup;
68
+ }
69
+ export { XYAudioPCMProcessor };
@@ -0,0 +1,31 @@
1
+ import { XYPluginIF } from '../../../interface/extension.type';
2
+ import { XYContentPreserverProcessor } from './processor';
3
+ import { PluginType, XYContentPreserverOptions } from './index.type';
4
+
5
+ export declare class XYContentPreserverExtension implements XYPluginIF<XYContentPreserverProcessor> {
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 { XYContentPreserverOptions } config - 插件配置项
28
+ * @returns { XYContentPreserverProcessor | null } - 返回处理器实例
29
+ */
30
+ createProcessor(config?: XYContentPreserverOptions): XYContentPreserverProcessor | null;
31
+ }
@@ -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,128 @@
1
+ import { XYProcessorIF } from '../../../interface/processor.type';
2
+ import { XYContentPreserverExtension } from './index';
3
+ import { IProcessTrack, XYContentPreserverOptions } from './index.type';
4
+
5
+ export declare class XYContentPreserverProcessor implements XYProcessorIF {
6
+ private canvas;
7
+ private canvasContext;
8
+ private options;
9
+ private enablePlugin;
10
+ private trackWidth;
11
+ private trackHeight;
12
+ private trackGenerator;
13
+ private pluginInstance;
14
+ private isPause;
15
+ private cacheBitmap;
16
+ private isCacheCanvas;
17
+ private cacheVideoTrack;
18
+ private transformController;
19
+ private detectInterval;
20
+ private createLastVideoFrame;
21
+ private isProcessorEnded;
22
+ private debounceDelay;
23
+ private detectIntervalGap;
24
+ constructor(config: XYContentPreserverOptions | undefined, pluginInstance: XYContentPreserverExtension);
25
+ getProcessorType(): import('./index.type').PluginType;
26
+ /**
27
+ * 销毁处理器实例
28
+ *
29
+ * 使用场景:当不再需要内容快照处理器时,调用此方法清理资源
30
+ * 调用时机:处理器实例需要销毁时
31
+ */
32
+ destroy(): void;
33
+ /**
34
+ * 清除检测定时器
35
+ */
36
+ private clearDetectInterval;
37
+ /**
38
+ * 初始化离线画布
39
+ */
40
+ private initOfflineCanvas;
41
+ /**
42
+ * 移除选项
43
+ */
44
+ removeOptions(): void;
45
+ /**
46
+ * 设置选项
47
+ *
48
+ * @param { XYContentPreserverOptions } option - 插件配置项
49
+ * @returns { Promise<boolean> } - 返回Promise对象
50
+ */
51
+ setOptions(option?: XYContentPreserverOptions): Promise<boolean>;
52
+ /**
53
+ * 启用插件
54
+ *
55
+ * @returns { Promise<boolean> } - 返回Promise对象
56
+ */
57
+ enable(): Promise<boolean>;
58
+ /**
59
+ * 禁用插件
60
+ *
61
+ * @returns { Promise<boolean> } - 返回Promise对象
62
+ */
63
+ disable(): Promise<boolean>;
64
+ /**
65
+ * 获取插件状态
66
+ */
67
+ getEnablePluginState(): boolean;
68
+ /**
69
+ * 暂停处理器
70
+ */
71
+ pause(): void;
72
+ /**
73
+ * 恢复处理器
74
+ */
75
+ resume(): void;
76
+ /**
77
+ * 当TransformStream freeze触发时,启动定时器接管转换流,每隔1000ms进行补帧操作
78
+ */
79
+ private createLastVideoFrameWrap;
80
+ /**
81
+ * 从视频轨道创建视频帧
82
+ *
83
+ * @return { Promise<XYLastFrameData> } - 返回最后一帧视频帧数据和读取器
84
+ */
85
+ private createVideoFrameFromVideoTrack;
86
+ /**
87
+ * 清除并缓存新的视频轨道
88
+ *
89
+ * @param { MediaStreamTrack } track - 视频轨道
90
+ */
91
+ private clearAndCacheVideoTrack;
92
+ /**
93
+ * 处理视频流
94
+ *
95
+ * @param { IProcessTrack } processTrack - 处理视频流
96
+ * @returns { Promise<IProcessTrack> } - 返回加工处理过后的 MediaStreamTrack 轨道数据
97
+ */
98
+ process(processTrack: IProcessTrack): Promise<IProcessTrack>;
99
+ /**
100
+ * 转换视频流
101
+ *
102
+ * @param { VideoFrame } videoFrame - 视频帧
103
+ * @param { TransformStreamDefaultController<VideoFrame> } controller - 转换流控制器
104
+ */
105
+ transformStream(videoFrame: VideoFrame, controller: TransformStreamDefaultController<VideoFrame>): Promise<void>;
106
+ /**
107
+ * 创建下一个视频帧
108
+ *
109
+ * @param { number } videoTimestamp - 视频帧时间戳
110
+ */
111
+ private createNextVideoFrame;
112
+ /**
113
+ * 创建暂停内容快照
114
+ */
115
+ private createContentPreserver;
116
+ /**
117
+ * 创建缓存位图
118
+ */
119
+ private createCacheBitmap;
120
+ /**
121
+ * 处理视频帧,将视频帧绘制到离线画布上
122
+ */
123
+ private addVideoEffectToFrame;
124
+ /**
125
+ * 清除离线画布
126
+ */
127
+ private clearRect;
128
+ }
@@ -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
+ }
@@ -3,6 +3,7 @@ import { default as Client } from '../client';
3
3
 
4
4
  declare class XYQualityReport implements XYBaseModule {
5
5
  private client;
6
+ private logger;
6
7
  private reportDataTime;
7
8
  private meetingQualityData;
8
9
  private previousInternals;
@@ -0,0 +1,46 @@
1
+ import { XYMuteState } from '../../type/index';
2
+ import { default as Logger } from '../../tools/log/logger';
3
+ import { default as XYRTCClient } from '../client';
4
+
5
+ declare class AudioManager {
6
+ private clientInstance;
7
+ private logger;
8
+ private streamId;
9
+ audioElement: HTMLAudioElement | null;
10
+ constructor(clientInstance: XYRTCClient, logger: Logger);
11
+ getAudioElement(): HTMLAudioElement | null;
12
+ /**
13
+ * 设置音频是否静音
14
+ *
15
+ * @param { XYMuteState } state - 视频静音状态
16
+ */
17
+ setMuteState(state: XYMuteState): void;
18
+ /**
19
+ * 播放音频
20
+ */
21
+ play(): Promise<void>;
22
+ /**
23
+ * 设置音频流和音频元素
24
+ *
25
+ * @param { string } streamId - MediaStream流ID
26
+ * @param { HTMLAudioElement } ele - Audio元素
27
+ */
28
+ setStreamAndElement(streamId: string, ele: HTMLAudioElement): void;
29
+ /**
30
+ * 设置当前Audio对应的Audio元素
31
+ */
32
+ setSource(): Promise<void>;
33
+ /**
34
+ * 创建Audio元素
35
+ *
36
+ * @param { string } streamId - MediaStream流ID
37
+ * @param { HTMLAudioElement } ele - Audio元素
38
+ * @returns { HTMLAudioElement }
39
+ */
40
+ private detectCreateAudioElement;
41
+ /**
42
+ * 销毁AudioManager
43
+ */
44
+ destroy(): void;
45
+ }
46
+ export default AudioManager;
@@ -1,4 +1,4 @@
1
- import { IAudioRenders, XYVideoRendererMap, XYBaseModule } from '../../type/index';
1
+ import { XYVideoRendererMap, XYAudioRendererMap, XYBaseModule } from '../../type/index';
2
2
  import { default as VideoManager } from './videoManager';
3
3
  import { default as XYRTCClient } from '../client';
4
4
 
@@ -6,11 +6,17 @@ export declare class XYRender implements XYBaseModule {
6
6
  private client;
7
7
  private logger;
8
8
  private slaveVideoManagers;
9
- private audioManagers;
10
9
  private videoManagerMap;
10
+ private audioManagerMap;
11
11
  constructor(client: XYRTCClient);
12
12
  getVideoManagerMap(): XYVideoRendererMap;
13
- getAudioManagers(): IAudioRenders;
13
+ /**
14
+ * 获取音频管理器
15
+ */
16
+ getAudioManagerMap(): XYAudioRendererMap;
17
+ /**
18
+ * 销毁资源
19
+ */
14
20
  destroy(): void;
15
21
  /**
16
22
  * 设置画面渲染元素并播放Video画面
@@ -18,20 +24,31 @@ export declare class XYRender implements XYBaseModule {
18
24
  * @param { string } id - 参会者Layout Id
19
25
  * @param { string } wrapEleId - 包裹video组件的容器ID字段
20
26
  */
21
- setVideoRenderer(id: string, wrapEleId: string): void;
27
+ setVideoRenderer(id: string, wrapEleId: string): Promise<void>;
28
+ /**
29
+ * 切换唇音同步通道状态
30
+ * 1、如果有视频通道,则切换使用视频通道,并Mute音频通道
31
+ * 2、如果没有视频通道,则切换使用音频通道播放
32
+ * 方案文档:https://nones.xylink.com/wiki/#/team/AQzvsooq/space/SLqJDsvD/page/13r8uVuq
33
+ *
34
+ * @param { string } id - 参会者Layout Id
35
+ * @param { XYMuteState } videoState - 视频静音状态
36
+ * @param { XYMuteState } audioState - 音频静音状态
37
+ */
38
+ private switchAudioVideoLipSync;
22
39
  /**
23
40
  * 设置画面渲染元素并播放Video画面
24
41
  *
25
42
  * @param { string } layoutId - 参会者Layout Id
26
43
  * @param { string } wrapEleId - 包裹video组件的容器ID字段
27
44
  */
28
- setSlaveVideoRenderer(layoutId: string, wrapEleId: string): import('../../type/index').IReturnResult;
45
+ setSlaveVideoRenderer(layoutId: string, wrapEleId: string): Promise<import('../../type/index').IReturnResult>;
29
46
  /**
30
47
  * videoManagers 移除key对应的元素
31
48
  *
32
49
  * @param { string } id - 参会者Layout Id
33
50
  */
34
- removeVideoRenderer(id: string): void;
51
+ removeVideoRenderer(id: string): Promise<void>;
35
52
  /**
36
53
  * 【副屏渲染】移除副屏渲染信息
37
54
  * 如果layoutId和viewId没有填写,则清空所有的副屏渲染配置数据
@@ -39,7 +56,7 @@ export declare class XYRender implements XYBaseModule {
39
56
  * @param { string } rosterId - 参会者Layout Id
40
57
  * @param { string } viewId 包裹video组件的元素id,此元素一定要提供宽高信息,内部会基于此宽高信息计算video的旋转信息
41
58
  */
42
- removeSlaveVideoRenderer(layoutId?: string, viewId?: string): void;
59
+ removeSlaveVideoRenderer(layoutId?: string, viewId?: string): Promise<void>;
43
60
  /**
44
61
  * 重新播放Video画面组件
45
62
  *
@@ -64,9 +81,9 @@ export declare class XYRender implements XYBaseModule {
64
81
  /**
65
82
  * 移除对应的AudioRender
66
83
  *
67
- * @param { string } id - MediaStream的Id字段
84
+ * @param { string } streamId - mediaStream流ID
68
85
  */
69
- removeAudioRender(key: string): void;
86
+ removeAudioRenderer(streamId: string): Promise<void>;
70
87
  /**
71
88
  * Video组件状态变更回调事件
72
89
  *
@@ -1,11 +1,8 @@
1
+ import { default as AudioManager } from './audioManager';
1
2
  import { default as VideoManager } from './videoManager';
2
3
 
3
4
  export type XYVideoRendererMap = Map<string, VideoManager>;
4
- export type IAudioRenders = {
5
- [key: string]: {
6
- ele: any;
7
- };
8
- };
5
+ export type XYAudioRendererMap = Map<string, AudioManager>;
9
6
  /**
10
7
  * 管理所有的Video Managers
11
8
  *