sip-connector 14.0.1-0 → 14.1.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 (96) hide show
  1. package/dist/SipConnector-BPIL3yLc.js +1343 -0
  2. package/dist/SipConnector-BUbfMgHs.cjs +1 -0
  3. package/dist/{src/SipConnector.d.ts → SipConnector.d.ts} +77 -63
  4. package/dist/{src/__fixtures__ → __fixtures__}/BaseSession.mock.d.ts +31 -19
  5. package/dist/{src/__fixtures__ → __fixtures__}/RTCPeerConnectionMock.d.ts +14 -14
  6. package/dist/{src/__fixtures__ → __fixtures__}/RTCRtpSenderMock.d.ts +2 -2
  7. package/dist/{src/__fixtures__ → __fixtures__}/RTCSessionMock.d.ts +27 -23
  8. package/dist/{src/__fixtures__ → __fixtures__}/UA.mock.d.ts +43 -24
  9. package/dist/{src/__fixtures__ → __fixtures__}/channelsNotify.d.ts +2 -2
  10. package/dist/{src/__fixtures__ → __fixtures__}/jssip.mock.d.ts +1 -1
  11. package/dist/{src/__fixtures__ → __fixtures__}/participantNotify.d.ts +2 -2
  12. package/dist/doMock.cjs +1 -1
  13. package/dist/doMock.js +390 -379
  14. package/dist/index.cjs +1 -1
  15. package/dist/{src/index.d.ts → index.d.ts} +1 -1
  16. package/dist/index.js +519 -510
  17. package/dist/{src/types.d.ts → types.d.ts} +1 -2
  18. package/dist/utils.d.ts +4 -0
  19. package/package.json +32 -32
  20. package/dist/SipConnector-CJN8qKAC.js +0 -1316
  21. package/dist/SipConnector-DO0YvSq6.cjs +0 -1
  22. /package/dist/{src/SipConnectorFacade → SipConnectorFacade}/SipConnectorFacade.d.ts +0 -0
  23. /package/dist/{src/SipConnectorFacade → SipConnectorFacade}/index.d.ts +0 -0
  24. /package/dist/{src/__fixtures__ → __fixtures__}/Registrator.mock.d.ts +0 -0
  25. /package/dist/{src/__fixtures__ → __fixtures__}/Request.mock.d.ts +0 -0
  26. /package/dist/{src/__fixtures__ → __fixtures__}/WebSocketInterface.mock.d.ts +0 -0
  27. /package/dist/{src/__fixtures__ → __fixtures__}/accountNotify.d.ts +0 -0
  28. /package/dist/{src/__fixtures__ → __fixtures__}/channels.d.ts +0 -0
  29. /package/dist/{src/__fixtures__ → __fixtures__}/conferenceParticipantTokenIssuedNotify.d.ts +0 -0
  30. /package/dist/{src/__fixtures__ → __fixtures__}/delayPromise.d.ts +0 -0
  31. /package/dist/{src/__fixtures__ → __fixtures__}/enterRoom.d.ts +0 -0
  32. /package/dist/{src/__fixtures__ → __fixtures__}/index.d.ts +0 -0
  33. /package/dist/{src/__fixtures__ → __fixtures__}/mediaState.d.ts +0 -0
  34. /package/dist/{src/__fixtures__ → __fixtures__}/participantMoveRequests.d.ts +0 -0
  35. /package/dist/{src/__fixtures__ → __fixtures__}/remoteCallerData.d.ts +0 -0
  36. /package/dist/{src/__fixtures__ → __fixtures__}/utils.d.ts +0 -0
  37. /package/dist/{src/__fixtures__ → __fixtures__}/webcastNotify.d.ts +0 -0
  38. /package/dist/{src/causes.d.ts → causes.d.ts} +0 -0
  39. /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
  40. /package/dist/{src/doMock.d.ts → doMock.d.ts} +0 -0
  41. /package/dist/{src/eventNames.d.ts → eventNames.d.ts} +0 -0
  42. /package/dist/{src/getExtraHeadersRemoteAddress.d.ts → getExtraHeadersRemoteAddress.d.ts} +0 -0
  43. /package/dist/{src/headers.d.ts → headers.d.ts} +0 -0
  44. /package/dist/{src/logger.d.ts → logger.d.ts} +0 -0
  45. /package/dist/{src/setParametersToSender → setParametersToSender}/configureDegradationPreference.d.ts +0 -0
  46. /package/dist/{src/setParametersToSender → setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
  47. /package/dist/{src/setParametersToSender → setParametersToSender}/configureEncodings.d.ts +0 -0
  48. /package/dist/{src/setParametersToSender → setParametersToSender}/configureMaxBitrate.d.ts +0 -0
  49. /package/dist/{src/setParametersToSender → setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
  50. /package/dist/{src/setParametersToSender → setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
  51. /package/dist/{src/setParametersToSender → setParametersToSender}/index.d.ts +0 -0
  52. /package/dist/{src/setParametersToSender → setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +0 -0
  53. /package/dist/{src/setParametersToSender → setParametersToSender}/setParametersToSender.d.ts +0 -0
  54. /package/dist/{src/tools → tools}/__fixtures__/call.d.ts +0 -0
  55. /package/dist/{src/tools → tools}/__fixtures__/connectToServer.d.ts +0 -0
  56. /package/dist/{src/tools → tools}/__fixtures__/hasValidUri.d.ts +0 -0
  57. /package/dist/{src/tools → tools}/__fixtures__/permissions.d.ts +0 -0
  58. /package/dist/{src/tools → tools}/__fixtures__/processRequest.d.ts +0 -0
  59. /package/dist/{src/tools → tools}/__tests-utils__/parseObject.d.ts +0 -0
  60. /package/dist/{src/tools → tools}/__tests-utils__/resolveParseArray.d.ts +0 -0
  61. /package/dist/{src/tools → tools}/error/getLinkError.d.ts +0 -0
  62. /package/dist/{src/tools → tools}/error/getTypeFromError.d.ts +0 -0
  63. /package/dist/{src/tools → tools}/error/getValuesFromError.d.ts +0 -0
  64. /package/dist/{src/tools → tools}/error/index.d.ts +0 -0
  65. /package/dist/{src/tools → tools}/error/stringifyMessage.d.ts +0 -0
  66. /package/dist/{src/tools → tools}/generateSimulcastEncodings.d.ts +0 -0
  67. /package/dist/{src/tools → tools}/getExtraHeaders.d.ts +0 -0
  68. /package/dist/{src/tools → tools}/getUserAgent.d.ts +0 -0
  69. /package/dist/{src/tools → tools}/hasPurgatory.d.ts +0 -0
  70. /package/dist/{src/tools → tools}/index.d.ts +0 -0
  71. /package/dist/{src/tools → tools}/prepareMediaStream.d.ts +0 -0
  72. /package/dist/{src/tools → tools}/resolveUpdateTransceiver.d.ts +0 -0
  73. /package/dist/{src/tools → tools}/sendDTMFAccumulated.d.ts +0 -0
  74. /package/dist/{src/tools → tools}/setVideoTrackContentHints.d.ts +0 -0
  75. /package/dist/{src/tools → tools}/syncMediaState/index.d.ts +0 -0
  76. /package/dist/{src/tools → tools}/syncMediaState/resolveOnStartMainCam.d.ts +0 -0
  77. /package/dist/{src/tools → tools}/syncMediaState/resolveOnStartMic.d.ts +0 -0
  78. /package/dist/{src/tools → tools}/syncMediaState/resolveOnStopMainCam.d.ts +0 -0
  79. /package/dist/{src/tools → tools}/syncMediaState/resolveOnStopMic.d.ts +0 -0
  80. /package/dist/{src/utils → utils}/errors.d.ts +0 -0
  81. /package/dist/{src/utils → utils}/findSenderByStream.d.ts +0 -0
  82. /package/dist/{src/utils → utils}/findVideoSender.d.ts +0 -0
  83. /package/dist/{src/utils → utils}/findVideoTrack.d.ts +0 -0
  84. /package/dist/{src/utils → utils}/getCodecFromSender.d.ts +0 -0
  85. /package/dist/{src/utils → utils}/replaceForbiddenSymbolsWithUnderscore.d.ts +0 -0
  86. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/balance.d.ts +0 -0
  87. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/getMaxBitrateByWidth.d.ts +0 -0
  88. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/getMaxBitrateByWidthAndCodec.d.ts +0 -0
  89. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/hasAv1Codec.d.ts +0 -0
  90. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/hasIncludesString.d.ts +0 -0
  91. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/index.d.ts +0 -0
  92. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/processSender.d.ts +0 -0
  93. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/scaleBitrate.d.ts +0 -0
  94. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/scaleBitrateByCodec.d.ts +0 -0
  95. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/scaleResolutionAndBitrate.d.ts +0 -0
  96. /package/dist/{src/videoSendingBalancer → videoSendingBalancer}/setEncodingsToSender.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,19 +1,22 @@
1
- import { B as W, N as G, l as i, E as w, s as se, a as oe, P as re, b as ie } from "./SipConnector-CJN8qKAC.js";
2
- import { i as Cn, j as Sn, m as fn, k as mn, S as hn, c as pn, d as Rn, f as gn, g as yn, e as Tn, h as En } from "./SipConnector-CJN8qKAC.js";
3
- import { sequentPromises as ce } from "sequent-promises";
4
- import { createStackPromises as ae } from "stack-promises";
5
- import K from "debug";
6
- import { default as bn } from "debug";
7
- import { isCanceledError as ue } from "@krivega/cancelable-promise";
8
- import { hasCanceledError as de } from "repeated-calls";
9
- import { debounce as le } from "ts-debounce";
10
- const $ = (n) => {
1
+ var se = Object.defineProperty;
2
+ var oe = (n, e, t) => e in n ? se(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var a = (n, e, t) => oe(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { B as G, N as K, l as c, E as x, s as re, a as ie, P as ce, b as ae } from "./SipConnector-BPIL3yLc.js";
5
+ import { j as Cn, k as mn, n as hn, m as Rn, S as gn, c as pn, d as yn, f as En, g as Tn, e as bn, h as Mn, i as _n } from "./SipConnector-BPIL3yLc.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 fe } from "ts-debounce";
11
+ import { default as vn } from "debug";
12
+ const H = (n) => {
11
13
  const { url: e, cause: t } = n;
12
14
  let s = e;
13
- return (t === W || t === G) && (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;
14
16
  };
15
17
  var Y = /* @__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))(Y || {});
16
18
  const Ce = (n = new Error()) => {
19
+ var o;
17
20
  const { cause: e, socket: t } = n;
18
21
  let s = "CONNECT_SERVER_FAILED";
19
22
  switch (e) {
@@ -21,36 +24,36 @@ const Ce = (n = new Error()) => {
21
24
  s = "WRONG_USER_OR_PASSWORD";
22
25
  break;
23
26
  }
24
- case W: {
27
+ case G: {
25
28
  s = "BAD_MEDIA_ERROR";
26
29
  break;
27
30
  }
28
- case G: {
31
+ case K: {
29
32
  s = "NOT_FOUND_ERROR";
30
33
  break;
31
34
  }
32
35
  default:
33
- t && t?._ws?.readyState === 3 ? s = "WS_CONNECTION_FAILED" : $(n) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
36
+ t && ((o = t == null ? void 0 : t._ws) == null ? void 0 : o.readyState) === 3 ? s = "WS_CONNECTION_FAILED" : H(n) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
34
37
  }
35
38
  return s;
36
- }, Se = (n) => {
39
+ }, me = (n) => {
37
40
  let e = "";
38
41
  try {
39
42
  e = JSON.stringify(n);
40
43
  } catch (t) {
41
- i("failed to stringify message", t);
44
+ c("failed to stringify message", t);
42
45
  }
43
46
  return e;
44
- }, fe = (n = new Error()) => {
45
- const { code: e, cause: t, message: s } = n, o = $(n), r = { code: "", cause: "", message: "" };
46
- return typeof s == "object" && s !== null ? r.message = Se(s) : s && (r.message = String(s)), o && (r.link = o), e && (r.code = e), t && (r.cause = t), r;
47
- }, me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47
+ }, he = (n = new Error()) => {
48
+ const { code: e, cause: t, message: s } = n, o = H(n), r = { code: "", cause: "", message: "" };
49
+ return typeof s == "object" && s !== null ? r.message = me(s) : s && (r.message = String(s)), o && (r.link = o), e && (r.code = e), t && (r.cause = t), r;
50
+ }, Re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
48
51
  __proto__: null,
49
52
  EErrorTypes: Y,
50
- getLinkError: $,
53
+ getLinkError: H,
51
54
  getTypeFromError: Ce,
52
- getValuesFromError: fe
53
- }, Symbol.toStringTag, { value: "Module" })), he = ({
55
+ getValuesFromError: he
56
+ }, Symbol.toStringTag, { value: "Module" })), ge = ({
54
57
  sessionId: n,
55
58
  remoteAddress: e,
56
59
  isMutedAudio: t,
@@ -58,147 +61,153 @@ const Ce = (n = new Error()) => {
58
61
  isRegistered: o,
59
62
  isPresentationCall: r
60
63
  }) => {
61
- const c = [], a = t ? "0" : "1", u = s ? "0" : "1";
62
- return c.push(`X-Vinteo-Mic-State: ${a}`, `X-Vinteo-MainCam-State: ${u}`), o || c.push("X-Vinteo-Purgatory-Call: yes"), n && c.push(`X-Vinteo-Session: ${n}`), r && c.push("X-Vinteo-Presentation-Call: yes"), e && c.push(`X-Vinteo-Remote: ${e}`), c;
63
- }, pe = "[@*!|]", Re = "_", ge = (n) => {
64
+ const i = [], u = t ? "0" : "1", l = s ? "0" : "1";
65
+ return i.push(`X-Vinteo-Mic-State: ${u}`, `X-Vinteo-MainCam-State: ${l}`), o || i.push("X-Vinteo-Purgatory-Call: yes"), n && i.push(`X-Vinteo-Session: ${n}`), r && i.push("X-Vinteo-Presentation-Call: yes"), e && i.push(`X-Vinteo-Remote: ${e}`), i;
66
+ }, pe = "[@*!|]", ye = "_", Ee = (n) => {
64
67
  let e = n;
65
- return e = e.replaceAll(new RegExp(pe, "g"), Re), e;
66
- }, ye = ({
68
+ return e = e.replaceAll(new RegExp(pe, "g"), ye), e;
69
+ }, Te = ({
67
70
  appName: n,
68
71
  appVersion: e,
69
72
  browserName: t,
70
73
  browserVersion: s
71
74
  }) => {
72
- const r = `${ge(n)} ${e}`;
75
+ const r = `${Ee(n)} ${e}`;
73
76
  return `ChromeNew - ${t ? `${t} ${s}, ${r}` : r}`;
74
- }, Te = ({
77
+ }, be = ({
75
78
  isUnifiedSdpSemantic: n,
76
79
  appVersion: e,
77
80
  browserName: t,
78
81
  browserVersion: s,
79
82
  appName: o
80
- }) => n ? ye({ appVersion: e, browserName: t, browserVersion: s, appName: o }) : "Chrome", q = "purgatory", I = (n) => n === q, Ee = (n) => (e) => [...e].map((s) => async () => n(s)), Me = async ({
83
+ }) => n ? Te({ appVersion: e, browserName: t, browserVersion: s, appName: o }) : "Chrome", q = "purgatory", D = (n) => n === q, Me = (n) => (e) => [...e].map((s) => async () => n(s)), _e = async ({
81
84
  accumulatedKeys: n,
82
85
  sendKey: e,
83
86
  canRunTask: t
84
87
  }) => {
85
- const o = Ee(e)(n);
86
- return ce(o, t);
87
- }, be = (n) => (t) => (i("onStartMainCam"), n.onSession("admin-start-main-cam", t)), Ae = (n) => (t) => (i("onStartMic"), n.onSession("admin-start-mic", t)), _e = (n) => (t) => (i("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), ve = (n) => (t) => (i("onStopMic"), n.onSession("admin-stop-mic", t)), Oe = ({ sipConnector: n }) => {
88
- const e = (f, R) => ({ isSyncForced: m = !1 }) => {
89
- if (m) {
90
- f();
88
+ const o = Me(e)(n);
89
+ return ue(o, t);
90
+ }, Ae = (n) => (t) => (c("onStartMainCam"), n.onSession("admin-start-main-cam", t)), ve = (n) => (t) => (c("onStartMic"), n.onSession("admin-start-mic", t)), Oe = (n) => (t) => (c("onStopMainCam"), n.onSession("admin-stop-main-cam", t)), Ne = (n) => (t) => (c("onStopMic"), n.onSession("admin-stop-mic", t)), we = ({ sipConnector: n }) => {
91
+ const e = (m, p) => ({ isSyncForced: h = !1 }) => {
92
+ if (h) {
93
+ m();
91
94
  return;
92
95
  }
93
- R();
94
- }, t = be(n), s = _e(n), o = Ae(n), r = ve(n);
95
- let c = () => {
96
- }, a = () => {
96
+ p();
97
+ }, t = Ae(n), s = Oe(n), o = ve(n), r = Ne(n);
98
+ let i = () => {
97
99
  }, u = () => {
98
100
  }, l = () => {
101
+ }, S = () => {
99
102
  };
100
- const S = ({
101
- onStartMainCamForced: f,
102
- onStartMainCamNotForced: R,
103
- onStopMainCamForced: m,
104
- onStopMainCamNotForced: h,
105
- onStartMicForced: g,
106
- onStartMicNotForced: y,
103
+ const C = ({
104
+ onStartMainCamForced: m,
105
+ onStartMainCamNotForced: p,
106
+ onStopMainCamForced: h,
107
+ onStopMainCamNotForced: R,
108
+ onStartMicForced: y,
109
+ onStartMicNotForced: E,
107
110
  onStopMicForced: T,
108
- onStopMicNotForced: E
111
+ onStopMicNotForced: b
109
112
  }) => {
110
113
  const A = e(
111
- f,
112
- R
113
- );
114
- c = t(A);
115
- const _ = e(
116
114
  m,
117
- h
115
+ p
116
+ );
117
+ i = t(A);
118
+ const v = e(
119
+ h,
120
+ R
118
121
  );
119
- a = s(_);
120
- const v = e(g, y);
121
- u = o(v);
122
- const O = e(T, E);
123
- l = r(O);
124
- }, C = () => {
125
- c(), a(), u(), l();
122
+ u = s(v);
123
+ const O = e(y, E);
124
+ l = o(O);
125
+ const N = e(T, b);
126
+ S = r(N);
127
+ }, f = () => {
128
+ i(), u(), l(), S();
126
129
  };
127
130
  return {
128
- start: (f) => {
129
- S(f);
131
+ start: (m) => {
132
+ C(m);
130
133
  },
131
134
  stop: () => {
132
- C();
135
+ f();
133
136
  }
134
137
  };
135
- }, cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
138
+ }, un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
136
139
  __proto__: null,
137
140
  PURGATORY_CONFERENCE_NUMBER: q,
138
- createSyncMediaState: Oe,
139
- error: me,
140
- getExtraHeaders: he,
141
- getUserAgent: Te,
142
- hasPurgatory: I,
143
- sendDTMFAccumulated: Me
144
- }, Symbol.toStringTag, { value: "Module" })), Ne = (n) => [...n.keys()].map((e) => n.get(e)), we = (n, e) => Ne(n).find((t) => t?.type === e), Be = async (n) => n.getStats().then((e) => we(e, "codec")?.mimeType), Pe = (n) => n.find((e) => e?.track?.kind === "video"), z = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Ie = 1e6, p = (n) => n * Ie, Q = p(0.06), De = p(4), Fe = (n) => n <= 64 ? Q : n <= 128 ? p(0.12) : n <= 256 ? p(0.25) : n <= 384 ? p(0.32) : n <= 426 ? p(0.38) : n <= 640 ? p(0.5) : n <= 848 ? p(0.7) : n <= 1280 ? p(1) : n <= 1920 ? p(2) : De, ke = "av1", Ve = (n) => z(n, ke), Ue = 0.6, J = (n, e) => Ve(e) ? n * Ue : n, xe = (n) => J(Q, n), Z = (n, e) => {
145
- const t = Fe(n);
141
+ createSyncMediaState: we,
142
+ error: Re,
143
+ getExtraHeaders: ge,
144
+ getUserAgent: be,
145
+ hasPurgatory: D,
146
+ sendDTMFAccumulated: _e
147
+ }, Symbol.toStringTag, { value: "Module" })), Be = (n) => [...n.keys()].map((e) => n.get(e)), Pe = (n, e) => Be(n).find((t) => t.type === e), De = async (n) => n.getStats().then((e) => {
148
+ const t = Pe(e, "codec");
149
+ return t == null ? void 0 : t.mimeType;
150
+ }), Ie = (n) => n.find((e) => {
151
+ var t;
152
+ return ((t = e == null ? void 0 : e.track) == null ? void 0 : t.kind) === "video";
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", xe = (n) => z(n, Ve), Le = 0.6, J = (n, e) => xe(e) ? n * Le : n, $e = (n) => J(Q, n), Z = (n, e) => {
154
+ const t = Ue(n);
146
155
  return J(t, e);
147
- }, Le = 1, ee = ({
156
+ }, He = 1, ee = ({
148
157
  videoTrack: n,
149
158
  targetSize: e,
150
159
  codec: t
151
160
  }) => {
152
- const s = n.getSettings(), o = s.width, r = s.height, c = o / e.width, a = r / e.height, u = Math.max(c, a, Le), l = Z(e.width, t);
153
- return { scaleResolutionDownBy: u, maxBitrate: l };
154
- }, ne = ae(), $e = async () => ne().catch((n) => {
155
- i("videoSendingBalancer: error", n);
156
- }), He = async (n) => (ne.add(n), $e()), H = async ({
161
+ const s = n.getSettings(), o = s.width, r = s.height, i = o / e.width, u = r / e.height, l = Math.max(i, u, He), S = Z(e.width, t);
162
+ return { scaleResolutionDownBy: l, maxBitrate: S };
163
+ }, ne = le(), Xe = async () => ne().catch((n) => {
164
+ c("videoSendingBalancer: error", n);
165
+ }), je = async (n) => (ne.add(n), Xe()), X = async ({
157
166
  sender: n,
158
167
  scaleResolutionDownBy: e,
159
168
  maxBitrate: t,
160
169
  onSetParameters: s
161
- }) => He(async () => se(n, { scaleResolutionDownBy: e, maxBitrate: t }, s)), Xe = async ({ sender: n, codec: e }, t) => {
162
- const o = xe(e);
163
- return H({
170
+ }) => je(async () => re(n, { scaleResolutionDownBy: e, maxBitrate: t }, s)), We = async ({ sender: n, codec: e }, t) => {
171
+ const o = $e(e);
172
+ return X({
164
173
  sender: n,
165
174
  maxBitrate: o,
166
175
  onSetParameters: t,
167
176
  scaleResolutionDownBy: 200
168
177
  });
169
- }, k = async ({
178
+ }, L = async ({
170
179
  sender: n,
171
180
  videoTrack: e,
172
181
  codec: t
173
182
  }, s) => {
174
- const c = e.getSettings().width, a = Z(c, t);
175
- return H({
183
+ const i = e.getSettings().width, u = Z(i, t);
184
+ return X({
176
185
  sender: n,
177
- maxBitrate: a,
186
+ maxBitrate: u,
178
187
  onSetParameters: s,
179
188
  scaleResolutionDownBy: 1
180
189
  });
181
- }, je = async ({
190
+ }, Ge = async ({
182
191
  sender: n,
183
192
  videoTrack: e,
184
193
  resolution: t,
185
194
  codec: s
186
195
  }, o) => {
187
- const [r, c] = t.split("x"), { maxBitrate: a, scaleResolutionDownBy: u } = ee({
196
+ const [r, i] = t.split("x"), { maxBitrate: u, scaleResolutionDownBy: l } = ee({
188
197
  videoTrack: e,
189
198
  codec: s,
190
199
  targetSize: {
191
200
  width: Number(r),
192
- height: Number(c)
201
+ height: Number(i)
193
202
  }
194
203
  });
195
- return H({
204
+ return X({
196
205
  sender: n,
197
- maxBitrate: a,
206
+ maxBitrate: u,
198
207
  onSetParameters: o,
199
- scaleResolutionDownBy: u
208
+ scaleResolutionDownBy: l
200
209
  });
201
- }, We = async ({
210
+ }, Ke = async ({
202
211
  mainCam: n,
203
212
  resolutionMainCam: e,
204
213
  sender: t,
@@ -206,23 +215,19 @@ const Ce = (n = new Error()) => {
206
215
  codec: o
207
216
  }, r) => {
208
217
  switch (n) {
209
- case w.PAUSE_MAIN_CAM:
210
- return Xe({ sender: t, codec: o }, r);
211
- case w.RESUME_MAIN_CAM:
212
- return k({ sender: t, videoTrack: s, codec: o }, r);
213
- case w.MAX_MAIN_CAM_RESOLUTION:
214
- return e !== void 0 ? je(
218
+ case x.PAUSE_MAIN_CAM:
219
+ return We({ sender: t, codec: o }, r);
220
+ case x.RESUME_MAIN_CAM:
221
+ return L({ sender: t, videoTrack: s, codec: o }, r);
222
+ case x.MAX_MAIN_CAM_RESOLUTION:
223
+ return e !== void 0 ? Ge(
215
224
  { sender: t, videoTrack: s, codec: o, resolution: e },
216
225
  r
217
- ) : k({ sender: t, videoTrack: s, codec: o }, r);
218
- case w.ADMIN_STOP_MAIN_CAM:
219
- case w.ADMIN_START_MAIN_CAM:
220
- case void 0:
221
- return k({ sender: t, videoTrack: s, codec: o }, r);
226
+ ) : L({ sender: t, videoTrack: s, codec: o }, r);
222
227
  default:
223
- return k({ sender: t, videoTrack: s, codec: o }, r);
228
+ return L({ sender: t, videoTrack: s, codec: o }, r);
224
229
  }
225
- }, X = {
230
+ }, j = {
226
231
  isChanged: !1,
227
232
  parameters: {
228
233
  encodings: [{}],
@@ -231,56 +236,54 @@ const Ce = (n = new Error()) => {
231
236
  headerExtensions: [],
232
237
  rtcp: {}
233
238
  }
234
- }, j = async ({
239
+ }, W = async ({
235
240
  mainCam: n,
236
241
  resolutionMainCam: e,
237
242
  connection: t,
238
243
  onSetParameters: s,
239
244
  ignoreForCodec: o
240
245
  }) => {
241
- const r = t.getSenders(), c = Pe(r);
242
- if (!c?.track)
243
- return X;
244
- const a = await Be(c);
245
- return z(a, o) ? X : We(
246
+ const r = t.getSenders(), i = Ie(r);
247
+ if (!(i != null && i.track))
248
+ return j;
249
+ const u = await De(i);
250
+ return z(u, o) ? j : Ke(
246
251
  {
247
252
  mainCam: n,
248
253
  resolutionMainCam: e,
249
- sender: c,
250
- codec: a,
251
- videoTrack: c.track
254
+ sender: i,
255
+ codec: u,
256
+ videoTrack: i.track
252
257
  },
253
258
  s
254
259
  );
255
- }, an = (n, {
260
+ }, ln = (n, {
256
261
  ignoreForCodec: e,
257
262
  onSetParameters: t
258
263
  } = {}) => {
259
264
  const s = async () => {
260
- const { connection: u } = n;
261
- if (!u)
265
+ const { connection: l } = n;
266
+ if (!l)
262
267
  throw new Error("connection is not exist");
263
- return j({
264
- connection: u,
268
+ return W({
269
+ connection: l,
265
270
  onSetParameters: t,
266
271
  ignoreForCodec: e
267
272
  });
268
273
  };
269
274
  let o = s;
270
- const r = (u) => {
271
- o = async () => {
272
- const { mainCam: l, resolutionMainCam: S } = u, { connection: C } = n;
273
- if (!C)
274
- throw new Error("connection is not exist");
275
- return j({
276
- mainCam: l,
277
- resolutionMainCam: S,
278
- connection: C,
279
- onSetParameters: t,
280
- ignoreForCodec: e
281
- });
282
- }, o().catch(K);
283
- };
275
+ const r = async (l) => (o = async () => {
276
+ const { mainCam: S, resolutionMainCam: C } = l, { connection: f } = n;
277
+ if (!f)
278
+ throw new Error("connection is not exist");
279
+ return W({
280
+ mainCam: S,
281
+ resolutionMainCam: C,
282
+ connection: f,
283
+ onSetParameters: t,
284
+ ignoreForCodec: e
285
+ });
286
+ }, o());
284
287
  return {
285
288
  subscribe: () => {
286
289
  n.onSession("main-cam-control", r);
@@ -296,51 +299,52 @@ const Ce = (n = new Error()) => {
296
299
  return o();
297
300
  }
298
301
  };
299
- }, Ge = (n) => n.getVideoTracks()[0], B = ({
302
+ }, Ye = (n) => n.getVideoTracks()[0], B = ({
300
303
  mediaStream: n,
301
304
  simulcastEncodings: e,
302
305
  sendEncodings: t
303
306
  }) => {
304
307
  if (e && e.length > 0) {
305
- const s = t ?? [], o = Ge(n);
306
- return e.forEach((r, c) => {
307
- const a = s[c] ?? {};
308
- a.active = !0, r.rid !== void 0 && (a.rid = r.rid), r.scalabilityMode !== void 0 && (a.scalabilityMode = r.scalabilityMode);
309
- const { maxBitrate: u, scaleResolutionDownBy: l } = ee({
308
+ const s = t ?? [], o = Ye(n);
309
+ return e.forEach((r, i) => {
310
+ const u = s[i] ?? {};
311
+ u.active = !0, r.rid !== void 0 && (u.rid = r.rid), r.scalabilityMode !== void 0 && (u.scalabilityMode = r.scalabilityMode);
312
+ const { maxBitrate: l, scaleResolutionDownBy: S } = ee({
310
313
  videoTrack: o,
311
314
  targetSize: {
312
315
  width: r.width,
313
316
  height: r.height
314
317
  }
315
318
  });
316
- a.maxBitrate = u, a.scaleResolutionDownBy = l, s[c] = a;
319
+ u.maxBitrate = l, u.scaleResolutionDownBy = S, s[i] = u;
317
320
  }), s;
318
321
  }
319
322
  return t;
320
- }, Ke = (n, e) => n.filter((s) => e.some((o) => o.clockRate === s.clockRate && o.mimeType === s.mimeType && o.channels === s.channels && o.sdpFmtpLine === s.sdpFmtpLine)), Ye = (n) => {
323
+ }, qe = (n, e) => n.filter((s) => e.some((o) => o.clockRate === s.clockRate && o.mimeType === s.mimeType && o.channels === s.channels && o.sdpFmtpLine === s.sdpFmtpLine)), ze = (n) => {
321
324
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, o = t === null ? [] : t.codecs;
322
- return Ke(s, o);
323
- }, qe = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
324
- const o = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), c = o === -1 ? Number.MAX_VALUE : o, a = r === -1 ? Number.MAX_VALUE : r;
325
- return c - a;
326
- }), ze = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), P = (n, {
325
+ return qe(s, o);
326
+ }, Qe = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
327
+ const o = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), i = o === -1 ? Number.MAX_VALUE : o, u = r === -1 ? Number.MAX_VALUE : r;
328
+ return i - u;
329
+ }), Je = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), P = (n, {
327
330
  preferredMimeTypesVideoCodecs: e,
328
331
  excludeMimeTypesVideoCodecs: t
329
332
  }) => async (s) => {
333
+ var o;
330
334
  try {
331
- if (typeof s.setCodecPreferences == "function" && s.sender.track?.kind === "video" && (e !== void 0 && e?.length > 0 || t !== void 0 && t?.length > 0)) {
332
- const o = Ye("video"), r = ze(o, t), c = qe(r, e);
333
- s.setCodecPreferences(c);
335
+ if (typeof s.setCodecPreferences == "function" && ((o = s.sender.track) == null ? void 0 : o.kind) === "video" && (e !== void 0 && (e == null ? void 0 : e.length) > 0 || t !== void 0 && (t == null ? void 0 : t.length) > 0)) {
336
+ const r = ze("video"), i = Je(r, t), u = Qe(i, e);
337
+ s.setCodecPreferences(u);
334
338
  }
335
- Object.keys(n).length > 0 && await oe(s.sender, n);
336
- } catch (o) {
337
- i("updateTransceiver error", o);
339
+ Object.keys(n).length > 0 && await ie(s.sender, n);
340
+ } catch (r) {
341
+ c("updateTransceiver error", r);
338
342
  }
339
- }, L = (n) => {
340
- if (!ue(n) && !de(n))
343
+ }, $ = (n) => {
344
+ if (!de(n) && !Se(n))
341
345
  throw n;
342
346
  return { isSuccessful: !1 };
343
- }, Qe = ({ kind: n, readyState: e }) => n === "video" && e === "live", Je = /* @__PURE__ */ new Set([
347
+ }, Ze = ({ kind: n, readyState: e }) => n === "video" && e === "live", en = /* @__PURE__ */ new Set([
344
348
  "on",
345
349
  "once",
346
350
  "onceRace",
@@ -362,385 +366,390 @@ const Ce = (n = new Error()) => {
362
366
  "isConfigured",
363
367
  "isRegistered"
364
368
  ]);
365
- class un {
366
- sipConnector;
367
- preferredMimeTypesVideoCodecs;
368
- excludeMimeTypesVideoCodecs;
369
- // @ts-expect-error: proxy method
370
- on;
371
- // @ts-expect-error: proxy method
372
- once;
373
- // @ts-expect-error: proxy method
374
- onceRace;
375
- // @ts-expect-error: proxy method
376
- wait;
377
- // @ts-expect-error: proxy method
378
- off;
379
- // @ts-expect-error: proxy method
380
- onSession;
381
- // @ts-expect-error: proxy method
382
- onceSession;
383
- // @ts-expect-error: proxy method
384
- onceRaceSession;
385
- // @ts-expect-error: proxy method
386
- waitSession;
387
- // @ts-expect-error: proxy method
388
- offSession;
389
- // @ts-expect-error: proxy method
390
- sendDTMF;
391
- // @ts-expect-error: proxy method
392
- hangUp;
393
- // @ts-expect-error: proxy method
394
- declineToIncomingCall;
395
- // @ts-expect-error: proxy method
396
- sendChannels;
397
- // @ts-expect-error: proxy method
398
- checkTelephony;
399
- // @ts-expect-error: proxy method
400
- waitChannels;
401
- // @ts-expect-error: proxy method
402
- ping;
403
- // proxy method
404
- connection;
405
- // @ts-expect-error: proxy method
406
- isConfigured;
407
- // @ts-expect-error: proxy method
408
- isRegistered;
369
+ class dn {
409
370
  constructor(e, {
410
371
  preferredMimeTypesVideoCodecs: t,
411
372
  excludeMimeTypesVideoCodecs: s
412
373
  } = {}) {
413
- return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.sipConnector = e, new Proxy(this, {
414
- get: (o, r, c) => {
415
- if (typeof r == "string" && Je.has(r) && r in this.sipConnector) {
416
- const u = Reflect.get(this.sipConnector, r, this.sipConnector);
417
- return typeof u == "function" ? u.bind(this.sipConnector) : u;
418
- }
419
- const a = Reflect.get(o, r, c);
420
- return typeof a == "function" ? a.bind(o) : a;
421
- }
374
+ a(this, "sipConnector");
375
+ a(this, "preferredMimeTypesVideoCodecs");
376
+ a(this, "excludeMimeTypesVideoCodecs");
377
+ // @ts-expect-error: proxy method
378
+ a(this, "on");
379
+ // @ts-expect-error: proxy method
380
+ a(this, "once");
381
+ // @ts-expect-error: proxy method
382
+ a(this, "onceRace");
383
+ // @ts-expect-error: proxy method
384
+ a(this, "wait");
385
+ // @ts-expect-error: proxy method
386
+ a(this, "off");
387
+ // @ts-expect-error: proxy method
388
+ a(this, "onSession");
389
+ // @ts-expect-error: proxy method
390
+ a(this, "onceSession");
391
+ // @ts-expect-error: proxy method
392
+ a(this, "onceRaceSession");
393
+ // @ts-expect-error: proxy method
394
+ a(this, "waitSession");
395
+ // @ts-expect-error: proxy method
396
+ a(this, "offSession");
397
+ // @ts-expect-error: proxy method
398
+ a(this, "sendDTMF");
399
+ // @ts-expect-error: proxy method
400
+ a(this, "hangUp");
401
+ // @ts-expect-error: proxy method
402
+ a(this, "declineToIncomingCall");
403
+ // @ts-expect-error: proxy method
404
+ a(this, "sendChannels");
405
+ // @ts-expect-error: proxy method
406
+ a(this, "checkTelephony");
407
+ // @ts-expect-error: proxy method
408
+ a(this, "waitChannels");
409
+ // @ts-expect-error: proxy method
410
+ a(this, "ping");
411
+ // proxy method
412
+ a(this, "connection");
413
+ // @ts-expect-error: proxy method
414
+ a(this, "isConfigured");
415
+ // @ts-expect-error: proxy method
416
+ a(this, "isRegistered");
417
+ a(this, "connectToServer", async (e) => {
418
+ const {
419
+ userAgent: t,
420
+ sipWebSocketServerURL: s,
421
+ sipServerUrl: o,
422
+ remoteAddress: r,
423
+ displayName: i,
424
+ name: u,
425
+ password: l,
426
+ isRegisteredUser: S,
427
+ isDisconnectOnFail: C
428
+ } = e;
429
+ return c("connectToServer", e), this.sipConnector.connect({
430
+ userAgent: t,
431
+ sipWebSocketServerURL: s,
432
+ sipServerUrl: o,
433
+ remoteAddress: r,
434
+ displayName: i,
435
+ password: l,
436
+ user: u,
437
+ register: S
438
+ }).then((f) => (c("connectToServer then"), { ua: f, isSuccessful: !0 })).catch(async (f) => (c("connectToServer catch: error", f), C === !0 ? this.sipConnector.disconnect().then(() => $(f)).catch(() => $(f)) : $(f)));
422
439
  });
423
- }
424
- connectToServer = async (e) => {
425
- const {
426
- userAgent: t,
427
- sipWebSocketServerURL: s,
428
- sipServerUrl: o,
429
- remoteAddress: r,
430
- displayName: c,
431
- name: a,
432
- password: u,
433
- isRegisteredUser: l,
434
- isDisconnectOnFail: S
435
- } = e;
436
- return i("connectToServer", e), this.sipConnector.connect({
437
- userAgent: t,
438
- sipWebSocketServerURL: s,
439
- sipServerUrl: o,
440
- remoteAddress: r,
441
- displayName: c,
442
- password: u,
443
- user: a,
444
- register: l
445
- }).then((C) => (i("connectToServer then"), { ua: C, isSuccessful: !0 })).catch(async (C) => (i("connectToServer catch: error", C), S === !0 ? this.sipConnector.disconnect().then(() => L(C)).catch(() => L(C)) : L(C)));
446
- };
447
- callToServer = async (e) => {
448
- const {
449
- conference: t,
450
- mediaStream: s,
451
- extraHeaders: o,
452
- iceServers: r,
453
- contentHint: c,
454
- simulcastEncodings: a,
455
- degradationPreference: u,
456
- sendEncodings: l,
457
- offerToReceiveAudio: S,
458
- offerToReceiveVideo: C,
459
- directionVideo: D,
460
- directionAudio: F,
461
- setRemoteStreams: f,
462
- onBeforeProgressCall: R,
463
- onSuccessProgressCall: m,
464
- onEnterPurgatory: h,
465
- onEnterConference: g,
466
- onFailProgressCall: y,
467
- onFinishProgressCall: T,
468
- onEndedCall: E
469
- } = e, A = this.resolveHandleReadyRemoteStreamsDebounced({
470
- onReadyRemoteStreams: f
471
- }), _ = this.resolveHandleReadyRemoteStreams({
472
- onReadyRemoteStreams: A
473
- }), v = P(
474
- {
475
- degradationPreference: u
476
- },
477
- {
478
- preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
479
- excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
480
- }
481
- );
482
- i("callToServer", e);
483
- const O = async () => (i("startCall"), this.sipConnector.call({
484
- mediaStream: s,
485
- extraHeaders: o,
486
- iceServers: r,
487
- contentHint: c,
488
- offerToReceiveAudio: S,
489
- offerToReceiveVideo: C,
490
- directionVideo: D,
491
- directionAudio: F,
492
- sendEncodings: B({
440
+ a(this, "callToServer", async (e) => {
441
+ const {
442
+ conference: t,
493
443
  mediaStream: s,
494
- simulcastEncodings: a,
495
- sendEncodings: l
496
- }),
497
- number: t,
498
- onAddedTransceiver: v,
499
- ontrack: _
500
- }));
501
- let M = !1, b;
502
- const N = (i("subscribeEnterConference: onEnterConference", g), h ?? g ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
503
- i("enterRoom", { _room: d, isSuccessProgressCall: M }), b = d, I(b) ? h && h() : g && g({ isSuccessProgressCall: M });
504
- }) : () => {
505
- }), V = (d) => (i("onSuccess"), M = !0, A().catch(K), m && m({ isPurgatory: I(b) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
506
- N(), E && E();
507
- }), d), U = (d) => {
508
- throw i("onFail"), y && y(), N(), d;
509
- }, x = () => {
510
- i("onFinish"), T && T();
511
- };
512
- return i("onBeforeProgressCall"), R && R(t), O().then(V).catch((d) => U(d)).finally(x);
513
- };
514
- disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (i("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (i("disconnectFromServer: catch", e), { isSuccessful: !1 }));
515
- answerIncomingCall = async (e) => {
516
- const {
517
- mediaStream: t,
518
- extraHeaders: s,
519
- iceServers: o,
520
- contentHint: r,
521
- simulcastEncodings: c,
522
- degradationPreference: a,
523
- sendEncodings: u,
524
- offerToReceiveAudio: l,
525
- offerToReceiveVideo: S,
526
- directionVideo: C,
527
- directionAudio: D,
528
- setRemoteStreams: F,
529
- onBeforeProgressCall: f,
530
- onSuccessProgressCall: R,
531
- onEnterPurgatory: m,
532
- onEnterConference: h,
533
- onFailProgressCall: g,
534
- onFinishProgressCall: y,
535
- onEndedCall: T
536
- } = e, E = this.resolveHandleReadyRemoteStreamsDebounced({
537
- onReadyRemoteStreams: F
538
- }), A = this.resolveHandleReadyRemoteStreams({
539
- onReadyRemoteStreams: E
540
- }), _ = P(
541
- {
542
- degradationPreference: a
543
- },
544
- {
545
- preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
546
- excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
547
- }
548
- );
549
- i("answerIncomingCall", e);
550
- const v = async () => this.sipConnector.answerToIncomingCall({
551
- mediaStream: t,
552
- extraHeaders: s,
553
- iceServers: o,
554
- contentHint: r,
555
- offerToReceiveAudio: l,
556
- offerToReceiveVideo: S,
557
- directionVideo: C,
558
- directionAudio: D,
559
- sendEncodings: B({
444
+ extraHeaders: o,
445
+ iceServers: r,
446
+ contentHint: i,
447
+ simulcastEncodings: u,
448
+ degradationPreference: l,
449
+ sendEncodings: S,
450
+ offerToReceiveAudio: C,
451
+ offerToReceiveVideo: f,
452
+ directionVideo: I,
453
+ directionAudio: F,
454
+ setRemoteStreams: m,
455
+ onBeforeProgressCall: p,
456
+ onSuccessProgressCall: h,
457
+ onEnterPurgatory: R,
458
+ onEnterConference: y,
459
+ onFailProgressCall: E,
460
+ onFinishProgressCall: T,
461
+ onEndedCall: b
462
+ } = e, A = this.resolveHandleReadyRemoteStreamsDebounced({
463
+ onReadyRemoteStreams: m
464
+ }), v = this.resolveHandleReadyRemoteStreams({
465
+ onReadyRemoteStreams: A
466
+ }), O = P(
467
+ {
468
+ degradationPreference: l
469
+ },
470
+ {
471
+ preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
472
+ excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
473
+ }
474
+ );
475
+ c("callToServer", e);
476
+ const N = async () => (c("startCall"), this.sipConnector.call({
477
+ mediaStream: s,
478
+ extraHeaders: o,
479
+ iceServers: r,
480
+ contentHint: i,
481
+ offerToReceiveAudio: C,
482
+ offerToReceiveVideo: f,
483
+ directionVideo: I,
484
+ directionAudio: F,
485
+ sendEncodings: B({
486
+ mediaStream: s,
487
+ simulcastEncodings: u,
488
+ sendEncodings: S
489
+ }),
490
+ number: t,
491
+ onAddedTransceiver: O,
492
+ ontrack: v
493
+ }));
494
+ let M = !1, _;
495
+ const w = (c("subscribeEnterConference: onEnterConference", y), R ?? y ? this.sipConnector.onSession("enterRoom", ({ room: d }) => {
496
+ c("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? R && R() : y && y({ isSuccessProgressCall: M });
497
+ }) : () => {
498
+ }), k = (d) => (c("onSuccess"), M = !0, A(), h && h({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
499
+ w(), b && b();
500
+ }), d), U = (d) => {
501
+ throw c("onFail"), E && E(), w(), d;
502
+ }, V = () => {
503
+ c("onFinish"), T && T();
504
+ };
505
+ return c("onBeforeProgressCall"), p && p(t), N().then(k).catch((d) => U(d)).finally(V);
506
+ });
507
+ a(this, "disconnectFromServer", async () => this.sipConnector.disconnect().then(() => (c("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (c("disconnectFromServer: catch", e), { isSuccessful: !1 })));
508
+ a(this, "answerIncomingCall", async (e) => {
509
+ const {
560
510
  mediaStream: t,
561
- simulcastEncodings: c,
562
- sendEncodings: u
563
- }),
564
- onAddedTransceiver: _,
565
- ontrack: A
566
- }), O = () => {
567
- const { remoteCallerData: d } = this.sipConnector;
568
- return d.incomingNumber;
569
- };
570
- let M = !1, b;
571
- const N = (i("subscribeEnterConference: onEnterConference", h), m ?? h ? this.sipConnector.onSession("enterRoom", (d) => {
572
- i("enterRoom", { _room: d, isSuccessProgressCall: M }), b = d, I(b) ? m && m() : h && h({ isSuccessProgressCall: M });
573
- }) : () => {
574
- }), V = (d) => (i("onSuccess"), M = !0, E(), R && R({ isPurgatory: I(b) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
575
- N(), T && T();
576
- }), d), U = (d) => {
577
- throw i("onFail"), g && g(), N(), d;
578
- }, x = () => {
579
- i("onFinish"), y && y();
580
- };
581
- if (i("onBeforeProgressCall"), f) {
582
- const d = O();
583
- f(d);
584
- }
585
- return v().then(V).catch((d) => U(d)).finally(x);
586
- };
587
- updatePresentation = async ({
588
- mediaStream: e,
589
- isP2P: t,
590
- maxBitrate: s,
591
- contentHint: o,
592
- simulcastEncodings: r,
593
- degradationPreference: c,
594
- sendEncodings: a,
595
- preferredMimeTypesVideoCodecs: u,
596
- excludeMimeTypesVideoCodecs: l
597
- }) => {
598
- const S = P(
599
- {
600
- degradationPreference: c
601
- },
602
- {
603
- preferredMimeTypesVideoCodecs: u,
604
- excludeMimeTypesVideoCodecs: l
511
+ extraHeaders: s,
512
+ iceServers: o,
513
+ contentHint: r,
514
+ simulcastEncodings: i,
515
+ degradationPreference: u,
516
+ sendEncodings: l,
517
+ offerToReceiveAudio: S,
518
+ offerToReceiveVideo: C,
519
+ directionVideo: f,
520
+ directionAudio: I,
521
+ setRemoteStreams: F,
522
+ onBeforeProgressCall: m,
523
+ onSuccessProgressCall: p,
524
+ onEnterPurgatory: h,
525
+ onEnterConference: R,
526
+ onFailProgressCall: y,
527
+ onFinishProgressCall: E,
528
+ onEndedCall: T
529
+ } = e, b = this.resolveHandleReadyRemoteStreamsDebounced({
530
+ onReadyRemoteStreams: F
531
+ }), A = this.resolveHandleReadyRemoteStreams({
532
+ onReadyRemoteStreams: b
533
+ }), v = P(
534
+ {
535
+ degradationPreference: u
536
+ },
537
+ {
538
+ preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
539
+ excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
540
+ }
541
+ );
542
+ c("answerIncomingCall", e);
543
+ const O = async () => this.sipConnector.answerToIncomingCall({
544
+ mediaStream: t,
545
+ extraHeaders: s,
546
+ iceServers: o,
547
+ contentHint: r,
548
+ offerToReceiveAudio: S,
549
+ offerToReceiveVideo: C,
550
+ directionVideo: f,
551
+ directionAudio: I,
552
+ sendEncodings: B({
553
+ mediaStream: t,
554
+ simulcastEncodings: i,
555
+ sendEncodings: l
556
+ }),
557
+ onAddedTransceiver: v,
558
+ ontrack: A
559
+ }), N = () => {
560
+ const { remoteCallerData: d } = this.sipConnector;
561
+ return d.incomingNumber;
562
+ };
563
+ let M = !1, _;
564
+ const w = (c("subscribeEnterConference: onEnterConference", R), h ?? R ? this.sipConnector.onSession("enterRoom", (d) => {
565
+ c("enterRoom", { _room: d, isSuccessProgressCall: M }), _ = d, D(_) ? h && h() : R && R({ isSuccessProgressCall: M });
566
+ }) : () => {
567
+ }), k = (d) => (c("onSuccess"), M = !0, b(), p && p({ isPurgatory: D(_) }), this.sipConnector.onceRaceSession(["ended", "failed"], () => {
568
+ w(), T && T();
569
+ }), d), U = (d) => {
570
+ throw c("onFail"), y && y(), w(), d;
571
+ }, V = () => {
572
+ c("onFinish"), E && E();
573
+ };
574
+ if (c("onBeforeProgressCall"), m) {
575
+ const d = N();
576
+ m(d);
605
577
  }
606
- );
607
- return i("updatePresentation"), this.sipConnector.updatePresentation(e, {
578
+ return O().then(k).catch((d) => U(d)).finally(V);
579
+ });
580
+ a(this, "updatePresentation", async ({
581
+ mediaStream: e,
608
582
  isP2P: t,
609
583
  maxBitrate: s,
610
584
  contentHint: o,
611
- sendEncodings: B({
612
- mediaStream: e,
613
- simulcastEncodings: r,
614
- sendEncodings: a
615
- }),
616
- onAddedTransceiver: S
617
- });
618
- };
619
- startPresentation = async ({
620
- mediaStream: e,
621
- isP2P: t,
622
- maxBitrate: s,
623
- contentHint: o,
624
- simulcastEncodings: r,
625
- degradationPreference: c,
626
- sendEncodings: a,
627
- preferredMimeTypesVideoCodecs: u,
628
- excludeMimeTypesVideoCodecs: l
629
- }, S) => {
630
- const C = P(
631
- {
632
- degradationPreference: c
633
- },
634
- {
635
- preferredMimeTypesVideoCodecs: u,
636
- excludeMimeTypesVideoCodecs: l
637
- }
638
- );
639
- return i("startPresentation"), this.sipConnector.startPresentation(
640
- e,
641
- {
585
+ simulcastEncodings: r,
586
+ degradationPreference: i,
587
+ sendEncodings: u,
588
+ preferredMimeTypesVideoCodecs: l,
589
+ excludeMimeTypesVideoCodecs: S
590
+ }) => {
591
+ const C = P(
592
+ {
593
+ degradationPreference: i
594
+ },
595
+ {
596
+ preferredMimeTypesVideoCodecs: l,
597
+ excludeMimeTypesVideoCodecs: S
598
+ }
599
+ );
600
+ return c("updatePresentation"), this.sipConnector.updatePresentation(e, {
642
601
  isP2P: t,
643
602
  maxBitrate: s,
644
603
  contentHint: o,
645
604
  sendEncodings: B({
646
605
  mediaStream: e,
647
606
  simulcastEncodings: r,
648
- sendEncodings: a
607
+ sendEncodings: u
649
608
  }),
650
609
  onAddedTransceiver: C
651
- },
652
- S
653
- );
654
- };
655
- stopShareSipConnector = async ({ isP2P: e = !1 } = {}) => (i("stopShareSipConnector"), this.sipConnector.stopPresentation({
656
- isP2P: e
657
- }).catch((t) => {
658
- i(t);
659
- }));
660
- sendRefusalToTurnOnMic = async () => {
661
- this.sipConnector.isCallActive && (i("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
662
- i("sendRefusalToTurnOnMic: error", e);
663
- }));
664
- };
665
- sendRefusalToTurnOnCam = async () => {
666
- this.sipConnector.isCallActive && (i("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
667
- i("sendRefusalToTurnOnCam: error", e);
668
- }));
669
- };
670
- sendMediaState = async ({
671
- isEnabledCam: e,
672
- isEnabledMic: t
673
- }) => {
674
- this.sipConnector.isCallActive && (i("sendMediaState"), await this.sipConnector.sendMediaState({ cam: e, mic: t }));
675
- };
676
- replaceMediaStream = async (e, {
677
- deleteExisting: t,
678
- addMissing: s,
679
- forceRenegotiation: o,
680
- contentHint: r,
681
- simulcastEncodings: c,
682
- degradationPreference: a,
683
- sendEncodings: u
684
- } = {}) => {
685
- const l = P(
686
- {
687
- degradationPreference: a
688
- },
689
- {
690
- preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
691
- excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
692
- }
693
- );
694
- return i("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
610
+ });
611
+ });
612
+ a(this, "startPresentation", async ({
613
+ mediaStream: e,
614
+ isP2P: t,
615
+ maxBitrate: s,
616
+ contentHint: o,
617
+ simulcastEncodings: r,
618
+ degradationPreference: i,
619
+ sendEncodings: u,
620
+ preferredMimeTypesVideoCodecs: l,
621
+ excludeMimeTypesVideoCodecs: S
622
+ }, C) => {
623
+ const f = P(
624
+ {
625
+ degradationPreference: i
626
+ },
627
+ {
628
+ preferredMimeTypesVideoCodecs: l,
629
+ excludeMimeTypesVideoCodecs: S
630
+ }
631
+ );
632
+ return c("startPresentation"), this.sipConnector.startPresentation(
633
+ e,
634
+ {
635
+ isP2P: t,
636
+ maxBitrate: s,
637
+ contentHint: o,
638
+ sendEncodings: B({
639
+ mediaStream: e,
640
+ simulcastEncodings: r,
641
+ sendEncodings: u
642
+ }),
643
+ onAddedTransceiver: f
644
+ },
645
+ C
646
+ );
647
+ });
648
+ a(this, "stopShareSipConnector", async ({ isP2P: e = !1 } = {}) => (c("stopShareSipConnector"), this.sipConnector.stopPresentation({
649
+ isP2P: e
650
+ }).catch((t) => {
651
+ c(t);
652
+ })));
653
+ a(this, "sendRefusalToTurnOnMic", async () => {
654
+ if (this.sipConnector.isCallActive)
655
+ return c("sendRefusalToTurnOnMic"), this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
656
+ c("sendRefusalToTurnOnMic: error", e);
657
+ });
658
+ });
659
+ a(this, "sendRefusalToTurnOnCam", async () => {
660
+ if (this.sipConnector.isCallActive)
661
+ return c("sendRefusalToTurnOnCam"), this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
662
+ c("sendRefusalToTurnOnCam: error", e);
663
+ });
664
+ });
665
+ a(this, "sendMediaState", async ({
666
+ isEnabledCam: e,
667
+ isEnabledMic: t
668
+ }) => {
669
+ if (this.sipConnector.isCallActive)
670
+ return c("sendMediaState"), this.sipConnector.sendMediaState({ cam: e, mic: t });
671
+ });
672
+ a(this, "replaceMediaStream", async (e, {
695
673
  deleteExisting: t,
696
674
  addMissing: s,
697
675
  forceRenegotiation: o,
698
676
  contentHint: r,
699
- sendEncodings: B({
700
- mediaStream: e,
701
- simulcastEncodings: c,
702
- sendEncodings: u
703
- }),
704
- onAddedTransceiver: l
677
+ simulcastEncodings: i,
678
+ degradationPreference: u,
679
+ sendEncodings: l
680
+ } = {}) => {
681
+ const S = P(
682
+ {
683
+ degradationPreference: u
684
+ },
685
+ {
686
+ preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
687
+ excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
688
+ }
689
+ );
690
+ return c("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
691
+ deleteExisting: t,
692
+ addMissing: s,
693
+ forceRenegotiation: o,
694
+ contentHint: r,
695
+ sendEncodings: B({
696
+ mediaStream: e,
697
+ simulcastEncodings: i,
698
+ sendEncodings: l
699
+ }),
700
+ onAddedTransceiver: S
701
+ });
705
702
  });
706
- };
707
- askPermissionToEnableCam = async () => {
708
- this.sipConnector.isCallActive && (i("askPermissionToEnableCam"), await this.sipConnector.askPermissionToEnableCam());
709
- };
710
- resolveHandleReadyRemoteStreamsDebounced = ({
711
- onReadyRemoteStreams: e
712
- }) => le(() => {
713
- const t = this.sipConnector.getRemoteStreams();
714
- i("remoteStreams", t), t && e(t);
715
- }, 200);
716
- resolveHandleReadyRemoteStreams = ({
717
- onReadyRemoteStreams: e
718
- }) => ({ track: t }) => {
719
- Qe(t) && e();
720
- };
721
- getRemoteStreams = () => (i("getRemoteStreams"), this.sipConnector.getRemoteStreams());
722
- onUseLicense = (e) => (i("onUseLicense"), this.sipConnector.onSession("useLicense", e));
723
- onMustStopPresentation = (e) => (i("onMustStopPresentation"), this.sipConnector.onSession("mustStopPresentation", e));
724
- onMoveToSpectators = (e) => (i("onMoveToSpectators"), this.sipConnector.onSession(re, e));
725
- onMoveToParticipants = (e) => (i("onMoveToParticipants"), this.sipConnector.onSession(ie, e));
703
+ a(this, "askPermissionToEnableCam", async () => {
704
+ if (this.sipConnector.isCallActive)
705
+ return c("askPermissionToEnableCam"), this.sipConnector.askPermissionToEnableCam();
706
+ });
707
+ a(this, "resolveHandleReadyRemoteStreamsDebounced", ({
708
+ onReadyRemoteStreams: e
709
+ }) => fe(() => {
710
+ const t = this.sipConnector.getRemoteStreams();
711
+ c("remoteStreams", t), t && e(t);
712
+ }, 200));
713
+ a(this, "resolveHandleReadyRemoteStreams", ({
714
+ onReadyRemoteStreams: e
715
+ }) => ({ track: t }) => {
716
+ Ze(t) && e();
717
+ });
718
+ a(this, "getRemoteStreams", () => (c("getRemoteStreams"), this.sipConnector.getRemoteStreams()));
719
+ a(this, "onUseLicense", (e) => (c("onUseLicense"), this.sipConnector.onSession("useLicense", e)));
720
+ a(this, "onMustStopPresentation", (e) => (c("onMustStopPresentation"), this.sipConnector.onSession("mustStopPresentation", e)));
721
+ a(this, "onMoveToSpectators", (e) => (c("onMoveToSpectators"), this.sipConnector.onSession(ce, e)));
722
+ a(this, "onMoveToParticipants", (e) => (c("onMoveToParticipants"), this.sipConnector.onSession(ae, e)));
723
+ return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.sipConnector = e, new Proxy(this, {
724
+ get: (o, r, i) => {
725
+ if (typeof r == "string" && en.has(r) && r in this.sipConnector) {
726
+ const l = Reflect.get(this.sipConnector, r, this.sipConnector);
727
+ return typeof l == "function" ? l.bind(this.sipConnector) : l;
728
+ }
729
+ const u = Reflect.get(o, r, i);
730
+ return typeof u == "function" ? u.bind(o) : u;
731
+ }
732
+ });
733
+ }
726
734
  }
727
735
  export {
728
- w as EEventsMainCAM,
736
+ x as EEventsMainCAM,
729
737
  Cn as EEventsMic,
730
- Sn as EEventsSyncMediaState,
731
- fn as EMimeTypesVideoCodecs,
732
- mn as EUseLicense,
733
- hn as SipConnector,
734
- un as SipConnectorFacade,
738
+ mn as EEventsSyncMediaState,
739
+ hn as EMimeTypesVideoCodecs,
740
+ Rn as EUseLicense,
741
+ gn as SipConnector,
742
+ dn as SipConnectorFacade,
735
743
  pn as causes,
736
- Rn as constants,
737
- bn as debug,
738
- gn as disableDebug,
739
- yn as enableDebug,
740
- Tn as eventNames,
741
- Be as getCodecFromSender,
742
- En as hasCanceledCallError,
743
- an as resolveVideoSendingBalancer,
744
- oe as setParametersToSender,
745
- cn as tools
744
+ yn as constants,
745
+ vn as debug,
746
+ En as disableDebug,
747
+ Tn as enableDebug,
748
+ bn as eventNames,
749
+ De as getCodecFromSender,
750
+ Mn as hasCanceledCallError,
751
+ _n as hasCanceledStartPresentationError,
752
+ ln as resolveVideoSendingBalancer,
753
+ ie as setParametersToSender,
754
+ un as tools
746
755
  };