opensips-js 0.1.41 → 0.1.43

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.
@@ -20145,7 +20145,8 @@ const KT = [
20145
20145
  //'originalStream',
20146
20146
  "localMuted",
20147
20147
  "autoAnswer",
20148
- "putOnHoldTimestamp"
20148
+ "putOnHoldTimestamp",
20149
+ "_remote_party_display_name"
20149
20150
  ], YT = [
20150
20151
  //'roomId',
20151
20152
  "_cancel_reason",
@@ -20186,17 +20187,23 @@ function JT(c, t, n, o) {
20186
20187
  a.id = t._id, a.className = "audioTag", a.srcObject = c, a.setSinkId(n), a.volume = o, a.play(), t.audioTag = a;
20187
20188
  }
20188
20189
  function zT(c) {
20190
+ if (!c)
20191
+ return null;
20192
+ const t = c.match(/^\s*"((?:[^"\\]|\\.)*)"/);
20193
+ return t ? t[1].replace(/\\(.)/g, "$1") : null;
20194
+ }
20195
+ function XT(c) {
20189
20196
  if (c && typeof c.log == "function" && typeof c.warn == "function" && typeof c.error == "function")
20190
20197
  return !0;
20191
20198
  }
20192
20199
  function Od() {
20193
20200
  return /Mobi|react-native|Android|iPhone/i.test(navigator.userAgent);
20194
20201
  }
