sip-connector 15.3.0 → 16.0.0

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 (41) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +526 -88
  3. package/dist/@SipConnector-DcaeAFrM.cjs +1 -0
  4. package/dist/{@SipConnector-Gt9XLkRE.js → @SipConnector-uiUlVCMv.js} +962 -401
  5. package/dist/CallManager/types.d.ts +2 -0
  6. package/dist/PresentationManager/@PresentationManager.d.ts +5 -3
  7. package/dist/SipConnector/@SipConnector.d.ts +14 -4
  8. package/dist/SipConnector/eventNames.d.ts +1 -1
  9. package/dist/SipConnectorFacade/SipConnectorFacade.d.ts +10 -21
  10. package/dist/StatsPeerConnection/StatsPeerConnection.d.ts +1 -1
  11. package/dist/StatsPeerConnection/__fixtures__/callStaticsState.d.ts +3 -3
  12. package/dist/StatsPeerConnection/eventNames.d.ts +3 -3
  13. package/dist/StatsPeerConnection/index.d.ts +1 -0
  14. package/dist/StatsPeerConnection/parseStatsReports.d.ts +3 -3
  15. package/dist/StatsPeerConnection/requestAllStatistics.d.ts +1 -1
  16. package/dist/StatsPeerConnection/{typings.d.ts → types.d.ts} +2 -2
  17. package/dist/VideoSendingBalancer/SenderBalancer.d.ts +3 -1
  18. package/dist/VideoSendingBalancer/TrackMonitor.d.ts +38 -0
  19. package/dist/VideoSendingBalancer/VideoSendingBalancer.d.ts +8 -9
  20. package/dist/VideoSendingBalancer/VideoSendingEventHandler.d.ts +4 -9
  21. package/dist/VideoSendingBalancer/__fixtures__/createMockTrack.d.ts +5 -0
  22. package/dist/VideoSendingBalancer/__fixtures__/index.d.ts +1 -0
  23. package/dist/VideoSendingBalancer/index.d.ts +1 -2
  24. package/dist/VideoSendingBalancer/types.d.ts +0 -1
  25. package/dist/VideoSendingBalancerManager/@VideoSendingBalancerManager.d.ts +47 -0
  26. package/dist/VideoSendingBalancerManager/eventNames.d.ts +20 -0
  27. package/dist/VideoSendingBalancerManager/index.d.ts +3 -0
  28. package/dist/doMock.cjs +1 -1
  29. package/dist/doMock.js +1 -1
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.js +281 -748
  33. package/dist/logger.d.ts +0 -1
  34. package/dist/tools/setCodecPreferences.d.ts +5 -0
  35. package/dist/tools/setParametersToSender/index.d.ts +1 -0
  36. package/package.json +5 -5
  37. package/dist/@SipConnector-DV4Ywba-.cjs +0 -1
  38. package/dist/tools/generateSimulcastEncodings.d.ts +0 -7
  39. package/dist/tools/resolveUpdateTransceiver.d.ts +0 -6
  40. package/dist/tools/scaleResolutionAndBitrate.d.ts +0 -10
  41. /package/dist/{PresentationManager → SipConnector}/constants.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,33 +1,30 @@
1
1
  import "events-constructor";
