opensips-js 0.1.41 → 0.1.42
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/dist/index.d.ts +1 -0
- package/dist/opensips-js.cjs.js +1 -1
- package/dist/opensips-js.es.js +58 -39
- package/dist/opensips-js.iife.js +1 -1
- package/dist/opensips-js.umd.js +1 -1
- package/package.json +1 -1
- package/src/types/listeners.d.ts +115 -115
package/dist/opensips-js.es.js
CHANGED
|
@@ -23555,7 +23555,7 @@ class hS {
|
|
|
23555
23555
|
}, this.activeStreamValue = null, this.initialStreamValue = null, this.vadSession = null, this.vadSessionState = {
|
|
23556
23556
|
currentMode: "clean",
|
|
23557
23557
|
isSpeaking: !1
|
|
23558
|
-
}, this.vadInterval = null, this.vadMrsInterval = null, this.ringbackTimers = {}, this.ringbackAudioContexts = {}, this.ringbackSessionProgressReceived = {}, this.hangupBeepContext = null, this.managedAudioContext = new fS(), this.context = t, this.context.on(
|
|
23558
|
+
}, this.vadInterval = null, this.vadMrsInterval = null, this.vadSessionGeneration = 0, this.ringbackTimers = {}, this.ringbackAudioContexts = {}, this.ringbackSessionProgressReceived = {}, this.hangupBeepContext = null, this.managedAudioContext = new fS(), this.context = t, this.context.on(
|
|
23559
23559
|
this.context.newRTCSessionEventName,
|
|
23560
23560
|
this.newRTCSessionCallback.bind(this)
|
|
23561
23561
|
), this.VUMeter = new cS({
|
|
@@ -24089,89 +24089,108 @@ class hS {
|
|
|
24089
24089
|
}, this.noiseReduction.noiseCheckInterval);
|
|
24090
24090
|
}
|
|
24091
24091
|
async processVADForActiveStream(t = {}) {
|
|
24092
|
+
var m;
|
|
24092
24093
|
const n = this.activeStream;
|
|
24093
|
-
this.stopSessionVad()
|
|
24094
|
+
this.stopSessionVad();
|
|
24095
|
+
const o = this.vadSessionGeneration, a = () => o !== this.vadSessionGeneration;
|
|
24096
|
+
this.vadSessionState = {
|
|
24094
24097
|
currentMode: "clean",
|
|
24095
24098
|
isSpeaking: !1
|
|
24096
24099
|
};
|
|
24097
|
-
const
|
|
24098
|
-
|
|
24099
|
-
|
|
24100
|
-
|
|
24100
|
+
const s = await this.managedAudioContext.getContext();
|
|
24101
|
+
if (a())
|
|
24102
|
+
return;
|
|
24103
|
+
const r = await hv(n, s, 150);
|
|
24104
|
+
if (a())
|
|
24105
|
+
return;
|
|
24106
|
+
let _ = !1;
|
|
24107
|
+
const d = Object.values(this.extendedCalls).filter((T) => T.roomId === this.currentActiveRoomId), h = await this.MicVAD.new({
|
|
24108
|
+
getStream: () => new Promise((T) => T(n)),
|
|
24109
|
+
pauseStream: async () => {
|
|
24110
|
+
},
|
|
24111
|
+
resumeStream: async (T) => T,
|
|
24101
24112
|
...uS,
|
|
24102
24113
|
...this.noiseReduction.vadConfig,
|
|
24103
24114
|
baseAssetPath: this.noiseReduction.baseAssetPath,
|
|
24104
24115
|
onnxWASMBasePath: this.noiseReduction.onnxWASMBasePath,
|
|
24105
24116
|
onFrameProcessed: () => {
|
|
24106
|
-
var
|
|
24107
|
-
if (!
|
|
24108
|
-
if (
|
|
24117
|
+
var T, S;
|
|
24118
|
+
if (!a() && !_) {
|
|
24119
|
+
if (_ = !0, console.log("✅ VAD initialized, starting background noise monitoring"), this.noiseReduction.mode === "enabled") {
|
|
24109
24120
|
if (t && Object.keys(t).length)
|
|
24110
|
-
Object.keys(t).forEach((
|
|
24111
|
-
const
|
|
24112
|
-
if (
|
|
24113
|
-
const
|
|
24114
|
-
|
|
24121
|
+
Object.keys(t).forEach((E) => {
|
|
24122
|
+
const C = this.extendedCalls[E];
|
|
24123
|
+
if (C && C.connection.getSenders()[0]) {
|
|
24124
|
+
const A = cu(r.stream, t[E]);
|
|
24125
|
+
C.connection.getSenders()[0].replaceTrack(A.getAudioTracks()[0]);
|
|
24115
24126
|
}
|
|
24116
24127
|
});
|
|
24117
24128
|
else {
|
|
24118
|
-
const
|
|
24119
|
-
|
|
24129
|
+
const E = d[0], C = (T = E == null ? void 0 : E.connection) == null ? void 0 : T.getSenders()[0], A = r.stream.getAudioTracks()[0];
|
|
24130
|
+
C && C.replaceTrack(A);
|
|
24120
24131
|
}
|
|
24121
24132
|
return;
|
|
24122
24133
|
}
|
|
24123
24134
|
if (!this.vadSessionState) {
|
|
24124
|
-
console.error("[processVAD] CRITICAL: State not found"), (
|
|
24135
|
+
console.error("[processVAD] CRITICAL: State not found"), (S = this.context.logger) == null || S.error("[processVAD] CRITICAL: State not found");
|
|
24125
24136
|
return;
|
|
24126
24137
|
}
|
|
24127
24138
|
this.startNoiseMonitor({
|
|
24128
24139
|
stream: n,
|
|
24129
24140
|
onNoiseDetected: async () => {
|
|
24130
|
-
var
|
|
24131
|
-
if (console.log("[processVad] - Replace track with Vad Controlled"), (
|
|
24132
|
-
Object.keys(t).forEach((
|
|
24133
|
-
const
|
|
24134
|
-
if (
|
|
24135
|
-
const
|
|
24136
|
-
|
|
24141
|
+
var E;
|
|
24142
|
+
if (console.log("[processVad] - Replace track with Vad Controlled"), (E = this.context.logger) == null || E.log("[processVad] - Replace track with Vad Controlled"), t && Object.keys(t).length)
|
|
24143
|
+
Object.keys(t).forEach((C) => {
|
|
24144
|
+
const A = this.extendedCalls[C];
|
|
24145
|
+
if (A && A.connection.getSenders()[0]) {
|
|
24146
|
+
const R = cu(r.stream, t[C]);
|
|
24147
|
+
A.connection.getSenders()[0].replaceTrack(R.getAudioTracks()[0]);
|
|
24137
24148
|
}
|
|
24138
24149
|
});
|
|
24139
24150
|
else {
|
|
24140
|
-
const
|
|
24141
|
-
|
|
24151
|
+
const C = d[0];
|
|
24152
|
+
C.connection.getSenders()[0] && C.connection.getSenders()[0].replaceTrack(r.stream.getAudioTracks()[0]);
|
|
24142
24153
|
}
|
|
24143
24154
|
},
|
|
24144
24155
|
onNoiseStop: async () => {
|
|
24145
24156
|
if (console.log("Replace track with Original"), t && Object.keys(t).length)
|
|
24146
|
-
Object.keys(t).forEach((
|
|
24147
|
-
const
|
|
24148
|
-
if (!
|
|
24157
|
+
Object.keys(t).forEach((E) => {
|
|
24158
|
+
const C = this.extendedCalls[E];
|
|
24159
|
+
if (!C)
|
|
24149
24160
|
return;
|
|
24150
|
-
const
|
|
24151
|
-
if (
|
|
24152
|
-
const
|
|
24153
|
-
|
|
24161
|
+
const A = C.connection.getSenders()[0];
|
|
24162
|
+
if (A && A.track && A.transport && A.transport.state !== "closed" && A.transport.state !== "failed") {
|
|
24163
|
+
const R = cu(n, t[E]);
|
|
24164
|
+
A.replaceTrack(R.getAudioTracks()[0]);
|
|
24154
24165
|
}
|
|
24155
24166
|
});
|
|
24156
24167
|
else {
|
|
24157
|
-
const
|
|
24158
|
-
|
|
24168
|
+
const E = d[0].connection.getSenders()[0];
|
|
24169
|
+
E && E.track && E.transport && E.transport.state !== "closed" && E.transport.state !== "failed" && E.replaceTrack(n.getAudioTracks()[0]);
|
|
24159
24170
|
}
|
|
24160
24171
|
}
|
|
24161
24172
|
});
|
|
24162
24173
|
}
|
|
24163
24174
|
},
|
|
24164
24175
|
onSpeechStart: () => {
|
|
24165
|
-
console.log("🎤 Speech started"),
|
|
24176
|
+
a() || (console.log("🎤 Speech started"), r.setSpeaking(!0), this.vadSessionState.isSpeaking = !0);
|
|
24166
24177
|
},
|
|
24167
24178
|
onSpeechEnd: () => {
|
|
24168
|
-
console.log("🛑 Speech end"),
|
|
24179
|
+
a() || (console.log("🛑 Speech end"), r.setSpeaking(!1), this.vadSessionState.isSpeaking = !1);
|
|
24169
24180
|
}
|
|
24170
24181
|
});
|
|
24171
|
-
|
|
24182
|
+
if (a()) {
|
|
24183
|
+
try {
|
|
24184
|
+
h.pause();
|
|
24185
|
+
} catch (T) {
|
|
24186
|
+
(m = this.context.logger) == null || m.error("[processVADForActiveStream] Error pausing stale vadSession:", T);
|
|
24187
|
+
}
|
|
24188
|
+
return;
|
|
24189
|
+
}
|
|
24190
|
+
this.vadSession && (this.vadSession.pause(), this.vadSession = null), this.vadSession = h, h.start();
|
|
24172
24191
|
}
|
|
24173
24192
|
stopSessionVad() {
|
|
24174
|
-
this.vadSession && (this.vadSession.pause(), this.vadSession = null), this.vadInterval && (clearInterval(this.vadInterval), this.vadInterval = null), this.vadMrsInterval && (clearInterval(this.vadMrsInterval), this.vadMrsInterval = null), this.vadSessionState && (this.vadSessionState = {
|
|
24193
|
+
this.vadSessionGeneration++, this.vadSession && (this.vadSession.pause(), this.vadSession = null), this.vadInterval && (clearInterval(this.vadInterval), this.vadInterval = null), this.vadMrsInterval && (clearInterval(this.vadMrsInterval), this.vadMrsInterval = null), this.vadSessionState && (this.vadSessionState = {
|
|
24175
24194
|
currentMode: "clean",
|
|
24176
24195
|
isSpeaking: !1
|
|
24177
24196
|
}, this.context.emit("changeNoiseReductionState", !1));
|