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