2
- import { E as R, O as ae, l as i, p as de, a as O } from "./@SipConnector-Gt9XLkRE.js";
3
- import { c as xn, b as Un, S as Vn, f as Ln, d as Hn, e as $n, h as Wn } from "./@SipConnector-Gt9XLkRE.js";
4
- import { isCanceledError as Y } from "@krivega/cancelable-promise";
5
- import { hasCanceledError as ue } from "repeated-calls";
6
- import { debounce as le } from "ts-debounce";
7
- import { UAParser as he } from "ua-parser-js";
8
- import { sequentPromises as fe } from "sequent-promises";
9
- import { createStackPromises as Se } from "stack-promises";
10
- import k from "debug";
11
- import { default as Jn } from "debug";
12
- const me = (n) => n instanceof Object && ("originator" in n || "cause" in n), Pn = (n) => {
13
- if (Y(n))
2
+ import { E as h, O as K, l as o, p as X, s as Y, a as G } from "./@SipConnector-uiUlVCMv.js";
3
+ import { c as ke, b as Le, S as xe, f as Ve, d as Be, e as $e, g as He, h as We } from "./@SipConnector-uiUlVCMv.js";
4
+ import { isCanceledError as B } from "@krivega/cancelable-promise";
5
+ import { hasCanceledError as q } from "repeated-calls";
6
+ import { debounce as z } from "ts-debounce";
7
+ import { UAParser as J } from "ua-parser-js";
8
+ import { sequentPromises as Q } from "sequent-promises";
9
+ const Z = (n) => n instanceof Object && ("originator" in n || "cause" in n), Ae = (n) => {
10
+ if (B(n))
14
11
  return !0;
15
- if (!me(n))
12
+ if (!Z(n))
16
13
  return !1;
17
14
  const { originator: e, cause: t } = n;
18
- return typeof t == "string" ? t === R.REQUEST_TIMEOUT || t === R.REJECTED || e === ae.LOCAL && (t === R.CANCELED || t === R.BYE) : !1;
19
- }, Ce = () => globalThis.process?.versions?.electron !== void 0, q = () => {
20
- const n = new he(), { name: e } = n.getBrowser(), t = Ce();
15
+ return typeof t == "string" ? t === h.REQUEST_TIMEOUT || t === h.REJECTED || e === K.LOCAL && (t === h.CANCELED || t === h.BYE) : !1;
16
+ }, ee = () => globalThis.process?.versions?.electron !== void 0, $ = () => {
17
+ const n = new J(), { name: e } = n.getBrowser(), t = ee();
21
18
  return {
22
19
  isChrome: e === "Chrome" || t
23
20
  };
24
- }, x = (n) => {
21
+ }, D = (n) => {
25
22
  const { url: e, cause: t } = n;
26
23
  let r = e;
27
- return (t === R.BAD_MEDIA_DESCRIPTION || t === R.NOT_FOUND) && (r = `${n.message.to.uri.user}@${n.message.to.uri.host}`), r;
24
+ return (t === h.BAD_MEDIA_DESCRIPTION || t === h.NOT_FOUND) && (r = `${n.message.to.uri.user}@${n.message.to.uri.host}`), r;
28
25
  };
29
- var z = /* @__PURE__ */ ((n) => (n.CONNECT_SERVER_FAILED = "CONNECT_SERVER_FAILED", n.WRONG_USER_OR_PASSWORD = "WRONG_USER_OR_PASSWORD", n.BAD_MEDIA_ERROR = "BAD_MEDIA_ERROR", n.NOT_FOUND_ERROR = "NOT_FOUND_ERROR", n.WS_CONNECTION_FAILED = "WS_CONNECTION_FAILED", n.CONNECT_SERVER_FAILED_BY_LINK = "CONNECT_SERVER_FAILED_BY_LINK", n))(z || {});
30
- const ge = new Error("Unknown error"), pe = (n = ge) => {
26
+ var H = /* @__PURE__ */ ((n) => (n.CONNECT_SERVER_FAILED = "CONNECT_SERVER_FAILED", n.WRONG_USER_OR_PASSWORD = "WRONG_USER_OR_PASSWORD", n.BAD_MEDIA_ERROR = "BAD_MEDIA_ERROR", n.NOT_FOUND_ERROR = "NOT_FOUND_ERROR", n.WS_CONNECTION_FAILED = "WS_CONNECTION_FAILED", n.CONNECT_SERVER_FAILED_BY_LINK = "CONNECT_SERVER_FAILED_BY_LINK", n))(H || {});
27
+ const ne = new Error("Unknown error"), te = (n = ne) => {
31
28
  const { cause: e, socket: t } = n;
32
29
  let r = "CONNECT_SERVER_FAILED";
33
30
  switch (e) {
@@ -35,521 +32,137 @@ const ge = new Error("Unknown error"), pe = (n = ge) => {
35
32
  r = "WRONG_USER_OR_PASSWORD";
36
33
  break;
37
34
  }
38
- case R.BAD_MEDIA_DESCRIPTION: {
35
+ case h.BAD_MEDIA_DESCRIPTION: {
39
36
  r = "BAD_MEDIA_ERROR";
40
37
  break;
41
38
  }
42
- case R.NOT_FOUND: {
39
+ case h.NOT_FOUND: {
43
40
  r = "NOT_FOUND_ERROR";
44
41
  break;
45
42
  }
46
43
  default:
47
- t !== void 0 && t._ws?.readyState === 3 ? r = "WS_CONNECTION_FAILED" : x(n) !== void 0 && x(n) !== "" && (r = "CONNECT_SERVER_FAILED_BY_LINK");
44
+ t !== void 0 && t._ws?.readyState === 3 ? r = "WS_CONNECTION_FAILED" : D(n) !== void 0 && D(n) !== "" && (r = "CONNECT_SERVER_FAILED_BY_LINK");
48
45
  }
49
46
  return r;
50
- }, Re = (n) => {
47
+ }, oe = (n) => {
51
48
  let e = "";
52
49
  try {
53
50
  e = JSON.stringify(n);
54
51
  } catch (t) {
55
- i("failed to stringify message", t);
52
+ o("failed to stringify message", t);
56
53
  }
57
54
  return e;
58
- }, ye = new Error("Unknown error"), ve = (n = ye) => {
59
- const { code: e, cause: t, message: r } = n, s = x(n), o = { code: "", cause: "", message: "" };
60
- return typeof r == "object" && r !== null ? o.message = Re(r) : r && (o.message = String(r)), s !== void 0 && s !== "" && (o.link = s), e !== void 0 && e !== "" && (o.code = e), t !== void 0 && t !== "" && (o.cause = t), o;
61
- }, Te = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
55
+ }, re = new Error("Unknown error"), se = (n = re) => {
56
+ const { code: e, cause: t, message: r } = n, a = D(n), s = { code: "", cause: "", message: "" };
57
+ return typeof r == "object" && r !== null ? s.message = oe(r) : r && (s.message = String(r)), a !== void 0 && a !== "" && (s.link = a), e !== void 0 && e !== "" && (s.code = e), t !== void 0 && t !== "" && (s.cause = t), s;
58
+ }, ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
62
59
  __proto__: null,
63
- EErrorTypes: z,
64
- getLinkError: x,
65
- getTypeFromError: pe,
66
- getValuesFromError: ve
67
- }, Symbol.toStringTag, { value: "Module" })), Ee = ({
60
+ EErrorTypes: H,
61
+ getLinkError: D,
62
+ getTypeFromError: te,
63
+ getValuesFromError: se
64
+ }, Symbol.toStringTag, { value: "Module" })), ce = ({
68
65
  sessionId: n,
69
66
  remoteAddress: e,
70
67
  isMutedAudio: t,
71
68
  isMutedVideo: r,
72
- isRegistered: s,
73
- isPresentationCall: o
69
+ isRegistered: a,
70
+ isPresentationCall: s
74
71
  }) => {
75
- const c = [], a = t ? "0" : "1", d = r ? "0" : "1";
76
- return c.push(`X-Vinteo-Mic-State: ${a}`, `X-Vinteo-MainCam-State: ${d}`), (s === !1 || s === void 0) && c.push("X-Vinteo-Purgatory-Call: yes"), n !== void 0 && n !== "" && c.push(`X-Vinteo-Session: ${n}`), o === !0 && c.push("X-Vinteo-Presentation-Call: yes"), e !== void 0 && e !== "" && c.push(`X-Vinteo-Remote: ${e}`), c;
77
- }, Me = "[@*!|]", be = "_", Be = (n) => {
72
+ const c = [], u = t ? "0" : "1", l = r ? "0" : "1";
73
+ return c.push(`X-Vinteo-Mic-State: ${u}`, `X-Vinteo-MainCam-State: ${l}`), (a === !1 || a === void 0) && c.push("X-Vinteo-Purgatory-Call: yes"), n !== void 0 && n !== "" && c.push(`X-Vinteo-Session: ${n}`), s === !0 && c.push("X-Vinteo-Presentation-Call: yes"), e !== void 0 && e !== "" && c.push(`X-Vinteo-Remote: ${e}`), c;
74
+ }, ie = "[@*!|]", ue = "_", le = (n) => {
78
75
  let e = n;
79
- return e = e.replaceAll(new RegExp(Me, "g"), be), e;
80
- }, _e = ({
76
+ return e = e.replaceAll(new RegExp(ie, "g"), ue), e;
77
+ }, de = ({
81
78
  appName: n,
82
79
  appVersion: e,
83
80
  browserName: t,
84
81
  browserVersion: r
85
82
  }) => {
86
- const o = `${Be(n)} ${e}`;
87
- return `ChromeNew - ${t === void 0 ? o : `${t} ${r}, ${o}`}`;
88
- }, Ae = ({
83
+ const s = `${le(n)} ${e}`;
84
+ return `ChromeNew - ${t === void 0 ? s : `${t} ${r}, ${s}`}`;
85
+ }, me = ({
89
86
  isUnifiedSdpSemantic: n,
90
87
  appVersion: e,
91
88
  browserName: t,
92
89
  browserVersion: r,
93
- appName: s
94
- }) => n ? _e({ appVersion: e, browserName: t, browserVersion: r, appName: s }) : "Chrome", Z = "purgatory", U = (n) => n === Z, Ne = (n) => (e) => [...e].map((r) => async () => n(r)), Pe = async ({
90
+ appName: a
91
+ }) => n ? de({ appVersion: e, browserName: t, browserVersion: r, appName: a }) : "Chrome", W = "purgatory", F = (n) => n === W, Se = (n) => (e) => [...e].map((r) => async () => n(r)), fe = async ({
95
92
  accumulatedKeys: n,
96
93
  sendKey: e,
97
94
  canRunTask: t
98
95
  }) => {
99
- const s = Ne(e)(n);
100
- return fe(s, t);
101
- }, Oe = (n, e) => (n.degradationPreference = e.degradationPreference, n), we = (n, e) => {
102
- n.encodings ??= [];
103
- for (let t = n.encodings.length; t < e; t += 1)
104
- n.encodings.push({});
105
- return n;
106
- }, ee = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, De = ee(), ke = (n, e) => {
107
- if (De(n, e))
108
- return n;
109
- }, Ie = (n, e) => {
110
- const t = n.maxBitrate, r = ke(e, t);
111
- return r !== void 0 && (n.maxBitrate = r), n;
112
- }, ne = 1, Fe = ee(
113
- ne
114
- ), xe = (n, e) => {
115
- const t = n === void 0 ? void 0 : Math.max(n, ne);
116
- if (t !== void 0 && Fe(
117
- t,
118
- e
119
- ))
120
- return t;
121
- }, Ue = (n, e) => {
122
- const t = n.scaleResolutionDownBy, r = xe(
123
- e,
124
- t
125
- );
126
- return r !== void 0 && (n.scaleResolutionDownBy = r), n;
127
- }, Ve = (n, e) => {
128
- const t = e.encodings?.length ?? 0;
129
- return we(n, t), n.encodings.forEach((r, s) => {
130
- const o = (e?.encodings ?? [])[s], c = o?.maxBitrate, a = o?.scaleResolutionDownBy;
131
- Ie(r, c), Ue(r, a);
132
- }), n;
133
- }, Le = (n, e) => {
134
- if (n.codecs?.length !== e.codecs?.length)
135
- return !0;
136
- for (let t = 0; t < (n.codecs?.length ?? 0); t++)
137
- if (JSON.stringify(n.codecs[t]) !== JSON.stringify(e.codecs[t]))
138
- return !0;
139
- if (n.headerExtensions?.length !== e.headerExtensions?.length)
140
- return !0;
141
- for (let t = 0; t < (n.headerExtensions?.length ?? 0); t++)
142
- if (JSON.stringify(n.headerExtensions[t]) !== JSON.stringify(e.headerExtensions[t]))
143
- return !0;
144
- if (n.encodings?.length !== e.encodings?.length)
145
- return !0;
146
- for (let t = 0; t < (n.encodings?.length ?? 0); t++)
147
- if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
148
- return !0;
149
- return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
150
- }, J = async (n, e) => {
151
- const t = n.getParameters(), r = JSON.parse(
152
- JSON.stringify(t)
153
- );
154
- Ve(t, e), Oe(t, e);
155
- const s = Le(r, t);
156
- return s && await n.setParameters(t), { parameters: t, isChanged: s };
157
- }, te = async (n, e, t) => {
158
- const { isChanged: r, parameters: s } = await J(n, {
159
- encodings: [
160
- {
161
- scaleResolutionDownBy: e.scaleResolutionDownBy,
162
- maxBitrate: e.maxBitrate
163
- }
164
- ]
165
- });
166
- return r && t && t(s), { isChanged: r, parameters: s };
167
- }, He = (n) => (t) => (i("onStartMainCam"), n.on("api:admin-start-main-cam", t)), $e = (n) => (t) => (i("onStartMic"), n.on("api:admin-start-mic", t)), We = (n) => (t) => (i("onStopMainCam"), n.on("api:admin-stop-main-cam", t)), Qe = (n) => (t) => (i("onStopMic"), n.on("api:admin-stop-mic", t)), Je = ({ sipConnector: n }) => {
168
- const e = (S, C) => ({ isSyncForced: g }) => {
169
- if (g === !0) {
170
- S();
96
+ const a = Se(e)(n);
97
+ return Q(a, t);
98
+ }, Ce = (n) => (t) => (o("onStartMainCam"), n.on("api:admin-start-main-cam", t)), pe = (n) => (t) => (o("onStartMic"), n.on("api:admin-start-mic", t)), he = (n) => (t) => (o("onStopMainCam"), n.on("api:admin-stop-main-cam", t)), Re = (n) => (t) => (o("onStopMic"), n.on("api:admin-stop-mic", t)), ge = ({ sipConnector: n }) => {
99
+ const e = (m, f) => ({ isSyncForced: S }) => {
100
+ if (S === !0) {
101
+ m();
171
102
  return;
172
103
  }
173
- C();
174
- }, t = He(n), r = We(n), s = $e(n), o = Qe(n);
175
- let c, a, d, l;
176
- const f = ({
177
- onStartMainCamForced: S,
178
- onStartMainCamNotForced: C,
179
- onStopMainCamForced: g,
180
- onStopMainCamNotForced: p,
181
- onStartMicForced: y,
182
- onStartMicNotForced: E,
183
- onStopMicForced: M,
184
- onStopMicNotForced: b
104
+ f();
105
+ }, t = Ce(n), r = he(n), a = pe(n), s = Re(n);
106
+ let c, u, l, p;
107
+ const R = ({
108
+ onStartMainCamForced: m,
109
+ onStartMainCamNotForced: f,
110
+ onStopMainCamForced: S,
111
+ onStopMainCamNotForced: g,
112
+ onStartMicForced: b,
113
+ onStartMicNotForced: v,
114
+ onStopMicForced: _,
115
+ onStopMicNotForced: O
185
116
  }) => {
186
- const B = e(
187
- S,
188
- C
117
+ const T = e(
118
+ m,
119
+ f
189
120
  );
190
- c = t(B);
191
- const _ = e(
192
- g,
193
- p
121
+ c = t(T);
122
+ const M = e(
123
+ S,
124
+ g
194
125
  );
195
- a = r(_);
196
- const A = e(y, E);
197
- d = s(A);
198
- const N = e(M, b);
199
- l = o(N);
200
- }, h = () => {
201
- c?.(), a?.(), d?.(), l?.();
126
+ u = r(M);
127
+ const P = e(b, v);
128
+ l = a(P);
129
+ const C = e(_, O);
130
+ p = s(C);
131
+ }, d = () => {
132
+ c?.(), u?.(), l?.(), p?.();
202
133
  };
203
134
  return {
204
- start: (S) => {
205
- f(S);
135
+ start: (m) => {
136
+ R(m);
206
137
  },
207
138
  stop: () => {
208
- h();
139
+ d();
209
140
  }
210
141
  };
211
- }, On = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
142
+ }, De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
212
143
  __proto__: null,
213
- PURGATORY_CONFERENCE_NUMBER: Z,
214
- createSyncMediaState: Je,
215
- createUaParser: q,
216
- error: Te,
217
- getExtraHeaders: Ee,
218
- getUserAgent: Ae,
219
- hasPurgatory: U,
220
- prepareMediaStream: de,
221
- sendDtmfAccumulated: Pe,
222
- setEncodingsToSender: te,
223
- setParametersToSender: J
224
- }, Symbol.toStringTag, { value: "Module" })), wn = () => q().isChrome, Xe = (n) => n.getVideoTracks()[0], je = 1e6, m = (n) => n * je, re = m(0.06), se = m(4), Ge = (n) => n <= 64 ? re : n <= 128 ? m(0.12) : n <= 256 ? m(0.25) : n <= 384 ? m(0.32) : n <= 426 ? m(0.38) : n <= 640 ? m(0.5) : n <= 848 ? m(0.7) : n <= 1280 ? m(1) : n <= 1920 ? m(2) : se, oe = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Ke = "av1", Ye = (n) => oe(n, Ke), qe = 0.6, X = (n, e) => Ye(e) ? n * qe : n, ze = (n) => X(re, n), Ze = (n) => X(se, n), Q = (n, e) => {
225
- const t = Ge(n);
226
- return X(t, e);
227
- }, $ = 1, ie = ({
228
- videoTrack: n,
229
- targetSize: e
230
- }) => {
231
- const t = n.getSettings(), r = t.width, s = t.height, o = r === void 0 ? $ : r / e.width, c = s === void 0 ? $ : s / e.height;
232
- return Math.max(o, c, $);
233
- }, en = (n) => [...n.keys()].map((e) => n.get(e)), nn = (n, e) => en(n).find((t) => t?.type === e), tn = async (n) => n.getStats().then((e) => nn(e, "codec")?.mimeType);
234
- class rn {
235
- // eslint-disable-next-line @typescript-eslint/class-methods-use-this
236
- async getCodecFromSender(e) {
237
- return await tn(e) ?? "";
238
- }
239
- }
240
- class sn {
241
- stackPromises = Se({
242
- noRunIsNotActual: !0
243
- });
244
- /**
245
- * Добавляет задачу в очередь и возвращает Promise с результатом
246
- * @param task - Функция для выполнения
247
- * @returns Promise с результатом выполнения задачи
248
- */
249
- async add(e) {
250
- return this.stackPromises.add(e), this.run();
251
- }
252
- stop() {
253
- this.stackPromises.stop();
254
- }
255
- /**
256
- * Выполняет задачи из очереди с обработкой ошибок
257
- * @returns Promise с результатом выполнения
258
- */
259
- async run() {
260
- return this.stackPromises().catch((e) => {
261
- i("TaskQueue: error", e);
262
- });
263
- }
264
- }
265
- class on {
266
- taskQueue;
267
- onSetParameters;
268
- constructor(e) {
269
- this.onSetParameters = e, this.taskQueue = new sn();
270
- }
271
- async setEncodingsToSender(e, t) {
272
- return this.taskQueue.add(async () => te(e, t, this.onSetParameters));
273
- }
274
- stop() {
275
- this.taskQueue.stop();
276
- }
277
- }
278
- class cn {
279
- ignoreForCodec;
280
- senderFinder;
281
- codecProvider;
282
- parametersSetter;
283
- resultNoChanged = {
284
- isChanged: !1,
285
- parameters: {
286
- encodings: [{}],
287
- transactionId: "0",
288
- codecs: [],
289
- headerExtensions: [],
290
- rtcp: {}
291
- }
292
- };
293
- constructor({
294
- senderFinder: e,
295
- codecProvider: t,
296
- parametersSetter: r
297
- }, s) {
298
- this.senderFinder = e, this.codecProvider = t, this.parametersSetter = r, this.ignoreForCodec = s.ignoreForCodec;
299
- }
300
- /**
301
- * Выполняет балансировку на основе заголовков от сервера
302
- * @param connection - RTCPeerConnection для получения отправителей
303
- * @param headers - Заголовки от сервера с командами управления
304
- * @returns Promise с результатом балансировки
305
- */
306
- async balance(e, t) {
307
- const r = e.getSenders(), s = this.senderFinder.findVideoSender(r);
308
- if (!s?.track)
309
- return this.resultNoChanged;
310
- const o = await this.codecProvider.getCodecFromSender(s);
311
- if (oe(o, this.ignoreForCodec))
312
- return this.resultNoChanged;
313
- const { mainCam: c, resolutionMainCam: a } = t ?? {};
314
- return this.processSender(
315
- { mainCam: c, resolutionMainCam: a },
316
- {
317
- sender: s,
318
- codec: o,
319
- videoTrack: s.track
320
- }
321
- );
322
- }
323
- /**
324
- * Обрабатывает отправитель в зависимости от команды управления
325
- * @param context - Контекст балансировки
326
- * @returns Promise с результатом обработки
327
- */
328
- async processSender(e, t) {
329
- const { mainCam: r, resolutionMainCam: s } = e;
330
- switch (r) {
331
- case O.PAUSE_MAIN_CAM:
332
- return this.downgradeResolutionSender(t);
333
- case O.RESUME_MAIN_CAM:
334
- return this.setBitrateByTrackResolution(t);
335
- case O.MAX_MAIN_CAM_RESOLUTION:
336
- return s !== void 0 ? this.setResolutionSender(s, t) : this.setBitrateByTrackResolution(t);
337
- case O.ADMIN_STOP_MAIN_CAM:
338
- case O.ADMIN_START_MAIN_CAM:
339
- case void 0:
340
- return this.setBitrateByTrackResolution(t);
341
- default:
342
- return this.setBitrateByTrackResolution(t);
343
- }
344
- }
345
- /**
346
- * Понижает разрешение отправителя (пауза камеры)
347
- * @param context - Контекст балансировки
348
- * @returns Promise с результатом
349
- */
350
- async downgradeResolutionSender(e) {
351
- const { sender: t, codec: r } = e, s = {
352
- scaleResolutionDownBy: 200,
353
- maxBitrate: ze(r)
354
- };
355
- return this.parametersSetter.setEncodingsToSender(t, s);
356
- }
357
- /**
358
- * Устанавливает битрейт на основе разрешения трека
359
- * @param context - Контекст балансировки
360
- * @returns Promise с результатом
361
- */
362
- async setBitrateByTrackResolution(e) {
363
- const { sender: t, videoTrack: r, codec: s } = e, c = r.getSettings().width, a = c === void 0 ? Ze(s) : Q(c, s);
364
- return this.parametersSetter.setEncodingsToSender(t, {
365
- scaleResolutionDownBy: 1,
366
- maxBitrate: a
367
- });
368
- }
369
- /**
370
- * Устанавливает разрешение отправителя на основе заголовка
371
- * @param resolutionMainCam - Разрешение главной камеры
372
- * @param context - Контекст балансировки
373
- * @returns Promise с результатом
374
- */
375
- async setResolutionSender(e, t) {
376
- const [r, s] = e.split("x"), { sender: o, videoTrack: c, codec: a } = t, d = {
377
- width: Number(r),
378
- height: Number(s)
379
- }, l = ie({
380
- videoTrack: c,
381
- targetSize: d
382
- }), f = Q(d.width, a), h = {
383
- scaleResolutionDownBy: l,
384
- maxBitrate: f
385
- };
386
- return this.parametersSetter.setEncodingsToSender(o, h);
387
- }
388
- }
389
- const an = (n) => n.find((e) => e.track?.kind === "video");
390
- class dn {
391
- // eslint-disable-next-line @typescript-eslint/class-methods-use-this
392
- findVideoSender(e) {
393
- return an(e);
394
- }
395
- }
396
- class un {
397
- sipConnector;
398
- currentHandler;
399
- constructor(e) {
400
- this.sipConnector = e;
401
- }
402
- /**
403
- * Подписывается на события управления главной камерой
404
- * @param handler - Обработчик события
405
- */
406
- subscribe(e) {
407
- this.currentHandler = e, this.sipConnector.on("api:main-cam-control", e);
408
- }
409
- /**
410
- * Отписывается от событий управления главной камерой
411
- */
412
- unsubscribe() {
413
- this.currentHandler && (this.sipConnector.off("api:main-cam-control", this.currentHandler), this.currentHandler = void 0);
414
- }
415
- /**
416
- * Получает соединение из SipConnector
417
- * @returns RTCPeerConnection или undefined
418
- */
419
- getConnection() {
420
- return this.sipConnector.connection;
421
- }
422
- }
423
- class ln {
424
- eventHandler;
425
- senderBalancer;
426
- parametersSetterWithQueue;
427
- serverHeaders;
428
- constructor(e, { ignoreForCodec: t, onSetParameters: r } = {}) {
429
- this.eventHandler = new un(e), this.parametersSetterWithQueue = new on(r), this.senderBalancer = new cn(
430
- {
431
- senderFinder: new dn(),
432
- codecProvider: new rn(),
433
- parametersSetter: this.parametersSetterWithQueue
434
- },
435
- {
436
- ignoreForCodec: t
437
- }
438
- );
439
- }
440
- /**
441
- * Подписывается на события управления главной камерой
442
- */
443
- subscribe() {
444
- this.eventHandler.subscribe(this.handleMainCamControl);
445
- }
446
- /**
447
- * Отписывается от событий и сбрасывает состояние
448
- */
449
- unsubscribe() {
450
- this.eventHandler.unsubscribe(), this.parametersSetterWithQueue.stop(), this.reset();
451
- }
452
- /**
453
- * Сбрасывает состояние балансировщика
454
- */
455
- reset() {
456
- delete this.serverHeaders;
457
- }
458
- /**
459
- * Перебалансирует текущее состояние
460
- * @returns Promise с результатом балансировки
461
- */
462
- async reBalance() {
463
- return this.balanceByTrack();
464
- }
465
- /**
466
- * Выполняет балансировку на основе текущего состояния
467
- * @returns Promise с результатом балансировки
468
- */
469
- async balanceByTrack() {
470
- const e = this.eventHandler.getConnection();
471
- if (!e)
472
- throw new Error("connection is not exist");
473
- return this.senderBalancer.balance(e, this.serverHeaders);
474
- }
475
- /**
476
- * Обработчик событий управления главной камерой
477
- * @param headers - Заголовки от сервера
478
- */
479
- handleMainCamControl = (e) => {
480
- this.serverHeaders = e, this.balanceByTrack().catch(k);
481
- };
482
- }
483
- const Dn = (n, e = {}) => new ln(n, e), hn = ({
484
- videoTrack: n,
485
- targetSize: e,
486
- codec: t
487
- }) => {
488
- const r = ie({
489
- videoTrack: n,
490
- targetSize: e
491
- }), s = Q(e.width, t);
492
- return { scaleResolutionDownBy: r, maxBitrate: s };
493
- }, w = ({
494
- mediaStream: n,
495
- simulcastEncodings: e,
496
- sendEncodings: t
497
- }) => {
498
- if (e && e.length > 0) {
499
- const r = t ?? [], s = Xe(n);
500
- if (s === void 0)
501
- throw new Error("No video track");
502
- return e.forEach((o, c) => {
503
- const a = r[c] ?? {};
504
- a.active = !0, o.rid !== void 0 && (a.rid = o.rid), o.scalabilityMode !== void 0 && (a.scalabilityMode = o.scalabilityMode);
505
- const { maxBitrate: d, scaleResolutionDownBy: l } = hn({
506
- videoTrack: s,
507
- targetSize: {
508
- width: o.width,
509
- height: o.height
510
- }
511
- });
512
- a.maxBitrate = d, a.scaleResolutionDownBy = l, r[c] = a;
513
- }), r;
514
- }
515
- return t;
516
- }, fn = (n, e) => n.filter((r) => e.some((s) => s.clockRate === r.clockRate && s.mimeType === r.mimeType && s.channels === r.channels && s.sdpFmtpLine === r.sdpFmtpLine)), Sn = (n) => {
517
- const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), r = e === null ? [] : e.codecs, s = t === null ? [] : t.codecs;
518
- return fn(r, s);
519
- }, mn = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, r) => {
520
- const s = e.indexOf(t.mimeType), o = e.indexOf(r.mimeType), c = s === -1 ? Number.MAX_VALUE : s, a = o === -1 ? Number.MAX_VALUE : o;
521
- return c - a;
522
- }), Cn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), gn = (n, {
523
- preferredMimeTypesVideoCodecs: e,
524
- excludeMimeTypesVideoCodecs: t
525
- }) => {
526
- if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
527
- const r = Sn("video"), s = Cn(r, t), o = mn(s, e);
528
- n.setCodecPreferences(o);
529
- }
530
- }, D = (n, {
531
- preferredMimeTypesVideoCodecs: e,
532
- excludeMimeTypesVideoCodecs: t
533
- }) => async (r) => {
534
- try {
535
- gn(r, {
536
- preferredMimeTypesVideoCodecs: e,
537
- excludeMimeTypesVideoCodecs: t
538
- }), Object.values(n).filter((o) => o != null).length > 0 && (i("updateTransceiver setParametersToSender", n), await J(r.sender, n));
539
- } catch (s) {
540
- i("updateTransceiver error", s);
541
- }
542
- }, W = (n) => {
543
- if (!Y(n) && !ue(n))
144
+ PURGATORY_CONFERENCE_NUMBER: W,
145
+ createSyncMediaState: ge,
146
+ createUaParser: $,
147
+ error: ae,
148
+ getExtraHeaders: ce,
149
+ getUserAgent: me,
150
+ hasPurgatory: F,
151
+ prepareMediaStream: X,
152
+ sendDtmfAccumulated: fe,
153
+ setEncodingsToSender: Y,
154
+ setParametersToSender: G
155
+ }, Symbol.toStringTag, { value: "Module" })), Fe = () => $().isChrome, k = (n) => {
156
+ if (!B(n) && !q(n))
544
157
  throw n;
545
158
  return { isSuccessful: !1 };
546
- }, pn = ({ kind: n, readyState: e }) => n === "video" && e === "live", j = (n, e, { onEnterPurgatory: t, onEnterConference: r }) => {
547
- U(n) ? t && t() : r && r({ isSuccessProgressCall: e });
548
- }, G = (n, e) => {
159
+ }, Ee = ({ kind: n, readyState: e }) => n === "video" && e === "live", L = (n, e, { onEnterPurgatory: t, onEnterConference: r }) => {
160
+ F(n) ? t && t() : r && r({ isSuccessProgressCall: e });
161
+ }, x = (n, e) => {
549
162
  n(), e && e();
550
- }, K = (n, e, t) => {
163
+ }, V = (n, e, t) => {
551
164
  throw n && n(), e(), t;
552
- }, Rn = /* @__PURE__ */ new Set([
165
+ }, be = /* @__PURE__ */ new Set([
553
166
  "on",
554
167
  "once",
555
168
  "onceRace",
@@ -566,7 +179,7 @@ const Dn = (n, e = {}) => new ln(n, e), hn = ({
566
179
  "isConfigured",
567
180
  "isRegistered"
568
181
  ]);
569
- class kn {
182
+ class we {
570
183
  // @ts-expect-error: proxy method
571
184
  on;
572
185
  // @ts-expect-error: proxy method
@@ -598,20 +211,15 @@ class kn {
598
211
  // @ts-expect-error: proxy method
599
212
  isRegistered;
600
213
  sipConnector;
601
- preferredMimeTypesVideoCodecs;
602
- excludeMimeTypesVideoCodecs;
603
- constructor(e, {
604
- preferredMimeTypesVideoCodecs: t,
605
- excludeMimeTypesVideoCodecs: r
606
- } = {}) {
607
- return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = r, this.sipConnector = e, new Proxy(this, {
608
- get: (s, o, c) => {
609
- if (typeof o == "string" && Rn.has(o) && o in this.sipConnector) {
610
- const d = Reflect.get(this.sipConnector, o, this.sipConnector);
611
- return typeof d == "function" ? d.bind(this.sipConnector) : d;
214
+ constructor(e) {
215
+ return this.sipConnector = e, new Proxy(this, {
216
+ get: (t, r, a) => {
217
+ if (typeof r == "string" && be.has(r) && r in this.sipConnector) {
218
+ const c = Reflect.get(this.sipConnector, r, this.sipConnector);
219
+ return typeof c == "function" ? c.bind(this.sipConnector) : c;
612
220
  }
613
- const a = Reflect.get(s, o, c);
614
- return typeof a == "function" ? a.bind(s) : a;
221
+ const s = Reflect.get(t, r, a);
222
+ return typeof s == "function" ? s.bind(t) : s;
615
223
  }
616
224
  });
617
225
  }
@@ -619,329 +227,254 @@ class kn {
619
227
  const {
620
228
  userAgent: t,
621
229
  sipWebSocketServerURL: r,
622
- sipServerUrl: s,
623
- remoteAddress: o,
230
+ sipServerUrl: a,
231
+ remoteAddress: s,
624
232
  displayName: c,
625
- name: a,
626
- password: d,
627
- isRegisteredUser: l,
628
- isDisconnectOnFail: f
233
+ name: u,
234
+ password: l,
235
+ isRegisteredUser: p,
236
+ isDisconnectOnFail: R
629
237
  } = e;
630
- return i("connectToServer", e), this.sipConnector.connect({
238
+ return o("connectToServer", e), this.sipConnector.connect({
631
239
  userAgent: t,
632
240
  sipWebSocketServerURL: r,
633
- sipServerUrl: s,
634
- remoteAddress: o,
241
+ sipServerUrl: a,
242
+ remoteAddress: s,
635
243
  displayName: c,
636
- password: d,
637
- user: a,
638
- register: l
639
- }).then((h) => (i("connectToServer then"), { ua: h, isSuccessful: !0 })).catch(async (h) => (i("connectToServer catch: error", h), f === !0 ? this.sipConnector.disconnect().then(() => W(h)).catch(() => W(h)) : W(h)));
244
+ password: l,
245
+ user: u,
246
+ register: p
247
+ }).then((d) => (o("connectToServer then"), { ua: d, isSuccessful: !0 })).catch(async (d) => (o("connectToServer catch: error", d), R === !0 ? this.sipConnector.disconnect().then(() => k(d)).catch(() => k(d)) : k(d)));
640
248
  };
641
249
  callToServer = async (e) => {
642
250
  const {
643
251
  conference: t,
644
252
  mediaStream: r,
645
- extraHeaders: s,
646
- iceServers: o,
253
+ extraHeaders: a,
254
+ iceServers: s,
647
255
  contentHint: c,
648
- simulcastEncodings: a,
649
- degradationPreference: d,
256
+ degradationPreference: u,
650
257
  sendEncodings: l,
651
- offerToReceiveAudio: f,
652
- offerToReceiveVideo: h,
653
- directionVideo: I,
654
- directionAudio: F,
655
- setRemoteStreams: S,
656
- onBeforeProgressCall: C,
657
- onSuccessProgressCall: g,
658
- onEnterPurgatory: p,
659
- onEnterConference: y,
660
- onFailProgressCall: E,
661
- onFinishProgressCall: M,
662
- onEndedCall: b
663
- } = e, B = this.resolveHandleReadyRemoteStreamsDebounced({
664
- onReadyRemoteStreams: S
665
- }), _ = this.resolveHandleReadyRemoteStreams({
258
+ offerToReceiveAudio: p,
259
+ offerToReceiveVideo: R,
260
+ directionVideo: d,
261
+ directionAudio: A,
262
+ setRemoteStreams: y,
263
+ onBeforeProgressCall: m,
264
+ onSuccessProgressCall: f,
265
+ onEnterPurgatory: S,
266
+ onEnterConference: g,
267
+ onFailProgressCall: b,
268
+ onFinishProgressCall: v,
269
+ onEndedCall: _,
270
+ onAddedTransceiver: O
271
+ } = e, T = this.resolveHandleReadyRemoteStreamsDebounced({
272
+ onReadyRemoteStreams: y
273
+ }), M = this.resolveHandleReadyRemoteStreams({
666
274
  onReadyRemoteStreams: () => {
667
- B().catch(k);
275
+ T().catch(o);
668
276
  }
669
- }), A = D(
670
- {
671
- degradationPreference: d
672
- },
673
- {
674
- preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
675
- excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
676
- }
677
- );
678
- i("callToServer", e);
679
- const N = async () => (i("startCall"), this.sipConnector.call({
277
+ });
278
+ o("callToServer", e);
279
+ const P = async () => (o("startCall"), this.sipConnector.call({
680
280
  mediaStream: r,
681
- extraHeaders: s,
682
- iceServers: o,
281
+ extraHeaders: a,
282
+ iceServers: s,
683
283
  contentHint: c,
684
- offerToReceiveAudio: f,
685
- offerToReceiveVideo: h,
686
- directionVideo: I,
687
- directionAudio: F,
688
- sendEncodings: w({
689
- mediaStream: r,
690
- simulcastEncodings: a,
691
- sendEncodings: l
692
- }),
284
+ offerToReceiveAudio: p,
285
+ offerToReceiveVideo: R,
286
+ directionVideo: d,
287
+ directionAudio: A,
288
+ degradationPreference: u,
289
+ onAddedTransceiver: O,
290
+ sendEncodings: l,
693
291
  number: t,
694
- onAddedTransceiver: A,
695
- ontrack: _
292
+ ontrack: M
696
293
  }));
697
- let v = !1, T;
698
- const P = (i("subscribeEnterConference: onEnterConference", y), this.sipConnector.on("api:enterRoom", ({ room: u }) => {
699
- i("enterRoom", { _room: u, isSuccessProgressCall: v }), T = u, (p ?? y) && j(T, v, {
700
- onEnterPurgatory: p,
701
- onEnterConference: y
294
+ let C = !1, E;
295
+ const N = (o("subscribeEnterConference: onEnterConference", g), this.sipConnector.on("api:enterRoom", ({ room: i }) => {
296
+ o("enterRoom", { _room: i, isSuccessProgressCall: C }), E = i, (S ?? g) && L(E, C, {
297
+ onEnterPurgatory: S,
298
+ onEnterConference: g
702
299
  });
703
- })), V = (u) => (i("onSuccess"), v = !0, B().catch(k), g && g({ isPurgatory: U(T) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
704
- G(P, b);
705
- }), u), L = (u) => (i("onFail"), K(E, P, u)), H = () => {
706
- i("onFinish"), M && M();
300
+ })), w = (i) => (o("onSuccess"), C = !0, T().catch(o), f && f({ isPurgatory: F(E) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
301
+ x(N, _);
302
+ }), i), I = (i) => (o("onFail"), V(b, N, i)), U = () => {
303
+ o("onFinish"), v && v();
707
304
  };
708
- return i("onBeforeProgressCall"), C && C(t), N().then(V).catch((u) => L(u)).finally(H);
305
+ return o("onBeforeProgressCall"), m && m(t), P().then(w).catch((i) => I(i)).finally(U);
709
306
  };
710
- disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (i("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (i("disconnectFromServer: catch", e), { isSuccessful: !1 }));
307
+ disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (o("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (o("disconnectFromServer: catch", e), { isSuccessful: !1 }));
711
308
  answerToIncomingCall = async (e) => {
712
309
  const {
713
310
  mediaStream: t,
714
311
  extraHeaders: r,
715
- iceServers: s,
716
- contentHint: o,
717
- simulcastEncodings: c,
718
- degradationPreference: a,
719
- sendEncodings: d,
312
+ iceServers: a,
313
+ contentHint: s,
314
+ degradationPreference: c,
315
+ sendEncodings: u,
720
316
  offerToReceiveAudio: l,
721
- offerToReceiveVideo: f,
722
- directionVideo: h,
723
- directionAudio: I,
724
- setRemoteStreams: F,
725
- onBeforeProgressCall: S,
726
- onSuccessProgressCall: C,
727
- onEnterPurgatory: g,
728
- onEnterConference: p,
729
- onFailProgressCall: y,
730
- onFinishProgressCall: E,
731
- onEndedCall: M
732
- } = e, b = this.resolveHandleReadyRemoteStreamsDebounced({
733
- onReadyRemoteStreams: F
734
- }), B = this.resolveHandleReadyRemoteStreams({
317
+ offerToReceiveVideo: p,
318
+ directionVideo: R,
319
+ directionAudio: d,
320
+ setRemoteStreams: A,
321
+ onBeforeProgressCall: y,
322
+ onSuccessProgressCall: m,
323
+ onEnterPurgatory: f,
324
+ onEnterConference: S,
325
+ onFailProgressCall: g,
326
+ onFinishProgressCall: b,
327
+ onEndedCall: v,
328
+ onAddedTransceiver: _
329
+ } = e, O = this.resolveHandleReadyRemoteStreamsDebounced({
330
+ onReadyRemoteStreams: A
331
+ }), T = this.resolveHandleReadyRemoteStreams({
735
332
  onReadyRemoteStreams: () => {
736
- b().catch(k);
333
+ O().catch(o);
737
334
  }
738
- }), _ = D(
739
- {
740
- degradationPreference: a
741
- },
742
- {
743
- preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
744
- excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
745
- }
746
- );
747
- i("answerToIncomingCall", e);
748
- const A = async () => this.sipConnector.answerToIncomingCall({
335
+ });
336
+ o("answerToIncomingCall", e);
337
+ const M = async () => this.sipConnector.answerToIncomingCall({
749
338
  mediaStream: t,
750
339
  extraHeaders: r,
751
- iceServers: s,
752
- contentHint: o,
340
+ iceServers: a,
341
+ contentHint: s,
753
342
  offerToReceiveAudio: l,
754
- offerToReceiveVideo: f,
755
- directionVideo: h,
756
- directionAudio: I,
757
- sendEncodings: w({
758
- mediaStream: t,
759
- simulcastEncodings: c,
760
- sendEncodings: d
761
- }),
343
+ offerToReceiveVideo: p,
344
+ directionVideo: R,
345
+ directionAudio: d,
346
+ degradationPreference: c,
762
347
  onAddedTransceiver: _,
763
- ontrack: B
764
- }), N = () => {
765
- const { remoteCallerData: u } = this.sipConnector;
766
- return u.incomingNumber;
348
+ sendEncodings: u,
349
+ ontrack: T
350
+ }), P = () => {
351
+ const { remoteCallerData: i } = this.sipConnector;
352
+ return i.incomingNumber;
767
353
  };
768
- let v = !1, T;
769
- const P = (i("subscribeEnterConference: onEnterConference", p), this.sipConnector.on("api:enterRoom", (u) => {
770
- i("enterRoom", { _room: u, isSuccessProgressCall: v }), T = u, (g ?? p) && j(T, v, {
771
- onEnterPurgatory: g,
772
- onEnterConference: p
354
+ let C = !1, E;
355
+ const N = (o("subscribeEnterConference: onEnterConference", S), this.sipConnector.on("api:enterRoom", (i) => {
356
+ o("enterRoom", { _room: i, isSuccessProgressCall: C }), E = i, (f ?? S) && L(E, C, {
357
+ onEnterPurgatory: f,
358
+ onEnterConference: S
773
359
  });
774
- })), V = (u) => (i("onSuccess"), v = !0, b().catch(k), C && C({ isPurgatory: U(T) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
775
- G(P, M);
776
- }), u), L = (u) => (i("onFail"), K(y, P, u)), H = () => {
777
- i("onFinish"), E && E();
360
+ })), w = (i) => (o("onSuccess"), C = !0, O().catch(o), m && m({ isPurgatory: F(E) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
361
+ x(N, v);
362
+ }), i), I = (i) => (o("onFail"), V(g, N, i)), U = () => {
363
+ o("onFinish"), b && b();
778
364
  };
779
- if (i("onBeforeProgressCall"), S) {
780
- const u = N();
781
- S(u);
365
+ if (o("onBeforeProgressCall"), y) {
366
+ const i = P();
367
+ y(i);
782
368
  }
783
- return A().then(V).catch((u) => L(u)).finally(H);
369
+ return M().then(w).catch((i) => I(i)).finally(U);
784
370
  };
785
371
  updatePresentation = async ({
786
372
  mediaStream: e,
787
373
  isP2P: t,
788
- maxBitrate: r,
789
- contentHint: s,
790
- simulcastEncodings: o,
791
- degradationPreference: c,
792
- sendEncodings: a,
793
- preferredMimeTypesVideoCodecs: d,
794
- excludeMimeTypesVideoCodecs: l
795
- }) => {
796
- const f = D(
797
- {
798
- degradationPreference: c
799
- },
800
- {
801
- preferredMimeTypesVideoCodecs: d,
802
- excludeMimeTypesVideoCodecs: l
803
- }
804
- );
805
- return i("updatePresentation"), this.sipConnector.updatePresentation(e, {
806
- isP2P: t,
807
- maxBitrate: r,
808
- contentHint: s,
809
- sendEncodings: w({
810
- mediaStream: e,
811
- simulcastEncodings: o,
812
- sendEncodings: a
813
- }),
814
- onAddedTransceiver: f
815
- });
816
- };
374
+ contentHint: r,
375
+ degradationPreference: a,
376
+ sendEncodings: s,
377
+ onAddedTransceiver: c
378
+ }) => (o("updatePresentation"), this.sipConnector.updatePresentation(e, {
379
+ isP2P: t,
380
+ contentHint: r,
381
+ degradationPreference: a,
382
+ onAddedTransceiver: c,
383
+ sendEncodings: s
384
+ }));
817
385
  startPresentation = async ({
818
386
  mediaStream: e,
819
387
  isP2P: t,
820
- maxBitrate: r,
821
- contentHint: s,
822
- simulcastEncodings: o,
823
- degradationPreference: c,
824
- sendEncodings: a,
825
- preferredMimeTypesVideoCodecs: d,
826
- excludeMimeTypesVideoCodecs: l,
827
- callLimit: f
828
- }) => {
829
- const h = D(
830
- {
831
- degradationPreference: c
832
- },
833
- {
834
- preferredMimeTypesVideoCodecs: d,
835
- excludeMimeTypesVideoCodecs: l
836
- }
837
- );
838
- return i("startPresentation"), this.sipConnector.startPresentation(e, {
839
- isP2P: t,
840
- maxBitrate: r,
841
- contentHint: s,
842
- callLimit: f,
843
- sendEncodings: w({
844
- mediaStream: e,
845
- simulcastEncodings: o,
846
- sendEncodings: a
847
- }),
848
- onAddedTransceiver: h
849
- });
850
- };
851
- stopShareSipConnector = async ({ isP2P: e = !1 } = {}) => (i("stopShareSipConnector"), this.sipConnector.stopPresentation({
388
+ contentHint: r,
389
+ degradationPreference: a,
390
+ sendEncodings: s,
391
+ callLimit: c,
392
+ onAddedTransceiver: u
393
+ }) => (o("startPresentation"), this.sipConnector.startPresentation(e, {
394
+ isP2P: t,
395
+ contentHint: r,
396
+ callLimit: c,
397
+ degradationPreference: a,
398
+ onAddedTransceiver: u,
399
+ sendEncodings: s
400
+ }));
401
+ stopShareSipConnector = async ({ isP2P: e = !1 } = {}) => (o("stopShareSipConnector"), this.sipConnector.stopPresentation({
852
402
  isP2P: e
853
403
  }).catch((t) => {
854
- i(t);
404
+ o(t);
855
405
  }));
856
406
  sendRefusalToTurnOnMic = async () => {
857
- i("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
858
- i("sendRefusalToTurnOnMic: error", e);
407
+ o("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
408
+ o("sendRefusalToTurnOnMic: error", e);
859
409
  });
860
410
  };
861
411
  sendRefusalToTurnOnCam = async () => {
862
- i("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
863
- i("sendRefusalToTurnOnCam: error", e);
412
+ o("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
413
+ o("sendRefusalToTurnOnCam: error", e);
864
414
  });
865
415
  };
866
416
  sendMediaState = async ({
867
417
  isEnabledCam: e,
868
418
  isEnabledMic: t
869
419
  }) => {
870
- i("sendMediaState"), await this.sipConnector.sendMediaState({ cam: e, mic: t });
420
+ o("sendMediaState"), await this.sipConnector.sendMediaState({ cam: e, mic: t });
871
421
  };
872
422
  replaceMediaStream = async (e, {
873
423
  deleteExisting: t,
874
424
  addMissing: r,
875
- forceRenegotiation: s,
876
- contentHint: o,
877
- simulcastEncodings: c,
878
- degradationPreference: a,
879
- sendEncodings: d
880
- }) => {
881
- const l = D(
882
- {
883
- degradationPreference: a
884
- },
885
- {
886
- preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
887
- excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
888
- }
889
- );
890
- return i("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
891
- deleteExisting: t,
892
- addMissing: r,
893
- forceRenegotiation: s,
894
- contentHint: o,
895
- sendEncodings: w({
896
- mediaStream: e,
897
- simulcastEncodings: c,
898
- sendEncodings: d
899
- }),
900
- onAddedTransceiver: l
901
- });
902
- };
425
+ forceRenegotiation: a,
426
+ contentHint: s,
427
+ degradationPreference: c,
428
+ sendEncodings: u,
429
+ onAddedTransceiver: l
430
+ }) => (o("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
431
+ deleteExisting: t,
432
+ addMissing: r,
433
+ forceRenegotiation: a,
434
+ contentHint: s,
435
+ degradationPreference: c,
436
+ onAddedTransceiver: l,
437
+ sendEncodings: u
438
+ }));
903
439
  askPermissionToEnableCam = async () => {
904
- i("askPermissionToEnableCam"), await this.sipConnector.askPermissionToEnableCam();
440
+ o("askPermissionToEnableCam"), await this.sipConnector.askPermissionToEnableCam();
905
441
  };
906
442
  resolveHandleReadyRemoteStreamsDebounced = ({
907
443
  onReadyRemoteStreams: e
908
- }) => le(() => {
444
+ }) => z(() => {
909
445
  const t = this.sipConnector.getRemoteStreams();
910
- i("remoteStreams", t), t && e(t);
446
+ o("remoteStreams", t), t && e(t);
911
447
  }, 200);
912
448
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
913
449
  resolveHandleReadyRemoteStreams = ({
914
450
  onReadyRemoteStreams: e
915
451
  }) => ({ track: t }) => {
916
- pn(t) && e();
452
+ Ee(t) && e();
917
453
  };
918
- getRemoteStreams = () => (i("getRemoteStreams"), this.sipConnector.getRemoteStreams());
919
- onUseLicense = (e) => (i("onUseLicense"), this.sipConnector.on("api:useLicense", e));
920
- onMustStopPresentation = (e) => (i("onMustStopPresentation"), this.sipConnector.on("api:mustStopPresentation", e));
921
- onMoveToSpectators = (e) => (i("onMoveToSpectators"), this.sipConnector.on("api:participant:move-request-to-spectators", e));
922
- onMoveToParticipants = (e) => (i("onMoveToParticipants"), this.sipConnector.on("api:participant:move-request-to-participants", e));
923
- onStats = (e) => (i("onStats"), this.sipConnector.on("stats:collected", e));
454
+ getRemoteStreams = () => (o("getRemoteStreams"), this.sipConnector.getRemoteStreams());
455
+ onUseLicense = (e) => (o("onUseLicense"), this.sipConnector.on("api:useLicense", e));
456
+ onMustStopPresentation = (e) => (o("onMustStopPresentation"), this.sipConnector.on("api:mustStopPresentation", e));
457
+ onMoveToSpectators = (e) => (o("onMoveToSpectators"), this.sipConnector.on("api:participant:move-request-to-spectators", e));
458
+ onMoveToParticipants = (e) => (o("onMoveToParticipants"), this.sipConnector.on("api:participant:move-request-to-participants", e));
459
+ onStats = (e) => (o("onStats"), this.sipConnector.on("stats:collected", e));
924
460
  offStats = (e) => {
925
- i("offStats"), this.sipConnector.off("stats:collected", e);
461
+ o("offStats"), this.sipConnector.off("stats:collected", e);
926
462
  };
927
463
  }
928
- var yn = /* @__PURE__ */ ((n) => (n.VP8 = "video/VP8", n.VP9 = "video/VP9", n.H264 = "video/H264", n.AV1 = "video/AV1", n.rtx = "video/rtx", n.red = "video/red", n.flexfec03 = "video/flexfec-03", n))(yn || {});
464
+ var ve = /* @__PURE__ */ ((n) => (n.VP8 = "video/VP8", n.VP9 = "video/VP9", n.H264 = "video/H264", n.AV1 = "video/AV1", n.rtx = "video/rtx", n.red = "video/red", n.flexfec03 = "video/flexfec-03", n))(ve || {});
929
465
  export {
930
- R as ECallCause,
931
- yn as EMimeTypesVideoCodecs,
932
- xn as EStatsTypes,
933
- Un as EUseLicense,
934
- Vn as SipConnector,
935
- kn as SipConnectorFacade,
936
- Ln as StatsPeerConnection,
937
- ln as VideoSendingBalancer,
938
- Jn as debug,
939
- Hn as disableDebug,
940
- $n as enableDebug,
941
- tn as getCodecFromSender,
942
- wn as hasAvailableStats,
943
- Pn as hasCanceledCallError,
944
- Wn as hasCanceledStartPresentationError,
945
- Dn as resolveVideoSendingBalancer,
946
- On as tools
466
+ h as ECallCause,
467
+ ve as EMimeTypesVideoCodecs,
468
+ ke as EStatsTypes,
469
+ Le as EUseLicense,
470
+ xe as SipConnector,
471
+ we as SipConnectorFacade,
472
+ Ve as StatsPeerConnection,
473
+ Be as disableDebug,
474
+ $e as enableDebug,
475
+ He as getCodecFromSender,
476
+ Fe as hasAvailableStats,
477
+ Ae as hasCanceledCallError,
478
+ We as hasCanceledStartPresentationError,
479
+ De as tools
947
480
  };