sip-connector 12.2.0 → 13.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.
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- var Z = Object.defineProperty;
2
- var ee = (n, e, t) => e in n ? Z(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var l = (n, e, t) => ee(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { B as X, N as j, l as a, E as k, s as ne, a as te, P as se, b as re, S as Je } from "./SipConnector-BxDInUHC.js";
5
- import { i as ln, j as dn, m as Sn, k as mn, c as Cn, d as fn, f as hn, g as Rn, e as gn, h as pn } from "./SipConnector-BxDInUHC.js";
6
- import { sequentPromises as oe } from "sequent-promises";
7
- import { createStackPromises as ce } from "stack-promises";
8
- import { isCanceledError as ie } from "@krivega/cancelable-promise";
9
- import { hasCanceledError as ae } from "repeated-calls";
10
- import { debounce as ue } from "ts-debounce";
11
- import { default as En } from "debug";
12
- const x = (n) => {
1
+ var se = Object.defineProperty;
2
+ var re = (n, e, t) => e in n ? se(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var l = (n, e, t) => re(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { B as G, N as K, l as a, E as L, s as oe, a as ie, P as ce, b as ae, S as tn } from "./SipConnector-B4xLnl6L.js";
5
+ import { i as Cn, j as fn, m as hn, k as Rn, c as gn, d as pn, f as yn, g as En, e as Tn, h as bn } from "./SipConnector-B4xLnl6L.js";
6
+ import { sequentPromises as ue } from "sequent-promises";
7
+ import { createStackPromises as le } from "stack-promises";
8
+ import { isCanceledError as de } from "@krivega/cancelable-promise";
9
+ import { hasCanceledError as Se } from "repeated-calls";
10
+ import { debounce as me } from "ts-debounce";
11
+ import { default as An } from "debug";
12
+ const H = (n) => {
13
13
  const { url: e, cause: t } = n;
14
14
  let s = e;
15
- return (t === X || t === j) && (s = `${n.message.to.uri.user}@${n.message.to.uri.host}`), s;
15
+ return (t === G || t === K) && (s = `${n.message.to.uri.user}@${n.message.to.uri.host}`), s;
16
16
  };
17
- var W = /* @__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))(W || {});
18
- const le = (n = new Error()) => {
17
+ var q = /* @__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))(q || {});
18
+ const Ce = (n = new Error()) => {
19
19
  var r;
20
20
  const { cause: e, socket: t } = n;
21
21
  let s = "CONNECT_SERVER_FAILED";
@@ -24,19 +24,19 @@ const le = (n = new Error()) => {
24
24
  s = "WRONG_USER_OR_PASSWORD";
25
25
  break;
26
26
  }
27
- case X: {
27
+ case G: {
28
28
  s = "BAD_MEDIA_ERROR";
29
29
  break;
30
30
  }
31
- case j: {
31
+ case K: {
32
32
  s = "NOT_FOUND_ERROR";
33
33
  break;
34
34
  }
35
35
  default:
36
- t && ((r = t == null ? void 0 : t._ws) == null ? void 0 : r.readyState) === 3 ? s = "WS_CONNECTION_FAILED" : x(n) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
36
+ t && ((r = t == null ? void 0 : t._ws) == null ? void 0 : r.readyState) === 3 ? s = "WS_CONNECTION_FAILED" : H(n) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
37
37
  }
38
38
  return s;
39
- }, de = (n) => {
39
+ }, fe = (n) => {
40
40
  let e = "";
41
41
  try {
42
42
  e = JSON.stringify(n);
@@ -44,16 +44,16 @@ const le = (n = new Error()) => {
44
44
  a("failed to stringify message", t);
45
45
  }
46
46
  return e;
47
- }, Se = (n = new Error()) => {
48
- const { code: e, cause: t, message: s } = n, r = x(n), o = { code: "", cause: "", message: "" };
49
- return typeof s == "object" && s !== null ? o.message = de(s) : s && (o.message = String(s)), r && (o.link = r), e && (o.code = e), t && (o.cause = t), o;
50
- }, me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47
+ }, he = (n = new Error()) => {
48
+ const { code: e, cause: t, message: s } = n, r = H(n), o = { code: "", cause: "", message: "" };
49
+ return typeof s == "object" && s !== null ? o.message = fe(s) : s && (o.message = String(s)), r && (o.link = r), e && (o.code = e), t && (o.cause = t), o;
50
+ }, Re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51
51
  __proto__: null,
52
- EErrorTypes: W,
53
- getLinkError: x,
54
- getTypeFromError: le,
55
- getValuesFromError: Se
56
- }, Symbol.toStringTag, { value: "Module" })), Ce = ({
52
+ EErrorTypes: q,
53
+ getLinkError: H,
54
+ getTypeFromError: Ce,
55
+ getValuesFromError: he
56
+ }, Symbol.toStringTag, { value: "Module" })), ge = ({
57
57
  sessionId: n,
58
58
  remoteAddress: e,
59
59
  isMutedAudio: t,
@@ -61,71 +61,71 @@ const le = (n = new Error()) => {
61
61
  isRegistered: r,
62
62
  isPresentationCall: o
63
63
  }) => {
64
- const c = [], i = t ? "0" : "1", u = s ? "0" : "1";
65
- return c.push(`X-Vinteo-Mic-State: ${i}`, `X-Vinteo-MainCam-State: ${u}`), r || c.push("X-Vinteo-Purgatory-Call: yes"), n && c.push(`X-Vinteo-Session: ${n}`), o && c.push("X-Vinteo-Presentation-Call: yes"), e && c.push(`X-Vinteo-Remote: ${e}`), c;
66
- }, fe = "[@*!|]", he = "_", Re = (n) => {
64
+ const i = [], c = t ? "0" : "1", u = s ? "0" : "1";
65
+ return i.push(`X-Vinteo-Mic-State: ${c}`, `X-Vinteo-MainCam-State: ${u}`), r || i.push("X-Vinteo-Purgatory-Call: yes"), n && i.push(`X-Vinteo-Session: ${n}`), o && i.push("X-Vinteo-Presentation-Call: yes"), e && i.push(`X-Vinteo-Remote: ${e}`), i;
66
+ }, pe = "[@*!|]", ye = "_", Ee = (n) => {
67
67
  let e = n;
68
- return e = e.replaceAll(new RegExp(fe, "g"), he), e;
69
- }, ge = ({
68
+ return e = e.replaceAll(new RegExp(pe, "g"), ye), e;
69
+ }, Te = ({
70
70
  appName: n,
71
71
  appVersion: e,
72
72
  browserName: t,
73
73
  browserVersion: s
74
74
  }) => {
75
- const o = `${Re(n)} ${e}`;
75
+ const o = `${Ee(n)} ${e}`;
76
76
  return `ChromeNew - ${t ? `${t} ${s}, ${o}` : o}`;
77
- }, pe = ({
77
+ }, be = ({
78
78
  isUnifiedSdpSemantic: n,
79
79
  appVersion: e,
80
80
  browserName: t,
81
81
  browserVersion: s,
82
82
  appName: r
83
- }) => n ? ge({ appVersion: e, browserName: t, browserVersion: s, appName: r }) : "Chrome", G = "purgatory", P = (n) => n === G, ye = (n) => (e) => [...e].map((s) => async () => n(s)), Ee = async ({
83
+ }) => n ? Te({ appVersion: e, browserName: t, browserVersion: s, appName: r }) : "Chrome", Y = "purgatory", D = (n) => n === Y, Me = (n) => (e) => [...e].map((s) => async () => n(s)), Ae = async ({
84
84
  accumulatedKeys: n,
85
85
  sendKey: e,
86
86
  canRunTask: t
87
87
  }) => {
88
- const r = ye(e)(n);
89
- return oe(r, t);
90
- }, Te = (n) => (t) => (a("onStartMainCam"), n.onSession("admin-start-main-cam", t)), be = (n) => (t) => (a("onStartMic"), n.onSession("admin-start-mic", t)), Me = (n) => (t) => (a("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), _e = (n) => (t) => (a("onStopMic"), n.onSession("admin-stop-mic", t)), Ae = ({ sipConnector: n }) => {
91
- const e = (f, g) => ({ isSyncForced: p = !1 }) => {
92
- if (p) {
88
+ const r = Me(e)(n);
89
+ return ue(r, t);
90
+ }, _e = (n) => (t) => (a("onStartMainCam"), n.onSession("admin-start-main-cam", t)), ve = (n) => (t) => (a("onStartMic"), n.onSession("admin-start-mic", t)), Oe = (n) => (t) => (a("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), Ne = (n) => (t) => (a("onStopMic"), n.onSession("admin-stop-mic", t)), Be = ({ sipConnector: n }) => {
91
+ const e = (f, p) => ({ isSyncForced: h = !1 }) => {
92
+ if (h) {
93
93
  f();
94
94
  return;
95
95
  }
96
- g();
97
- }, t = Te(n), s = Me(n), r = be(n), o = _e(n);
98
- let c = () => {
99
- }, i = () => {
96
+ p();
97
+ }, t = _e(n), s = Oe(n), r = ve(n), o = Ne(n);
98
+ let i = () => {
99
+ }, c = () => {
100
100
  }, u = () => {
101
101
  }, S = () => {
102
102
  };
103
103
  const C = ({
104
104
  onStartMainCamForced: f,
105
- onStartMainCamNotForced: g,
106
- onStopMainCamForced: p,
107
- onStopMainCamNotForced: b,
108
- onStartMicForced: _,
109
- onStartMicNotForced: A,
110
- onStopMicForced: v,
111
- onStopMicNotForced: O
105
+ onStartMainCamNotForced: p,
106
+ onStopMainCamForced: h,
107
+ onStopMainCamNotForced: R,
108
+ onStartMicForced: y,
109
+ onStartMicNotForced: E,
110
+ onStopMicForced: T,
111
+ onStopMicNotForced: b
112
112
  }) => {
113
- const y = e(
113
+ const _ = e(
114
114
  f,
115
- g
115
+ p
116
116
  );
117
- c = t(y);
118
- const E = e(
119
- p,
120
- b
117
+ i = t(_);
118
+ const v = e(
119
+ h,
120
+ R
121
121
  );
122
- i = s(E);
123
- const w = e(_, A);
124
- u = r(w);
125
- const M = e(v, O);
126
- S = o(M);
122
+ c = s(v);
123
+ const O = e(y, E);
124
+ u = r(O);
125
+ const N = e(T, b);
126
+ S = o(N);
127
127
  }, m = () => {
128
- c(), i(), u(), S();
128
+ i(), c(), u(), S();
129
129
  };
130
130
  return {
131
131
  start: (f) => {
@@ -135,79 +135,79 @@ const le = (n = new Error()) => {
135
135
  m();
136
136
  }
137
137
  };
138
- }, rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
138
+ }, un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
139
139
  __proto__: null,
140
- PURGATORY_CONFERENCE_NUMBER: G,
141
- createSyncMediaState: Ae,
142
- error: me,
143
- getExtraHeaders: Ce,
144
- getUserAgent: pe,
145
- hasPurgatory: P,
146
- sendDTMFAccumulated: Ee
147
- }, Symbol.toStringTag, { value: "Module" })), ve = (n) => [...n.keys()].map((e) => n.get(e)), Oe = (n, e) => ve(n).find((t) => t.type === e), Ne = async (n) => n.getStats().then((e) => {
148
- const t = Oe(e, "codec");
140
+ PURGATORY_CONFERENCE_NUMBER: Y,
141
+ createSyncMediaState: Be,
142
+ error: Re,
143
+ getExtraHeaders: ge,
144
+ getUserAgent: be,
145
+ hasPurgatory: D,
146
+ sendDTMFAccumulated: Ae
147
+ }, Symbol.toStringTag, { value: "Module" })), Pe = (n) => [...n.keys()].map((e) => n.get(e)), we = (n, e) => Pe(n).find((t) => t.type === e), De = async (n) => n.getStats().then((e) => {
148
+ const t = we(e, "codec");
149
149
  return t == null ? void 0 : t.mimeType;
150
- }), Be = (n) => n.find((e) => {
150
+ }), Ie = (n) => n.find((e) => {
151
151
  var t;
152
152
  return ((t = e == null ? void 0 : e.track) == null ? void 0 : t.kind) === "video";
153
- }), K = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Pe = 1e6, h = (n) => n * Pe, q = h(0.06), we = h(4), De = (n) => n <= 64 ? q : n <= 128 ? h(0.12) : n <= 256 ? h(0.25) : n <= 384 ? h(0.32) : n <= 426 ? h(0.38) : n <= 640 ? h(0.5) : n <= 848 ? h(0.7) : n <= 1280 ? h(1) : n <= 1920 ? h(2) : we, Ie = "av1", Fe = (n) => K(n, Ie), ke = 0.6, Y = (n, e) => Fe(e) ? n * ke : n, Ue = (n) => Y(q, n), z = (n, e) => {
154
- const t = De(n);
155
- return Y(t, e);
156
- }, Le = 1, Q = ({
153
+ }), z = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Fe = 1e6, g = (n) => n * Fe, Q = g(0.06), ke = g(4), Ue = (n) => n <= 64 ? Q : n <= 128 ? g(0.12) : n <= 256 ? g(0.25) : n <= 384 ? g(0.32) : n <= 426 ? g(0.38) : n <= 640 ? g(0.5) : n <= 848 ? g(0.7) : n <= 1280 ? g(1) : n <= 1920 ? g(2) : ke, Ve = "av1", Le = (n) => z(n, Ve), xe = 0.6, J = (n, e) => Le(e) ? n * xe : n, $e = (n) => J(Q, n), Z = (n, e) => {
154
+ const t = Ue(n);
155
+ return J(t, e);
156
+ }, He = 1, ee = ({
157
157
  videoTrack: n,
158
158
  targetSize: e,
159
159
  codec: t
160
160
  }) => {
161
- const s = n.getSettings(), r = s.width, o = s.height, c = r / e.width, i = o / e.height, u = Math.max(c, i, Le), S = z(e.width, t);
161
+ const s = n.getSettings(), r = s.width, o = s.height, i = r / e.width, c = o / e.height, u = Math.max(i, c, He), S = Z(e.width, t);
162
162
  return { scaleResolutionDownBy: u, maxBitrate: S };
163
- }, J = ce(), xe = async () => J().catch((n) => {
163
+ }, ne = le(), Xe = async () => ne().catch((n) => {
164
164
  a("videoSendingBalancer: error", n);
165
- }), Ve = async (n) => (J.add(n), xe()), V = async ({
165
+ }), je = async (n) => (ne.add(n), Xe()), X = async ({
166
166
  sender: n,
167
167
  scaleResolutionDownBy: e,
168
168
  maxBitrate: t,
169
169
  onSetParameters: s
170
- }) => Ve(async () => ne(n, { scaleResolutionDownBy: e, maxBitrate: t }, s)), $e = async ({ sender: n, codec: e }, t) => {
171
- const r = Ue(e);
172
- return V({
170
+ }) => je(async () => oe(n, { scaleResolutionDownBy: e, maxBitrate: t }, s)), We = async ({ sender: n, codec: e }, t) => {
171
+ const r = $e(e);
172
+ return X({
173
173
  sender: n,
174
174
  maxBitrate: r,
175
175
  onSetParameters: t,
176
176
  scaleResolutionDownBy: 200
177
177
  });
178
- }, U = async ({
178
+ }, x = async ({
179
179
  sender: n,
180
180
  videoTrack: e,
181
181
  codec: t
182
182
  }, s) => {
183
- const c = e.getSettings().width, i = z(c, t);
184
- return V({
183
+ const i = e.getSettings().width, c = Z(i, t);
184
+ return X({
185
185
  sender: n,
186
- maxBitrate: i,
186
+ maxBitrate: c,
187
187
  onSetParameters: s,
188
188
  scaleResolutionDownBy: 1
189
189
  });
190
- }, He = async ({
190
+ }, Ge = async ({
191
191
  sender: n,
192
192
  videoTrack: e,
193
193
  resolution: t,
194
194
  codec: s
195
195
  }, r) => {
196
- const [o, c] = t.split("x"), { maxBitrate: i, scaleResolutionDownBy: u } = Q({
196
+ const [o, i] = t.split("x"), { maxBitrate: c, scaleResolutionDownBy: u } = ee({
197
197
  videoTrack: e,
198
198
  codec: s,
199
199
  targetSize: {
200
200
  width: Number(o),
201
- height: Number(c)
201
+ height: Number(i)
202
202
  }
203
203
  });
204
- return V({
204
+ return X({
205
205
  sender: n,
206
- maxBitrate: i,
206
+ maxBitrate: c,
207
207
  onSetParameters: r,
208
208
  scaleResolutionDownBy: u
209
209
  });
210
- }, Xe = async ({
210
+ }, Ke = async ({
211
211
  mainCam: n,
212
212
  resolutionMainCam: e,
213
213
  sender: t,
@@ -215,19 +215,19 @@ const le = (n = new Error()) => {
215
215
  codec: r
216
216
  }, o) => {
217
217
  switch (n) {
218
- case k.PAUSE_MAIN_CAM:
219
- return $e({ sender: t, codec: r }, o);
220
- case k.RESUME_MAIN_CAM:
221
- return U({ sender: t, videoTrack: s, codec: r }, o);
222
- case k.MAX_MAIN_CAM_RESOLUTION:
223
- return e !== void 0 ? He(
218
+ case L.PAUSE_MAIN_CAM:
219
+ return We({ sender: t, codec: r }, o);
220
+ case L.RESUME_MAIN_CAM:
221
+ return x({ sender: t, videoTrack: s, codec: r }, o);
222
+ case L.MAX_MAIN_CAM_RESOLUTION:
223
+ return e !== void 0 ? Ge(
224
224
  { sender: t, videoTrack: s, codec: r, resolution: e },
225
225
  o
226
- ) : U({ sender: t, videoTrack: s, codec: r }, o);
226
+ ) : x({ sender: t, videoTrack: s, codec: r }, o);
227
227
  default:
228
- return U({ sender: t, videoTrack: s, codec: r }, o);
228
+ return x({ sender: t, videoTrack: s, codec: r }, o);
229
229
  }
230
- }, $ = {
230
+ }, j = {
231
231
  isChanged: !1,
232
232
  parameters: {
233
233
  encodings: [{}],
@@ -236,28 +236,28 @@ const le = (n = new Error()) => {
236
236
  headerExtensions: [],
237
237
  rtcp: {}
238
238
  }
239
- }, H = async ({
239
+ }, W = async ({
240
240
  mainCam: n,
241
241
  resolutionMainCam: e,
242
242
  connection: t,
243
243
  onSetParameters: s,
244
244
  ignoreForCodec: r
245
245
  }) => {
246
- const o = t.getSenders(), c = Be(o);
247
- if (!(c != null && c.track))
248
- return $;
249
- const i = await Ne(c);
250
- return K(i, r) ? $ : Xe(
246
+ const o = t.getSenders(), i = Ie(o);
247
+ if (!(i != null && i.track))
248
+ return j;
249
+ const c = await De(i);
250
+ return z(c, r) ? j : Ke(
251
251
  {
252
252
  mainCam: n,
253
253
  resolutionMainCam: e,
254
- sender: c,
255
- codec: i,
256
- videoTrack: c.track
254
+ sender: i,
255
+ codec: c,
256
+ videoTrack: i.track
257
257
  },
258
258
  s
259
259
  );
260
- }, on = (n, {
260
+ }, ln = (n, {
261
261
  ignoreForCodec: e,
262
262
  onSetParameters: t
263
263
  } = {}) => {
@@ -265,7 +265,7 @@ const le = (n = new Error()) => {
265
265
  const { connection: u } = n;
266
266
  if (!u)
267
267
  throw new Error("connection is not exist");
268
- return H({
268
+ return W({
269
269
  connection: u,
270
270
  onSetParameters: t,
271
271
  ignoreForCodec: e
@@ -276,7 +276,7 @@ const le = (n = new Error()) => {
276
276
  const { mainCam: S, resolutionMainCam: C } = u, { connection: m } = n;
277
277
  if (!m)
278
278
  throw new Error("connection is not exist");
279
- return H({
279
+ return W({
280
280
  mainCam: S,
281
281
  resolutionMainCam: C,
282
282
  connection: m,
@@ -299,49 +299,49 @@ const le = (n = new Error()) => {
299
299
  return r();
300
300
  }
301
301
  };
302
- }, je = (n) => n.getVideoTracks()[0], N = ({
302
+ }, qe = (n) => n.getVideoTracks()[0], P = ({
303
303
  mediaStream: n,
304
304
  simulcastEncodings: e,
305
305
  sendEncodings: t
306
306
  }) => {
307
307
  if (e && e.length > 0) {
308
- const s = t ?? [], r = je(n);
309
- return e.forEach((o, c) => {
310
- const i = s[c] ?? {};
311
- i.active = !0, o.rid !== void 0 && (i.rid = o.rid), o.scalabilityMode !== void 0 && (i.scalabilityMode = o.scalabilityMode);
312
- const { maxBitrate: u, scaleResolutionDownBy: S } = Q({
308
+ const s = t ?? [], r = qe(n);
309
+ return e.forEach((o, i) => {
310
+ const c = s[i] ?? {};
311
+ c.active = !0, o.rid !== void 0 && (c.rid = o.rid), o.scalabilityMode !== void 0 && (c.scalabilityMode = o.scalabilityMode);
312
+ const { maxBitrate: u, scaleResolutionDownBy: S } = ee({
313
313
  videoTrack: r,
314
314
  targetSize: {
315
315
  width: o.width,
316
316
  height: o.height
317
317
  }
318
318
  });
319
- i.maxBitrate = u, i.scaleResolutionDownBy = S, s[c] = i;
319
+ c.maxBitrate = u, c.scaleResolutionDownBy = S, s[i] = c;
320
320
  }), s;
321
321
  }
322
322
  return t;
323
- }, We = (n, e) => [...n, ...e].filter((r, o, c) => o === c.findIndex((i) => i.clockRate === r.clockRate && i.mimeType === r.mimeType && i.channels === r.channels && i.sdpFmtpLine === r.sdpFmtpLine)), Ge = (n) => {
323
+ }, Ye = (n, e) => [...n, ...e].filter((r, o, i) => o === i.findIndex((c) => c.clockRate === r.clockRate && c.mimeType === r.mimeType && c.channels === r.channels && c.sdpFmtpLine === r.sdpFmtpLine)), ze = (n) => {
324
324
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, r = t === null ? [] : t.codecs;
325
- return We(s, r);
326
- }, Ke = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
327
- const r = e.indexOf(t.mimeType), o = e.indexOf(s.mimeType), c = r === -1 ? Number.MAX_VALUE : r, i = o === -1 ? Number.MAX_VALUE : o;
328
- return c - i;
329
- }), qe = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), B = (n, {
325
+ return Ye(s, r);
326
+ }, Qe = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
327
+ const r = e.indexOf(t.mimeType), o = e.indexOf(s.mimeType), i = r === -1 ? Number.MAX_VALUE : r, c = o === -1 ? Number.MAX_VALUE : o;
328
+ return i - c;
329
+ }), Je = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), w = (n, {
330
330
  preferredMimeTypesVideoCodecs: e,
331
331
  excludeMimeTypesVideoCodecs: t
332
332
  }) => async (s) => {
333
333
  var r;
334
334
  if (typeof s.setCodecPreferences == "function" && ((r = s.sender.track) == null ? void 0 : r.kind) === "video" && (e !== void 0 && (e == null ? void 0 : e.length) > 0 || t !== void 0 && (t == null ? void 0 : t.length) > 0)) {
335
- const o = Ge("video"), c = qe(o, t), i = Ke(c, e);
336
- s.setCodecPreferences(i);
335
+ const o = ze("video"), i = Je(o, t), c = Qe(i, e);
336
+ s.setCodecPreferences(c);
337
337
  }
338
- Object.keys(n).length > 0 && await te(s.sender, n);
339
- }, L = (n) => {
340
- if (!ie(n) && !ae(n))
338
+ Object.keys(n).length > 0 && await ie(s.sender, n);
339
+ }, $ = (n) => {
340
+ if (!de(n) && !Se(n))
341
341
  throw n;
342
342
  return { isSuccessful: !1 };
343
- }, Ye = ({ kind: n, readyState: e }) => n === "video" && e === "live";
344
- class cn {
343
+ }, Ze = ({ kind: n, readyState: e }) => n === "video" && e === "live";
344
+ class dn {
345
345
  constructor(e, {
346
346
  preferredMimeTypesVideoCodecs: t,
347
347
  excludeMimeTypesVideoCodecs: s
@@ -355,8 +355,8 @@ class cn {
355
355
  sipWebSocketServerURL: s,
356
356
  sipServerUrl: r,
357
357
  remoteAddress: o,
358
- displayName: c,
359
- name: i,
358
+ displayName: i,
359
+ name: c,
360
360
  password: u,
361
361
  isRegisteredUser: S,
362
362
  isDisconnectOnFail: C
@@ -366,11 +366,11 @@ class cn {
366
366
  sipWebSocketServerURL: s,
367
367
  sipServerUrl: r,
368
368
  remoteAddress: o,
369
- displayName: c,
369
+ displayName: i,
370
370
  password: u,
371
- user: i,
371
+ user: c,
372
372
  register: S
373
- }).then((m) => (a("connectToServer then"), { ua: m, isSuccessful: !0 })).catch(async (m) => (a("connectToServer catch: error", m), C === !0 ? this.sipConnector.disconnect().then(() => L(m)).catch(() => L(m)) : L(m)));
373
+ }).then((m) => (a("connectToServer then"), { ua: m, isSuccessful: !0 })).catch(async (m) => (a("connectToServer catch: error", m), C === !0 ? this.sipConnector.disconnect().then(() => $(m)).catch(() => $(m)) : $(m)));
374
374
  });
375
375
  l(this, "callToServer", async (e) => {
376
376
  const {
@@ -378,23 +378,27 @@ class cn {
378
378
  mediaStream: s,
379
379
  extraHeaders: r,
380
380
  iceServers: o,
381
- contentHint: c,
382
- simulcastEncodings: i,
381
+ contentHint: i,
382
+ simulcastEncodings: c,
383
383
  degradationPreference: u,
384
384
  sendEncodings: S,
385
- setRemoteStreams: C,
386
- onBeforeProgressCall: m,
387
- onSuccessProgressCall: T,
385
+ offerToReceiveAudio: C,
386
+ offerToReceiveVideo: m,
387
+ directionVideo: I,
388
+ directionAudio: F,
389
+ setRemoteStreams: f,
390
+ onBeforeProgressCall: p,
391
+ onSuccessProgressCall: h,
388
392
  onEnterPurgatory: R,
389
- onEnterConference: f,
390
- onFailProgressCall: g,
391
- onFinishProgressCall: p,
393
+ onEnterConference: y,
394
+ onFailProgressCall: E,
395
+ onFinishProgressCall: T,
392
396
  onEndedCall: b
393
397
  } = e, _ = this.resolveHandleReadyRemoteStreamsDebounced({
394
- onReadyRemoteStreams: C
395
- }), A = this.resolveHandleReadyRemoteStreams({
398
+ onReadyRemoteStreams: f
399
+ }), v = this.resolveHandleReadyRemoteStreams({
396
400
  onReadyRemoteStreams: _
397
- }), v = B(
401
+ }), O = w(
398
402
  {
399
403
  degradationPreference: u
400
404
  },
@@ -404,32 +408,36 @@ class cn {
404
408
  }
405
409
  );
406
410
  a("callToServer", e);
407
- const O = async () => (a("startCall"), this.sipConnector.call({
411
+ const N = async () => (a("startCall"), this.sipConnector.call({
408
412
  mediaStream: s,
409
413
  extraHeaders: r,
410
414
  iceServers: o,
411
- contentHint: c,
412
- sendEncodings: N({
415
+ contentHint: i,
416
+ offerToReceiveAudio: C,
417
+ offerToReceiveVideo: m,
418
+ directionVideo: I,
419
+ directionAudio: F,
420
+ sendEncodings: P({
413
421
  mediaStream: s,
414
- simulcastEncodings: i,
422
+ simulcastEncodings: c,
415
423
  sendEncodings: S
416
424
  }),
417
425
  number: t,
418
- onAddedTransceiver: v,
419
- ontrack: A
426
+ onAddedTransceiver: O,
427
+ ontrack: v
420
428
  }));
421
- let y = !1, E;
422
- const M = (a("subscribeEnterConference: onEnterConference", f), R ?? f ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
423
- a("enterRoom", { _room: d, isSuccessProgressCall: y }), E = d, P(E) ? R && R() : f && f({ isSuccessProgressCall: y });
429
+ let M = !1, A;
430
+ const B = (a("subscribeEnterConference: onEnterConference", y), R ?? y ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
431
+ a("enterRoom", { _room: d, isSuccessProgressCall: M }), A = d, D(A) ? R && R() : y && y({ isSuccessProgressCall: M });
424
432
  }) : () => {
425
- }), D = (d) => (a("onSuccess"), y = !0, _(), T && T({ isPurgatory: P(E) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
426
- M(), b && b();
427
- }), d), I = (d) => {
428
- throw a("onFail"), g && g(), M(), d;
429
- }, F = () => {
430
- a("onFinish"), p && p();
433
+ }), k = (d) => (a("onSuccess"), M = !0, _(), h && h({ isPurgatory: D(A) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
434
+ B(), b && b();
435
+ }), d), U = (d) => {
436
+ throw a("onFail"), E && E(), B(), d;
437
+ }, V = () => {
438
+ a("onFinish"), T && T();
431
439
  };
432
- return a("onBeforeProgressCall"), m && m(t), O().then(D).catch((d) => I(d)).finally(F);
440
+ return a("onBeforeProgressCall"), p && p(t), N().then(k).catch((d) => U(d)).finally(V);
433
441
  });
434
442
  l(this, "disconnectFromServer", async () => this.sipConnector.disconnect().then(() => (a("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (a("disconnectFromServer: catch", e), { isSuccessful: !1 })));
435
443
  l(this, "answerIncomingCall", async (e) => {
@@ -438,24 +446,28 @@ class cn {
438
446
  extraHeaders: s,
439
447
  iceServers: r,
440
448
  contentHint: o,
441
- simulcastEncodings: c,
442
- degradationPreference: i,
449
+ simulcastEncodings: i,
450
+ degradationPreference: c,
443
451
  sendEncodings: u,
444
- setRemoteStreams: S,
445
- onBeforeProgressCall: C,
446
- onSuccessProgressCall: m,
447
- onEnterPurgatory: T,
452
+ offerToReceiveAudio: S,
453
+ offerToReceiveVideo: C,
454
+ directionVideo: m,
455
+ directionAudio: I,
456
+ setRemoteStreams: F,
457
+ onBeforeProgressCall: f,
458
+ onSuccessProgressCall: p,
459
+ onEnterPurgatory: h,
448
460
  onEnterConference: R,
449
- onFailProgressCall: f,
450
- onFinishProgressCall: g,
451
- onEndedCall: p
461
+ onFailProgressCall: y,
462
+ onFinishProgressCall: E,
463
+ onEndedCall: T
452
464
  } = e, b = this.resolveHandleReadyRemoteStreamsDebounced({
453
- onReadyRemoteStreams: S
465
+ onReadyRemoteStreams: F
454
466
  }), _ = this.resolveHandleReadyRemoteStreams({
455
467
  onReadyRemoteStreams: b
456
- }), A = B(
468
+ }), v = w(
457
469
  {
458
- degradationPreference: i
470
+ degradationPreference: c
459
471
  },
460
472
  {
461
473
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
@@ -463,38 +475,42 @@ class cn {
463
475
  }
464
476
  );
465
477
  a("answerIncomingCall", e);
466
- const v = async () => this.sipConnector.answerToIncomingCall({
478
+ const O = async () => this.sipConnector.answerToIncomingCall({
467
479
  mediaStream: t,
468
480
  extraHeaders: s,
469
481
  iceServers: r,
470
482
  contentHint: o,
471
- sendEncodings: N({
483
+ offerToReceiveAudio: S,
484
+ offerToReceiveVideo: C,
485
+ directionVideo: m,
486
+ directionAudio: I,
487
+ sendEncodings: P({
472
488
  mediaStream: t,
473
- simulcastEncodings: c,
489
+ simulcastEncodings: i,
474
490
  sendEncodings: u
475
491
  }),
476
- onAddedTransceiver: A,
492
+ onAddedTransceiver: v,
477
493
  ontrack: _
478
- }), O = () => {
494
+ }), N = () => {
479
495
  const { remoteCallerData: d } = this.sipConnector;
480
496
  return d.incomingNumber;
481
497
  };
482
- let y = !1, E;
483
- const M = (a("subscribeEnterConference: onEnterConference", R), T ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
484
- a("enterRoom", { _room: d, isSuccessProgressCall: y }), E = d, P(E) ? T && T() : R && R({ isSuccessProgressCall: y });
498
+ let M = !1, A;
499
+ const B = (a("subscribeEnterConference: onEnterConference", R), h ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
500
+ a("enterRoom", { _room: d, isSuccessProgressCall: M }), A = d, D(A) ? h && h() : R && R({ isSuccessProgressCall: M });
485
501
  }) : () => {
486
- }), D = (d) => (a("onSuccess"), y = !0, b(), m && m({ isPurgatory: P(E) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
487
- M(), p && p();
488
- }), d), I = (d) => {
489
- throw a("onFail"), f && f(), M(), d;
490
- }, F = () => {
491
- a("onFinish"), g && g();
502
+ }), k = (d) => (a("onSuccess"), M = !0, b(), p && p({ isPurgatory: D(A) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
503
+ B(), T && T();
504
+ }), d), U = (d) => {
505
+ throw a("onFail"), y && y(), B(), d;
506
+ }, V = () => {
507
+ a("onFinish"), E && E();
492
508
  };
493
- if (a("onBeforeProgressCall"), C) {
494
- const d = O();
495
- C(d);
509
+ if (a("onBeforeProgressCall"), f) {
510
+ const d = N();
511
+ f(d);
496
512
  }
497
- return v().then(D).catch((d) => I(d)).finally(F);
513
+ return O().then(k).catch((d) => U(d)).finally(V);
498
514
  });
499
515
  l(this, "updatePresentation", async ({
500
516
  mediaStream: e,
@@ -502,14 +518,14 @@ class cn {
502
518
  maxBitrate: s,
503
519
  contentHint: r,
504
520
  simulcastEncodings: o,
505
- degradationPreference: c,
506
- sendEncodings: i,
521
+ degradationPreference: i,
522
+ sendEncodings: c,
507
523
  preferredMimeTypesVideoCodecs: u,
508
524
  excludeMimeTypesVideoCodecs: S
509
525
  }) => {
510
- const C = B(
526
+ const C = w(
511
527
  {
512
- degradationPreference: c
528
+ degradationPreference: i
513
529
  },
514
530
  {
515
531
  preferredMimeTypesVideoCodecs: u,
@@ -520,10 +536,10 @@ class cn {
520
536
  isP2P: t,
521
537
  maxBitrate: s,
522
538
  contentHint: r,
523
- sendEncodings: N({
539
+ sendEncodings: P({
524
540
  mediaStream: e,
525
541
  simulcastEncodings: o,
526
- sendEncodings: i
542
+ sendEncodings: c
527
543
  }),
528
544
  onAddedTransceiver: C
529
545
  });
@@ -534,14 +550,14 @@ class cn {
534
550
  maxBitrate: s,
535
551
  contentHint: r,
536
552
  simulcastEncodings: o,
537
- degradationPreference: c,
538
- sendEncodings: i,
553
+ degradationPreference: i,
554
+ sendEncodings: c,
539
555
  preferredMimeTypesVideoCodecs: u,
540
556
  excludeMimeTypesVideoCodecs: S
541
557
  }, C) => {
542
- const m = B(
558
+ const m = w(
543
559
  {
544
- degradationPreference: c
560
+ degradationPreference: i
545
561
  },
546
562
  {
547
563
  preferredMimeTypesVideoCodecs: u,
@@ -554,10 +570,10 @@ class cn {
554
570
  isP2P: t,
555
571
  maxBitrate: s,
556
572
  contentHint: r,
557
- sendEncodings: N({
573
+ sendEncodings: P({
558
574
  mediaStream: e,
559
575
  simulcastEncodings: o,
560
- sendEncodings: i
576
+ sendEncodings: c
561
577
  }),
562
578
  onAddedTransceiver: m
563
579
  },
@@ -593,13 +609,13 @@ class cn {
593
609
  addMissing: s,
594
610
  forceRenegotiation: r,
595
611
  contentHint: o,
596
- simulcastEncodings: c,
597
- degradationPreference: i,
612
+ simulcastEncodings: i,
613
+ degradationPreference: c,
598
614
  sendEncodings: u
599
615
  } = {}) => {
600
- const S = B(
616
+ const S = w(
601
617
  {
602
- degradationPreference: i
618
+ degradationPreference: c
603
619
  },
604
620
  {
605
621
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
@@ -611,9 +627,9 @@ class cn {
611
627
  addMissing: s,
612
628
  forceRenegotiation: r,
613
629
  contentHint: o,
614
- sendEncodings: N({
630
+ sendEncodings: P({
615
631
  mediaStream: e,
616
- simulcastEncodings: c,
632
+ simulcastEncodings: i,
617
633
  sendEncodings: u
618
634
  }),
619
635
  onAddedTransceiver: S
@@ -625,40 +641,40 @@ class cn {
625
641
  });
626
642
  l(this, "resolveHandleReadyRemoteStreamsDebounced", ({
627
643
  onReadyRemoteStreams: e
628
- }) => ue(() => {
644
+ }) => me(() => {
629
645
  const t = this.sipConnector.getRemoteStreams();
630
646
  a("remoteStreams", t), t && e(t);
631
647
  }, 200));
632
648
  l(this, "resolveHandleReadyRemoteStreams", ({
633
649
  onReadyRemoteStreams: e
634
650
  }) => ({ track: t }) => {
635
- Ye(t) && e();
651
+ Ze(t) && e();
636
652
  });
637
653
  l(this, "getRemoteStreams", () => (a("getRemoteStreams"), this.sipConnector.getRemoteStreams()));
638
654
  l(this, "onUseLicense", (e) => (a("onUseLicense"), this.sipConnector.onSession("useLicense", e)));
639
655
  l(this, "onMustStopPresentation", (e) => (a("onMustStopPresentation"), this.sipConnector.onSession("mustStopPresentation", e)));
640
- l(this, "onMoveToSpectators", (e) => (a("onMoveToSpectators"), this.sipConnector.onSession(se, e)));
641
- l(this, "onMoveToParticipants", (e) => (a("onMoveToParticipants"), this.sipConnector.onSession(re, e)));
656
+ l(this, "onMoveToSpectators", (e) => (a("onMoveToSpectators"), this.sipConnector.onSession(ce, e)));
657
+ l(this, "onMoveToParticipants", (e) => (a("onMoveToParticipants"), this.sipConnector.onSession(ae, e)));
642
658
  this.sipConnector = e, this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s;
643
659
  }
644
660
  }
645
661
  export {
646
- k as EEventsMainCAM,
647
- ln as EEventsMic,
648
- dn as EEventsSyncMediaState,
649
- Sn as EMimeTypesVideoCodecs,
650
- mn as EUseLicense,
651
- cn as SipConnectorFacade,
652
- Cn as causes,
653
- fn as constants,
654
- En as debug,
655
- Je as default,
656
- hn as disableDebug,
657
- Rn as enableDebug,
658
- gn as eventNames,
659
- Ne as getCodecFromSender,
660
- pn as hasCanceledCallError,
661
- on as resolveVideoSendingBalancer,
662
- te as setParametersToSender,
663
- rn as tools
662
+ L as EEventsMainCAM,
663
+ Cn as EEventsMic,
664
+ fn as EEventsSyncMediaState,
665
+ hn as EMimeTypesVideoCodecs,
666
+ Rn as EUseLicense,
667
+ dn as SipConnectorFacade,
668
+ gn as causes,
669
+ pn as constants,
670
+ An as debug,
671
+ tn as default,
672
+ yn as disableDebug,
673
+ En as enableDebug,
674
+ Tn as eventNames,
675
+ De as getCodecFromSender,
676
+ bn as hasCanceledCallError,
677
+ ln as resolveVideoSendingBalancer,
678
+ ie as setParametersToSender,
679
+ un as tools
664
680
  };