sip-connector 14.0.1-0 → 14.1.0-alpha.1

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