sip-connector 15.3.1 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +522 -98
- package/dist/@SipConnector-DcaeAFrM.cjs +1 -0
- package/dist/{@SipConnector-5Rac5oq2.js → @SipConnector-uiUlVCMv.js} +955 -395
- package/dist/CallManager/types.d.ts +2 -0
- package/dist/PresentationManager/@PresentationManager.d.ts +5 -3
- package/dist/SipConnector/@SipConnector.d.ts +14 -4
- package/dist/SipConnector/eventNames.d.ts +1 -1
- package/dist/SipConnectorFacade/SipConnectorFacade.d.ts +10 -21
- package/dist/VideoSendingBalancer/SenderBalancer.d.ts +3 -1
- package/dist/VideoSendingBalancer/TrackMonitor.d.ts +38 -0
- package/dist/VideoSendingBalancer/VideoSendingBalancer.d.ts +8 -9
- package/dist/VideoSendingBalancer/VideoSendingEventHandler.d.ts +4 -9
- package/dist/VideoSendingBalancer/__fixtures__/createMockTrack.d.ts +5 -0
- package/dist/VideoSendingBalancer/__fixtures__/index.d.ts +1 -0
- package/dist/VideoSendingBalancer/index.d.ts +1 -2
- package/dist/VideoSendingBalancer/types.d.ts +0 -1
- package/dist/VideoSendingBalancerManager/@VideoSendingBalancerManager.d.ts +47 -0
- package/dist/VideoSendingBalancerManager/eventNames.d.ts +20 -0
- package/dist/VideoSendingBalancerManager/index.d.ts +3 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +281 -748
- package/dist/logger.d.ts +0 -1
- package/dist/tools/setCodecPreferences.d.ts +5 -0
- package/dist/tools/setParametersToSender/index.d.ts +1 -0
- package/package.json +5 -5
- package/dist/@SipConnector-Bv3-Y4Rz.cjs +0 -1
- package/dist/tools/generateSimulcastEncodings.d.ts +0 -7
- package/dist/tools/resolveUpdateTransceiver.d.ts +0 -6
- package/dist/tools/scaleResolutionAndBitrate.d.ts +0 -10
- /package/dist/{PresentationManager → SipConnector}/constants.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
import "events-constructor";
|
|
2
|
-
import { E as
|
|
3
|
-
import { c as
|
|
4
|
-
import { isCanceledError as
|
|
5
|
-
import { hasCanceledError as
|
|
6
|
-
import { debounce as
|
|
7
|
-
import { UAParser as
|
|
8
|
-
import { sequentPromises as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { default as Jn } from "debug";
|
|
12
|
-
const me = (n) => n instanceof Object && ("originator" in n || "cause" in n), Pn = (n) => {
|
|
13
|
-
if (Y(n))
|
|
2
|
+
import { E as h, O as K, l as o, p as X, s as Y, a as G } from "./@SipConnector-uiUlVCMv.js";
|
|
3
|
+
import { c as ke, b as Le, S as xe, f as Ve, d as Be, e as $e, g as He, h as We } from "./@SipConnector-uiUlVCMv.js";
|
|
4
|
+
import { isCanceledError as B } from "@krivega/cancelable-promise";
|
|
5
|
+
import { hasCanceledError as q } from "repeated-calls";
|
|
6
|
+
import { debounce as z } from "ts-debounce";
|
|
7
|
+
import { UAParser as J } from "ua-parser-js";
|
|
8
|
+
import { sequentPromises as Q } from "sequent-promises";
|
|
9
|
+
const Z = (n) => n instanceof Object && ("originator" in n || "cause" in n), Ae = (n) => {
|
|
10
|
+
if (B(n))
|
|
14
11
|
return !0;
|
|
15
|
-
if (!
|
|
12
|
+
if (!Z(n))
|
|
16
13
|
return !1;
|
|
17
14
|
const { originator: e, cause: t } = n;
|
|
18
|
-
return typeof t == "string" ? t ===
|
|
19
|
-
},
|
|
20
|
-
const n = new
|
|
15
|
+
return typeof t == "string" ? t === h.REQUEST_TIMEOUT || t === h.REJECTED || e === K.LOCAL && (t === h.CANCELED || t === h.BYE) : !1;
|
|
16
|
+
}, ee = () => globalThis.process?.versions?.electron !== void 0, $ = () => {
|
|
17
|
+
const n = new J(), { name: e } = n.getBrowser(), t = ee();
|
|
21
18
|
return {
|
|
22
19
|
isChrome: e === "Chrome" || t
|
|
23
20
|
};
|
|
24
|
-
},
|
|
21
|
+
}, D = (n) => {
|
|
25
22
|
const { url: e, cause: t } = n;
|
|
26
23
|
let r = e;
|
|
27
|
-
return (t ===
|
|
24
|
+
return (t === h.BAD_MEDIA_DESCRIPTION || t === h.NOT_FOUND) && (r = `${n.message.to.uri.user}@${n.message.to.uri.host}`), r;
|
|
28
25
|
};
|
|
29
|
-
var
|
|
30
|
-
const
|
|
26
|
+
var H = /* @__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))(H || {});
|
|
27
|
+
const ne = new Error("Unknown error"), te = (n = ne) => {
|
|
31
28
|
const { cause: e, socket: t } = n;
|
|
32
29
|
let r = "CONNECT_SERVER_FAILED";
|
|
33
30
|
switch (e) {
|
|
@@ -35,521 +32,137 @@ const ge = new Error("Unknown error"), pe = (n = ge) => {
|
|
|
35
32
|
r = "WRONG_USER_OR_PASSWORD";
|
|
36
33
|
break;
|
|
37
34
|
}
|
|
38
|
-
case
|
|
35
|
+
case h.BAD_MEDIA_DESCRIPTION: {
|
|
39
36
|
r = "BAD_MEDIA_ERROR";
|
|
40
37
|
break;
|
|
41
38
|
}
|
|
42
|
-
case
|
|
39
|
+
case h.NOT_FOUND: {
|
|
43
40
|
r = "NOT_FOUND_ERROR";
|
|
44
41
|
break;
|
|
45
42
|
}
|
|
46
43
|
default:
|
|
47
|
-
t !== void 0 && t._ws?.readyState === 3 ? r = "WS_CONNECTION_FAILED" :
|
|
44
|
+
t !== void 0 && t._ws?.readyState === 3 ? r = "WS_CONNECTION_FAILED" : D(n) !== void 0 && D(n) !== "" && (r = "CONNECT_SERVER_FAILED_BY_LINK");
|
|
48
45
|
}
|
|
49
46
|
return r;
|
|
50
|
-
},
|
|
47
|
+
}, oe = (n) => {
|
|
51
48
|
let e = "";
|
|
52
49
|
try {
|
|
53
50
|
e = JSON.stringify(n);
|
|
54
51
|
} catch (t) {
|
|
55
|
-
|
|
52
|
+
o("failed to stringify message", t);
|
|
56
53
|
}
|
|
57
54
|
return e;
|
|
58
|
-
},
|
|
59
|
-
const { code: e, cause: t, message: r } = n,
|
|
60
|
-
return typeof r == "object" && r !== null ?
|
|
61
|
-
},
|
|
55
|
+
}, re = new Error("Unknown error"), se = (n = re) => {
|
|
56
|
+
const { code: e, cause: t, message: r } = n, a = D(n), s = { code: "", cause: "", message: "" };
|
|
57
|
+
return typeof r == "object" && r !== null ? s.message = oe(r) : r && (s.message = String(r)), a !== void 0 && a !== "" && (s.link = a), e !== void 0 && e !== "" && (s.code = e), t !== void 0 && t !== "" && (s.cause = t), s;
|
|
58
|
+
}, ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
62
59
|
__proto__: null,
|
|
63
|
-
EErrorTypes:
|
|
64
|
-
getLinkError:
|
|
65
|
-
getTypeFromError:
|
|
66
|
-
getValuesFromError:
|
|
67
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
60
|
+
EErrorTypes: H,
|
|
61
|
+
getLinkError: D,
|
|
62
|
+
getTypeFromError: te,
|
|
63
|
+
getValuesFromError: se
|
|
64
|
+
}, Symbol.toStringTag, { value: "Module" })), ce = ({
|
|
68
65
|
sessionId: n,
|
|
69
66
|
remoteAddress: e,
|
|
70
67
|
isMutedAudio: t,
|
|
71
68
|
isMutedVideo: r,
|
|
72
|
-
isRegistered:
|
|
73
|
-
isPresentationCall:
|
|
69
|
+
isRegistered: a,
|
|
70
|
+
isPresentationCall: s
|
|
74
71
|
}) => {
|
|
75
|
-
const c = [],
|
|
76
|
-
return c.push(`X-Vinteo-Mic-State: ${
|
|
77
|
-
},
|
|
72
|
+
const c = [], u = t ? "0" : "1", l = r ? "0" : "1";
|
|
73
|
+
return c.push(`X-Vinteo-Mic-State: ${u}`, `X-Vinteo-MainCam-State: ${l}`), (a === !1 || a === void 0) && c.push("X-Vinteo-Purgatory-Call: yes"), n !== void 0 && n !== "" && c.push(`X-Vinteo-Session: ${n}`), s === !0 && c.push("X-Vinteo-Presentation-Call: yes"), e !== void 0 && e !== "" && c.push(`X-Vinteo-Remote: ${e}`), c;
|
|
74
|
+
}, ie = "[@*!|]", ue = "_", le = (n) => {
|
|
78
75
|
let e = n;
|
|
79
|
-
return e = e.replaceAll(new RegExp(
|
|
80
|
-
},
|
|
76
|
+
return e = e.replaceAll(new RegExp(ie, "g"), ue), e;
|
|
77
|
+
}, de = ({
|
|
81
78
|
appName: n,
|
|
82
79
|
appVersion: e,
|
|
83
80
|
browserName: t,
|
|
84
81
|
browserVersion: r
|
|
85
82
|
}) => {
|
|
86
|
-
const
|
|
87
|
-
return `ChromeNew - ${t === void 0 ?
|
|
88
|
-
},
|
|
83
|
+
const s = `${le(n)} ${e}`;
|
|
84
|
+
return `ChromeNew - ${t === void 0 ? s : `${t} ${r}, ${s}`}`;
|
|
85
|
+
}, me = ({
|
|
89
86
|
isUnifiedSdpSemantic: n,
|
|
90
87
|
appVersion: e,
|
|
91
88
|
browserName: t,
|
|
92
89
|
browserVersion: r,
|
|
93
|
-
appName:
|
|
94
|
-
}) => n ?
|
|
90
|
+
appName: a
|
|
91
|
+
}) => n ? de({ appVersion: e, browserName: t, browserVersion: r, appName: a }) : "Chrome", W = "purgatory", F = (n) => n === W, Se = (n) => (e) => [...e].map((r) => async () => n(r)), fe = async ({
|
|
95
92
|
accumulatedKeys: n,
|
|
96
93
|
sendKey: e,
|
|
97
94
|
canRunTask: t
|
|
98
95
|
}) => {
|
|
99
|
-
const
|
|
100
|
-
return
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return n;
|
|
106
|
-
}, ee = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, De = ee(), ke = (n, e) => {
|
|
107
|
-
if (De(n, e))
|
|
108
|
-
return n;
|
|
109
|
-
}, Ie = (n, e) => {
|
|
110
|
-
const t = n.maxBitrate, r = ke(e, t);
|
|
111
|
-
return r !== void 0 && (n.maxBitrate = r), n;
|
|
112
|
-
}, ne = 1, Fe = ee(
|
|
113
|
-
ne
|
|
114
|
-
), xe = (n, e) => {
|
|
115
|
-
const t = n === void 0 ? void 0 : Math.max(n, ne);
|
|
116
|
-
if (t !== void 0 && Fe(
|
|
117
|
-
t,
|
|
118
|
-
e
|
|
119
|
-
))
|
|
120
|
-
return t;
|
|
121
|
-
}, Ue = (n, e) => {
|
|
122
|
-
const t = n.scaleResolutionDownBy, r = xe(
|
|
123
|
-
e,
|
|
124
|
-
t
|
|
125
|
-
);
|
|
126
|
-
return r !== void 0 && (n.scaleResolutionDownBy = r), n;
|
|
127
|
-
}, Ve = (n, e) => {
|
|
128
|
-
const t = e.encodings?.length ?? 0;
|
|
129
|
-
return we(n, t), n.encodings.forEach((r, s) => {
|
|
130
|
-
const o = (e?.encodings ?? [])[s], c = o?.maxBitrate, a = o?.scaleResolutionDownBy;
|
|
131
|
-
Ie(r, c), Ue(r, a);
|
|
132
|
-
}), n;
|
|
133
|
-
}, Le = (n, e) => {
|
|
134
|
-
if (n.codecs?.length !== e.codecs?.length)
|
|
135
|
-
return !0;
|
|
136
|
-
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
137
|
-
if (JSON.stringify(n.codecs[t]) !== JSON.stringify(e.codecs[t]))
|
|
138
|
-
return !0;
|
|
139
|
-
if (n.headerExtensions?.length !== e.headerExtensions?.length)
|
|
140
|
-
return !0;
|
|
141
|
-
for (let t = 0; t < (n.headerExtensions?.length ?? 0); t++)
|
|
142
|
-
if (JSON.stringify(n.headerExtensions[t]) !== JSON.stringify(e.headerExtensions[t]))
|
|
143
|
-
return !0;
|
|
144
|
-
if (n.encodings?.length !== e.encodings?.length)
|
|
145
|
-
return !0;
|
|
146
|
-
for (let t = 0; t < (n.encodings?.length ?? 0); t++)
|
|
147
|
-
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
148
|
-
return !0;
|
|
149
|
-
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
150
|
-
}, J = async (n, e) => {
|
|
151
|
-
const t = n.getParameters(), r = JSON.parse(
|
|
152
|
-
JSON.stringify(t)
|
|
153
|
-
);
|
|
154
|
-
Ve(t, e), Oe(t, e);
|
|
155
|
-
const s = Le(r, t);
|
|
156
|
-
return s && await n.setParameters(t), { parameters: t, isChanged: s };
|
|
157
|
-
}, te = async (n, e, t) => {
|
|
158
|
-
const { isChanged: r, parameters: s } = await J(n, {
|
|
159
|
-
encodings: [
|
|
160
|
-
{
|
|
161
|
-
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
162
|
-
maxBitrate: e.maxBitrate
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
});
|
|
166
|
-
return r && t && t(s), { isChanged: r, parameters: s };
|
|
167
|
-
}, He = (n) => (t) => (i("onStartMainCam"), n.on("api:admin-start-main-cam", t)), $e = (n) => (t) => (i("onStartMic"), n.on("api:admin-start-mic", t)), We = (n) => (t) => (i("onStopMainCam"), n.on("api:admin-stop-main-cam", t)), Qe = (n) => (t) => (i("onStopMic"), n.on("api:admin-stop-mic", t)), Je = ({ sipConnector: n }) => {
|
|
168
|
-
const e = (S, C) => ({ isSyncForced: g }) => {
|
|
169
|
-
if (g === !0) {
|
|
170
|
-
S();
|
|
96
|
+
const a = Se(e)(n);
|
|
97
|
+
return Q(a, t);
|
|
98
|
+
}, Ce = (n) => (t) => (o("onStartMainCam"), n.on("api:admin-start-main-cam", t)), pe = (n) => (t) => (o("onStartMic"), n.on("api:admin-start-mic", t)), he = (n) => (t) => (o("onStopMainCam"), n.on("api:admin-stop-main-cam", t)), Re = (n) => (t) => (o("onStopMic"), n.on("api:admin-stop-mic", t)), ge = ({ sipConnector: n }) => {
|
|
99
|
+
const e = (m, f) => ({ isSyncForced: S }) => {
|
|
100
|
+
if (S === !0) {
|
|
101
|
+
m();
|
|
171
102
|
return;
|
|
172
103
|
}
|
|
173
|
-
|
|
174
|
-
}, t =
|
|
175
|
-
let c,
|
|
176
|
-
const
|
|
177
|
-
onStartMainCamForced:
|
|
178
|
-
onStartMainCamNotForced:
|
|
179
|
-
onStopMainCamForced:
|
|
180
|
-
onStopMainCamNotForced:
|
|
181
|
-
onStartMicForced:
|
|
182
|
-
onStartMicNotForced:
|
|
183
|
-
onStopMicForced:
|
|
184
|
-
onStopMicNotForced:
|
|
104
|
+
f();
|
|
105
|
+
}, t = Ce(n), r = he(n), a = pe(n), s = Re(n);
|
|
106
|
+
let c, u, l, p;
|
|
107
|
+
const R = ({
|
|
108
|
+
onStartMainCamForced: m,
|
|
109
|
+
onStartMainCamNotForced: f,
|
|
110
|
+
onStopMainCamForced: S,
|
|
111
|
+
onStopMainCamNotForced: g,
|
|
112
|
+
onStartMicForced: b,
|
|
113
|
+
onStartMicNotForced: v,
|
|
114
|
+
onStopMicForced: _,
|
|
115
|
+
onStopMicNotForced: O
|
|
185
116
|
}) => {
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
117
|
+
const T = e(
|
|
118
|
+
m,
|
|
119
|
+
f
|
|
189
120
|
);
|
|
190
|
-
c = t(
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
121
|
+
c = t(T);
|
|
122
|
+
const M = e(
|
|
123
|
+
S,
|
|
124
|
+
g
|
|
194
125
|
);
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
},
|
|
201
|
-
c?.(),
|
|
126
|
+
u = r(M);
|
|
127
|
+
const P = e(b, v);
|
|
128
|
+
l = a(P);
|
|
129
|
+
const C = e(_, O);
|
|
130
|
+
p = s(C);
|
|
131
|
+
}, d = () => {
|
|
132
|
+
c?.(), u?.(), l?.(), p?.();
|
|
202
133
|
};
|
|
203
134
|
return {
|
|
204
|
-
start: (
|
|
205
|
-
|
|
135
|
+
start: (m) => {
|
|
136
|
+
R(m);
|
|
206
137
|
},
|
|
207
138
|
stop: () => {
|
|
208
|
-
|
|
139
|
+
d();
|
|
209
140
|
}
|
|
210
141
|
};
|
|
211
|
-
},
|
|
142
|
+
}, De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
212
143
|
__proto__: null,
|
|
213
|
-
PURGATORY_CONFERENCE_NUMBER:
|
|
214
|
-
createSyncMediaState:
|
|
215
|
-
createUaParser:
|
|
216
|
-
error:
|
|
217
|
-
getExtraHeaders:
|
|
218
|
-
getUserAgent:
|
|
219
|
-
hasPurgatory:
|
|
220
|
-
prepareMediaStream:
|
|
221
|
-
sendDtmfAccumulated:
|
|
222
|
-
setEncodingsToSender:
|
|
223
|
-
setParametersToSender:
|
|
224
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
225
|
-
|
|
226
|
-
return X(t, e);
|
|
227
|
-
}, $ = 1, ie = ({
|
|
228
|
-
videoTrack: n,
|
|
229
|
-
targetSize: e
|
|
230
|
-
}) => {
|
|
231
|
-
const t = n.getSettings(), r = t.width, s = t.height, o = r === void 0 ? $ : r / e.width, c = s === void 0 ? $ : s / e.height;
|
|
232
|
-
return Math.max(o, c, $);
|
|
233
|
-
}, en = (n) => [...n.keys()].map((e) => n.get(e)), nn = (n, e) => en(n).find((t) => t?.type === e), tn = async (n) => n.getStats().then((e) => nn(e, "codec")?.mimeType);
|
|
234
|
-
class rn {
|
|
235
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
236
|
-
async getCodecFromSender(e) {
|
|
237
|
-
return await tn(e) ?? "";
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
class sn {
|
|
241
|
-
stackPromises = Se({
|
|
242
|
-
noRunIsNotActual: !0
|
|
243
|
-
});
|
|
244
|
-
/**
|
|
245
|
-
* Добавляет задачу в очередь и возвращает Promise с результатом
|
|
246
|
-
* @param task - Функция для выполнения
|
|
247
|
-
* @returns Promise с результатом выполнения задачи
|
|
248
|
-
*/
|
|
249
|
-
async add(e) {
|
|
250
|
-
return this.stackPromises.add(e), this.run();
|
|
251
|
-
}
|
|
252
|
-
stop() {
|
|
253
|
-
this.stackPromises.stop();
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Выполняет задачи из очереди с обработкой ошибок
|
|
257
|
-
* @returns Promise с результатом выполнения
|
|
258
|
-
*/
|
|
259
|
-
async run() {
|
|
260
|
-
return this.stackPromises().catch((e) => {
|
|
261
|
-
i("TaskQueue: error", e);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
class on {
|
|
266
|
-
taskQueue;
|
|
267
|
-
onSetParameters;
|
|
268
|
-
constructor(e) {
|
|
269
|
-
this.onSetParameters = e, this.taskQueue = new sn();
|
|
270
|
-
}
|
|
271
|
-
async setEncodingsToSender(e, t) {
|
|
272
|
-
return this.taskQueue.add(async () => te(e, t, this.onSetParameters));
|
|
273
|
-
}
|
|
274
|
-
stop() {
|
|
275
|
-
this.taskQueue.stop();
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
class cn {
|
|
279
|
-
ignoreForCodec;
|
|
280
|
-
senderFinder;
|
|
281
|
-
codecProvider;
|
|
282
|
-
parametersSetter;
|
|
283
|
-
resultNoChanged = {
|
|
284
|
-
isChanged: !1,
|
|
285
|
-
parameters: {
|
|
286
|
-
encodings: [{}],
|
|
287
|
-
transactionId: "0",
|
|
288
|
-
codecs: [],
|
|
289
|
-
headerExtensions: [],
|
|
290
|
-
rtcp: {}
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
constructor({
|
|
294
|
-
senderFinder: e,
|
|
295
|
-
codecProvider: t,
|
|
296
|
-
parametersSetter: r
|
|
297
|
-
}, s) {
|
|
298
|
-
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = r, this.ignoreForCodec = s.ignoreForCodec;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Выполняет балансировку на основе заголовков от сервера
|
|
302
|
-
* @param connection - RTCPeerConnection для получения отправителей
|
|
303
|
-
* @param headers - Заголовки от сервера с командами управления
|
|
304
|
-
* @returns Promise с результатом балансировки
|
|
305
|
-
*/
|
|
306
|
-
async balance(e, t) {
|
|
307
|
-
const r = e.getSenders(), s = this.senderFinder.findVideoSender(r);
|
|
308
|
-
if (!s?.track)
|
|
309
|
-
return this.resultNoChanged;
|
|
310
|
-
const o = await this.codecProvider.getCodecFromSender(s);
|
|
311
|
-
if (oe(o, this.ignoreForCodec))
|
|
312
|
-
return this.resultNoChanged;
|
|
313
|
-
const { mainCam: c, resolutionMainCam: a } = t ?? {};
|
|
314
|
-
return this.processSender(
|
|
315
|
-
{ mainCam: c, resolutionMainCam: a },
|
|
316
|
-
{
|
|
317
|
-
sender: s,
|
|
318
|
-
codec: o,
|
|
319
|
-
videoTrack: s.track
|
|
320
|
-
}
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Обрабатывает отправитель в зависимости от команды управления
|
|
325
|
-
* @param context - Контекст балансировки
|
|
326
|
-
* @returns Promise с результатом обработки
|
|
327
|
-
*/
|
|
328
|
-
async processSender(e, t) {
|
|
329
|
-
const { mainCam: r, resolutionMainCam: s } = e;
|
|
330
|
-
switch (r) {
|
|
331
|
-
case O.PAUSE_MAIN_CAM:
|
|
332
|
-
return this.downgradeResolutionSender(t);
|
|
333
|
-
case O.RESUME_MAIN_CAM:
|
|
334
|
-
return this.setBitrateByTrackResolution(t);
|
|
335
|
-
case O.MAX_MAIN_CAM_RESOLUTION:
|
|
336
|
-
return s !== void 0 ? this.setResolutionSender(s, t) : this.setBitrateByTrackResolution(t);
|
|
337
|
-
case O.ADMIN_STOP_MAIN_CAM:
|
|
338
|
-
case O.ADMIN_START_MAIN_CAM:
|
|
339
|
-
case void 0:
|
|
340
|
-
return this.setBitrateByTrackResolution(t);
|
|
341
|
-
default:
|
|
342
|
-
return this.setBitrateByTrackResolution(t);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Понижает разрешение отправителя (пауза камеры)
|
|
347
|
-
* @param context - Контекст балансировки
|
|
348
|
-
* @returns Promise с результатом
|
|
349
|
-
*/
|
|
350
|
-
async downgradeResolutionSender(e) {
|
|
351
|
-
const { sender: t, codec: r } = e, s = {
|
|
352
|
-
scaleResolutionDownBy: 200,
|
|
353
|
-
maxBitrate: ze(r)
|
|
354
|
-
};
|
|
355
|
-
return this.parametersSetter.setEncodingsToSender(t, s);
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Устанавливает битрейт на основе разрешения трека
|
|
359
|
-
* @param context - Контекст балансировки
|
|
360
|
-
* @returns Promise с результатом
|
|
361
|
-
*/
|
|
362
|
-
async setBitrateByTrackResolution(e) {
|
|
363
|
-
const { sender: t, videoTrack: r, codec: s } = e, c = r.getSettings().width, a = c === void 0 ? Ze(s) : Q(c, s);
|
|
364
|
-
return this.parametersSetter.setEncodingsToSender(t, {
|
|
365
|
-
scaleResolutionDownBy: 1,
|
|
366
|
-
maxBitrate: a
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Устанавливает разрешение отправителя на основе заголовка
|
|
371
|
-
* @param resolutionMainCam - Разрешение главной камеры
|
|
372
|
-
* @param context - Контекст балансировки
|
|
373
|
-
* @returns Promise с результатом
|
|
374
|
-
*/
|
|
375
|
-
async setResolutionSender(e, t) {
|
|
376
|
-
const [r, s] = e.split("x"), { sender: o, videoTrack: c, codec: a } = t, d = {
|
|
377
|
-
width: Number(r),
|
|
378
|
-
height: Number(s)
|
|
379
|
-
}, l = ie({
|
|
380
|
-
videoTrack: c,
|
|
381
|
-
targetSize: d
|
|
382
|
-
}), f = Q(d.width, a), h = {
|
|
383
|
-
scaleResolutionDownBy: l,
|
|
384
|
-
maxBitrate: f
|
|
385
|
-
};
|
|
386
|
-
return this.parametersSetter.setEncodingsToSender(o, h);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
const an = (n) => n.find((e) => e.track?.kind === "video");
|
|
390
|
-
class dn {
|
|
391
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
392
|
-
findVideoSender(e) {
|
|
393
|
-
return an(e);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
class un {
|
|
397
|
-
sipConnector;
|
|
398
|
-
currentHandler;
|
|
399
|
-
constructor(e) {
|
|
400
|
-
this.sipConnector = e;
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Подписывается на события управления главной камерой
|
|
404
|
-
* @param handler - Обработчик события
|
|
405
|
-
*/
|
|
406
|
-
subscribe(e) {
|
|
407
|
-
this.currentHandler = e, this.sipConnector.on("api:main-cam-control", e);
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Отписывается от событий управления главной камерой
|
|
411
|
-
*/
|
|
412
|
-
unsubscribe() {
|
|
413
|
-
this.currentHandler && (this.sipConnector.off("api:main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Получает соединение из SipConnector
|
|
417
|
-
* @returns RTCPeerConnection или undefined
|
|
418
|
-
*/
|
|
419
|
-
getConnection() {
|
|
420
|
-
return this.sipConnector.connection;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
class ln {
|
|
424
|
-
eventHandler;
|
|
425
|
-
senderBalancer;
|
|
426
|
-
parametersSetterWithQueue;
|
|
427
|
-
serverHeaders;
|
|
428
|
-
constructor(e, { ignoreForCodec: t, onSetParameters: r } = {}) {
|
|
429
|
-
this.eventHandler = new un(e), this.parametersSetterWithQueue = new on(r), this.senderBalancer = new cn(
|
|
430
|
-
{
|
|
431
|
-
senderFinder: new dn(),
|
|
432
|
-
codecProvider: new rn(),
|
|
433
|
-
parametersSetter: this.parametersSetterWithQueue
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
ignoreForCodec: t
|
|
437
|
-
}
|
|
438
|
-
);
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Подписывается на события управления главной камерой
|
|
442
|
-
*/
|
|
443
|
-
subscribe() {
|
|
444
|
-
this.eventHandler.subscribe(this.handleMainCamControl);
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Отписывается от событий и сбрасывает состояние
|
|
448
|
-
*/
|
|
449
|
-
unsubscribe() {
|
|
450
|
-
this.eventHandler.unsubscribe(), this.parametersSetterWithQueue.stop(), this.reset();
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Сбрасывает состояние балансировщика
|
|
454
|
-
*/
|
|
455
|
-
reset() {
|
|
456
|
-
delete this.serverHeaders;
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Перебалансирует текущее состояние
|
|
460
|
-
* @returns Promise с результатом балансировки
|
|
461
|
-
*/
|
|
462
|
-
async reBalance() {
|
|
463
|
-
return this.balanceByTrack();
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Выполняет балансировку на основе текущего состояния
|
|
467
|
-
* @returns Promise с результатом балансировки
|
|
468
|
-
*/
|
|
469
|
-
async balanceByTrack() {
|
|
470
|
-
const e = this.eventHandler.getConnection();
|
|
471
|
-
if (!e)
|
|
472
|
-
throw new Error("connection is not exist");
|
|
473
|
-
return this.senderBalancer.balance(e, this.serverHeaders);
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Обработчик событий управления главной камерой
|
|
477
|
-
* @param headers - Заголовки от сервера
|
|
478
|
-
*/
|
|
479
|
-
handleMainCamControl = (e) => {
|
|
480
|
-
this.serverHeaders = e, this.balanceByTrack().catch(k);
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
const Dn = (n, e = {}) => new ln(n, e), hn = ({
|
|
484
|
-
videoTrack: n,
|
|
485
|
-
targetSize: e,
|
|
486
|
-
codec: t
|
|
487
|
-
}) => {
|
|
488
|
-
const r = ie({
|
|
489
|
-
videoTrack: n,
|
|
490
|
-
targetSize: e
|
|
491
|
-
}), s = Q(e.width, t);
|
|
492
|
-
return { scaleResolutionDownBy: r, maxBitrate: s };
|
|
493
|
-
}, w = ({
|
|
494
|
-
mediaStream: n,
|
|
495
|
-
simulcastEncodings: e,
|
|
496
|
-
sendEncodings: t
|
|
497
|
-
}) => {
|
|
498
|
-
if (e && e.length > 0) {
|
|
499
|
-
const r = t ?? [], s = Xe(n);
|
|
500
|
-
if (s === void 0)
|
|
501
|
-
throw new Error("No video track");
|
|
502
|
-
return e.forEach((o, c) => {
|
|
503
|
-
const a = r[c] ?? {};
|
|
504
|
-
a.active = !0, o.rid !== void 0 && (a.rid = o.rid), o.scalabilityMode !== void 0 && (a.scalabilityMode = o.scalabilityMode);
|
|
505
|
-
const { maxBitrate: d, scaleResolutionDownBy: l } = hn({
|
|
506
|
-
videoTrack: s,
|
|
507
|
-
targetSize: {
|
|
508
|
-
width: o.width,
|
|
509
|
-
height: o.height
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
a.maxBitrate = d, a.scaleResolutionDownBy = l, r[c] = a;
|
|
513
|
-
}), r;
|
|
514
|
-
}
|
|
515
|
-
return t;
|
|
516
|
-
}, fn = (n, e) => n.filter((r) => e.some((s) => s.clockRate === r.clockRate && s.mimeType === r.mimeType && s.channels === r.channels && s.sdpFmtpLine === r.sdpFmtpLine)), Sn = (n) => {
|
|
517
|
-
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), r = e === null ? [] : e.codecs, s = t === null ? [] : t.codecs;
|
|
518
|
-
return fn(r, s);
|
|
519
|
-
}, mn = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, r) => {
|
|
520
|
-
const s = e.indexOf(t.mimeType), o = e.indexOf(r.mimeType), c = s === -1 ? Number.MAX_VALUE : s, a = o === -1 ? Number.MAX_VALUE : o;
|
|
521
|
-
return c - a;
|
|
522
|
-
}), Cn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), gn = (n, {
|
|
523
|
-
preferredMimeTypesVideoCodecs: e,
|
|
524
|
-
excludeMimeTypesVideoCodecs: t
|
|
525
|
-
}) => {
|
|
526
|
-
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
527
|
-
const r = Sn("video"), s = Cn(r, t), o = mn(s, e);
|
|
528
|
-
n.setCodecPreferences(o);
|
|
529
|
-
}
|
|
530
|
-
}, D = (n, {
|
|
531
|
-
preferredMimeTypesVideoCodecs: e,
|
|
532
|
-
excludeMimeTypesVideoCodecs: t
|
|
533
|
-
}) => async (r) => {
|
|
534
|
-
try {
|
|
535
|
-
gn(r, {
|
|
536
|
-
preferredMimeTypesVideoCodecs: e,
|
|
537
|
-
excludeMimeTypesVideoCodecs: t
|
|
538
|
-
}), Object.values(n).filter((o) => o != null).length > 0 && (i("updateTransceiver setParametersToSender", n), await J(r.sender, n));
|
|
539
|
-
} catch (s) {
|
|
540
|
-
i("updateTransceiver error", s);
|
|
541
|
-
}
|
|
542
|
-
}, W = (n) => {
|
|
543
|
-
if (!Y(n) && !ue(n))
|
|
144
|
+
PURGATORY_CONFERENCE_NUMBER: W,
|
|
145
|
+
createSyncMediaState: ge,
|
|
146
|
+
createUaParser: $,
|
|
147
|
+
error: ae,
|
|
148
|
+
getExtraHeaders: ce,
|
|
149
|
+
getUserAgent: me,
|
|
150
|
+
hasPurgatory: F,
|
|
151
|
+
prepareMediaStream: X,
|
|
152
|
+
sendDtmfAccumulated: fe,
|
|
153
|
+
setEncodingsToSender: Y,
|
|
154
|
+
setParametersToSender: G
|
|
155
|
+
}, Symbol.toStringTag, { value: "Module" })), Fe = () => $().isChrome, k = (n) => {
|
|
156
|
+
if (!B(n) && !q(n))
|
|
544
157
|
throw n;
|
|
545
158
|
return { isSuccessful: !1 };
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
},
|
|
159
|
+
}, Ee = ({ kind: n, readyState: e }) => n === "video" && e === "live", L = (n, e, { onEnterPurgatory: t, onEnterConference: r }) => {
|
|
160
|
+
F(n) ? t && t() : r && r({ isSuccessProgressCall: e });
|
|
161
|
+
}, x = (n, e) => {
|
|
549
162
|
n(), e && e();
|
|
550
|
-
},
|
|
163
|
+
}, V = (n, e, t) => {
|
|
551
164
|
throw n && n(), e(), t;
|
|
552
|
-
},
|
|
165
|
+
}, be = /* @__PURE__ */ new Set([
|
|
553
166
|
"on",
|
|
554
167
|
"once",
|
|
555
168
|
"onceRace",
|
|
@@ -566,7 +179,7 @@ const Dn = (n, e = {}) => new ln(n, e), hn = ({
|
|
|
566
179
|
"isConfigured",
|
|
567
180
|
"isRegistered"
|
|
568
181
|
]);
|
|
569
|
-
class
|
|
182
|
+
class we {
|
|
570
183
|
// @ts-expect-error: proxy method
|
|
571
184
|
on;
|
|
572
185
|
// @ts-expect-error: proxy method
|
|
@@ -598,20 +211,15 @@ class kn {
|
|
|
598
211
|
// @ts-expect-error: proxy method
|
|
599
212
|
isRegistered;
|
|
600
213
|
sipConnector;
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
return this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = r, this.sipConnector = e, new Proxy(this, {
|
|
608
|
-
get: (s, o, c) => {
|
|
609
|
-
if (typeof o == "string" && Rn.has(o) && o in this.sipConnector) {
|
|
610
|
-
const d = Reflect.get(this.sipConnector, o, this.sipConnector);
|
|
611
|
-
return typeof d == "function" ? d.bind(this.sipConnector) : d;
|
|
214
|
+
constructor(e) {
|
|
215
|
+
return this.sipConnector = e, new Proxy(this, {
|
|
216
|
+
get: (t, r, a) => {
|
|
217
|
+
if (typeof r == "string" && be.has(r) && r in this.sipConnector) {
|
|
218
|
+
const c = Reflect.get(this.sipConnector, r, this.sipConnector);
|
|
219
|
+
return typeof c == "function" ? c.bind(this.sipConnector) : c;
|
|
612
220
|
}
|
|
613
|
-
const
|
|
614
|
-
return typeof
|
|
221
|
+
const s = Reflect.get(t, r, a);
|
|
222
|
+
return typeof s == "function" ? s.bind(t) : s;
|
|
615
223
|
}
|
|
616
224
|
});
|
|
617
225
|
}
|
|
@@ -619,329 +227,254 @@ class kn {
|
|
|
619
227
|
const {
|
|
620
228
|
userAgent: t,
|
|
621
229
|
sipWebSocketServerURL: r,
|
|
622
|
-
sipServerUrl:
|
|
623
|
-
remoteAddress:
|
|
230
|
+
sipServerUrl: a,
|
|
231
|
+
remoteAddress: s,
|
|
624
232
|
displayName: c,
|
|
625
|
-
name:
|
|
626
|
-
password:
|
|
627
|
-
isRegisteredUser:
|
|
628
|
-
isDisconnectOnFail:
|
|
233
|
+
name: u,
|
|
234
|
+
password: l,
|
|
235
|
+
isRegisteredUser: p,
|
|
236
|
+
isDisconnectOnFail: R
|
|
629
237
|
} = e;
|
|
630
|
-
return
|
|
238
|
+
return o("connectToServer", e), this.sipConnector.connect({
|
|
631
239
|
userAgent: t,
|
|
632
240
|
sipWebSocketServerURL: r,
|
|
633
|
-
sipServerUrl:
|
|
634
|
-
remoteAddress:
|
|
241
|
+
sipServerUrl: a,
|
|
242
|
+
remoteAddress: s,
|
|
635
243
|
displayName: c,
|
|
636
|
-
password:
|
|
637
|
-
user:
|
|
638
|
-
register:
|
|
639
|
-
}).then((
|
|
244
|
+
password: l,
|
|
245
|
+
user: u,
|
|
246
|
+
register: p
|
|
247
|
+
}).then((d) => (o("connectToServer then"), { ua: d, isSuccessful: !0 })).catch(async (d) => (o("connectToServer catch: error", d), R === !0 ? this.sipConnector.disconnect().then(() => k(d)).catch(() => k(d)) : k(d)));
|
|
640
248
|
};
|
|
641
249
|
callToServer = async (e) => {
|
|
642
250
|
const {
|
|
643
251
|
conference: t,
|
|
644
252
|
mediaStream: r,
|
|
645
|
-
extraHeaders:
|
|
646
|
-
iceServers:
|
|
253
|
+
extraHeaders: a,
|
|
254
|
+
iceServers: s,
|
|
647
255
|
contentHint: c,
|
|
648
|
-
|
|
649
|
-
degradationPreference: d,
|
|
256
|
+
degradationPreference: u,
|
|
650
257
|
sendEncodings: l,
|
|
651
|
-
offerToReceiveAudio:
|
|
652
|
-
offerToReceiveVideo:
|
|
653
|
-
directionVideo:
|
|
654
|
-
directionAudio:
|
|
655
|
-
setRemoteStreams:
|
|
656
|
-
onBeforeProgressCall:
|
|
657
|
-
onSuccessProgressCall:
|
|
658
|
-
onEnterPurgatory:
|
|
659
|
-
onEnterConference:
|
|
660
|
-
onFailProgressCall:
|
|
661
|
-
onFinishProgressCall:
|
|
662
|
-
onEndedCall:
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
258
|
+
offerToReceiveAudio: p,
|
|
259
|
+
offerToReceiveVideo: R,
|
|
260
|
+
directionVideo: d,
|
|
261
|
+
directionAudio: A,
|
|
262
|
+
setRemoteStreams: y,
|
|
263
|
+
onBeforeProgressCall: m,
|
|
264
|
+
onSuccessProgressCall: f,
|
|
265
|
+
onEnterPurgatory: S,
|
|
266
|
+
onEnterConference: g,
|
|
267
|
+
onFailProgressCall: b,
|
|
268
|
+
onFinishProgressCall: v,
|
|
269
|
+
onEndedCall: _,
|
|
270
|
+
onAddedTransceiver: O
|
|
271
|
+
} = e, T = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
272
|
+
onReadyRemoteStreams: y
|
|
273
|
+
}), M = this.resolveHandleReadyRemoteStreams({
|
|
666
274
|
onReadyRemoteStreams: () => {
|
|
667
|
-
|
|
275
|
+
T().catch(o);
|
|
668
276
|
}
|
|
669
|
-
})
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
},
|
|
673
|
-
{
|
|
674
|
-
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
675
|
-
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
676
|
-
}
|
|
677
|
-
);
|
|
678
|
-
i("callToServer", e);
|
|
679
|
-
const N = async () => (i("startCall"), this.sipConnector.call({
|
|
277
|
+
});
|
|
278
|
+
o("callToServer", e);
|
|
279
|
+
const P = async () => (o("startCall"), this.sipConnector.call({
|
|
680
280
|
mediaStream: r,
|
|
681
|
-
extraHeaders:
|
|
682
|
-
iceServers:
|
|
281
|
+
extraHeaders: a,
|
|
282
|
+
iceServers: s,
|
|
683
283
|
contentHint: c,
|
|
684
|
-
offerToReceiveAudio:
|
|
685
|
-
offerToReceiveVideo:
|
|
686
|
-
directionVideo:
|
|
687
|
-
directionAudio:
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
sendEncodings: l
|
|
692
|
-
}),
|
|
284
|
+
offerToReceiveAudio: p,
|
|
285
|
+
offerToReceiveVideo: R,
|
|
286
|
+
directionVideo: d,
|
|
287
|
+
directionAudio: A,
|
|
288
|
+
degradationPreference: u,
|
|
289
|
+
onAddedTransceiver: O,
|
|
290
|
+
sendEncodings: l,
|
|
693
291
|
number: t,
|
|
694
|
-
|
|
695
|
-
ontrack: _
|
|
292
|
+
ontrack: M
|
|
696
293
|
}));
|
|
697
|
-
let
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
onEnterPurgatory:
|
|
701
|
-
onEnterConference:
|
|
294
|
+
let C = !1, E;
|
|
295
|
+
const N = (o("subscribeEnterConference: onEnterConference", g), this.sipConnector.on("api:enterRoom", ({ room: i }) => {
|
|
296
|
+
o("enterRoom", { _room: i, isSuccessProgressCall: C }), E = i, (S ?? g) && L(E, C, {
|
|
297
|
+
onEnterPurgatory: S,
|
|
298
|
+
onEnterConference: g
|
|
702
299
|
});
|
|
703
|
-
})),
|
|
704
|
-
|
|
705
|
-
}),
|
|
706
|
-
|
|
300
|
+
})), w = (i) => (o("onSuccess"), C = !0, T().catch(o), f && f({ isPurgatory: F(E) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
|
|
301
|
+
x(N, _);
|
|
302
|
+
}), i), I = (i) => (o("onFail"), V(b, N, i)), U = () => {
|
|
303
|
+
o("onFinish"), v && v();
|
|
707
304
|
};
|
|
708
|
-
return
|
|
305
|
+
return o("onBeforeProgressCall"), m && m(t), P().then(w).catch((i) => I(i)).finally(U);
|
|
709
306
|
};
|
|
710
|
-
disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (
|
|
307
|
+
disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (o("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (o("disconnectFromServer: catch", e), { isSuccessful: !1 }));
|
|
711
308
|
answerToIncomingCall = async (e) => {
|
|
712
309
|
const {
|
|
713
310
|
mediaStream: t,
|
|
714
311
|
extraHeaders: r,
|
|
715
|
-
iceServers:
|
|
716
|
-
contentHint:
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
sendEncodings: d,
|
|
312
|
+
iceServers: a,
|
|
313
|
+
contentHint: s,
|
|
314
|
+
degradationPreference: c,
|
|
315
|
+
sendEncodings: u,
|
|
720
316
|
offerToReceiveAudio: l,
|
|
721
|
-
offerToReceiveVideo:
|
|
722
|
-
directionVideo:
|
|
723
|
-
directionAudio:
|
|
724
|
-
setRemoteStreams:
|
|
725
|
-
onBeforeProgressCall:
|
|
726
|
-
onSuccessProgressCall:
|
|
727
|
-
onEnterPurgatory:
|
|
728
|
-
onEnterConference:
|
|
729
|
-
onFailProgressCall:
|
|
730
|
-
onFinishProgressCall:
|
|
731
|
-
onEndedCall:
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
317
|
+
offerToReceiveVideo: p,
|
|
318
|
+
directionVideo: R,
|
|
319
|
+
directionAudio: d,
|
|
320
|
+
setRemoteStreams: A,
|
|
321
|
+
onBeforeProgressCall: y,
|
|
322
|
+
onSuccessProgressCall: m,
|
|
323
|
+
onEnterPurgatory: f,
|
|
324
|
+
onEnterConference: S,
|
|
325
|
+
onFailProgressCall: g,
|
|
326
|
+
onFinishProgressCall: b,
|
|
327
|
+
onEndedCall: v,
|
|
328
|
+
onAddedTransceiver: _
|
|
329
|
+
} = e, O = this.resolveHandleReadyRemoteStreamsDebounced({
|
|
330
|
+
onReadyRemoteStreams: A
|
|
331
|
+
}), T = this.resolveHandleReadyRemoteStreams({
|
|
735
332
|
onReadyRemoteStreams: () => {
|
|
736
|
-
|
|
333
|
+
O().catch(o);
|
|
737
334
|
}
|
|
738
|
-
})
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
},
|
|
742
|
-
{
|
|
743
|
-
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
744
|
-
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
745
|
-
}
|
|
746
|
-
);
|
|
747
|
-
i("answerToIncomingCall", e);
|
|
748
|
-
const A = async () => this.sipConnector.answerToIncomingCall({
|
|
335
|
+
});
|
|
336
|
+
o("answerToIncomingCall", e);
|
|
337
|
+
const M = async () => this.sipConnector.answerToIncomingCall({
|
|
749
338
|
mediaStream: t,
|
|
750
339
|
extraHeaders: r,
|
|
751
|
-
iceServers:
|
|
752
|
-
contentHint:
|
|
340
|
+
iceServers: a,
|
|
341
|
+
contentHint: s,
|
|
753
342
|
offerToReceiveAudio: l,
|
|
754
|
-
offerToReceiveVideo:
|
|
755
|
-
directionVideo:
|
|
756
|
-
directionAudio:
|
|
757
|
-
|
|
758
|
-
mediaStream: t,
|
|
759
|
-
simulcastEncodings: c,
|
|
760
|
-
sendEncodings: d
|
|
761
|
-
}),
|
|
343
|
+
offerToReceiveVideo: p,
|
|
344
|
+
directionVideo: R,
|
|
345
|
+
directionAudio: d,
|
|
346
|
+
degradationPreference: c,
|
|
762
347
|
onAddedTransceiver: _,
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
348
|
+
sendEncodings: u,
|
|
349
|
+
ontrack: T
|
|
350
|
+
}), P = () => {
|
|
351
|
+
const { remoteCallerData: i } = this.sipConnector;
|
|
352
|
+
return i.incomingNumber;
|
|
767
353
|
};
|
|
768
|
-
let
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
onEnterPurgatory:
|
|
772
|
-
onEnterConference:
|
|
354
|
+
let C = !1, E;
|
|
355
|
+
const N = (o("subscribeEnterConference: onEnterConference", S), this.sipConnector.on("api:enterRoom", (i) => {
|
|
356
|
+
o("enterRoom", { _room: i, isSuccessProgressCall: C }), E = i, (f ?? S) && L(E, C, {
|
|
357
|
+
onEnterPurgatory: f,
|
|
358
|
+
onEnterConference: S
|
|
773
359
|
});
|
|
774
|
-
})),
|
|
775
|
-
|
|
776
|
-
}),
|
|
777
|
-
|
|
360
|
+
})), w = (i) => (o("onSuccess"), C = !0, O().catch(o), m && m({ isPurgatory: F(E) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
|
|
361
|
+
x(N, v);
|
|
362
|
+
}), i), I = (i) => (o("onFail"), V(g, N, i)), U = () => {
|
|
363
|
+
o("onFinish"), b && b();
|
|
778
364
|
};
|
|
779
|
-
if (
|
|
780
|
-
const
|
|
781
|
-
|
|
365
|
+
if (o("onBeforeProgressCall"), y) {
|
|
366
|
+
const i = P();
|
|
367
|
+
y(i);
|
|
782
368
|
}
|
|
783
|
-
return
|
|
369
|
+
return M().then(w).catch((i) => I(i)).finally(U);
|
|
784
370
|
};
|
|
785
371
|
updatePresentation = async ({
|
|
786
372
|
mediaStream: e,
|
|
787
373
|
isP2P: t,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
},
|
|
800
|
-
{
|
|
801
|
-
preferredMimeTypesVideoCodecs: d,
|
|
802
|
-
excludeMimeTypesVideoCodecs: l
|
|
803
|
-
}
|
|
804
|
-
);
|
|
805
|
-
return i("updatePresentation"), this.sipConnector.updatePresentation(e, {
|
|
806
|
-
isP2P: t,
|
|
807
|
-
maxBitrate: r,
|
|
808
|
-
contentHint: s,
|
|
809
|
-
sendEncodings: w({
|
|
810
|
-
mediaStream: e,
|
|
811
|
-
simulcastEncodings: o,
|
|
812
|
-
sendEncodings: a
|
|
813
|
-
}),
|
|
814
|
-
onAddedTransceiver: f
|
|
815
|
-
});
|
|
816
|
-
};
|
|
374
|
+
contentHint: r,
|
|
375
|
+
degradationPreference: a,
|
|
376
|
+
sendEncodings: s,
|
|
377
|
+
onAddedTransceiver: c
|
|
378
|
+
}) => (o("updatePresentation"), this.sipConnector.updatePresentation(e, {
|
|
379
|
+
isP2P: t,
|
|
380
|
+
contentHint: r,
|
|
381
|
+
degradationPreference: a,
|
|
382
|
+
onAddedTransceiver: c,
|
|
383
|
+
sendEncodings: s
|
|
384
|
+
}));
|
|
817
385
|
startPresentation = async ({
|
|
818
386
|
mediaStream: e,
|
|
819
387
|
isP2P: t,
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
preferredMimeTypesVideoCodecs: d,
|
|
835
|
-
excludeMimeTypesVideoCodecs: l
|
|
836
|
-
}
|
|
837
|
-
);
|
|
838
|
-
return i("startPresentation"), this.sipConnector.startPresentation(e, {
|
|
839
|
-
isP2P: t,
|
|
840
|
-
maxBitrate: r,
|
|
841
|
-
contentHint: s,
|
|
842
|
-
callLimit: f,
|
|
843
|
-
sendEncodings: w({
|
|
844
|
-
mediaStream: e,
|
|
845
|
-
simulcastEncodings: o,
|
|
846
|
-
sendEncodings: a
|
|
847
|
-
}),
|
|
848
|
-
onAddedTransceiver: h
|
|
849
|
-
});
|
|
850
|
-
};
|
|
851
|
-
stopShareSipConnector = async ({ isP2P: e = !1 } = {}) => (i("stopShareSipConnector"), this.sipConnector.stopPresentation({
|
|
388
|
+
contentHint: r,
|
|
389
|
+
degradationPreference: a,
|
|
390
|
+
sendEncodings: s,
|
|
391
|
+
callLimit: c,
|
|
392
|
+
onAddedTransceiver: u
|
|
393
|
+
}) => (o("startPresentation"), this.sipConnector.startPresentation(e, {
|
|
394
|
+
isP2P: t,
|
|
395
|
+
contentHint: r,
|
|
396
|
+
callLimit: c,
|
|
397
|
+
degradationPreference: a,
|
|
398
|
+
onAddedTransceiver: u,
|
|
399
|
+
sendEncodings: s
|
|
400
|
+
}));
|
|
401
|
+
stopShareSipConnector = async ({ isP2P: e = !1 } = {}) => (o("stopShareSipConnector"), this.sipConnector.stopPresentation({
|
|
852
402
|
isP2P: e
|
|
853
403
|
}).catch((t) => {
|
|
854
|
-
|
|
404
|
+
o(t);
|
|
855
405
|
}));
|
|
856
406
|
sendRefusalToTurnOnMic = async () => {
|
|
857
|
-
|
|
858
|
-
|
|
407
|
+
o("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
|
|
408
|
+
o("sendRefusalToTurnOnMic: error", e);
|
|
859
409
|
});
|
|
860
410
|
};
|
|
861
411
|
sendRefusalToTurnOnCam = async () => {
|
|
862
|
-
|
|
863
|
-
|
|
412
|
+
o("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
|
|
413
|
+
o("sendRefusalToTurnOnCam: error", e);
|
|
864
414
|
});
|
|
865
415
|
};
|
|
866
416
|
sendMediaState = async ({
|
|
867
417
|
isEnabledCam: e,
|
|
868
418
|
isEnabledMic: t
|
|
869
419
|
}) => {
|
|
870
|
-
|
|
420
|
+
o("sendMediaState"), await this.sipConnector.sendMediaState({ cam: e, mic: t });
|
|
871
421
|
};
|
|
872
422
|
replaceMediaStream = async (e, {
|
|
873
423
|
deleteExisting: t,
|
|
874
424
|
addMissing: r,
|
|
875
|
-
forceRenegotiation:
|
|
876
|
-
contentHint:
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
}) => {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
);
|
|
890
|
-
return i("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
|
|
891
|
-
deleteExisting: t,
|
|
892
|
-
addMissing: r,
|
|
893
|
-
forceRenegotiation: s,
|
|
894
|
-
contentHint: o,
|
|
895
|
-
sendEncodings: w({
|
|
896
|
-
mediaStream: e,
|
|
897
|
-
simulcastEncodings: c,
|
|
898
|
-
sendEncodings: d
|
|
899
|
-
}),
|
|
900
|
-
onAddedTransceiver: l
|
|
901
|
-
});
|
|
902
|
-
};
|
|
425
|
+
forceRenegotiation: a,
|
|
426
|
+
contentHint: s,
|
|
427
|
+
degradationPreference: c,
|
|
428
|
+
sendEncodings: u,
|
|
429
|
+
onAddedTransceiver: l
|
|
430
|
+
}) => (o("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
|
|
431
|
+
deleteExisting: t,
|
|
432
|
+
addMissing: r,
|
|
433
|
+
forceRenegotiation: a,
|
|
434
|
+
contentHint: s,
|
|
435
|
+
degradationPreference: c,
|
|
436
|
+
onAddedTransceiver: l,
|
|
437
|
+
sendEncodings: u
|
|
438
|
+
}));
|
|
903
439
|
askPermissionToEnableCam = async () => {
|
|
904
|
-
|
|
440
|
+
o("askPermissionToEnableCam"), await this.sipConnector.askPermissionToEnableCam();
|
|
905
441
|
};
|
|
906
442
|
resolveHandleReadyRemoteStreamsDebounced = ({
|
|
907
443
|
onReadyRemoteStreams: e
|
|
908
|
-
}) =>
|
|
444
|
+
}) => z(() => {
|
|
909
445
|
const t = this.sipConnector.getRemoteStreams();
|
|
910
|
-
|
|
446
|
+
o("remoteStreams", t), t && e(t);
|
|
911
447
|
}, 200);
|
|
912
448
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
913
449
|
resolveHandleReadyRemoteStreams = ({
|
|
914
450
|
onReadyRemoteStreams: e
|
|
915
451
|
}) => ({ track: t }) => {
|
|
916
|
-
|
|
452
|
+
Ee(t) && e();
|
|
917
453
|
};
|
|
918
|
-
getRemoteStreams = () => (
|
|
919
|
-
onUseLicense = (e) => (
|
|
920
|
-
onMustStopPresentation = (e) => (
|
|
921
|
-
onMoveToSpectators = (e) => (
|
|
922
|
-
onMoveToParticipants = (e) => (
|
|
923
|
-
onStats = (e) => (
|
|
454
|
+
getRemoteStreams = () => (o("getRemoteStreams"), this.sipConnector.getRemoteStreams());
|
|
455
|
+
onUseLicense = (e) => (o("onUseLicense"), this.sipConnector.on("api:useLicense", e));
|
|
456
|
+
onMustStopPresentation = (e) => (o("onMustStopPresentation"), this.sipConnector.on("api:mustStopPresentation", e));
|
|
457
|
+
onMoveToSpectators = (e) => (o("onMoveToSpectators"), this.sipConnector.on("api:participant:move-request-to-spectators", e));
|
|
458
|
+
onMoveToParticipants = (e) => (o("onMoveToParticipants"), this.sipConnector.on("api:participant:move-request-to-participants", e));
|
|
459
|
+
onStats = (e) => (o("onStats"), this.sipConnector.on("stats:collected", e));
|
|
924
460
|
offStats = (e) => {
|
|
925
|
-
|
|
461
|
+
o("offStats"), this.sipConnector.off("stats:collected", e);
|
|
926
462
|
};
|
|
927
463
|
}
|
|
928
|
-
var
|
|
464
|
+
var ve = /* @__PURE__ */ ((n) => (n.VP8 = "video/VP8", n.VP9 = "video/VP9", n.H264 = "video/H264", n.AV1 = "video/AV1", n.rtx = "video/rtx", n.red = "video/red", n.flexfec03 = "video/flexfec-03", n))(ve || {});
|
|
929
465
|
export {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
Wn as hasCanceledStartPresentationError,
|
|
945
|
-
Dn as resolveVideoSendingBalancer,
|
|
946
|
-
On as tools
|
|
466
|
+
h as ECallCause,
|
|
467
|
+
ve as EMimeTypesVideoCodecs,
|
|
468
|
+
ke as EStatsTypes,
|
|
469
|
+
Le as EUseLicense,
|
|
470
|
+
xe as SipConnector,
|
|
471
|
+
we as SipConnectorFacade,
|
|
472
|
+
Ve as StatsPeerConnection,
|
|
473
|
+
Be as disableDebug,
|
|
474
|
+
$e as enableDebug,
|
|
475
|
+
He as getCodecFromSender,
|
|
476
|
+
Fe as hasAvailableStats,
|
|
477
|
+
Ae as hasCanceledCallError,
|
|
478
|
+
We as hasCanceledStartPresentationError,
|
|
479
|
+
De as tools
|
|
947
480
|
};
|