@vivix-ai/ivi-frontend-sdk 0.3.2 → 0.3.3
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.
- package/README.md +7 -0
- package/dist/index.cjs +64 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +64 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -72,6 +72,21 @@ interface IviRuntimeTrtcEvent {
|
|
|
72
72
|
streamType?: unknown;
|
|
73
73
|
}
|
|
74
74
|
type IviRuntimeTrtcEventListener = (event: IviRuntimeTrtcEvent) => void;
|
|
75
|
+
type IviRuntimeTrtcAIDenoiserMode = "normal" | "far_field_reduction";
|
|
76
|
+
interface IviRuntimeTrtcAIDenoiserOptions {
|
|
77
|
+
/**
|
|
78
|
+
* 是否启用 TRTC AIDenoiser 插件,默认 true。
|
|
79
|
+
*/
|
|
80
|
+
enabled?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* 降噪模式,默认 "normal"。
|
|
83
|
+
*/
|
|
84
|
+
mode?: IviRuntimeTrtcAIDenoiserMode;
|
|
85
|
+
/**
|
|
86
|
+
* TRTC AIDenoiser 资源路径;未配置时使用 TRTC SDK 默认加载逻辑。
|
|
87
|
+
*/
|
|
88
|
+
assetsPath?: string;
|
|
89
|
+
}
|
|
75
90
|
type IviRuntimeConversationLifecycle = "added" | "done";
|
|
76
91
|
type IviRuntimeConversationStatus = "in_progress" | "completed" | "incomplete";
|
|
77
92
|
interface IviRuntimeConversationItem {
|
|
@@ -103,6 +118,10 @@ interface IviRuntimeCoordinatorConfig {
|
|
|
103
118
|
* TRTC SDK 原始事件回调;可用于业务监听远端音视频可用性等底层事件。
|
|
104
119
|
*/
|
|
105
120
|
onTrtcEvent?: IviRuntimeTrtcEventListener;
|
|
121
|
+
/**
|
|
122
|
+
* TRTC SDK AIDenoiser 降噪配置。默认开启;传 false 可关闭。
|
|
123
|
+
*/
|
|
124
|
+
trtcAIDenoiser?: boolean | IviRuntimeTrtcAIDenoiserOptions;
|
|
106
125
|
}
|
|
107
126
|
/**
|
|
108
127
|
* 用户输入触发回复链路配置。
|
|
@@ -177,9 +196,10 @@ type TrtcSourceListener = (snapshot: TrtcSourceSnapshot) => void;
|
|
|
177
196
|
declare class TrtcSourceManager {
|
|
178
197
|
private readonly onLog?;
|
|
179
198
|
private readonly onTrtcEvent?;
|
|
199
|
+
private readonly aiDenoiser?;
|
|
180
200
|
private readonly sessions;
|
|
181
201
|
private readonly listeners;
|
|
182
|
-
constructor(onLog?: IviRuntimeLogCallback | undefined, onTrtcEvent?: IviRuntimeTrtcEventListener | undefined);
|
|
202
|
+
constructor(onLog?: IviRuntimeLogCallback | undefined, onTrtcEvent?: IviRuntimeTrtcEventListener | undefined, aiDenoiser?: (boolean | IviRuntimeTrtcAIDenoiserOptions) | undefined);
|
|
183
203
|
/**
|
|
184
204
|
* 将 runtime 当前 sources 与 TRTC 会话池对齐:
|
|
185
205
|
* - 对 ready + trtc 的 source 进行 upsert(必要时建立连接)
|
|
@@ -190,7 +210,7 @@ declare class TrtcSourceManager {
|
|
|
190
210
|
* 按 sourceId 注册/更新 TRTC 配置。
|
|
191
211
|
* 若配置发生变化,会先销毁旧会话再按新参数重建连接。
|
|
192
212
|
*/
|
|
193
|
-
upsertSource(sourceId: string, trtc: IviSourcePlaybackTrtc): void;
|
|
213
|
+
upsertSource(sourceId: string, trtc: IviSourcePlaybackTrtc, aiDenoiser?: boolean | IviRuntimeTrtcAIDenoiserOptions): void;
|
|
194
214
|
/**
|
|
195
215
|
* 删除指定 source 的 TRTC 会话并释放连接资源。
|
|
196
216
|
* 该操作通常由 source.deleted 或会话重置触发。
|
|
@@ -232,6 +252,7 @@ declare class TrtcSourceManager {
|
|
|
232
252
|
* - 至少一个 view 需出声 -> 对可用远端用户解除静音
|
|
233
253
|
*/
|
|
234
254
|
private applyAudioPolicy;
|
|
255
|
+
private applyAIDenoiserPolicy;
|
|
235
256
|
/**
|
|
236
257
|
* 销毁单个 source 会话:
|
|
237
258
|
* 解绑事件、停止远端视频、退出房间并销毁客户端。
|
|
@@ -546,6 +567,11 @@ interface IVITrtcPlayerProps {
|
|
|
546
567
|
loadingFallback?: ReactNode;
|
|
547
568
|
errorFallback?: ReactNode;
|
|
548
569
|
muted?: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* 独立使用 IVITrtcPlayer(未传 runtime)时的 TRTC AIDenoiser 降噪配置。
|
|
572
|
+
* 默认开启;传 false 可关闭。
|
|
573
|
+
*/
|
|
574
|
+
trtcAIDenoiser?: boolean | IviRuntimeTrtcAIDenoiserOptions;
|
|
549
575
|
}
|
|
550
576
|
/**
|
|
551
577
|
* 默认 TRTC 播放器:挂载即加入房间并拉流,连接由 TrtcSourceManager 统一复用。
|
|
@@ -724,4 +750,4 @@ declare function useManagedIviRuntime(config: IviManagedRuntimeConfig): IviRunti
|
|
|
724
750
|
|
|
725
751
|
declare function useIviStageView(): IviStageViewContextValue;
|
|
726
752
|
|
|
727
|
-
export { EMPTY_RUNTIME_STATE, IVILivekitPlayer, type IVILivekitPlayerProps, IVIStageView, type IVIStageViewProps, IVISubtitleOverlay, type IVISubtitleOverlayProps, type IVISubtitleOverlayStyle, IVITrackSlot, type IVITrackSlotProps, IVITrtcPlayer, type IVITrtcPlayerProps, type IviFrontendClientConfig, IviFrontendSdk, type IviManagedRuntimeConfig, type IviManagedRuntimeLogCallback, type IviManagedRuntimeLogEntry, type IviManagedRuntimeLogLevel, type IviManagedRuntimeLogSource, type IviRuntimeConversationItem, type IviRuntimeConversationLifecycle, type IviRuntimeConversationStatus, IviRuntimeCoordinator, type IviRuntimeCoordinatorConfig, IviRuntimeDispatcher, type IviRuntimeDispatcherConfig, type IviRuntimeEventListener, type IviRuntimeLogCallback, type IviRuntimeLogEntry, type IviRuntimeLogLevel, type IviRuntimeSource, type IviRuntimeSourcePreloadState, type IviRuntimeState, type IviRuntimeStatus, type IviRuntimeStream, type IviRuntimeTrtcEvent, type IviRuntimeTrtcEventListener, type IviRuntimeTrtcEventType, type IviRuntimeUserTextToResponseCallbacks, type IviRuntimeUserTextToResponseOptions, type IviRuntimeUserTextToResponseResult, type IviSourcePlaybackLivekit, type IviSourcePlaybackLivekitDescriptor, type IviStageSlotBinding, type IviStageViewContextValue, type IviSubtitleItem, type IviSubtitleRole, type IviUseSubtitlesOptions, LivekitSourceManager, TrtcSourceManager, isLivekitSourcePlayback, isReadyLivekitRuntimeSource, isSameLivekitConfig, useIviStageView, useIviSubtitles, useManagedIviRuntime, useRuntimeState };
|
|
753
|
+
export { EMPTY_RUNTIME_STATE, IVILivekitPlayer, type IVILivekitPlayerProps, IVIStageView, type IVIStageViewProps, IVISubtitleOverlay, type IVISubtitleOverlayProps, type IVISubtitleOverlayStyle, IVITrackSlot, type IVITrackSlotProps, IVITrtcPlayer, type IVITrtcPlayerProps, type IviFrontendClientConfig, IviFrontendSdk, type IviManagedRuntimeConfig, type IviManagedRuntimeLogCallback, type IviManagedRuntimeLogEntry, type IviManagedRuntimeLogLevel, type IviManagedRuntimeLogSource, type IviRuntimeConversationItem, type IviRuntimeConversationLifecycle, type IviRuntimeConversationStatus, IviRuntimeCoordinator, type IviRuntimeCoordinatorConfig, IviRuntimeDispatcher, type IviRuntimeDispatcherConfig, type IviRuntimeEventListener, type IviRuntimeLogCallback, type IviRuntimeLogEntry, type IviRuntimeLogLevel, type IviRuntimeSource, type IviRuntimeSourcePreloadState, type IviRuntimeState, type IviRuntimeStatus, type IviRuntimeStream, type IviRuntimeTrtcAIDenoiserMode, type IviRuntimeTrtcAIDenoiserOptions, type IviRuntimeTrtcEvent, type IviRuntimeTrtcEventListener, type IviRuntimeTrtcEventType, type IviRuntimeUserTextToResponseCallbacks, type IviRuntimeUserTextToResponseOptions, type IviRuntimeUserTextToResponseResult, type IviSourcePlaybackLivekit, type IviSourcePlaybackLivekitDescriptor, type IviStageSlotBinding, type IviStageViewContextValue, type IviSubtitleItem, type IviSubtitleRole, type IviUseSubtitlesOptions, LivekitSourceManager, TrtcSourceManager, isLivekitSourcePlayback, isReadyLivekitRuntimeSource, isSameLivekitConfig, useIviStageView, useIviSubtitles, useManagedIviRuntime, useRuntimeState };
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,21 @@ interface IviRuntimeTrtcEvent {
|
|
|
72
72
|
streamType?: unknown;
|
|
73
73
|
}
|
|
74
74
|
type IviRuntimeTrtcEventListener = (event: IviRuntimeTrtcEvent) => void;
|
|
75
|
+
type IviRuntimeTrtcAIDenoiserMode = "normal" | "far_field_reduction";
|
|
76
|
+
interface IviRuntimeTrtcAIDenoiserOptions {
|
|
77
|
+
/**
|
|
78
|
+
* 是否启用 TRTC AIDenoiser 插件,默认 true。
|
|
79
|
+
*/
|
|
80
|
+
enabled?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* 降噪模式,默认 "normal"。
|
|
83
|
+
*/
|
|
84
|
+
mode?: IviRuntimeTrtcAIDenoiserMode;
|
|
85
|
+
/**
|
|
86
|
+
* TRTC AIDenoiser 资源路径;未配置时使用 TRTC SDK 默认加载逻辑。
|
|
87
|
+
*/
|
|
88
|
+
assetsPath?: string;
|
|
89
|
+
}
|
|
75
90
|
type IviRuntimeConversationLifecycle = "added" | "done";
|
|
76
91
|
type IviRuntimeConversationStatus = "in_progress" | "completed" | "incomplete";
|
|
77
92
|
interface IviRuntimeConversationItem {
|
|
@@ -103,6 +118,10 @@ interface IviRuntimeCoordinatorConfig {
|
|
|
103
118
|
* TRTC SDK 原始事件回调;可用于业务监听远端音视频可用性等底层事件。
|
|
104
119
|
*/
|
|
105
120
|
onTrtcEvent?: IviRuntimeTrtcEventListener;
|
|
121
|
+
/**
|
|
122
|
+
* TRTC SDK AIDenoiser 降噪配置。默认开启;传 false 可关闭。
|
|
123
|
+
*/
|
|
124
|
+
trtcAIDenoiser?: boolean | IviRuntimeTrtcAIDenoiserOptions;
|
|
106
125
|
}
|
|
107
126
|
/**
|
|
108
127
|
* 用户输入触发回复链路配置。
|
|
@@ -177,9 +196,10 @@ type TrtcSourceListener = (snapshot: TrtcSourceSnapshot) => void;
|
|
|
177
196
|
declare class TrtcSourceManager {
|
|
178
197
|
private readonly onLog?;
|
|
179
198
|
private readonly onTrtcEvent?;
|
|
199
|
+
private readonly aiDenoiser?;
|
|
180
200
|
private readonly sessions;
|
|
181
201
|
private readonly listeners;
|
|
182
|
-
constructor(onLog?: IviRuntimeLogCallback | undefined, onTrtcEvent?: IviRuntimeTrtcEventListener | undefined);
|
|
202
|
+
constructor(onLog?: IviRuntimeLogCallback | undefined, onTrtcEvent?: IviRuntimeTrtcEventListener | undefined, aiDenoiser?: (boolean | IviRuntimeTrtcAIDenoiserOptions) | undefined);
|
|
183
203
|
/**
|
|
184
204
|
* 将 runtime 当前 sources 与 TRTC 会话池对齐:
|
|
185
205
|
* - 对 ready + trtc 的 source 进行 upsert(必要时建立连接)
|
|
@@ -190,7 +210,7 @@ declare class TrtcSourceManager {
|
|
|
190
210
|
* 按 sourceId 注册/更新 TRTC 配置。
|
|
191
211
|
* 若配置发生变化,会先销毁旧会话再按新参数重建连接。
|
|
192
212
|
*/
|
|
193
|
-
upsertSource(sourceId: string, trtc: IviSourcePlaybackTrtc): void;
|
|
213
|
+
upsertSource(sourceId: string, trtc: IviSourcePlaybackTrtc, aiDenoiser?: boolean | IviRuntimeTrtcAIDenoiserOptions): void;
|
|
194
214
|
/**
|
|
195
215
|
* 删除指定 source 的 TRTC 会话并释放连接资源。
|
|
196
216
|
* 该操作通常由 source.deleted 或会话重置触发。
|
|
@@ -232,6 +252,7 @@ declare class TrtcSourceManager {
|
|
|
232
252
|
* - 至少一个 view 需出声 -> 对可用远端用户解除静音
|
|
233
253
|
*/
|
|
234
254
|
private applyAudioPolicy;
|
|
255
|
+
private applyAIDenoiserPolicy;
|
|
235
256
|
/**
|
|
236
257
|
* 销毁单个 source 会话:
|
|
237
258
|
* 解绑事件、停止远端视频、退出房间并销毁客户端。
|
|
@@ -546,6 +567,11 @@ interface IVITrtcPlayerProps {
|
|
|
546
567
|
loadingFallback?: ReactNode;
|
|
547
568
|
errorFallback?: ReactNode;
|
|
548
569
|
muted?: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* 独立使用 IVITrtcPlayer(未传 runtime)时的 TRTC AIDenoiser 降噪配置。
|
|
572
|
+
* 默认开启;传 false 可关闭。
|
|
573
|
+
*/
|
|
574
|
+
trtcAIDenoiser?: boolean | IviRuntimeTrtcAIDenoiserOptions;
|
|
549
575
|
}
|
|
550
576
|
/**
|
|
551
577
|
* 默认 TRTC 播放器:挂载即加入房间并拉流,连接由 TrtcSourceManager 统一复用。
|
|
@@ -724,4 +750,4 @@ declare function useManagedIviRuntime(config: IviManagedRuntimeConfig): IviRunti
|
|
|
724
750
|
|
|
725
751
|
declare function useIviStageView(): IviStageViewContextValue;
|
|
726
752
|
|
|
727
|
-
export { EMPTY_RUNTIME_STATE, IVILivekitPlayer, type IVILivekitPlayerProps, IVIStageView, type IVIStageViewProps, IVISubtitleOverlay, type IVISubtitleOverlayProps, type IVISubtitleOverlayStyle, IVITrackSlot, type IVITrackSlotProps, IVITrtcPlayer, type IVITrtcPlayerProps, type IviFrontendClientConfig, IviFrontendSdk, type IviManagedRuntimeConfig, type IviManagedRuntimeLogCallback, type IviManagedRuntimeLogEntry, type IviManagedRuntimeLogLevel, type IviManagedRuntimeLogSource, type IviRuntimeConversationItem, type IviRuntimeConversationLifecycle, type IviRuntimeConversationStatus, IviRuntimeCoordinator, type IviRuntimeCoordinatorConfig, IviRuntimeDispatcher, type IviRuntimeDispatcherConfig, type IviRuntimeEventListener, type IviRuntimeLogCallback, type IviRuntimeLogEntry, type IviRuntimeLogLevel, type IviRuntimeSource, type IviRuntimeSourcePreloadState, type IviRuntimeState, type IviRuntimeStatus, type IviRuntimeStream, type IviRuntimeTrtcEvent, type IviRuntimeTrtcEventListener, type IviRuntimeTrtcEventType, type IviRuntimeUserTextToResponseCallbacks, type IviRuntimeUserTextToResponseOptions, type IviRuntimeUserTextToResponseResult, type IviSourcePlaybackLivekit, type IviSourcePlaybackLivekitDescriptor, type IviStageSlotBinding, type IviStageViewContextValue, type IviSubtitleItem, type IviSubtitleRole, type IviUseSubtitlesOptions, LivekitSourceManager, TrtcSourceManager, isLivekitSourcePlayback, isReadyLivekitRuntimeSource, isSameLivekitConfig, useIviStageView, useIviSubtitles, useManagedIviRuntime, useRuntimeState };
|
|
753
|
+
export { EMPTY_RUNTIME_STATE, IVILivekitPlayer, type IVILivekitPlayerProps, IVIStageView, type IVIStageViewProps, IVISubtitleOverlay, type IVISubtitleOverlayProps, type IVISubtitleOverlayStyle, IVITrackSlot, type IVITrackSlotProps, IVITrtcPlayer, type IVITrtcPlayerProps, type IviFrontendClientConfig, IviFrontendSdk, type IviManagedRuntimeConfig, type IviManagedRuntimeLogCallback, type IviManagedRuntimeLogEntry, type IviManagedRuntimeLogLevel, type IviManagedRuntimeLogSource, type IviRuntimeConversationItem, type IviRuntimeConversationLifecycle, type IviRuntimeConversationStatus, IviRuntimeCoordinator, type IviRuntimeCoordinatorConfig, IviRuntimeDispatcher, type IviRuntimeDispatcherConfig, type IviRuntimeEventListener, type IviRuntimeLogCallback, type IviRuntimeLogEntry, type IviRuntimeLogLevel, type IviRuntimeSource, type IviRuntimeSourcePreloadState, type IviRuntimeState, type IviRuntimeStatus, type IviRuntimeStream, type IviRuntimeTrtcAIDenoiserMode, type IviRuntimeTrtcAIDenoiserOptions, type IviRuntimeTrtcEvent, type IviRuntimeTrtcEventListener, type IviRuntimeTrtcEventType, type IviRuntimeUserTextToResponseCallbacks, type IviRuntimeUserTextToResponseOptions, type IviRuntimeUserTextToResponseResult, type IviSourcePlaybackLivekit, type IviSourcePlaybackLivekitDescriptor, type IviStageSlotBinding, type IviStageViewContextValue, type IviSubtitleItem, type IviSubtitleRole, type IviUseSubtitlesOptions, LivekitSourceManager, TrtcSourceManager, isLivekitSourcePlayback, isReadyLivekitRuntimeSource, isSameLivekitConfig, useIviStageView, useIviSubtitles, useManagedIviRuntime, useRuntimeState };
|
package/dist/index.js
CHANGED
|
@@ -1105,10 +1105,15 @@ var ConversationManager = class {
|
|
|
1105
1105
|
|
|
1106
1106
|
// src/runtime/managers/trtc-source-manager.ts
|
|
1107
1107
|
var TAG = "[IVI-TRTC]";
|
|
1108
|
+
var DEFAULT_DENOISER_OPTIONS = {
|
|
1109
|
+
enabled: true,
|
|
1110
|
+
mode: "normal"
|
|
1111
|
+
};
|
|
1108
1112
|
var TrtcSourceManager = class {
|
|
1109
|
-
constructor(onLog, onTrtcEvent) {
|
|
1113
|
+
constructor(onLog, onTrtcEvent, aiDenoiser) {
|
|
1110
1114
|
this.onLog = onLog;
|
|
1111
1115
|
this.onTrtcEvent = onTrtcEvent;
|
|
1116
|
+
this.aiDenoiser = aiDenoiser;
|
|
1112
1117
|
this.sessions = /* @__PURE__ */ new Map();
|
|
1113
1118
|
this.listeners = /* @__PURE__ */ new Map();
|
|
1114
1119
|
}
|
|
@@ -1135,21 +1140,21 @@ var TrtcSourceManager = class {
|
|
|
1135
1140
|
* 按 sourceId 注册/更新 TRTC 配置。
|
|
1136
1141
|
* 若配置发生变化,会先销毁旧会话再按新参数重建连接。
|
|
1137
1142
|
*/
|
|
1138
|
-
upsertSource(sourceId, trtc) {
|
|
1143
|
+
upsertSource(sourceId, trtc, aiDenoiser) {
|
|
1139
1144
|
const existing = this.sessions.get(sourceId);
|
|
1140
1145
|
if (!existing) {
|
|
1141
1146
|
this.log("info", `\u65B0\u5EFA\u4F1A\u8BDD source=${sourceId} room=${getTrtcString(trtc, "room_id")} user=${getTrtcString(trtc, "user_id")}`);
|
|
1142
|
-
const session2 = this.createSession(sourceId, trtc);
|
|
1147
|
+
const session2 = this.createSession(sourceId, trtc, aiDenoiser);
|
|
1143
1148
|
this.sessions.set(sourceId, session2);
|
|
1144
1149
|
void this.ensureConnected(session2);
|
|
1145
1150
|
return;
|
|
1146
1151
|
}
|
|
1147
|
-
if (isSameTrtcConfig(existing.trtc, trtc)) {
|
|
1152
|
+
if (isSameTrtcConfig(existing.trtc, trtc) && isSameAIDenoiserOptions(existing.aiDenoiser, aiDenoiser)) {
|
|
1148
1153
|
return;
|
|
1149
1154
|
}
|
|
1150
1155
|
this.log("info", `\u914D\u7F6E\u53D8\u66F4\uFF0C\u91CD\u5EFA\u4F1A\u8BDD source=${sourceId} room=${getTrtcString(trtc, "room_id")}`);
|
|
1151
1156
|
void this.disposeSession(existing);
|
|
1152
|
-
const session = this.createSession(sourceId, trtc);
|
|
1157
|
+
const session = this.createSession(sourceId, trtc, aiDenoiser);
|
|
1153
1158
|
this.sessions.set(sourceId, session);
|
|
1154
1159
|
void this.ensureConnected(session);
|
|
1155
1160
|
}
|
|
@@ -1286,10 +1291,11 @@ var TrtcSourceManager = class {
|
|
|
1286
1291
|
binding.muted = muted;
|
|
1287
1292
|
void this.applyAudioPolicy(session);
|
|
1288
1293
|
}
|
|
1289
|
-
createSession(sourceId, trtc) {
|
|
1294
|
+
createSession(sourceId, trtc, aiDenoiser) {
|
|
1290
1295
|
return {
|
|
1291
1296
|
sourceId,
|
|
1292
1297
|
trtc,
|
|
1298
|
+
aiDenoiser,
|
|
1293
1299
|
TRTC: null,
|
|
1294
1300
|
client: null,
|
|
1295
1301
|
connectPromise: null,
|
|
@@ -1395,6 +1401,7 @@ var TrtcSourceManager = class {
|
|
|
1395
1401
|
session.status = "connected";
|
|
1396
1402
|
session.error = void 0;
|
|
1397
1403
|
this.log("info", `\u8FDB\u623F\u6210\u529F source=${session.sourceId} room=${roomId}`);
|
|
1404
|
+
await this.applyAIDenoiserPolicy(session, client, sdkAppId, userId, userSig);
|
|
1398
1405
|
this.emitSnapshot(session.sourceId, {
|
|
1399
1406
|
status: session.status
|
|
1400
1407
|
});
|
|
@@ -1480,6 +1487,25 @@ var TrtcSourceManager = class {
|
|
|
1480
1487
|
await client.muteRemoteAudio(userId, false);
|
|
1481
1488
|
}
|
|
1482
1489
|
}
|
|
1490
|
+
async applyAIDenoiserPolicy(session, client, sdkAppId, userId, userSig) {
|
|
1491
|
+
const options = resolveAIDenoiserOptions(session.aiDenoiser ?? this.aiDenoiser);
|
|
1492
|
+
if (!options.enabled) {
|
|
1493
|
+
this.log("info", `TRTC AIDenoiser \u5DF2\u5173\u95ED source=${session.sourceId}`);
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1496
|
+
try {
|
|
1497
|
+
await client.startPlugin("AIDenoiser", {
|
|
1498
|
+
sdkAppId,
|
|
1499
|
+
userId,
|
|
1500
|
+
userSig,
|
|
1501
|
+
mode: getAIDenoiserModeValue(options.mode),
|
|
1502
|
+
...options.assetsPath ? { assetsPath: options.assetsPath } : {}
|
|
1503
|
+
});
|
|
1504
|
+
this.log("info", `TRTC AIDenoiser \u5DF2\u5F00\u542F source=${session.sourceId} mode=${options.mode}`);
|
|
1505
|
+
} catch (error) {
|
|
1506
|
+
this.log("warn", `TRTC AIDenoiser \u5F00\u542F\u5931\u8D25 source=${session.sourceId}`, error);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1483
1509
|
/**
|
|
1484
1510
|
* 销毁单个 source 会话:
|
|
1485
1511
|
* 解绑事件、停止远端视频、退出房间并销毁客户端。
|
|
@@ -1561,6 +1587,11 @@ function isRuntimeTrtcSource(source) {
|
|
|
1561
1587
|
function isSameTrtcConfig(a, b) {
|
|
1562
1588
|
return a.app_id === b.app_id && a.user_id === b.user_id && a.user_sig === b.user_sig && a.room_id === b.room_id;
|
|
1563
1589
|
}
|
|
1590
|
+
function isSameAIDenoiserOptions(a, b) {
|
|
1591
|
+
const left = resolveAIDenoiserOptions(a);
|
|
1592
|
+
const right = resolveAIDenoiserOptions(b);
|
|
1593
|
+
return left.enabled === right.enabled && left.mode === right.mode && left.assetsPath === right.assetsPath;
|
|
1594
|
+
}
|
|
1564
1595
|
function shouldUseStringRoomId(roomId) {
|
|
1565
1596
|
if (!/^\d+$/.test(roomId)) {
|
|
1566
1597
|
return true;
|
|
@@ -1572,6 +1603,26 @@ function getTrtcString(trtc, key) {
|
|
|
1572
1603
|
const value = trtc[key];
|
|
1573
1604
|
return typeof value === "string" ? value : "";
|
|
1574
1605
|
}
|
|
1606
|
+
function resolveAIDenoiserOptions(options) {
|
|
1607
|
+
if (options === false) {
|
|
1608
|
+
return {
|
|
1609
|
+
...DEFAULT_DENOISER_OPTIONS,
|
|
1610
|
+
enabled: false
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
if (options === true || options === void 0) {
|
|
1614
|
+
return DEFAULT_DENOISER_OPTIONS;
|
|
1615
|
+
}
|
|
1616
|
+
return {
|
|
1617
|
+
...DEFAULT_DENOISER_OPTIONS,
|
|
1618
|
+
...options,
|
|
1619
|
+
enabled: options.enabled ?? DEFAULT_DENOISER_OPTIONS.enabled,
|
|
1620
|
+
mode: options.mode ?? DEFAULT_DENOISER_OPTIONS.mode
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
function getAIDenoiserModeValue(mode) {
|
|
1624
|
+
return mode === "far_field_reduction" ? 1 : 0;
|
|
1625
|
+
}
|
|
1575
1626
|
function buildRemoteVideoKey(userId, streamType) {
|
|
1576
1627
|
return `${userId}::${streamType}`;
|
|
1577
1628
|
}
|
|
@@ -2074,7 +2125,8 @@ var IviRuntimeCoordinator = class {
|
|
|
2074
2125
|
};
|
|
2075
2126
|
this.trtcSourceManager = new TrtcSourceManager(
|
|
2076
2127
|
this.config.onLog,
|
|
2077
|
-
(event) => this.emitTrtcEvent(event)
|
|
2128
|
+
(event) => this.emitTrtcEvent(event),
|
|
2129
|
+
this.config.trtcAIDenoiser
|
|
2078
2130
|
);
|
|
2079
2131
|
this.livekitSourceManager = new LivekitSourceManager(this.config.onLog);
|
|
2080
2132
|
this.sessionHandler = new SessionEventHandler(this.sessionManager, {
|
|
@@ -3154,7 +3206,8 @@ function IVITrtcPlayer(props) {
|
|
|
3154
3206
|
style,
|
|
3155
3207
|
loadingFallback = null,
|
|
3156
3208
|
errorFallback = null,
|
|
3157
|
-
muted = false
|
|
3209
|
+
muted = false,
|
|
3210
|
+
trtcAIDenoiser
|
|
3158
3211
|
} = props;
|
|
3159
3212
|
const containerRef = useRef(null);
|
|
3160
3213
|
const viewIdRef = useRef(`trtc-view-${Math.random().toString(36).slice(2, 10)}`);
|
|
@@ -3175,7 +3228,7 @@ function IVITrtcPlayer(props) {
|
|
|
3175
3228
|
}
|
|
3176
3229
|
let disposed = false;
|
|
3177
3230
|
if (shouldManageSourceLifecycle) {
|
|
3178
|
-
manager.upsertSource(resolvedSourceId, trtc);
|
|
3231
|
+
manager.upsertSource(resolvedSourceId, trtc, trtcAIDenoiser);
|
|
3179
3232
|
}
|
|
3180
3233
|
const unsubscribe = manager.subscribe(resolvedSourceId, (snapshot) => {
|
|
3181
3234
|
if (disposed) {
|
|
@@ -3206,7 +3259,8 @@ function IVITrtcPlayer(props) {
|
|
|
3206
3259
|
trtc.app_id,
|
|
3207
3260
|
trtc.room_id,
|
|
3208
3261
|
trtc.user_id,
|
|
3209
|
-
trtc.user_sig
|
|
3262
|
+
trtc.user_sig,
|
|
3263
|
+
trtcAIDenoiser
|
|
3210
3264
|
]);
|
|
3211
3265
|
useEffect(() => {
|
|
3212
3266
|
manager.updateViewMuted(resolvedSourceId, viewIdRef.current, muted);
|