20195
- const XT = ut, QT = Zt(), Dt = new XT("WebSocketInterface");
20196
- var ZT = class {
20202
+ const QT = ut, ZT = Zt(), Dt = new QT("WebSocketInterface");
20203
+ var ev = class {
20197
20204
  constructor(t) {
20198
20205
  Dt.debug('new() [url:"%s"]', t), this._url = t, this._sip_uri = null, this._via_transport = null, this._ws = null;
20199
- const n = QT.parse(t, "absoluteURI");
20206
+ const n = ZT.parse(t, "absoluteURI");
20200
20207
  if (n === -1)
20201
20208
  throw Dt.warn(`invalid WebSocket URI: ${t}`), new TypeError(`Invalid argument: ${t}`);
20202
20209
  if (n.scheme !== "wss" && n.scheme !== "ws")
@@ -20262,17 +20269,17 @@ var ZT = class {
20262
20269
  Dt.warn(`WebSocket ${this._url} error: `, t);
20263
20270
  }
20264
20271
  };
20265
- const Ou = Vo, ev = De, tv = Cs, sv = Ct(), nv = wd, rv = ys(), iv = Fu(), lv = Zt(), ov = ZT, av = gr("JsSIP");
20266
- av("version %s", Ou.version);
20267
- var uv = {
20268
- C: ev,
20269
- Exceptions: tv,
20270
- Utils: sv,
20271
- UA: nv,
20272
- URI: rv,
20273
- NameAddrHeader: iv,
20274
- WebSocketInterface: ov,
20275
- Grammar: lv,
20272
+ const Ou = Vo, tv = De, sv = Cs, nv = Ct(), rv = wd, iv = ys(), lv = Fu(), ov = Zt(), av = ev, uv = gr("JsSIP");
20273
+ uv("version %s", Ou.version);
20274
+ var cv = {
20275
+ C: tv,
20276
+ Exceptions: sv,
20277
+ Utils: nv,
20278
+ UA: rv,
20279
+ URI: iv,
20280
+ NameAddrHeader: lv,
20281
+ WebSocketInterface: av,
20282
+ Grammar: ov,
20276
20283
  // Expose the debug module.
20277
20284
  debug: gr,
20278
20285
  get name() {
@@ -20282,11 +20289,11 @@ var uv = {
20282
20289
  return Ou.version;
20283
20290
  }
20284
20291
  };
20285
- const cv = /* @__PURE__ */ Xe(uv);
20292
+ const fv = /* @__PURE__ */ Xe(cv);
20286
20293
  function lu(c) {
20287
20294
  return c < 10 ? `0${c}` : `${c}`;
20288
20295
  }
20289
- function fv(c) {
20296
+ function dv(c) {
20290
20297
  let t = c.hours || 0, n = c.minutes || 0, o = c.seconds || 0;
20291
20298
  o++, o === 60 && (o = 0, n++, n === 60 && (n = 0, t++));
20292
20299
  const a = `${lu(t)}:${lu(n)}:${lu(o)}`;
@@ -20297,13 +20304,13 @@ function fv(c) {
20297
20304
  formatted: a
20298
20305
  };
20299
20306
  }
20300
- function dv(c) {
20307
+ function hv(c) {
20301
20308
  let t = 0;
20302
20309
  for (let n = 0; n < c.length; n++)
20303
20310
  t += c[n] * c[n];
20304
20311
  return Math.sqrt(t / c.length);
20305
20312
  }
20306
- async function hv(c, t, n = 150) {
20313
+ async function _v(c, t, n = 150) {
20307
20314
  const o = t.createMediaStreamSource(c), a = t.createDelay();
20308
20315
  a.delayTime.value = n / 1e3;
20309
20316
  const s = t.createGain();
@@ -20449,8 +20456,8 @@ var Dd = {};
20449
20456
  };
20450
20457
  });
20451
20458
  })(Dd);
20452
- const _v = At, pv = Dd;
20453
- var gv = Object.assign(_v, { instanceMethods: pv });
20459
+ const pv = At, gv = Dd;
20460
+ var mv = Object.assign(pv, { instanceMethods: gv });
20454
20461
  const Xt = {
20455
20462
  NEW_CALL: "new_call",
20456
20463
  CALL_CONFIRMED: "confirmed",
@@ -20481,7 +20488,7 @@ const Xt = {
20481
20488
  BUSY_EVERYWHERE: 600,
20482
20489
  DECLINE: 603
20483
20490
  };
20484
- var mv = { exports: {} };
20491
+ var Tv = { exports: {} };
20485
20492
  (function(c) {
20486
20493
  var t = function(n) {
20487
20494
  var o = Object.prototype, a = o.hasOwnProperty, s = Object.defineProperty || function(Q, W, G) {
@@ -20825,7 +20832,7 @@ var mv = { exports: {} };
20825
20832
  } catch {
20826
20833
  typeof globalThis == "object" ? globalThis.regeneratorRuntime = t : Function("r", "regeneratorRuntime = r")(t);
20827
20834
  }
20828
- })(mv);
20835
+ })(Tv);
20829
20836
  var Nd = { exports: {} };
20830
20837
  (function(c) {
20831
20838
  (function(t, n) {
@@ -20971,9 +20978,9 @@ var Nd = { exports: {} };
20971
20978
  var It = Nd.exports;
20972
20979
  const vs = () => `${(/* @__PURE__ */ new Date()).toISOString()} | metrics`, Ss = (c, t, n) => `${c} | ${t} | ${n}`;
20973
20980
  It.setDefaultLevel(It.levels.TRACE);
20974
- const Tv = (c) => {
20981
+ const vv = (c) => {
20975
20982
  It.info(Ss(vs(), "log ", `set log level to ${c ? "verbose" : "info"}`)), It.setLevel(c ? It.levels.TRACE : It.levels.INFO);
20976
- }, vv = (c) => {
20983
+ }, Sv = (c) => {
20977
20984
  const t = [...Object.keys(It.levels)];
20978
20985
  t.includes(c) ? (It.info(Ss(vs(), "log ", `update log level to ${c.toLowerCase()}`)), It.setLevel(c)) : It.warn(Ss(vs(), "log ", "Incorrect log level please choose one of "), t);
20979
20986
  }, Ue = (c, t, n) => {
@@ -20987,7 +20994,7 @@ const Tv = (c) => {
20987
20994
  }, dr = (c, t) => {
20988
20995
  It.error(Ss(vs(), c, t));
20989
20996
  };
20990
- function Sv(c) {
20997
+ function Ev(c) {
20991
20998
  return Math.floor(Math.random() * c).toString();
20992
20999
  }
20993
21000
  function Pf(c, t) {
@@ -20996,13 +21003,13 @@ function Pf(c, t) {
20996
21003
  n = n.replace(o, "");
20997
21004
  }), n;
20998
21005
  }
20999
- function Ev(c, t) {
21006
+ function yv(c, t) {
21000
21007
  let n = "";
21001
21008
  for (let o = 0; o < t; o += 1)
21002
- n += c[Sv(c.length)];
21009
+ n += c[Ev(c.length)];
21003
21010
  return n;
21004
21011
  }
21005
- function yv({
21012
+ function Cv({
21006
21013
  length: c = 20,
21007
21014
  useLetters: t = !0,
21008
21015
  useNumbers: n = !0,
@@ -21010,10 +21017,10 @@ function yv({
21010
21017
  excludeSymbols: a = []
21011
21018
  } = {}) {
21012
21019
  let s = "abcdefghijklmnopqrstuvwxyz", r = "0123456789", _ = [], d = [], h = [];
21013
- return t && (a.length && (s = Pf(a, s)), d = s.split("")), n && (a.length && (r = Pf(a, r)), h = r.split("")), _ = [...d, ...h, ...o], Ev(_, c);
21020
+ return t && (a.length && (s = Pf(a, s)), d = s.split("")), n && (a.length && (r = Pf(a, r)), h = r.split("")), _ = [...d, ...h, ...o], yv(_, c);
21014
21021
  }
21015
- var Cv = yv;
21016
- const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3", $e = {
21022
+ var Av = Cv;
21023
+ const Xi = /* @__PURE__ */ Xe(Av), Rv = () => "WebRTCMetrics", Iv = () => "5.0.3", $e = {
21017
21024
  INBOUND: "inbound",
21018
21025
  OUTBOUND: "outbound"
21019
21026
  }, ms = {
@@ -21028,7 +21035,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21028
21035
  DISCONNECTED: "disconnected",
21029
21036
  FAILED: "failed",
21030
21037
  CLOSED: "closed"
21031
- }, Iv = () => ({
21038
+ }, bv = () => ({
21032
21039
  ...{
21033
21040
  delta_time_to_measure_probes_ms: 0,
21034
21041
  // Total time to measure all probes
@@ -21131,7 +21138,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21131
21138
  timestamp_out: null,
21132
21139
  ssrc: "",
21133
21140
  direction: $e.OUTBOUND
21134
- }, bv = (c) => {
21141
+ }, wv = (c) => {
21135
21142
  const t = {
21136
21143
  pname: "",
21137
21144
  call_id: "",
@@ -21190,7 +21197,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21190
21197
  network: { ...t.network },
21191
21198
  experimental: { ...t.experimental }
21192
21199
  };
21193
- }, wv = {
21200
+ }, Ov = {
21194
21201
  refreshEvery: 2e3,
21195
21202
  // Default - generate a report every 2s (in ms). Min 1s.
21196
21203
  startAfter: 0,
@@ -21293,12 +21300,12 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21293
21300
  VIDEO: "video",
21294
21301
  NETWORK: "network",
21295
21302
  DATA: "data"
21296
- }, uu = "config ", Ov = (c, t = {}, n) => {
21303
+ }, uu = "config ", Dv = (c, t = {}, n) => {
21297
21304
  const o = { ...n, ...t };
21298
21305
  return t.pname || Do(uu, `Argument [String] 'cfg.pname' for the peerConnection name or id is missing - use generated '${n.pname}'`), t.cid || Do(uu, `Argument [String] 'cfg.cid' for the call name or id is missing - use generated '${n.cid}'`), t.uid || Do(uu, `Argument [String] 'cfg.uid' for the user name or id is missing - use generated '${n.uid}'`), o.pc = c, o;
21299
- }, Dv = (c = {}) => {
21300
- const t = { ...wv, ...c };
21301
- return t.name = Av(), t.version = Rv(), t;
21306
+ }, Nv = (c = {}) => {
21307
+ const t = { ...Ov, ...c };
21308
+ return t.name = Rv(), t.version = Iv(), t;
21302
21309
  }, pl = (c, t, n, o = !1, a) => {
21303
21310
  let s = c.map((r) => {
21304
21311
  if (!n)
@@ -21309,7 +21316,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21309
21316
  return _ ? _[n] : null;
21310
21317
  });
21311
21318
  return s = s.filter((r) => o ? Number.isFinite(r) && r > 0 : Number.isFinite(r)), s.length === 0 ? [] : s;
21312
- }, Gs = (c) => c.reduce((t, n) => t + n, 0) / c.length, Nv = () => `probe-${Xi()}`, xv = () => `coltr-${Xi()}`, Mf = (c) => new Promise((t) => setTimeout(t, c)), Du = (c, t, n) => {
21319
+ }, Gs = (c) => c.reduce((t, n) => t + n, 0) / c.length, xv = () => `probe-${Xi()}`, Uv = () => `coltr-${Xi()}`, Mf = (c) => new Promise((t) => setTimeout(t, c)), Du = (c, t, n) => {
21313
21320
  t ? c.call(t, n) : c(n);
21314
21321
  }, Ye = (c, t, n, o) => {
21315
21322
  const a = pl(c, t, n, !0, o);
@@ -21336,7 +21343,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21336
21343
  return a[t][n];
21337
21344
  const s = a[t][o];
21338
21345
  return s ? s[n] : null;
21339
- }, Uv = (c) => c.slice().pop(), ct = (c, t, n) => {
21346
+ }, kv = (c) => c.slice().pop(), ct = (c, t, n) => {
21340
21347
  if (!t)
21341
21348
  return null;
21342
21349
  const o = {};
@@ -21344,7 +21351,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21344
21351
  a || (a = n === $e.INBOUND ? { ...xd } : { ...Ud }), o[M.AUDIO] = a;
21345
21352
  let s = t[M.VIDEO][c];
21346
21353
  return s || (s = n === $e.INBOUND ? { ...kd } : { ...Pd }), o[M.VIDEO] = s, o;
21347
- }, Yi = "exporter ", kv = "2.0", Lf = (c, t, n) => {
21354
+ }, Yi = "exporter ", Pv = "2.0", Lf = (c, t, n) => {
21348
21355
  if (!c || c.length === 0)
21349
21356
  return 0;
21350
21357
  const o = c[c.length - 1];
@@ -21356,7 +21363,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21356
21363
  return !r || !s ? Qe(c, t, "delta_rtt_ms_out", !1, n) : Number(s / r);
21357
21364
  }
21358
21365
  return null;
21359
- }, Pv = (c, t) => {
21366
+ }, Mv = (c, t) => {
21360
21367
  if (!c || c.length === 0)
21361
21368
  return 0;
21362
21369
  const n = c[c.length - 1];
@@ -21368,7 +21375,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21368
21375
  t,
21369
21376
  "delta_rtt_connectivity_ms"
21370
21377
  ) : Number(o / a);
21371
- }, Mv = (c) => mt(
21378
+ }, Lv = (c) => mt(
21372
21379
  c,
21373
21380
  "network",
21374
21381
  "local_candidate_type"
@@ -21380,7 +21387,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21380
21387
  c,
21381
21388
  "network",
21382
21389
  "local_candidate_relay_protocol"
21383
- )}`, Lv = (c) => {
21390
+ )}`, $v = (c) => {
21384
21391
  const t = mt(
21385
21392
  c,
21386
21393
  "network",
@@ -21392,7 +21399,7 @@ const Xi = /* @__PURE__ */ Xe(Cv), Av = () => "WebRTCMetrics", Rv = () => "5.0.3
21392
21399
  );
21393
21400
  return t !== "relay" ? `direct/${n}` : `turn/${n}`;
21394
21401
  };
21395
- class $v {
21402
+ class Hv {
21396
21403
  constructor(t) {
21397
21404
  this._start = null, this._end = null, this._cfg = t, this._referenceReport = null, this._reports = [], this._events = [];
21398
21405
  }
@@ -21442,7 +21449,7 @@ class $v {
21442
21449
  this._reports,
21443
21450
  "video",
21444
21451
  "total_packets_in"
21445
- ), s = {}, r = Uv(this._reports);
21452
+ ), s = {}, r = kv(this._reports);
21446
21453
  return r && (Object.keys(r[M.AUDIO]).forEach((_) => {
21447
21454
  const d = r[M.AUDIO][_];
21448
21455
  if (s[d.ssrc] = {
@@ -22019,7 +22026,7 @@ class $v {
22019
22026
  s[_].jitter = h, s[_].rtt = S, s[_].traffic = T, s[_].bitrate = m, s[_].loss = A;
22020
22027
  }
22021
22028
  })), {
22022
- version: kv,
22029
+ version: Pv,
22023
22030
  configuration: {
22024
22031
  frequency: this._cfg.refreshEvery
22025
22032
  },
@@ -22042,7 +22049,7 @@ class $v {
22042
22049
  ssrc: s,
22043
22050
  data: {
22044
22051
  rtt: {
22045
- avg: Pv(this._reports, "data"),
22052
+ avg: Mv(this._reports, "data"),
22046
22053
  min: Je(
22047
22054
  this._reports,
22048
22055
  "data",
@@ -22145,8 +22152,8 @@ class $v {
22145
22152
  }
22146
22153
  },
22147
22154
  network: {
22148
- localConnection: Mv(this._reports),
22149
- remoteConnection: Lv(this._reports)
22155
+ localConnection: Lv(this._reports),
22156
+ remoteConnection: $v(this._reports)
22150
22157
  }
22151
22158
  }
22152
22159
  };
@@ -22184,7 +22191,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22184
22191
  totalRTT: T,
22185
22192
  totalRTTMeasurements: S
22186
22193
  };
22187
- }, Hv = (c, t, n, o) => {
22194
+ }, Fv = (c, t, n, o) => {
22188
22195
  if (!Object.prototype.hasOwnProperty.call(
22189
22196
  c,
22190
22197
  K.CURRENT_ROUND_TRIP_TIME
@@ -22201,7 +22208,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22201
22208
  totalRTT: s,
22202
22209
  totalRTTMeasurements: r
22203
22210
  };
22204
- }, _o = (c, t, n) => c[K.TIMESTAMP] === n[t].timestamp_out || !Object.prototype.hasOwnProperty.call(c, K.JITTER) ? null : 1e3 * (Number(c[K.JITTER]) || 0), Fv = (c, t) => {
22211
+ }, _o = (c, t, n) => c[K.TIMESTAMP] === n[t].timestamp_out || !Object.prototype.hasOwnProperty.call(c, K.JITTER) ? null : 1e3 * (Number(c[K.JITTER]) || 0), Vv = (c, t) => {
22205
22212
  if (!Object.prototype.hasOwnProperty.call(c, K.FRAMES_DECODED) || !Object.prototype.hasOwnProperty.call(c, K.TOTAL_DECODE_TIME))
22206
22213
  return {
22207
22214
  delta_ms_decode_frame: t[M.VIDEO].delta_ms_decode_frame_in,
@@ -22214,7 +22221,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22214
22221
  frames_decoded: n,
22215
22222
  total_decode_time: o
22216
22223
  };
22217
- }, Vv = (c, t) => {
22224
+ }, jv = (c, t) => {
22218
22225
  if (!Object.prototype.hasOwnProperty.call(c, K.FRAMES_ENCODED) || !Object.prototype.hasOwnProperty.call(c, K.TOTAL_ENCODE_TIME))
22219
22226
  return {
22220
22227
  delta_ms_encode_frame: t[M.VIDEO].delta_ms_encode_frame_out,
@@ -22274,7 +22281,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22274
22281
  deltaKBytesReceived: m,
22275
22282
  kbsReceived: A
22276
22283
  };
22277
- }, jv = (c) => c[K.CANDIDATE_TYPE] !== "relay" ? "" : c[K.RELAY_PROTOCOL] || "", qv = (c) => {
22284
+ }, qv = (c) => c[K.CANDIDATE_TYPE] !== "relay" ? "" : c[K.RELAY_PROTOCOL] || "", Bv = (c) => {
22278
22285
  if (!Object.prototype.hasOwnProperty.call(c, K.NETWORK_TYPE))
22279
22286
  return Ki.WIFI;
22280
22287
  switch (c[K.NETWORK_TYPE]) {
@@ -22291,7 +22298,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22291
22298
  width: c[K.FRAME_WIDTH] || null,
22292
22299
  height: c[K.FRAME_HEIGHT] || null,
22293
22300
  framerate: c[K.FRAMES_PER_SECOND]
22294
- }, Bv = (c) => {
22301
+ }, Gv = (c) => {
22295
22302
  const t = Object.prototype.hasOwnProperty.call(
22296
22303
  c,
22297
22304
  K.QUALITY_LIMITATION_REASON
@@ -22305,7 +22312,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22305
22312
  return o && Object.keys(o).forEach((a) => {
22306
22313
  o[a] > 1e3 && (o[a] = Number(o[a] / 1e3));
22307
22314
  }), { reason: t, durations: o, resolutionChanges: n };
22308
- }, Gv = (c, t, n) => {
22315
+ }, Wv = (c, t, n) => {
22309
22316
  if (!Object.prototype.hasOwnProperty.call(c, K.PLI) || !Object.prototype.hasOwnProperty.call(c, K.NACK))
22310
22317
  return {
22311
22318
  pliCount: t.total_pli_sent_in,
@@ -22320,7 +22327,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22320
22327
  deltaPliCount: o - t[M.VIDEO].total_pli_sent_in,
22321
22328
  deltaNackCount: a - t[M.VIDEO].total_nack_sent_in
22322
22329
  };
22323
- }, Wv = (c, t, n) => {
22330
+ }, Kv = (c, t, n) => {
22324
22331
  if (!Object.prototype.hasOwnProperty.call(c, K.PLI) || !Object.prototype.hasOwnProperty.call(c, K.NACK))
22325
22332
  return {
22326
22333
  pliCount: t.total_pli_received_out,
@@ -22335,15 +22342,15 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22335
22342
  deltaPliCount: o - t[M.VIDEO].total_pli_received_out,
22336
22343
  deltaNackCount: a - t[M.VIDEO].total_nack_received_out
22337
22344
  };
22338
- }, Kv = (c) => ({
22345
+ }, Yv = (c) => ({
22339
22346
  channels: c[K.CHANNELS] || null,
22340
22347
  clock_rate: c[K.CLOCK_RATE] || null,
22341
22348
  mime_type: c[K.MIME_TYPE] || null,
22342
22349
  sdp_fmtp_line: c[K.SDP_FMTP_LINE] || null
22343
- }), Yv = (c) => ({
22350
+ }), Jv = (c) => ({
22344
22351
  clock_rate: c[K.CLOCK_RATE] || null,
22345
22352
  mime_type: c[K.MIME_TYPE] || null
22346
- }), Jv = (c, t, n) => {
22353
+ }), zv = (c, t, n) => {
22347
22354
  const o = (c[K.BYTES_RECEIVED] || 0) / 1024 - (n ? n.data.total_KBytes_in : 0), a = (c[K.BYTES_SENT] || 0) / 1024 - (n ? n.data.total_KBytes_out : 0), s = c[K.TIMESTAMP] || Date.now(), r = o - t.data.total_KBytes_in, _ = a - t.data.total_KBytes_out, d = n ? n.timestamp : null;
22348
22355
  let h = t.timestamp;
22349
22356
  !h && d && (h = d);
@@ -22356,13 +22363,13 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22356
22363
  kbs_speed_received: T,
22357
22364
  kbs_speed_sent: S
22358
22365
  };
22359
- }, zv = (c) => {
22366
+ }, Xv = (c) => {
22360
22367
  const t = c[K.AVAILABLE_INCOMING_BITRATE] / 1024 || 0, n = c[K.AVAILABLE_OUTGOING_BITRATE] / 1024 || 0;
22361
22368
  return {
22362
22369
  kbs_incoming_bandwidth: t,
22363
22370
  kbs_outgoing_bandwidth: n
22364
22371
  };
22365
- }, Xv = (c, t, n, o) => {
22372
+ }, Qv = (c, t, n, o) => {
22366
22373
  if (!c)
22367
22374
  return [];
22368
22375
  switch (c[K.TYPE]) {
@@ -22373,11 +22380,11 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22373
22380
  `analyze() - got stats ${c[K.TYPE]} for ${n}`,
22374
22381
  c
22375
22382
  ), K.SELECTED in c && !c[K.SELECTED] && (a = !1)), a) {
22376
- const r = c[K.LOCAL_CANDIDATE_ID], _ = c[K.REMOTE_CANDIDATE_ID], d = Jv(
22383
+ const r = c[K.LOCAL_CANDIDATE_ID], _ = c[K.REMOTE_CANDIDATE_ID], d = zv(
22377
22384
  c,
22378
22385
  t,
22379
22386
  o
22380
- ), h = zv(c), m = Hv(
22387
+ ), h = Xv(c), m = Fv(
22381
22388
  c,
22382
22389
  "data",
22383
22390
  o,
@@ -22448,7 +22455,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22448
22455
  return [
22449
22456
  {
22450
22457
  type: ne.NETWORK,
22451
- value: { infrastructure: qv(c) }
22458
+ value: { infrastructure: Bv(c) }
22452
22459
  },
22453
22460
  {
22454
22461
  type: ne.NETWORK,
@@ -22463,7 +22470,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22463
22470
  {
22464
22471
  type: ne.NETWORK,
22465
22472
  value: {
22466
- local_candidate_relay_protocol: jv(c)
22473
+ local_candidate_relay_protocol: qv(c)
22467
22474
  }
22468
22475
  }
22469
22476
  ];
@@ -22555,12 +22562,12 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22555
22562
  ];
22556
22563
  }
22557
22564
  if (c[K.MEDIA_TYPE] === M.VIDEO) {
22558
- const h = Fv(c, _), m = Vf(
22565
+ const h = Vv(c, _), m = Vf(
22559
22566
  c,
22560
22567
  M.VIDEO,
22561
22568
  _,
22562
22569
  d
22563
- ), T = _o(c, M.VIDEO, _), S = c[K.DECODER_IMPLEMENTATION] || null, E = c[K.CODEC_ID] || null, C = jf(c), A = Gv(
22570
+ ), T = _o(c, M.VIDEO, _), S = c[K.DECODER_IMPLEMENTATION] || null, E = c[K.CODEC_ID] || null, C = jf(c), A = Wv(
22564
22571
  c,
22565
22572
  _,
22566
22573
  d
@@ -22710,7 +22717,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22710
22717
  ];
22711
22718
  }
22712
22719
  if (c[K.MEDIA_TYPE] === M.VIDEO) {
22713
- const h = c[K.ENCODER_IMPLEMENTATION] || null, m = c[K.CODEC_ID] || null, T = Vv(c, _), S = jf(c), E = Bv(c), C = Wv(
22720
+ const h = c[K.ENCODER_IMPLEMENTATION] || null, m = c[K.CODEC_ID] || null, T = jv(c, _), S = jf(c), E = Gv(c), C = Kv(
22714
22721
  c,
22715
22722
  _,
22716
22723
  d
@@ -22826,7 +22833,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22826
22833
  `analyze() - got stats ${c[K.TYPE]} for ${n}`,
22827
22834
  c
22828
22835
  );
22829
- const d = Kv(c);
22836
+ const d = Yv(c);
22830
22837
  c[K.ID] === _.codec_id_in ? s.push({ ssrc: _.ssrc, type: ne.AUDIO, value: { codec_in: d } }) : s.push({ ssrc: _.ssrc, type: ne.AUDIO, value: { codec_out: d } });
22831
22838
  }
22832
22839
  }), Object.keys(t[M.VIDEO]).forEach((r) => {
@@ -22837,7 +22844,7 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22837
22844
  `analyze() - got stats ${c[K.TYPE]} for ${n}`,
22838
22845
  c
22839
22846
  );
22840
- const d = Yv(c);
22847
+ const d = Jv(c);
22841
22848
  c[K.ID] === _.codec_id_in ? s.push({ ssrc: _.ssrc, type: ne.VIDEO, value: { codec_in: d } }) : s.push({ ssrc: _.ssrc, type: ne.VIDEO, value: { codec_out: d } });
22842
22849
  }
22843
22850
  }), s;
@@ -22952,40 +22959,40 @@ const Vs = "extractor ", $f = (c, t, n, o) => {
22952
22959
  }
22953
22960
  }
22954
22961
  return [];
22955
- }, Jo = (c) => c < 0 ? 1 : c > 100 ? 4.5 : 1 + 0.035 * c + 7 / 1e6 * c * (c - 60) * (100 - c), Qv = (c, t = M.AUDIO, n, o, a) => {
22962
+ }, Jo = (c) => c < 0 ? 1 : c > 100 ? 4.5 : 1 + 0.035 * c + 7 / 1e6 * c * (c - 60) * (100 - c), Zv = (c, t = M.AUDIO, n, o, a) => {
22956
22963
  const s = ct(a, c, $e.INBOUND), r = ct(a, n, $e.INBOUND), _ = ct(a, o, $e.INBOUND), d = [], h = [], m = s[t].percent_packets_lost_in, T = s[t].delta_jitter_ms_in, S = r && r[t].delta_jitter_ms_in || null, E = _ && _[t].delta_jitter_ms_in || null, C = c.data.delta_rtt_connectivity_ms, A = n && n.data.delta_rtt_connectivity_ms || null, R = o && o.data.delta_rtt_connectivity_ms || null;
22957
22964
  C && d.push(C), A && d.push(A), R && d.push(R), T && h.push(T), n && S && h.push(S), o && E && h.push(E);
22958
22965
  const L = d.length > 0 ? Gs(d) : 100, b = h.length > 0 ? Gs(h) : 10, ie = 93.2 - m, N = 0.18 * ie * ie - 27.9 * ie + 1126.62, H = (L + b) / 2, me = H - 177.3 < 0 ? 0 : 1, _e = 0.024 * H + 0.11 * (H - 177.3) * me, U = N - _e;
22959
22966
  return Jo(U);
22960
- }, Zv = (c, t = M.AUDIO, n, o, a) => {
22967
+ }, eS = (c, t = M.AUDIO, n, o, a) => {
22961
22968
  const s = ct(a, c, $e.OUTBOUND), r = ct(a, n, $e.OUTBOUND), _ = ct(a, o, $e.OUTBOUND), d = [], h = [], m = s[t].percent_packets_lost_out, T = s[t].delta_rtt_ms_out, S = r && r[t].delta_rtt_ms_out || null, E = _ && _[t].delta_rtt_ms_out || null, C = s[t].delta_jitter_ms_out, A = r && r[t].delta_jitter_ms_out || null, R = _ && _[t].delta_jitter_ms_out || null, L = c.data.delta_rtt_connectivity_ms, b = n && n.data.delta_rtt_connectivity_ms || null, ie = o && o.data.delta_rtt_connectivity_ms || null;
22962
22969
  T ? d.push(T) : L && d.push(L), S ? d.push(S) : b && d.push(b), E ? d.push(E) : ie && d.push(ie), C && h.push(C), n && A && h.push(A), o && R && h.push(R);
22963
22970
  const N = d.length > 0 ? Gs(d) : 100, H = h.length > 0 ? Gs(h) : 10, me = 93.2 - m, _e = 0.18 * me * me - 27.9 * me + 1126.62, U = (N + H) / 2, x = U - 177.3 < 0 ? 0 : 1, q = 0.024 * U + 0.11 * (U - 177.3) * x, j = _e - q;
22964
22971
  return Jo(j);
22965
- }, eS = (c, t = M.AUDIO, n, o, a) => {
22972
+ }, tS = (c, t = M.AUDIO, n, o, a) => {
22966
22973
  const s = ct(a, c, $e.INBOUND), r = ct(a, n, $e.INBOUND), _ = ct(a, o, $e.INBOUND), d = [], h = [], m = s[t].percent_packets_lost_in / 100, T = s[t].delta_jitter_ms_in, S = r && r[t].delta_jitter_ms_in || null, E = _ && _[t].delta_jitter_ms_in || null, C = c.data.delta_rtt_connectivity_ms, A = n && n.data.delta_rtt_connectivity_ms || null, R = o && o.data.delta_rtt_connectivity_ms || null;
22967
22974
  C && d.push(C), A && d.push(A), R && d.push(R), T && h.push(T), r && S && h.push(S), _ && E && h.push(E);
22968
22975
  const L = d.length > 0 ? Gs(d) : 100, b = h.length > 0 ? Gs(h) : 10, ie = 0, N = 19.8, H = 29.7, me = 30, _e = (L + b) / 2 + me, U = _e - 177.3 < 0 ? 0 : 1, x = 0.024 * _e + 0.11 * (_e - 177.3) * U, j = 93.2 - (ie + N * Math.log(1 + H * m) + x);
22969
22976
  return Jo(j);
22970
- }, tS = (c, t = M.AUDIO, n, o, a) => {
22977
+ }, sS = (c, t = M.AUDIO, n, o, a) => {
22971
22978
  const s = ct(a, c, $e.OUTBOUND), r = ct(a, n, $e.OUTBOUND), _ = ct(a, o, $e.OUTBOUND), d = [], h = [], m = s[t].percent_packets_lost_out / 100, T = s[t].delta_rtt_ms_out, S = r && r[t].delta_rtt_ms_out || null, E = _ && _[t].delta_rtt_ms_out || null, C = s[t].delta_jitter_ms_out, A = r && r[t].delta_jitter_ms_out || null, R = _ && _[t].delta_jitter_ms_out || null, L = c.data.delta_rtt_connectivity_ms, b = n && n.data.delta_rtt_connectivity_ms || null, ie = o && o.data.delta_rtt_connectivity_ms || null;
22972
22979
  T ? d.push(T) : L && d.push(L), S ? d.push(S) : b && d.push(b), E ? d.push(E) : ie && d.push(ie), C && h.push(C), r && A && h.push(A), _ && R && h.push(R);
22973
22980
  const N = d.length > 0 ? Gs(d) : 100, H = h.length > 0 ? Gs(h) : 10, me = 0, _e = 19.8, U = 29.7, x = 30, q = (N + H) / 2 + x, j = q - 177.3 < 0 ? 0 : 1, Y = 0.024 * q + 0.11 * (q - 177.3) * j, X = 93.2 - (me + _e * Math.log(1 + U * m) + Y);
22974
22981
  return Jo(X);
22975
22982
  };
22976
- class sS {
22983
+ class nS {
22977
22984
  constructor(t, n) {
22978
22985
  this._callbacks = {
22979
22986
  onreport: null,
22980
22987
  onticket: null
22981
- }, this._id = xv(), this._moduleName = this._id, this._probeId = n, this._config = t, this._exporter = new $v(t), this._state = ms.IDLE, this.registerToPCEvents(), An(this._moduleName, `new collector created for probe ${this._probeId}`);
22988
+ }, this._id = Uv(), this._moduleName = this._id, this._probeId = n, this._config = t, this._exporter = new Hv(t), this._state = ms.IDLE, this.registerToPCEvents(), An(this._moduleName, `new collector created for probe ${this._probeId}`);
22982
22989
  }
22983
22990
  analyze(t, n, o, a) {
22984
- const s = (d, h) => d === M.AUDIO ? h === zt.INBOUND_RTP ? { ...xd } : { ...Ud } : h === zt.INBOUND_RTP ? { ...kd } : { ...Pd }, r = bv(n);
22991
+ const s = (d, h) => d === M.AUDIO ? h === zt.INBOUND_RTP ? { ...xd } : { ...Ud } : h === zt.INBOUND_RTP ? { ...kd } : { ...Pd }, r = wv(n);
22985
22992
  r.pname = this._config.pname, r.call_id = this._config.cid, r.user_id = this._config.uid, r.count = n ? n.count + 1 : 1;
22986
22993
  let _ = null;
22987
22994
  return t.forEach((d) => {
22988
- !_ && d.timestamp && (_ = d.timestamp), Xv(d, r, r.pname, a).forEach((m) => {
22995
+ !_ && d.timestamp && (_ = d.timestamp), Qv(d, r, r.pname, a).forEach((m) => {
22989
22996
  if (m.value && m.type)
22990
22997
  if (m.ssrc) {
22991
22998
  let T = r[m.type][m.ssrc];
@@ -22999,25 +23006,25 @@ class sS {
22999
23006
  });
23000
23007
  }), r.timestamp = _, Object.keys(r[M.AUDIO]).forEach((d) => {
23001
23008
  const h = r[M.AUDIO][d];
23002
- h.direction === $e.INBOUND ? (h.mos_emodel_in = Qv(
23009
+ h.direction === $e.INBOUND ? (h.mos_emodel_in = Zv(
23003
23010
  r,
23004
23011
  M.AUDIO,
23005
23012
  n,
23006
23013
  o,
23007
23014
  h.ssrc
23008
- ), h.mos_in = eS(
23015
+ ), h.mos_in = tS(
23009
23016
  r,
23010
23017
  M.AUDIO,
23011
23018
  n,
23012
23019
  o,
23013
23020
  h.ssrc
23014
- )) : (h.mos_emodel_out = Zv(
23021
+ )) : (h.mos_emodel_out = eS(
23015
23022
  r,
23016
23023
  M.AUDIO,
23017
23024
  n,
23018
23025
  o,
23019
23026
  h.ssrc
23020
- ), h.mos_out = tS(
23027
+ ), h.mos_out = sS(
23021
23028
  r,
23022
23029
  M.AUDIO,
23023
23030
  n,
@@ -23199,9 +23206,9 @@ class sS {
23199
23206
  }
23200
23207
  }
23201
23208
  }
23202
- class nS {
23209
+ class rS {
23203
23210
  constructor(t) {
23204
- this._id = t.pname && t.pname.substr(0, 12).padEnd(12, " ") || Nv(), this._moduleName = this._id, An(this._moduleName, "probe created"), this._config = t, this._collector = new sS(this._config, this._id);
23211
+ this._id = t.pname && t.pname.substr(0, 12).padEnd(12, " ") || xv(), this._moduleName = this._id, An(this._moduleName, "probe created"), this._config = t, this._collector = new nS(this._config, this._id);
23205
23212
  }
23206
23213
  /**
23207
23214
  * Register a callback to 'onreport'
@@ -23311,7 +23318,7 @@ class nS {
23311
23318
  }
23312
23319
  }
23313
23320
  const Rt = "engine ";
23314
- class rS {
23321
+ class iS {
23315
23322
  constructor(t) {
23316
23323
  this._config = t, this._probes = [], this._startedTime = null, this._callbacks = {
23317
23324
  onresult: null
@@ -23329,7 +23336,7 @@ class rS {
23329
23336
  addNewProbe(t, n) {
23330
23337
  if (!t)
23331
23338
  throw new Error("undefined peer connection");
23332
- const o = Ov(t, n, this._config), a = new nS(o);
23339
+ const o = Dv(t, n, this._config), a = new rS(o);
23333
23340
  return this._probes.push(a), Ue(Rt, `${this._probes.length} probes registered`), a;
23334
23341
  }
23335
23342
  removeExistingProbe(t) {
@@ -23341,7 +23348,7 @@ class rS {
23341
23348
  const t = () => {
23342
23349
  this._probes.forEach((s) => s.start());
23343
23350
  }, n = async () => Promise.all(this._probes.map((s) => s.takeReferenceStats())), o = () => this.isIdle ? !1 : !this._config.stopAfter || this._config.stopAfter < 0 ? !0 : Date.now() < this._startedTime + this._config.stopAfter, a = async () => {
23344
- const s = Iv(), r = this._probes.filter((_) => _.isRunning);
23351
+ const s = bv(), r = this._probes.filter((_) => _.isRunning);
23345
23352
  for (const _ of r) {
23346
23353
  const d = await _.collectStats();
23347
23354
  d && s.probes.push(d), Ue(Rt, `got probe ${_.id}`), await Mf(0);
@@ -23376,17 +23383,17 @@ class rS {
23376
23383
  this._callbacks.onresult && t.probes.length > 0 && Du(this._callbacks.onresult.callback, this._callbacks.onresult.context, t);
23377
23384
  }
23378
23385
  }
23379
- const iS = "interface ";
23380
- class lS {
23386
+ const lS = "interface ";
23387
+ class oS {
23381
23388
  constructor(t) {
23382
- this._config = Dv(t), An(iS, `welcome to ${this._config.name} version ${this._config.version}`), Tv(this._config.verbose || !1), this._engine = new rS(this._config);
23389
+ this._config = Nv(t), An(lS, `welcome to ${this._config.name} version ${this._config.version}`), vv(this._config.verbose || !1), this._engine = new iS(this._config);
23383
23390
  }
23384
23391
  /**
23385
23392
  * Change log level manually
23386
23393
  * @param {string} level - The level of logs. Can be one of 'TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'SILENT'
23387
23394
  */
23388
23395
  setupLogLevel(t) {
23389
- vv(t);
23396
+ Sv(t);
23390
23397
  }
23391
23398
  /**
23392
23399
  * Get the version
@@ -23451,7 +23458,7 @@ class lS {
23451
23458
  t ? this._engine.registerCallback("onresult", t) : this._engine.unregisterCallback("onresult");
23452
23459
  }
23453
23460
  }
23454
- function oS(c, t) {
23461
+ function aS(c, t) {
23455
23462
  return Object.keys(c).filter((n) => t.includes(n)).reduce((n, o) => {
23456
23463
  const a = o;
23457
23464
  return {
@@ -23460,14 +23467,14 @@ function oS(c, t) {
23460
23467
  };
23461
23468
  }, {});
23462
23469
  }
23463
- const aS = ["mos_in", "codec_in", "delta_KBytes_in", "delta_kbs_in", "delta_jitter_ms_in", "delta_packets_lost_in"], uS = {
23470
+ const uS = ["mos_in", "codec_in", "delta_KBytes_in", "delta_kbs_in", "delta_jitter_ms_in", "delta_packets_lost_in"], cS = {
23464
23471
  positiveSpeechThreshold: 0.6,
23465
23472
  negativeSpeechThreshold: 0.3,
23466
23473
  preSpeechPadMs: 150,
23467
23474
  redemptionMs: 1500,
23468
23475
  minSpeechMs: 50
23469
23476
  };
23470
- class cS {
23477
+ class fS {
23471
23478
  constructor(t) {
23472
23479
  this.intervals = {}, this.analysers = {}, this.emitInterval = t.emitInterval || 200, this.onChangeFunction = t.onChangeFunction;
23473
23480
  }
@@ -23500,7 +23507,7 @@ class cS {
23500
23507
  }, this.emitInterval);
23501
23508
  }
23502
23509
  }
23503
- class fS {
23510
+ class dS {
23504
23511
  constructor() {
23505
23512
  this.resumePromise = null, this.context = new AudioContext(), this.setupErrorHandling();
23506
23513
  }
@@ -23537,14 +23544,14 @@ class fS {
23537
23544
  const po = {
23538
23545
  SELECTED_INPUT_DEVICE: "OpensipsJSInputDevice",
23539
23546
  SELECTED_OUTPUT_DEVICE: "OpensipsJSOutputDevice"
23540
- }, dS = 0;
23547
+ }, hS = 0;
23541
23548
  function cu(c, t) {
23542
23549
  const n = new AudioContext(), o = n.createMediaStreamSource(c), a = n.createMediaStreamSource(
23543
23550
  new MediaStream([t])
23544
23551
  ), s = n.createMediaStreamDestination();
23545
23552
  return o.connect(s), a.connect(s), s.stream;
23546
23553
  }
23547
- class hS {
23554
+ class _S {
23548
23555
  constructor(t) {
23549
23556
  var n;
23550
23557
  this.isAutoAnswer = !1, this.muteWhenJoinEnabled = !1, this.isDNDEnabled = !1, this.isCallWaitingEnabled = !0, this.muted = !1, this.microphoneInputLevelValue = 1, this.speakerVolumeValue = 1, this.activeRooms = {}, this.activeCalls = {}, this.extendedCalls = {}, this.conferenceNodes = {}, this.availableMediaDevices = [], this.selectedMediaDevices = {
@@ -23555,10 +23562,10 @@ class hS {
23555
23562
  }, this.activeStreamValue = null, this.initialStreamValue = null, this.vadSession = null, this.vadSessionState = {
23556
23563
  currentMode: "clean",
23557
23564
  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(
23565
+ }, this.vadInterval = null, this.vadMrsInterval = null, this.vadSessionGeneration = 0, this.ringbackTimers = {}, this.ringbackAudioContexts = {}, this.ringbackSessionProgressReceived = {}, this.hangupBeepContext = null, this.managedAudioContext = new dS(), this.context = t, this.context.on(
23559
23566
  this.context.newRTCSessionEventName,
23560
23567
  this.newRTCSessionCallback.bind(this)
23561
- ), this.VUMeter = new cS({
23568
+ ), this.VUMeter = new fS({
23562
23569
  onChangeFunction: this.emitVolumeChange.bind(this)
23563
23570
  }), this.initializeMediaDevices(), this.processVADConfiguration(((n = this.context.options.configuration) == null ? void 0 : n.noiseReductionOptions) || {}), this.setupVADInstance();
23564
23571
  }
@@ -23900,7 +23907,7 @@ class hS {
23900
23907
  });
23901
23908
  }
23902
23909
  cancelAllOutgoingUnanswered() {
23903
- Object.values(this.getActiveCalls).filter((t) => t.direction === "outgoing" && t.status === dS).forEach((t) => this.terminateCall(t._id));
23910
+ Object.values(this.getActiveCalls).filter((t) => t.direction === "outgoing" && t.status === hS).forEach((t) => this.terminateCall(t._id));
23904
23911
  }
23905
23912
  answerCall(t) {
23906
23913
  const n = this.extendedCalls[t];
@@ -24069,7 +24076,7 @@ class hS {
24069
24076
  const d = [];
24070
24077
  this.vadInterval && (clearInterval(this.vadInterval), this.vadInterval = null), this.vadMrsInterval && (clearInterval(this.vadMrsInterval), this.vadMrsInterval = null), this.vadMrsInterval = setInterval(() => {
24071
24078
  r.getFloatTimeDomainData(_);
24072
- const S = dv(_);
24079
+ const S = hv(_);
24073
24080
  d.push(S);
24074
24081
  const E = Math.ceil(
24075
24082
  this.noiseReduction.noiseCheckInterval / this.noiseReduction.checkEveryMs
@@ -24089,89 +24096,108 @@ class hS {
24089
24096
  }, this.noiseReduction.noiseCheckInterval);
24090
24097
  }
24091
24098
  async processVADForActiveStream(t = {}) {
24099
+ var m;
24092
24100
  const n = this.activeStream;
24093
- this.stopSessionVad(), this.vadSessionState = {
24101
+ this.stopSessionVad();
24102
+ const o = this.vadSessionGeneration, a = () => o !== this.vadSessionGeneration;
24103
+ this.vadSessionState = {
24094
24104
  currentMode: "clean",
24095
24105
  isSpeaking: !1
24096
24106
  };
24097
- const o = await this.managedAudioContext.getContext(), a = await hv(n, o, 150);
24098
- let s = !1;
24099
- const r = Object.values(this.extendedCalls).filter((d) => d.roomId === this.currentActiveRoomId), _ = await this.MicVAD.new({
24100
- getStream: () => new Promise((d) => d(n)),
24101
- ...uS,
24107
+ const s = await this.managedAudioContext.getContext();
24108
+ if (a())
24109
+ return;
24110
+ const r = await _v(n, s, 150);
24111
+ if (a())
24112
+ return;
24113
+ let _ = !1;
24114
+ const d = Object.values(this.extendedCalls).filter((T) => T.roomId === this.currentActiveRoomId), h = await this.MicVAD.new({
24115
+ getStream: () => new Promise((T) => T(n)),
24116
+ pauseStream: async () => {
24117
+ },
24118
+ resumeStream: async (T) => T,
24119
+ ...cS,
24102
24120
  ...this.noiseReduction.vadConfig,
24103
24121
  baseAssetPath: this.noiseReduction.baseAssetPath,
24104
24122
  onnxWASMBasePath: this.noiseReduction.onnxWASMBasePath,
24105
24123
  onFrameProcessed: () => {
24106
- var d;
24107
- if (!s) {
24108
- if (s = !0, console.log("✅ VAD initialized, starting background noise monitoring"), this.noiseReduction.mode === "enabled") {
24124
+ var T, S;
24125
+ if (!a() && !_) {
24126
+ if (_ = !0, console.log("✅ VAD initialized, starting background noise monitoring"), this.noiseReduction.mode === "enabled") {
24109
24127
  if (t && Object.keys(t).length)
24110
- Object.keys(t).forEach((h) => {
24111
- const m = this.extendedCalls[h];
24112
- if (m && m.connection.getSenders()[0]) {
24113
- const T = cu(a.stream, t[h]);
24114
- m.connection.getSenders()[0].replaceTrack(T.getAudioTracks()[0]);
24128
+ Object.keys(t).forEach((E) => {
24129
+ const C = this.extendedCalls[E];
24130
+ if (C && C.connection.getSenders()[0]) {
24131
+ const A = cu(r.stream, t[E]);
24132
+ C.connection.getSenders()[0].replaceTrack(A.getAudioTracks()[0]);
24115
24133
  }
24116
24134
  });
24117
24135
  else {
24118
- const h = r[0];
24119
- h.connection.getSenders()[0] && h.connection.getSenders()[0].replaceTrack(a.stream.getAudioTracks()[0]);
24136
+ const E = d[0], C = (T = E == null ? void 0 : E.connection) == null ? void 0 : T.getSenders()[0], A = r.stream.getAudioTracks()[0];
24137
+ C && C.replaceTrack(A);
24120
24138
  }
24121
24139
  return;
24122
24140
  }
24123
24141
  if (!this.vadSessionState) {
24124
- console.error("[processVAD] CRITICAL: State not found"), (d = this.context.logger) == null || d.error("[processVAD] CRITICAL: State not found");
24142
+ console.error("[processVAD] CRITICAL: State not found"), (S = this.context.logger) == null || S.error("[processVAD] CRITICAL: State not found");
24125
24143
  return;
24126
24144
  }
24127
24145
  this.startNoiseMonitor({
24128
24146
  stream: n,
24129
24147
  onNoiseDetected: async () => {
24130
- var h;
24131
- if (console.log("[processVad] - Replace track with Vad Controlled"), (h = this.context.logger) == null || h.log("[processVad] - Replace track with Vad Controlled"), t && Object.keys(t).length)
24132
- Object.keys(t).forEach((m) => {
24133
- const T = this.extendedCalls[m];
24134
- if (T && T.connection.getSenders()[0]) {
24135
- const S = cu(a.stream, t[m]);
24136
- T.connection.getSenders()[0].replaceTrack(S.getAudioTracks()[0]);
24148
+ var E;
24149
+ 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)
24150
+ Object.keys(t).forEach((C) => {
24151
+ const A = this.extendedCalls[C];
24152
+ if (A && A.connection.getSenders()[0]) {
24153
+ const R = cu(r.stream, t[C]);
24154
+ A.connection.getSenders()[0].replaceTrack(R.getAudioTracks()[0]);
24137
24155
  }
24138
24156
  });
24139
24157
  else {
24140
- const m = r[0];
24141
- m.connection.getSenders()[0] && m.connection.getSenders()[0].replaceTrack(a.stream.getAudioTracks()[0]);
24158
+ const C = d[0];
24159
+ C.connection.getSenders()[0] && C.connection.getSenders()[0].replaceTrack(r.stream.getAudioTracks()[0]);
24142
24160
  }
24143
24161
  },
24144
24162
  onNoiseStop: async () => {
24145
24163
  if (console.log("Replace track with Original"), t && Object.keys(t).length)
24146
- Object.keys(t).forEach((h) => {
24147
- const m = this.extendedCalls[h];
24148
- if (!m)
24164
+ Object.keys(t).forEach((E) => {
24165
+ const C = this.extendedCalls[E];
24166
+ if (!C)
24149
24167
  return;
24150
- const T = m.connection.getSenders()[0];
24151
- if (T && T.track && T.transport && T.transport.state !== "closed" && T.transport.state !== "failed") {
24152
- const S = cu(n, t[h]);
24153
- T.replaceTrack(S.getAudioTracks()[0]);
24168
+ const A = C.connection.getSenders()[0];
24169
+ if (A && A.track && A.transport && A.transport.state !== "closed" && A.transport.state !== "failed") {
24170
+ const R = cu(n, t[E]);
24171
+ A.replaceTrack(R.getAudioTracks()[0]);
24154
24172
  }
24155
24173
  });
24156
24174
  else {
24157
- const h = r[0].connection.getSenders()[0];
24158
- h && h.track && h.transport && h.transport.state !== "closed" && h.transport.state !== "failed" && h.replaceTrack(n.getAudioTracks()[0]);
24175
+ const E = d[0].connection.getSenders()[0];
24176
+ E && E.track && E.transport && E.transport.state !== "closed" && E.transport.state !== "failed" && E.replaceTrack(n.getAudioTracks()[0]);
24159
24177
  }
24160
24178
  }
24161
24179
  });
24162
24180
  }
24163
24181
  },
24164
24182
  onSpeechStart: () => {
24165
- console.log("🎤 Speech started"), a.setSpeaking(!0), this.vadSessionState.isSpeaking = !0;
24183
+ a() || (console.log("🎤 Speech started"), r.setSpeaking(!0), this.vadSessionState.isSpeaking = !0);
24166
24184
  },
24167
24185
  onSpeechEnd: () => {
24168
- console.log("🛑 Speech end"), a.setSpeaking(!1), this.vadSessionState.isSpeaking = !1;
24186
+ a() || (console.log("🛑 Speech end"), r.setSpeaking(!1), this.vadSessionState.isSpeaking = !1);
24169
24187
  }
24170
24188
  });
24171
- this.vadSession && (this.vadSession.pause(), this.vadSession = null), this.vadSession = _, _.start();
24189
+ if (a()) {
24190
+ try {
24191
+ h.pause();
24192
+ } catch (T) {
24193
+ (m = this.context.logger) == null || m.error("[processVADForActiveStream] Error pausing stale vadSession:", T);
24194
+ }
24195
+ return;
24196
+ }
24197
+ this.vadSession && (this.vadSession.pause(), this.vadSession = null), this.vadSession = h, h.start();
24172
24198
  }
24173
24199
  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 = {
24200
+ 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
24201
  currentMode: "clean",
24176
24202
  isSpeaking: !1
24177
24203
  }, this.context.emit("changeNoiseReductionState", !1));
@@ -24272,7 +24298,7 @@ class hS {
24272
24298
  console.log("[doConference] - No session or RTC connection, session:", b), (me = this.context.logger) == null || me.log("[doConference] - No session or RTC connection, session:", b);
24273
24299
  }), await this.setupActiveStream();
24274
24300
  const h = {};
24275
- await gv.forEach(t, async (b, ie) => {
24301
+ await mv.forEach(t, async (b, ie) => {
24276
24302
  var Y, V, X, k, P;
24277
24303
  if (!b || !b.connection) {
24278
24304
  console.log("[doConference] - Return because of no session or connection, session:", b), (Y = this.context.logger) == null || Y.log("[doConference] - Return because of no session or connection, session:", b);
@@ -24555,7 +24581,7 @@ class hS {
24555
24581
  };
24556
24582
  this.setCallTime(n);
24557
24583
  const o = setInterval(() => {
24558
- const a = { ...this.callTime[t] }, s = fv(a);
24584
+ const a = { ...this.callTime[t] }, s = dv(a);
24559
24585
  this.setCallTime({
24560
24586
  callId: t,
24561
24587
  ...s
@@ -24650,7 +24676,7 @@ class hS {
24650
24676
  }
24651
24677
  async newRTCSessionCallback(t) {
24652
24678
  const n = t.session;
24653
- if (this.shouldTerminateNewSession(t)) {
24679
+ if (n._remote_party_display_name = n.direction === "incoming" ? zT(t.request.getHeader("Remote-Party-ID")) : null, this.shouldTerminateNewSession(t)) {
24654
24680
  n.terminate({
24655
24681
  status_code: 486,
24656
24682
  reason_phrase: "Do Not Disturb"
@@ -24759,7 +24785,7 @@ class hS {
24759
24785
  }, this.context.emit("changeCallMetrics", this.callMetrics);
24760
24786
  }
24761
24787
  getCallQuality(t) {
24762
- const n = new lS(this.metricConfig), o = n.createProbe(t.connection, {
24788
+ const n = new oS(this.metricConfig), o = n.createProbe(t.connection, {
24763
24789
  cid: t._id
24764
24790
  }), a = [];
24765
24791
  let s;
@@ -24770,7 +24796,7 @@ class hS {
24770
24796
  const _ = r.audio[s];
24771
24797
  if (!_)
24772
24798
  return;
24773
- const d = oS(_, aS);
24799
+ const d = aS(_, uS);
24774
24800
  d.callId = t._id, this.setCallMetrics(d);
24775
24801
  }, this.context.subscribe(Xt.CALL_ENDED, (r) => {
24776
24802
  r._id === t._id && n.stopAllProbes();
@@ -24837,7 +24863,7 @@ class hS {
24837
24863
  o.roomId = n, this.updateCall(o), await this.roomReconfigure(a), await this.roomReconfigure(n);
24838
24864
  }
24839
24865
  }
24840
- class _S {
24866
+ class pS {
24841
24867
  constructor(t) {
24842
24868
  this.context = t;
24843
24869
  }
@@ -24883,7 +24909,7 @@ class _S {
24883
24909
  this.context.stopBlur();
24884
24910
  }
24885
24911
  }
24886
- class pS {
24912
+ class gS {
24887
24913
  constructor(t) {
24888
24914
  this.activeMessages = {}, this.extendedMessages = {}, this.msrpHistory = {}, this.context = t, this.context.on(
24889
24915
  this.context.newMSRPSessionEventName,
@@ -25070,7 +25096,7 @@ class Md {
25070
25096
  this.opensips.kill(this.name);
25071
25097
  }
25072
25098
  }
25073
- class gS extends Md {
25099
+ class mS extends Md {
25074
25100
  constructor(t, n) {
25075
25101
  super(t), this._candidates = [], this._subscribeSent = !1, this._configureSent = !1, this._lastTrickleReceived = !1, this.type = n;
25076
25102
  }
@@ -25253,7 +25279,7 @@ class gS extends Md {
25253
25279
  throw new Error("generateStream method is not implemented");
25254
25280
  }
25255
25281
  }
25256
- class mS extends Md {
25282
+ class TS extends Md {
25257
25283
  constructor(t, n, o = {}) {
25258
25284
  super(t), this.stream = null, this.running = !1, this.immediate = !1, this.type = "video", this.immediate = o.immediate || !1, this.type = n;
25259
25285
  }
@@ -25280,15 +25306,15 @@ class mS extends Md {
25280
25306
  this.stop(), this.running = !1, await this.session.resyncPlugins(this.type);
25281
25307
  }
25282
25308
  }
25283
- class kS extends jT {
25309
+ class PS extends jT {
25284
25310
  constructor(t, n) {
25285
25311
  if (!t.modules.length)
25286
25312
  throw new Error("options.modules should include at least 1 module");
25287
25313
  const o = {
25288
25314
  ...t.configuration,
25289
- sockets: t.socketInterfaces.map((a) => new cv.WebSocketInterface(a))
25315
+ sockets: t.socketInterfaces.map((a) => new fv.WebSocketInterface(a))
25290
25316
  };
25291
- super(o), this.initialized = !1, this.connected = !1, this.logger = console, this.newRTCSessionEventName = "newRTCSession", this.registeredEventName = "registered", this.unregisteredEventName = "unregistered", this.disconnectedEventName = "disconnected", this.connectedEventName = "connected", this.newMSRPSessionEventName = "newMSRPSession", this.isReconnecting = !1, this.activeConnection = !1, this.waitingForSessionHangup = !1, this.waitingForSessionTimeout = null, this.reconnectionAttemptsLimit = 1 / 0, this.reconnectionAttemptsCounter = 0, this.audio = null, this.msrp = null, this.video = null, this.listenersList = {}, this.modules = [], t.pnExtraHeaders && Object.keys(t.pnExtraHeaders).length && this.registrator().setExtraContactUriParams(t.pnExtraHeaders), this.options = t, this.modules = t.modules, t.configuration.reconnectionAttemptsLimit && (this.reconnectionAttemptsLimit = t.configuration.reconnectionAttemptsLimit), n && zT(n) && (this.logger = n);
25317
+ super(o), this.initialized = !1, this.connected = !1, this.logger = console, this.newRTCSessionEventName = "newRTCSession", this.registeredEventName = "registered", this.unregisteredEventName = "unregistered", this.disconnectedEventName = "disconnected", this.connectedEventName = "connected", this.newMSRPSessionEventName = "newMSRPSession", this.isReconnecting = !1, this.activeConnection = !1, this.waitingForSessionHangup = !1, this.waitingForSessionTimeout = null, this.reconnectionAttemptsLimit = 1 / 0, this.reconnectionAttemptsCounter = 0, this.audio = null, this.msrp = null, this.video = null, this.listenersList = {}, this.modules = [], t.pnExtraHeaders && Object.keys(t.pnExtraHeaders).length && this.registrator().setExtraContactUriParams(t.pnExtraHeaders), this.options = t, this.modules = t.modules, t.configuration.reconnectionAttemptsLimit && (this.reconnectionAttemptsLimit = t.configuration.reconnectionAttemptsLimit), n && XT(n) && (this.logger = n);
25292
25318
  }
25293
25319
  /*public setWaitingForSessionHangup (value: boolean) {
25294
25320
  this.waitingForSessionHangup = value
@@ -25317,9 +25343,9 @@ class kS extends jT {
25317
25343
  use(t) {
25318
25344
  if (this.newStreamPlugins.find((n) => n.name === t.name) || this.processStreamPlugins.find((n) => n.name === t.name))
25319
25345
  throw new Error(`Plugin with name ${t.name} already exists`);
25320
- if (t instanceof gS)
25346
+ if (t instanceof mS)
25321
25347
  t.setOpensips(this), this.newStreamPlugins.push(t);
25322
- else if (t instanceof mS)
25348
+ else if (t instanceof TS)
25323
25349
  t.setOpensips(this), this.processStreamPlugins.push(t);
25324
25350
  else
25325
25351
  throw new Error("Wrong plugin instance");
@@ -25339,7 +25365,7 @@ class kS extends jT {
25339
25365
  console.error("Connection is already established");
25340
25366
  return;
25341
25367
  }
25342
- return this.modules.includes(go.AUDIO) && (this.audio = new hS(this)), this.modules.includes(go.MSRP) && (this.msrp = new pS(this)), this.modules.includes(go.VIDEO) && (this.video = new _S(this)), this.on(
25368
+ return this.modules.includes(go.AUDIO) && (this.audio = new _S(this)), this.modules.includes(go.MSRP) && (this.msrp = new gS(this)), this.modules.includes(go.VIDEO) && (this.video = new pS(this)), this.on(
25343
25369
  this.registeredEventName,
25344
25370
  () => {
25345
25371
  this.logger.log("Successfully registered to", this.options.socketInterfaces[0]), this.setInitialized(!0);
@@ -26524,7 +26550,7 @@ class kS extends jT {
26524
26550
  }*/
26525
26551
  }
26526
26552
  export {
26527
- gS as BaseNewStreamPlugin,
26528
- mS as BaseProcessStreamPlugin,
26529
- kS as default
26553
+ mS as BaseNewStreamPlugin,
26554
+ TS as BaseProcessStreamPlugin,
26555
+ PS as default
26530
26556
  };