sip-connector 11.0.0 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,141 +1,180 @@
1
- import { l as o, B as x, N as $, E as P, s as z, S as Je } from "./SipConnector-zEWljwQJ.js";
2
- import { g as cn, i as un, j as ln, c as Sn, a as mn, d as dn, b as fn, e as Cn, h as gn, f as Rn } from "./SipConnector-zEWljwQJ.js";
3
- import { debounce as J } from "ts-debounce";
4
- import { isCanceledError as Q } from "@krivega/cancelable-promise";
5
- import { hasCanceledError as Z } from "repeated-calls";
6
- import { sequentPromises as ee } from "sequent-promises";
7
- import { createStackPromises as ne } from "stack-promises";
8
- import { default as Mn } from "debug";
9
- const X = "purgatory", A = (e) => e === X, D = (e) => () => (o("getRemoteStreams"), e.getRemoteStreams()), te = ({ kind: e, readyState: t }) => e === "video" && t === "live", H = (e) => ({ track: t }) => {
10
- te(t) && e();
11
- }, F = ({
1
+ import { l as a, B as X, N as G, P as Z, a as ee, E as I, s as ne, S as on } from "./SipConnector-BqK7EICM.js";
2
+ import { i as Cn, j as En, k as Rn, c as Tn, b as hn, d as Mn, f as yn, e as _n, h as bn, g as On } from "./SipConnector-BqK7EICM.js";
3
+ import { debounce as te } from "ts-debounce";
4
+ import { isCanceledError as se } from "@krivega/cancelable-promise";
5
+ import { hasCanceledError as re } from "repeated-calls";
6
+ import { sequentPromises as oe } from "sequent-promises";
7
+ import { createStackPromises as ae } from "stack-promises";
8
+ import { default as vn } from "debug";
9
+ const ce = (e) => e.getVideoTracks()[0], ie = 1e6, C = (e) => e * ie, H = C(0.06), ue = C(4), le = (e) => e <= 64 ? H : e <= 128 ? C(0.12) : e <= 256 ? C(0.25) : e <= 384 ? C(0.32) : e <= 426 ? C(0.38) : e <= 640 ? C(0.5) : e <= 848 ? C(0.7) : e <= 1280 ? C(1) : e <= 1920 ? C(2) : ue, W = (e, t) => e !== void 0 && t !== void 0 && e.toLowerCase().includes(t.toLowerCase()), Se = "av1", de = (e) => W(e, Se), me = 0.6, j = (e, t) => de(t) ? e * me : e, fe = (e) => j(H, e), K = (e, t) => {
10
+ const n = le(e);
11
+ return j(n, t);
12
+ }, ge = 1, Y = ({
13
+ videoTrack: e,
14
+ targetSize: t,
15
+ codec: n
16
+ }) => {
17
+ const s = e.getSettings(), r = s.width, o = s.height, c = r / t.width, i = o / t.height, u = Math.max(c, i, ge), S = K(t.width, n);
18
+ return { scaleResolutionDownBy: u, maxBitrate: S };
19
+ }, N = ({
20
+ mediaStream: e,
21
+ simulcastEncodings: t,
22
+ sendEncodings: n
23
+ }) => {
24
+ if (t && t.length > 0) {
25
+ const s = n ?? [], r = ce(e);
26
+ return t.forEach((o, c) => {
27
+ const i = s[c] ?? {}, { maxBitrate: u, scaleResolutionDownBy: S } = Y({
28
+ videoTrack: r,
29
+ targetSize: {
30
+ width: o.width,
31
+ height: o.height
32
+ }
33
+ });
34
+ i.maxBitrate = u, i.scaleResolutionDownBy = S, s[c] = i;
35
+ }), s;
36
+ }
37
+ return n;
38
+ }, z = "purgatory", A = (e) => e === z, k = (e) => () => (a("getRemoteStreams"), e.getRemoteStreams()), Ce = ({ kind: e, readyState: t }) => e === "video" && t === "live", Q = (e) => ({ track: t }) => {
39
+ Ce(t) && e();
40
+ }, U = ({
12
41
  getRemoteStreams: e,
13
42
  setRemoteStreams: t
14
- }) => J(() => {
43
+ }) => te(() => {
15
44
  const n = e();
16
- o("remoteStreams", n), n && t(n);
17
- }, 200), se = (e) => async (n) => {
45
+ a("remoteStreams", n), n && t(n);
46
+ }, 200), Ee = (e) => async (n) => {
18
47
  const {
19
48
  mediaStream: s,
20
49
  extraHeaders: r,
21
- iceServers: a,
50
+ iceServers: o,
22
51
  contentHint: c,
23
- sendEncodings: i,
24
- setRemoteStreams: l,
25
- onBeforeProgressCall: d,
52
+ simulcastEncodings: i,
53
+ sendEncodings: u,
54
+ setRemoteStreams: S,
55
+ onBeforeProgressCall: g,
26
56
  onSuccessProgressCall: f,
27
- onEnterPurgatory: m,
28
- onEnterConference: S,
29
- onFailProgressCall: g,
30
- onFinishProgressCall: C,
31
- onEndedCall: E
32
- } = n, M = F({
33
- setRemoteStreams: l,
34
- getRemoteStreams: D(e)
35
- }), b = H(M);
36
- o("answerIncomingCall", n);
37
- const _ = async () => e.answerToIncomingCall({
57
+ onEnterPurgatory: d,
58
+ onEnterConference: E,
59
+ onFailProgressCall: m,
60
+ onFinishProgressCall: R,
61
+ onEndedCall: T
62
+ } = n, y = U({
63
+ setRemoteStreams: S,
64
+ getRemoteStreams: k(e)
65
+ }), b = Q(y);
66
+ a("answerIncomingCall", n);
67
+ const O = async () => e.answerToIncomingCall({
38
68
  mediaStream: s,
39
69
  extraHeaders: r,
40
- iceServers: a,
70
+ iceServers: o,
41
71
  contentHint: c,
42
- sendEncodings: i,
72
+ sendEncodings: N({
73
+ mediaStream: s,
74
+ simulcastEncodings: i,
75
+ sendEncodings: u
76
+ }),
43
77
  ontrack: b
44
78
  }), p = () => {
45
- const { remoteCallerData: u } = e;
46
- return u.incomingNumber;
79
+ const { remoteCallerData: l } = e;
80
+ return l.incomingNumber;
47
81
  };
48
- let T = !1, y;
49
- const h = (o("subscribeEnterConference: onEnterConference", S), m ?? S ? e.onSession("enterRoom", (u) => {
50
- o("enterRoom", { _room: u, isSuccessProgressCall: T }), y = u, A(y) ? m && m() : S && S({ isSuccessProgressCall: T });
82
+ let h = !1, M;
83
+ const _ = (a("subscribeEnterConference: onEnterConference", E), d ?? E ? e.onSession("enterRoom", (l) => {
84
+ a("enterRoom", { _room: l, isSuccessProgressCall: h }), M = l, A(M) ? d && d() : E && E({ isSuccessProgressCall: h });
51
85
  }) : () => {
52
- }), O = (u) => (o("onSuccess"), T = !0, M(), f && f({ isPurgatory: A(y) }), e.onceRaceSession(["ended", "failed"], () => {
53
- h(), E && E();
54
- }), u), v = (u) => {
55
- throw o("onFail"), g && g(), h(), u;
56
- }, B = () => {
57
- o("onFinish"), C && C();
86
+ }), v = (l) => (a("onSuccess"), h = !0, y(), f && f({ isPurgatory: A(M) }), e.onceRaceSession(["ended", "failed"], () => {
87
+ _(), T && T();
88
+ }), l), B = (l) => {
89
+ throw a("onFail"), m && m(), _(), l;
90
+ }, w = () => {
91
+ a("onFinish"), R && R();
58
92
  };
59
- if (o("onBeforeProgressCall"), d) {
60
- const u = p();
61
- d(u);
93
+ if (a("onBeforeProgressCall"), g) {
94
+ const l = p();
95
+ g(l);
62
96
  }
63
- return _().then(O).catch((u) => v(u)).finally(B);
64
- }, re = (e) => async (n) => {
97
+ return O().then(v).catch((l) => B(l)).finally(w);
98
+ }, Re = (e) => async (n) => {
65
99
  const {
66
100
  conference: s,
67
101
  mediaStream: r,
68
- extraHeaders: a,
102
+ extraHeaders: o,
69
103
  iceServers: c,
70
104
  contentHint: i,
71
- sendEncodings: l,
72
- setRemoteStreams: d,
105
+ simulcastEncodings: u,
106
+ sendEncodings: S,
107
+ setRemoteStreams: g,
73
108
  onBeforeProgressCall: f,
74
- onSuccessProgressCall: m,
75
- onEnterPurgatory: S,
76
- onEnterConference: g,
77
- onFailProgressCall: C,
78
- onFinishProgressCall: E,
79
- onEndedCall: M
80
- } = n, b = F({
81
- setRemoteStreams: d,
82
- getRemoteStreams: D(e)
83
- }), _ = H(b);
84
- o("callToServer", n);
85
- const p = async () => (o("startCall"), e.call({
109
+ onSuccessProgressCall: d,
110
+ onEnterPurgatory: E,
111
+ onEnterConference: m,
112
+ onFailProgressCall: R,
113
+ onFinishProgressCall: T,
114
+ onEndedCall: y
115
+ } = n, b = U({
116
+ setRemoteStreams: g,
117
+ getRemoteStreams: k(e)
118
+ }), O = Q(b);
119
+ a("callToServer", n);
120
+ const p = async () => (a("startCall"), e.call({
86
121
  mediaStream: r,
87
- extraHeaders: a,
122
+ extraHeaders: o,
88
123
  iceServers: c,
89
124
  contentHint: i,
90
- sendEncodings: l,
125
+ sendEncodings: N({
126
+ mediaStream: r,
127
+ simulcastEncodings: u,
128
+ sendEncodings: S
129
+ }),
91
130
  number: s,
92
- ontrack: _
131
+ ontrack: O
93
132
  }));
94
- let T = !1, y;
95
- const h = (o("subscribeEnterConference: onEnterConference", g), S ?? g ? e.onSession("enterRoom", ({ room: u }) => {
96
- o("enterRoom", { _room: u, isSuccessProgressCall: T }), y = u, A(y) ? S && S() : g && g({ isSuccessProgressCall: T });
133
+ let h = !1, M;
134
+ const _ = (a("subscribeEnterConference: onEnterConference", m), E ?? m ? e.onSession("enterRoom", ({ room: l }) => {
135
+ a("enterRoom", { _room: l, isSuccessProgressCall: h }), M = l, A(M) ? E && E() : m && m({ isSuccessProgressCall: h });
97
136
  }) : () => {
98
- }), O = (u) => (o("onSuccess"), T = !0, b(), m && m({ isPurgatory: A(y) }), e.onceRaceSession(["ended", "failed"], () => {
99
- h(), M && M();
100
- }), u), v = (u) => {
101
- throw o("onFail"), C && C(), h(), u;
102
- }, B = () => {
103
- o("onFinish"), E && E();
137
+ }), v = (l) => (a("onSuccess"), h = !0, b(), d && d({ isPurgatory: A(M) }), e.onceRaceSession(["ended", "failed"], () => {
138
+ _(), y && y();
139
+ }), l), B = (l) => {
140
+ throw a("onFail"), R && R(), _(), l;
141
+ }, w = () => {
142
+ a("onFinish"), T && T();
104
143
  };
105
- return o("onBeforeProgressCall"), f && f(s), p().then(O).catch((u) => v(u)).finally(B);
106
- }, I = (e) => {
107
- if (!Q(e) && !Z(e))
144
+ return a("onBeforeProgressCall"), f && f(s), p().then(v).catch((l) => B(l)).finally(w);
145
+ }, D = (e) => {
146
+ if (!se(e) && !re(e))
108
147
  throw e;
109
148
  return { isSuccessful: !1 };
110
- }, oe = (e) => async (n) => {
149
+ }, Te = (e) => async (n) => {
111
150
  const {
112
151
  userAgent: s,
113
152
  sipWebSocketServerURL: r,
114
- sipServerUrl: a,
153
+ sipServerUrl: o,
115
154
  remoteAddress: c,
116
155
  displayName: i,
117
- name: l,
118
- password: d,
119
- isRegisteredUser: f,
120
- isDisconnectOnFail: m
156
+ name: u,
157
+ password: S,
158
+ isRegisteredUser: g,
159
+ isDisconnectOnFail: f
121
160
  } = n;
122
- return o("connectToServer", n), e.connect({
161
+ return a("connectToServer", n), e.connect({
123
162
  userAgent: s,
124
163
  sipWebSocketServerURL: r,
125
- sipServerUrl: a,
164
+ sipServerUrl: o,
126
165
  remoteAddress: c,
127
166
  displayName: i,
128
- password: d,
129
- user: l,
130
- register: f
131
- }).then((S) => (o("connectToServer then"), { ua: S, isSuccessful: !0 })).catch(async (S) => (o("connectToServer catch: error", S), m === !0 ? e.disconnect().then(() => I(S)).catch(() => I(S)) : I(S)));
132
- }, ae = (e) => async () => (o("disconnectFromServer"), e.disconnect().then(() => (o("disconnectFromServer: then"), { isSuccessful: !0 })).catch((t) => (o("disconnectFromServer: catch", t), { isSuccessful: !1 }))), k = (e) => {
167
+ password: S,
168
+ user: u,
169
+ register: g
170
+ }).then((d) => (a("connectToServer then"), { ua: d, isSuccessful: !0 })).catch(async (d) => (a("connectToServer catch: error", d), f === !0 ? e.disconnect().then(() => D(d)).catch(() => D(d)) : D(d)));
171
+ }, he = (e) => async () => (a("disconnectFromServer"), e.disconnect().then(() => (a("disconnectFromServer: then"), { isSuccessful: !0 })).catch((t) => (a("disconnectFromServer: catch", t), { isSuccessful: !1 }))), L = (e) => {
133
172
  const { url: t, cause: n } = e;
134
173
  let s = t;
135
- return (n === x || n === $) && (s = `${e.message.to.uri.user}@${e.message.to.uri.host}`), s;
174
+ return (n === X || n === G) && (s = `${e.message.to.uri.user}@${e.message.to.uri.host}`), s;
136
175
  };
137
- var W = /* @__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))(W || {});
138
- const ce = (e = new Error()) => {
176
+ var q = /* @__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))(q || {});
177
+ const Me = (e = new Error()) => {
139
178
  var r;
140
179
  const { cause: t, socket: n } = e;
141
180
  let s = "CONNECT_SERVER_FAILED";
@@ -144,257 +183,276 @@ const ce = (e = new Error()) => {
144
183
  s = "WRONG_USER_OR_PASSWORD";
145
184
  break;
146
185
  }
147
- case x: {
186
+ case X: {
148
187
  s = "BAD_MEDIA_ERROR";
149
188
  break;
150
189
  }
151
- case $: {
190
+ case G: {
152
191
  s = "NOT_FOUND_ERROR";
153
192
  break;
154
193
  }
155
194
  default:
156
- n && ((r = n == null ? void 0 : n._ws) == null ? void 0 : r.readyState) === 3 ? s = "WS_CONNECTION_FAILED" : k(e) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
195
+ n && ((r = n == null ? void 0 : n._ws) == null ? void 0 : r.readyState) === 3 ? s = "WS_CONNECTION_FAILED" : L(e) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
157
196
  }
158
197
  return s;
159
- }, ie = (e) => {
198
+ }, ye = (e) => {
160
199
  let t = "";
161
200
  try {
162
201
  t = JSON.stringify(e);
163
202
  } catch (n) {
164
- o("failed to stringify message", n);
203
+ a("failed to stringify message", n);
165
204
  }
166
205
  return t;
167
- }, ue = (e = new Error()) => {
168
- const { code: t, cause: n, message: s } = e, r = k(e), a = { code: "", cause: "", message: "" };
169
- return typeof s == "object" && s !== null ? a.message = ie(s) : s && (a.message = String(s)), r && (a.link = r), t && (a.code = t), n && (a.cause = n), a;
170
- }, le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
206
+ }, _e = (e = new Error()) => {
207
+ const { code: t, cause: n, message: s } = e, r = L(e), o = { code: "", cause: "", message: "" };
208
+ return typeof s == "object" && s !== null ? o.message = ye(s) : s && (o.message = String(s)), r && (o.link = r), t && (o.code = t), n && (o.cause = n), o;
209
+ }, be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
171
210
  __proto__: null,
172
- EErrorTypes: W,
173
- getLinkError: k,
174
- getTypeFromError: ce,
175
- getValuesFromError: ue
176
- }, Symbol.toStringTag, { value: "Module" })), Se = ({
211
+ EErrorTypes: q,
212
+ getLinkError: L,
213
+ getTypeFromError: Me,
214
+ getValuesFromError: _e
215
+ }, Symbol.toStringTag, { value: "Module" })), Oe = ({
177
216
  sessionId: e,
178
217
  remoteAddress: t,
179
218
  isMutedAudio: n,
180
219
  isMutedVideo: s,
181
220
  isRegistered: r,
182
- isPresentationCall: a
221
+ isPresentationCall: o
183
222
  }) => {
184
- const c = [], i = n ? "0" : "1", l = s ? "0" : "1";
185
- return c.push(`X-Vinteo-Mic-State: ${i}`, `X-Vinteo-MainCam-State: ${l}`), r || c.push("X-Vinteo-Purgatory-Call: yes"), e && c.push(`X-Vinteo-Session: ${e}`), a && c.push("X-Vinteo-Presentation-Call: yes"), t && c.push(`X-Vinteo-Remote: ${t}`), c;
186
- }, me = "[@*!|]", de = "_", fe = (e) => {
223
+ const c = [], i = n ? "0" : "1", u = s ? "0" : "1";
224
+ return c.push(`X-Vinteo-Mic-State: ${i}`, `X-Vinteo-MainCam-State: ${u}`), r || c.push("X-Vinteo-Purgatory-Call: yes"), e && c.push(`X-Vinteo-Session: ${e}`), o && c.push("X-Vinteo-Presentation-Call: yes"), t && c.push(`X-Vinteo-Remote: ${t}`), c;
225
+ }, pe = "[@*!|]", ve = "_", Ae = (e) => {
187
226
  let t = e;
188
- return t = t.replaceAll(new RegExp(me, "g"), de), t;
189
- }, Ce = ({
227
+ return t = t.replaceAll(new RegExp(pe, "g"), ve), t;
228
+ }, Ne = ({
190
229
  appName: e,
191
230
  appVersion: t,
192
231
  browserName: n,
193
232
  browserVersion: s
194
233
  }) => {
195
- const a = `${fe(e)} ${t}`;
196
- return `ChromeNew - ${n ? `${n} ${s}, ${a}` : a}`;
197
- }, ge = ({
234
+ const o = `${Ae(e)} ${t}`;
235
+ return `ChromeNew - ${n ? `${n} ${s}, ${o}` : o}`;
236
+ }, Pe = ({
198
237
  isUnifiedSdpSemantic: e,
199
238
  appVersion: t,
200
239
  browserName: n,
201
240
  browserVersion: s,
202
241
  appName: r
203
- }) => e ? Ce({ appVersion: t, browserName: n, browserVersion: s, appName: r }) : "Chrome", Re = (e) => async () => {
242
+ }) => e ? Ne({ appVersion: t, browserName: n, browserVersion: s, appName: r }) : "Chrome", Be = (e) => async () => {
204
243
  if (e.isCallActive)
205
- return o("askPermissionToEnableCam"), e.askPermissionToEnableCam();
206
- }, Ee = (e) => (n) => (o("onMustStopPresentation"), e.onSession("mustStopPresentation", n)), Me = (e) => (n) => (o("onMoveToSpectators"), e.onSession("participant:move-request-to-spectators", n)), Te = (e) => (n) => (o("onUseLicense"), e.onSession("useLicense", n)), ye = (e) => async ({
244
+ return a("askPermissionToEnableCam"), e.askPermissionToEnableCam();
245
+ }, we = (e) => (n) => (a("onMustStopPresentation"), e.onSession("mustStopPresentation", n)), Ie = (e) => (n) => (a("onMoveToSpectators"), e.onSession(Z, n)), De = (e) => (n) => (a("onMoveToParticipants"), e.onSession(ee, n)), Fe = (e) => (n) => (a("onUseLicense"), e.onSession("useLicense", n)), ke = (e) => async ({
207
246
  isEnabledCam: n,
208
247
  isEnabledMic: s
209
248
  }) => {
210
249
  if (e.isCallActive)
211
- return o("sendMediaState"), e.sendMediaState({ cam: n, mic: s });
212
- }, he = (e) => async () => {
250
+ return a("sendMediaState"), e.sendMediaState({ cam: n, mic: s });
251
+ }, Ue = (e) => async () => {
213
252
  if (e.isCallActive)
214
- return o("sendRefusalToTurnOnCam"), e.sendRefusalToTurnOnCam().catch((n) => {
215
- o("sendRefusalToTurnOnCam: error", n);
253
+ return a("sendRefusalToTurnOnCam"), e.sendRefusalToTurnOnCam().catch((n) => {
254
+ a("sendRefusalToTurnOnCam: error", n);
216
255
  });
217
- }, be = (e) => async () => {
256
+ }, Le = (e) => async () => {
218
257
  if (e.isCallActive)
219
- return o("sendRefusalToTurnOnMic"), e.sendRefusalToTurnOnMic().catch((n) => {
220
- o("sendRefusalToTurnOnMic: error", n);
258
+ return a("sendRefusalToTurnOnMic"), e.sendRefusalToTurnOnMic().catch((n) => {
259
+ a("sendRefusalToTurnOnMic: error", n);
221
260
  });
222
- }, _e = (e) => async ({
261
+ }, Ve = (e) => async ({
223
262
  mediaStream: n,
224
263
  isP2P: s,
225
264
  maxBitrate: r,
226
- contentHint: a,
227
- sendEncodings: c
228
- }, i) => (o("startPresentation"), e.startPresentation(
265
+ contentHint: o,
266
+ simulcastEncodings: c,
267
+ sendEncodings: i
268
+ }, u) => (a("startPresentation"), e.startPresentation(
229
269
  n,
230
270
  {
231
271
  isP2P: s,
232
272
  maxBitrate: r,
233
- contentHint: a,
234
- sendEncodings: c
273
+ contentHint: o,
274
+ sendEncodings: N({
275
+ mediaStream: n,
276
+ simulcastEncodings: c,
277
+ sendEncodings: i
278
+ })
235
279
  },
236
- i
237
- )), pe = (e) => async ({ isP2P: n = !1 } = {}) => (o("stopShareSipConnector"), e.stopPresentation({
280
+ u
281
+ )), xe = (e) => async ({ isP2P: n = !1 } = {}) => (a("stopShareSipConnector"), e.stopPresentation({
238
282
  isP2P: n
239
283
  }).catch((s) => {
240
- o(s);
241
- })), Oe = (e) => async ({
284
+ a(s);
285
+ })), $e = (e) => async ({
242
286
  mediaStream: n,
243
287
  isP2P: s,
244
288
  maxBitrate: r,
245
- contentHint: a,
246
- sendEncodings: c
247
- }) => (o("updatePresentation"), e.updatePresentation(n, {
289
+ contentHint: o,
290
+ simulcastEncodings: c,
291
+ sendEncodings: i
292
+ }) => (a("updatePresentation"), e.updatePresentation(n, {
248
293
  isP2P: s,
249
294
  maxBitrate: r,
250
- contentHint: a,
251
- sendEncodings: c
252
- })), ve = (e) => (t) => [...t].map((s) => async () => e(s)), Ae = async ({
295
+ contentHint: o,
296
+ sendEncodings: N({
297
+ mediaStream: n,
298
+ simulcastEncodings: c,
299
+ sendEncodings: i
300
+ })
301
+ })), Xe = (e) => (t) => [...t].map((s) => async () => e(s)), Ge = async ({
253
302
  accumulatedKeys: e,
254
303
  sendKey: t,
255
304
  canRunTask: n
256
305
  }) => {
257
- const r = ve(t)(e);
258
- return ee(r, n);
259
- }, Ne = (e) => (n) => (o("onStartMainCam"), e.onSession("admin-start-main-cam", n)), Be = (e) => (n) => (o("onStartMic"), e.onSession("admin-start-mic", n)), Pe = (e) => (n) => (o("onStopMainCam"), e.onSession("admin-stop-main-cam", n)), Ie = (e) => (n) => (o("onStopMic"), e.onSession("admin-stop-mic", n)), we = ({ sipConnector: e }) => {
260
- const t = (C, E) => ({ isSyncForced: M = !1 }) => {
261
- if (M) {
262
- C();
306
+ const r = Xe(t)(e);
307
+ return oe(r, n);
308
+ }, He = (e) => (n) => (a("onStartMainCam"), e.onSession("admin-start-main-cam", n)), We = (e) => (n) => (a("onStartMic"), e.onSession("admin-start-mic", n)), je = (e) => (n) => (a("onStopMainCam"), e.onSession("admin-stop-main-cam", n)), Ke = (e) => (n) => (a("onStopMic"), e.onSession("admin-stop-mic", n)), Ye = ({ sipConnector: e }) => {
309
+ const t = (m, R) => ({ isSyncForced: T = !1 }) => {
310
+ if (T) {
311
+ m();
263
312
  return;
264
313
  }
265
- E();
266
- }, n = Ne(e), s = Pe(e), r = Be(e), a = Ie(e);
314
+ R();
315
+ }, n = He(e), s = je(e), r = We(e), o = Ke(e);
267
316
  let c = () => {
268
317
  }, i = () => {
269
- }, l = () => {
270
- }, d = () => {
318
+ }, u = () => {
319
+ }, S = () => {
271
320
  };
272
- const f = ({
273
- onStartMainCamForced: C,
274
- onStartMainCamNotForced: E,
275
- onStopMainCamForced: M,
276
- onStopMainCamNotForced: b,
277
- onStartMicForced: _,
278
- onStartMicNotForced: p,
279
- onStopMicForced: T,
280
- onStopMicNotForced: y
321
+ const g = ({
322
+ onStartMainCamForced: m,
323
+ onStartMainCamNotForced: R,
324
+ onStopMainCamForced: T,
325
+ onStopMainCamNotForced: y,
326
+ onStartMicForced: b,
327
+ onStartMicNotForced: O,
328
+ onStopMicForced: p,
329
+ onStopMicNotForced: h
281
330
  }) => {
282
- const N = t(
283
- C,
284
- E
331
+ const M = t(
332
+ m,
333
+ R
285
334
  );
286
- c = n(N);
287
- const h = t(
288
- M,
289
- b
335
+ c = n(M);
336
+ const P = t(
337
+ T,
338
+ y
290
339
  );
291
- i = s(h);
292
- const O = t(_, p);
293
- l = r(O);
294
- const v = t(T, y);
295
- d = a(v);
296
- }, m = () => {
297
- c(), i(), l(), d();
340
+ i = s(P);
341
+ const _ = t(b, O);
342
+ u = r(_);
343
+ const v = t(p, h);
344
+ S = o(v);
345
+ }, f = () => {
346
+ c(), i(), u(), S();
298
347
  };
299
348
  return {
300
- start: (C) => {
301
- f(C);
349
+ start: (m) => {
350
+ g(m);
302
351
  },
303
352
  stop: () => {
304
- m();
353
+ f();
305
354
  }
306
355
  };
307
- }, sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
356
+ }, dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
308
357
  __proto__: null,
309
- PURGATORY_CONFERENCE_NUMBER: X,
310
- createSyncMediaState: we,
311
- error: le,
312
- getExtraHeaders: Se,
313
- getUserAgent: ge,
358
+ PURGATORY_CONFERENCE_NUMBER: z,
359
+ createSyncMediaState: Ye,
360
+ error: be,
361
+ getExtraHeaders: Oe,
362
+ getUserAgent: Pe,
314
363
  hasPurgatory: A,
315
- resolveAnswerIncomingCall: se,
316
- resolveAskPermissionToEnableCam: Re,
317
- resolveCallToServer: re,
318
- resolveConnectToServer: oe,
319
- resolveDisconnectFromServer: ae,
320
- resolveGetRemoteStreams: D,
321
- resolveOnMoveToSpectators: Me,
322
- resolveOnMustStopPresentation: Ee,
323
- resolveOnUseLicense: Te,
324
- resolveSendMediaState: ye,
325
- resolveSendRefusalToTurnOnCam: he,
326
- resolveSendRefusalToTurnOnMic: be,
327
- resolveStartPresentation: _e,
328
- resolveStopShareSipConnector: pe,
329
- resolveUpdatePresentation: Oe,
330
- resolveUpdateRemoteStreams: F,
331
- sendDTMFAccumulated: Ae
332
- }, Symbol.toStringTag, { value: "Module" })), De = (e) => [...e.keys()].map((t) => e.get(t)), Fe = (e, t) => De(e).find((n) => n.type === t), ke = async (e) => e.getStats().then((t) => {
333
- const n = Fe(t, "codec");
364
+ resolveAnswerIncomingCall: Ee,
365
+ resolveAskPermissionToEnableCam: Be,
366
+ resolveCallToServer: Re,
367
+ resolveConnectToServer: Te,
368
+ resolveDisconnectFromServer: he,
369
+ resolveGetRemoteStreams: k,
370
+ resolveOnMoveToParticipants: De,
371
+ resolveOnMoveToSpectators: Ie,
372
+ resolveOnMustStopPresentation: we,
373
+ resolveOnUseLicense: Fe,
374
+ resolveSendMediaState: ke,
375
+ resolveSendRefusalToTurnOnCam: Ue,
376
+ resolveSendRefusalToTurnOnMic: Le,
377
+ resolveStartPresentation: Ve,
378
+ resolveStopShareSipConnector: xe,
379
+ resolveUpdatePresentation: $e,
380
+ resolveUpdateRemoteStreams: U,
381
+ sendDTMFAccumulated: Ge
382
+ }, Symbol.toStringTag, { value: "Module" })), ze = (e) => [...e.keys()].map((t) => e.get(t)), Qe = (e, t) => ze(e).find((n) => n.type === t), qe = async (e) => e.getStats().then((t) => {
383
+ const n = Qe(t, "codec");
334
384
  return n == null ? void 0 : n.mimeType;
335
- }), Ue = (e) => e.find((t) => {
385
+ }), Je = (e) => e.find((t) => {
336
386
  var n;
337
387
  return ((n = t == null ? void 0 : t.track) == null ? void 0 : n.kind) === "video";
338
- }), j = (e, t) => e !== void 0 && t !== void 0 && e.toLowerCase().includes(t.toLowerCase()), Le = 1e6, R = (e) => e * Le, G = R(0.06), Ve = R(4), xe = (e) => e <= 64 ? G : e <= 128 ? R(0.12) : e <= 256 ? R(0.25) : e <= 384 ? R(0.32) : e <= 426 ? R(0.38) : e <= 640 ? R(0.5) : e <= 848 ? R(0.7) : e <= 1280 ? R(1) : e <= 1920 ? R(2) : Ve, $e = "av1", Xe = (e) => j(e, $e), He = 0.6, K = (e, t) => Xe(t) ? e * He : e, We = (e) => K(G, e), Y = (e, t) => {
339
- const n = xe(e);
340
- return K(n, t);
341
- }, q = ne(), je = async () => q().catch((e) => {
342
- o("videoSendingBalancer: error", e);
343
- }), Ge = async (e) => (q.add(e), je()), U = async ({
388
+ }), J = ae(), Ze = async () => J().catch((e) => {
389
+ a("videoSendingBalancer: error", e);
390
+ }), en = async (e) => (J.add(e), Ze()), V = async ({
344
391
  sender: e,
345
392
  scaleResolutionDownBy: t,
346
393
  maxBitrate: n,
347
394
  onSetParameters: s
348
- }) => Ge(async () => z(e, { scaleResolutionDownBy: t, maxBitrate: n }, s)), Ke = async ({ sender: e, codec: t }, n) => {
349
- const r = We(t);
350
- return U({
395
+ }) => en(async () => ne(e, { scaleResolutionDownBy: t, maxBitrate: n }, s)), nn = async ({ sender: e, codec: t }, n) => {
396
+ const r = fe(t);
397
+ return V({
351
398
  sender: e,
352
399
  maxBitrate: r,
353
400
  onSetParameters: n,
354
401
  scaleResolutionDownBy: 200
355
402
  });
356
- }, w = async ({ sender: e, track: t, codec: n }, s) => {
357
- const c = t.getSettings().width, i = Y(c, n);
358
- return U({
403
+ }, F = async ({
404
+ sender: e,
405
+ videoTrack: t,
406
+ codec: n
407
+ }, s) => {
408
+ const c = t.getSettings().width, i = K(c, n);
409
+ return V({
359
410
  sender: e,
360
411
  maxBitrate: i,
361
412
  onSetParameters: s,
362
413
  scaleResolutionDownBy: 1
363
414
  });
364
- }, Ye = async ({
415
+ }, tn = async ({
365
416
  sender: e,
366
- track: t,
417
+ videoTrack: t,
367
418
  resolution: n,
368
419
  codec: s
369
420
  }, r) => {
370
- const a = t.getSettings(), c = a.width, i = a.height, [l, d] = n.split("x"), f = c / Number(l), m = i / Number(d), g = Math.max(f, m, 1), C = Y(Number(l), s);
371
- return U({
421
+ const [o, c] = n.split("x"), { maxBitrate: i, scaleResolutionDownBy: u } = Y({
422
+ videoTrack: t,
423
+ codec: s,
424
+ targetSize: {
425
+ width: Number(o),
426
+ height: Number(c)
427
+ }
428
+ });
429
+ return V({
372
430
  sender: e,
373
- maxBitrate: C,
431
+ maxBitrate: i,
374
432
  onSetParameters: r,
375
- scaleResolutionDownBy: g
433
+ scaleResolutionDownBy: u
376
434
  });
377
- }, qe = async ({
435
+ }, sn = async ({
378
436
  mainCam: e,
379
437
  resolutionMainCam: t,
380
438
  sender: n,
381
- track: s,
439
+ videoTrack: s,
382
440
  codec: r
383
- }, a) => {
441
+ }, o) => {
384
442
  switch (e) {
385
- case P.PAUSE_MAIN_CAM:
386
- return Ke({ sender: n, codec: r }, a);
387
- case P.RESUME_MAIN_CAM:
388
- return w({ sender: n, track: s, codec: r }, a);
389
- case P.MAX_MAIN_CAM_RESOLUTION:
390
- return t !== void 0 ? Ye(
391
- { sender: n, track: s, codec: r, resolution: t },
392
- a
393
- ) : w({ sender: n, track: s, codec: r }, a);
443
+ case I.PAUSE_MAIN_CAM:
444
+ return nn({ sender: n, codec: r }, o);
445
+ case I.RESUME_MAIN_CAM:
446
+ return F({ sender: n, videoTrack: s, codec: r }, o);
447
+ case I.MAX_MAIN_CAM_RESOLUTION:
448
+ return t !== void 0 ? tn(
449
+ { sender: n, videoTrack: s, codec: r, resolution: t },
450
+ o
451
+ ) : F({ sender: n, videoTrack: s, codec: r }, o);
394
452
  default:
395
- return w({ sender: n, track: s, codec: r }, a);
453
+ return F({ sender: n, videoTrack: s, codec: r }, o);
396
454
  }
397
- }, L = {
455
+ }, x = {
398
456
  isChanged: !1,
399
457
  parameters: {
400
458
  encodings: [{}],
@@ -403,54 +461,60 @@ const ce = (e = new Error()) => {
403
461
  headerExtensions: [],
404
462
  rtcp: {}
405
463
  }
406
- }, V = async ({
464
+ }, $ = async ({
407
465
  mainCam: e,
408
466
  resolutionMainCam: t,
409
467
  connection: n,
410
468
  onSetParameters: s,
411
469
  ignoreForCodec: r
412
470
  }) => {
413
- const a = n.getSenders(), c = Ue(a);
471
+ const o = n.getSenders(), c = Je(o);
414
472
  if (!(c != null && c.track))
415
- return L;
416
- const i = await ke(c);
417
- return j(i, r) ? L : qe(
418
- { mainCam: e, resolutionMainCam: t, sender: c, codec: i, track: c.track },
473
+ return x;
474
+ const i = await qe(c);
475
+ return W(i, r) ? x : sn(
476
+ {
477
+ mainCam: e,
478
+ resolutionMainCam: t,
479
+ sender: c,
480
+ codec: i,
481
+ videoTrack: c.track
482
+ },
419
483
  s
420
484
  );
421
- }, rn = (e, {
485
+ }, mn = (e, {
422
486
  ignoreForCodec: t,
423
487
  onSetParameters: n
424
488
  } = {}) => {
425
489
  const s = async () => {
426
- const { connection: l } = e;
427
- if (!l)
490
+ const { connection: u } = e;
491
+ if (!u)
428
492
  throw new Error("connection is not exist");
429
- return V({
430
- connection: l,
493
+ return $({
494
+ connection: u,
431
495
  onSetParameters: n,
432
496
  ignoreForCodec: t
433
497
  });
434
498
  };
435
499
  let r = s;
436
- const a = async (l) => (r = async () => {
437
- const { mainCam: d, resolutionMainCam: f } = l, { connection: m } = e;
438
- if (!m)
500
+ const o = async (u) => (r = async () => {
501
+ const { mainCam: S, resolutionMainCam: g } = u, { connection: f } = e;
502
+ if (!f)
439
503
  throw new Error("connection is not exist");
440
- return V({
441
- mainCam: d,
442
- resolutionMainCam: f,
443
- connection: m,
504
+ return $({
505
+ mainCam: S,
506
+ resolutionMainCam: g,
507
+ connection: f,
444
508
  onSetParameters: n,
445
509
  ignoreForCodec: t
446
510
  });
447
511
  }, r());
448
512
  return {
449
513
  subscribe: () => {
450
- e.onSession("main-cam-control", a);
514
+ e.onSession("main-cam-control", o);
451
515
  },
452
516
  unsubscribe: () => {
453
- e.offSession("main-cam-control", a);
517
+ e.offSession("main-cam-control", o);
454
518
  },
455
519
  balanceByTrack: s,
456
520
  resetMainCamControl() {
@@ -462,20 +526,20 @@ const ce = (e = new Error()) => {
462
526
  };
463
527
  };
464
528
  export {
465
- P as EEventsMainCAM,
466
- cn as EEventsMic,
467
- un as EEventsSyncMediaState,
468
- ln as EUseLicense,
469
- Sn as causes,
470
- mn as constants,
471
- Mn as debug,
472
- Je as default,
473
- dn as disableDebug,
474
- fn as enableDebug,
475
- Cn as eventNames,
476
- ke as getCodecFromSender,
477
- gn as hasCanceledCallError,
478
- rn as resolveVideoSendingBalancer,
479
- Rn as setParametersToSender,
480
- sn as tools
529
+ I as EEventsMainCAM,
530
+ Cn as EEventsMic,
531
+ En as EEventsSyncMediaState,
532
+ Rn as EUseLicense,
533
+ Tn as causes,
534
+ hn as constants,
535
+ vn as debug,
536
+ on as default,
537
+ Mn as disableDebug,
538
+ yn as enableDebug,
539
+ _n as eventNames,
540
+ qe as getCodecFromSender,
541
+ bn as hasCanceledCallError,
542
+ mn as resolveVideoSendingBalancer,
543
+ On as setParametersToSender,
544
+ dn as tools
481
545
  };