sip-connector 6.20.1 → 6.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SipConnector-3317ff75.cjs +1 -0
- package/dist/SipConnector-abcad4a1.js +1098 -0
- package/dist/SipConnector.d.ts +1 -5
- package/dist/doMock.cjs +1 -0
- package/dist/doMock.d.ts +3 -0
- package/dist/doMock.js +629 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +416 -1371
- package/package.json +8 -6
package/dist/index.js
CHANGED
|
@@ -1,1450 +1,495 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
BUSY: jt,
|
|
17
|
-
BYE: st,
|
|
18
|
-
CANCELED: rt,
|
|
19
|
-
CONNECTION_ERROR: Kt,
|
|
20
|
-
DIALOG_ERROR: En,
|
|
21
|
-
EXPIRES: cn,
|
|
22
|
-
INCOMPATIBLE_SDP: nn,
|
|
23
|
-
INTERNAL_ERROR: Qt,
|
|
24
|
-
MISSING_SDP: sn,
|
|
25
|
-
NOT_FOUND: se,
|
|
26
|
-
NO_ACK: un,
|
|
27
|
-
NO_ANSWER: an,
|
|
28
|
-
REDIRECTED: Zt,
|
|
29
|
-
REJECTED: nt,
|
|
30
|
-
REQUEST_TIMEOUT: tt,
|
|
31
|
-
RTP_TIMEOUT: ln,
|
|
32
|
-
SIP_FAILURE_CODE: Jt,
|
|
33
|
-
UNAVAILABLE: en,
|
|
34
|
-
USER_DENIED_MEDIA_ACCESS: _n,
|
|
35
|
-
WEBRTC_ERROR: on
|
|
36
|
-
}, Symbol.toStringTag, { value: "Module" })), oe = "incomingCall", ie = "declinedIncomingCall", ae = "failedIncomingCall", ce = "terminatedIncomingCall", z = "connecting", V = "connected", D = "disconnected", W = "newRTCSession", L = "registered", ue = "unregistered", B = "registrationFailed", ot = "newMessage", Ee = "sipEvent", _e = "availableSecondRemoteStream", le = "notAvailableSecondRemoteStream", de = "mustStopPresentation", q = "shareState", Se = "enterRoom", he = "useLicense", Te = "peerconnection:confirmed", Ce = "peerconnection:ontrack", $ = "channels", ge = "channels:notify", Ne = "ended:fromserver", me = "main-cam-control", Re = "admin-stop-main-cam", Ae = "admin-start-main-cam", fe = "admin-stop-mic", Ie = "admin-start-mic", x = "admin-force-sync-media-state", Me = "participant:added-to-list-moderators", Oe = "participant:removed-from-list-moderators", Pe = "participant:move-request-to-conference", De = "participant:move-request-to-stream", pe = "participant:canceling-word-request", ve = "webcast:started", ye = "webcast:stopped", be = "account:changed", we = "account:deleted", Ue = "conference:participant-token-issued", F = "ended", it = "sending", at = "reinvite", ct = "replaces", ut = "refer", Et = "progress", _t = "accepted", Y = "confirmed", G = "peerconnection", y = "failed", lt = "muted", dt = "unmuted", Le = "newDTMF", Be = "newInfo", St = "hold", ht = "unhold", Tt = "update", Ct = "sdp", gt = "icecandidate", Nt = "getusermediafailed", mt = "peerconnection:createofferfailed", Rt = "peerconnection:createanswerfailed", At = "peerconnection:setlocaldescriptionfailed", ft = "peerconnection:setremotedescriptionfailed", It = "presentation:start", Mt = "presentation:started", Ot = "presentation:end", Fe = "presentation:ended", X = "presentation:failed", Er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
37
|
-
__proto__: null,
|
|
38
|
-
ACCEPTED: _t,
|
|
39
|
-
ACCOUNT_CHANGED: be,
|
|
40
|
-
ACCOUNT_DELETED: we,
|
|
41
|
-
ADMIN_FORCE_SYNC_MEDIA_STATE: x,
|
|
42
|
-
ADMIN_START_MAIN_CAM: Ae,
|
|
43
|
-
ADMIN_START_MIC: Ie,
|
|
44
|
-
ADMIN_STOP_MAIN_CAM: Re,
|
|
45
|
-
ADMIN_STOP_MIC: fe,
|
|
46
|
-
AVAILABLE_SECOND_REMOTE_STREAM_EVENT: _e,
|
|
47
|
-
CHANNELS: $,
|
|
48
|
-
CHANNELS_NOTIFY: ge,
|
|
49
|
-
CONFERENCE_PARTICIPANT_TOKEN_ISSUED: Ue,
|
|
50
|
-
CONFIRMED: Y,
|
|
51
|
-
CONNECTED: V,
|
|
52
|
-
CONNECTING: z,
|
|
53
|
-
DECLINED_INCOMING_CALL: ie,
|
|
54
|
-
DISCONNECTED: D,
|
|
55
|
-
ENDED: F,
|
|
56
|
-
ENDED_FROM_SERVER: Ne,
|
|
57
|
-
ENTER_ROOM: Se,
|
|
58
|
-
FAILED: y,
|
|
59
|
-
FAILED_INCOMING_CALL: ae,
|
|
60
|
-
GET_USER_MEDIA_FAILED: Nt,
|
|
61
|
-
HOLD: St,
|
|
62
|
-
ICE_CANDIDATE: gt,
|
|
63
|
-
INCOMING_CALL: oe,
|
|
64
|
-
MAIN_CAM_CONTROL: me,
|
|
65
|
-
MUST_STOP_PRESENTATION_EVENT: de,
|
|
66
|
-
MUTED: lt,
|
|
67
|
-
NEW_DTMF: Le,
|
|
68
|
-
NEW_INFO: Be,
|
|
69
|
-
NEW_MESSAGE: ot,
|
|
70
|
-
NEW_RTC_SESSION: W,
|
|
71
|
-
NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: le,
|
|
72
|
-
PARTICIPANT_ADDED_TO_LIST_MODERATORS: Me,
|
|
73
|
-
PARTICIPANT_CANCELLING_WORD_REQUEST: pe,
|
|
74
|
-
PARTICIPANT_MOVE_REQUEST_TO_CONFERENCE: Pe,
|
|
75
|
-
PARTICIPANT_MOVE_REQUEST_TO_STREAM: De,
|
|
76
|
-
PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: Oe,
|
|
77
|
-
PEER_CONNECTION: G,
|
|
78
|
-
PEER_CONNECTION_CONFIRMED: Te,
|
|
79
|
-
PEER_CONNECTION_CREATE_ANSWER_FAILED: Rt,
|
|
80
|
-
PEER_CONNECTION_CREATE_OFFER_FAILED: mt,
|
|
81
|
-
PEER_CONNECTION_ONTRACK: Ce,
|
|
82
|
-
PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED: At,
|
|
83
|
-
PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED: ft,
|
|
84
|
-
PRESENTATION_END: Ot,
|
|
85
|
-
PRESENTATION_ENDED: Fe,
|
|
86
|
-
PRESENTATION_FAILED: X,
|
|
87
|
-
PRESENTATION_START: It,
|
|
88
|
-
PRESENTATION_STARTED: Mt,
|
|
89
|
-
PROGRESS: Et,
|
|
90
|
-
REFER: ut,
|
|
91
|
-
REGISTERED: L,
|
|
92
|
-
REGISTRATION_FAILED: B,
|
|
93
|
-
REINVITE: at,
|
|
94
|
-
REPLACES: ct,
|
|
95
|
-
SDP: Ct,
|
|
96
|
-
SENDING: it,
|
|
97
|
-
SHARE_STATE: q,
|
|
98
|
-
SIP_EVENT: Ee,
|
|
99
|
-
TERMINATED_INCOMING_CALL: ce,
|
|
100
|
-
UNHOLD: ht,
|
|
101
|
-
UNMUTED: dt,
|
|
102
|
-
UNREGISTERED: ue,
|
|
103
|
-
UPDATE: Tt,
|
|
104
|
-
USE_LICENSE: he,
|
|
105
|
-
WEBCAST_STARTED: ve,
|
|
106
|
-
WEBCAST_STOPPED: ye
|
|
107
|
-
}, Symbol.toStringTag, { value: "Module" })), Pt = [
|
|
108
|
-
oe,
|
|
109
|
-
ie,
|
|
110
|
-
ce,
|
|
111
|
-
ae,
|
|
112
|
-
pe,
|
|
113
|
-
De,
|
|
114
|
-
Pe,
|
|
115
|
-
ge,
|
|
116
|
-
Ue,
|
|
117
|
-
be,
|
|
118
|
-
we,
|
|
119
|
-
ve,
|
|
120
|
-
ye,
|
|
121
|
-
Me,
|
|
122
|
-
Oe
|
|
123
|
-
], ke = [
|
|
124
|
-
z,
|
|
125
|
-
V,
|
|
126
|
-
D,
|
|
127
|
-
W,
|
|
128
|
-
L,
|
|
129
|
-
ue,
|
|
130
|
-
B,
|
|
131
|
-
ot,
|
|
132
|
-
Ee
|
|
133
|
-
], Dt = [
|
|
134
|
-
_e,
|
|
135
|
-
le,
|
|
136
|
-
de,
|
|
137
|
-
q,
|
|
138
|
-
Se,
|
|
139
|
-
he,
|
|
140
|
-
Te,
|
|
141
|
-
Ce,
|
|
142
|
-
$,
|
|
143
|
-
Ne,
|
|
144
|
-
me,
|
|
145
|
-
Ae,
|
|
146
|
-
Re,
|
|
147
|
-
fe,
|
|
148
|
-
Ie,
|
|
149
|
-
x
|
|
150
|
-
], He = [
|
|
151
|
-
F,
|
|
152
|
-
z,
|
|
153
|
-
it,
|
|
154
|
-
at,
|
|
155
|
-
ct,
|
|
156
|
-
ut,
|
|
157
|
-
Et,
|
|
158
|
-
_t,
|
|
159
|
-
Y,
|
|
160
|
-
G,
|
|
161
|
-
y,
|
|
162
|
-
lt,
|
|
163
|
-
dt,
|
|
164
|
-
Le,
|
|
165
|
-
Be,
|
|
166
|
-
St,
|
|
167
|
-
ht,
|
|
168
|
-
Tt,
|
|
169
|
-
Ct,
|
|
170
|
-
gt,
|
|
171
|
-
Nt,
|
|
172
|
-
mt,
|
|
173
|
-
Rt,
|
|
174
|
-
At,
|
|
175
|
-
ft,
|
|
176
|
-
It,
|
|
177
|
-
Mt,
|
|
178
|
-
Ot,
|
|
179
|
-
Fe,
|
|
180
|
-
X
|
|
181
|
-
], pt = [...ke, ...Pt], vt = [
|
|
182
|
-
...He,
|
|
183
|
-
...Dt
|
|
184
|
-
], _r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
185
|
-
__proto__: null,
|
|
186
|
-
SESSION_EVENT_NAMES: vt,
|
|
187
|
-
SESSION_JSSIP_EVENT_NAMES: He,
|
|
188
|
-
SESSION_SYNTHETICS_EVENT_NAMES: Dt,
|
|
189
|
-
UA_EVENT_NAMES: pt,
|
|
190
|
-
UA_JSSIP_EVENT_NAMES: ke,
|
|
191
|
-
UA_SYNTHETICS_EVENT_NAMES: Pt
|
|
192
|
-
}, Symbol.toStringTag, { value: "Module" })), dn = (n) => {
|
|
193
|
-
const e = [];
|
|
194
|
-
return n && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
195
|
-
}, Sn = "content-type", hn = "x-webrtc-enter-room", K = "application/vinteo.webrtc.sharedesktop", Tn = "application/vinteo.webrtc.roomname", Cn = "application/vinteo.webrtc.channels", gn = "application/vinteo.webrtc.mediastate", Nn = "application/vinteo.webrtc.refusal", Ge = "application/vinteo.webrtc.maincam", mn = "application/vinteo.webrtc.mic", Rn = "application/vinteo.webrtc.uselic", An = "X-WEBRTC-USE-LICENSE", Xe = "X-WEBRTC-INPUT-CHANNELS", ze = "X-WEBRTC-OUTPUT-CHANNELS", fn = "X-WEBRTC-MAINCAM", In = "X-WEBRTC-MIC", Ke = "X-WEBRTC-SYNC", Mn = "X-WEBRTC-MAINCAM-RESOLUTION", On = "X-WEBRTC-MEDIA-STATE", Pn = "X-Vinteo-Media-Type", Dn = "X-Vinteo-MainCam-State", pn = "X-Vinteo-Mic-State", vn = "application/vinteo.webrtc.notify", yn = "X-VINTEO-NOTIFY", H = "x-webrtc-share-state", bn = `${H}: LETMESTARTPRESENTATION`, wn = `${H}: STOPPRESENTATION`, yt = "YOUCANRECEIVECONTENT", bt = "CONTENTEND", Un = "YOUMUSTSTOPSENDCONTENT", Ln = `${H}: ${yt}`, Bn = `${H}: ${bt}`, Fn = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", kn = `${Fn}: LETMESTARTMAINCAM`, Ve = "sip-connector", E = ne(Ve), lr = () => {
|
|
196
|
-
ne.enable(`${Ve}`);
|
|
197
|
-
}, dr = () => {
|
|
198
|
-
ne.enable(`-${Ve}`);
|
|
199
|
-
};
|
|
200
|
-
var I = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(I || {}), Z = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(Z || {}), ee = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(ee || {}), Hn = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Hn || {});
|
|
201
|
-
function Vn(n) {
|
|
202
|
-
return (e) => `sip:${e}@${n}`;
|
|
203
|
-
}
|
|
204
|
-
const Wn = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Je = (n) => n.trim().replaceAll(" ", "_"), qn = Wn(1e5, 99999999), J = (n, {
|
|
205
|
-
videoMode: e,
|
|
206
|
-
audioMode: t
|
|
207
|
-
} = {}) => {
|
|
208
|
-
if (!n || e === "recvonly" && t === "recvonly")
|
|
209
|
-
return;
|
|
210
|
-
const s = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), o = [...s, ...r], i = new MediaStream(o);
|
|
211
|
-
return i.getTracks = () => [...i.getAudioTracks(), ...i.getVideoTracks()], i;
|
|
212
|
-
}, $n = (n) => n.some((t) => {
|
|
213
|
-
const { kind: s } = t;
|
|
214
|
-
return s === "video";
|
|
215
|
-
}), xn = "Error decline with 603", Yn = (n) => n.message === xn, Gn = (n, e) => n.find((t) => t.track && e.getTracks().includes(t.track)), wt = 1, Ut = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Xn = Ut(
|
|
216
|
-
wt
|
|
217
|
-
), zn = (n, e) => {
|
|
218
|
-
const t = n === void 0 ? void 0 : Math.max(n, wt);
|
|
219
|
-
if (t !== void 0 && Xn(
|
|
220
|
-
t,
|
|
221
|
-
e
|
|
222
|
-
))
|
|
223
|
-
return t;
|
|
224
|
-
}, Kn = Ut(), Jn = (n, e) => {
|
|
225
|
-
if (Kn(n, e))
|
|
226
|
-
return n;
|
|
227
|
-
}, Lt = async (n, e, t) => {
|
|
228
|
-
const s = n.getParameters();
|
|
229
|
-
(s.encodings === void 0 || s.encodings.length === 0) && (s.encodings = [{}]);
|
|
230
|
-
const [r] = s.encodings, o = r.scaleResolutionDownBy, i = zn(
|
|
231
|
-
e.scaleResolutionDownBy,
|
|
232
|
-
o
|
|
233
|
-
);
|
|
234
|
-
let c = !1;
|
|
235
|
-
i !== void 0 && (s.encodings[0].scaleResolutionDownBy = i, c = !0);
|
|
236
|
-
const u = r.maxBitrate, _ = Jn(e.maxBitrate, u);
|
|
237
|
-
return _ !== void 0 && (s.encodings[0].maxBitrate = _, c = !0), c ? (t && t(s), n.setParameters(s).then(() => ({ parameters: s, isChanged: c }))) : { parameters: s, isChanged: c };
|
|
238
|
-
}, Qn = async (n, e, t) => {
|
|
239
|
-
const s = Gn(n, e);
|
|
240
|
-
if (s)
|
|
241
|
-
return Lt(s, { maxBitrate: t });
|
|
242
|
-
}, jn = 486, Zn = 487, te = "local", Qe = "remote", Sr = (n = new Error()) => {
|
|
243
|
-
const { originator: e, cause: t } = n;
|
|
244
|
-
return et(n) ? !0 : typeof t == "string" ? t === tt || t === nt || e === te && (t === rt || t === st) : !1;
|
|
245
|
-
}, P = "SipConnector", es = "channels", ts = "WebcastStarted", ns = "WebcastStopped", ss = "accountChanged", rs = "accountDeleted", os = "addedToListModerators", is = "removedFromListModerators", as = "WebcastParticipationAccepted", cs = "WebcastParticipationRejected", us = "ParticipantMovedToWebcast", Es = "ConferenceParticipantTokenIssued";
|
|
246
|
-
class hr {
|
|
247
|
-
constructor({ JsSIP: e }) {
|
|
248
|
-
a(this, "_isRegisterConfig", !1);
|
|
249
|
-
a(this, "_connectionConfiguration", {});
|
|
250
|
-
a(this, "_remoteStreams", {});
|
|
251
|
-
a(this, "JsSIP");
|
|
252
|
-
a(this, "_sessionEvents");
|
|
253
|
-
a(this, "_uaEvents");
|
|
254
|
-
a(this, "_cancelableConnect");
|
|
255
|
-
a(this, "_cancelableCreateUa");
|
|
256
|
-
a(this, "_cancelableDisconnect");
|
|
257
|
-
a(this, "_cancelableSet");
|
|
258
|
-
a(this, "_cancelableCall");
|
|
259
|
-
a(this, "_cancelableAnswer");
|
|
260
|
-
a(this, "_cancelableSendDTMF");
|
|
261
|
-
a(this, "getSipServerUrl", (e) => e);
|
|
262
|
-
a(this, "promisePendingStartPresentation");
|
|
263
|
-
a(this, "promisePendingStopPresentation");
|
|
264
|
-
a(this, "ua");
|
|
265
|
-
a(this, "session");
|
|
266
|
-
a(this, "incomingSession");
|
|
267
|
-
a(this, "_streamPresentationCurrent");
|
|
268
|
-
a(this, "socket");
|
|
269
|
-
a(this, "connect", async (e) => (this._cancelRequests(), this._cancelableConnect.request(e)));
|
|
270
|
-
a(this, "createUa", async (e) => this._cancelableCreateUa.request(e));
|
|
271
|
-
a(this, "set", async (e) => this._cancelableSet.request(e));
|
|
272
|
-
a(this, "call", async (e) => this._cancelableCall.request(e));
|
|
273
|
-
a(this, "disconnect", async () => (this._cancelRequests(), this._disconnectWithoutCancelRequests()));
|
|
274
|
-
a(this, "answerToIncomingCall", async (e) => this._cancelableAnswer.request(e));
|
|
275
|
-
a(this, "sendDTMF", async (e) => this._cancelableSendDTMF.request(e));
|
|
276
|
-
a(this, "hangUp", async () => (this._cancelRequests(), this._hangUpWithoutCancelRequests()));
|
|
277
|
-
a(this, "tryRegister", async () => {
|
|
278
|
-
if (!this.isRegisterConfig)
|
|
279
|
-
throw new Error("Config is not registered");
|
|
280
|
-
this._uaEvents.trigger(z, void 0);
|
|
281
|
-
try {
|
|
282
|
-
await this.unregister();
|
|
283
|
-
} catch (e) {
|
|
284
|
-
E("tryRegister", e);
|
|
285
|
-
}
|
|
286
|
-
return this.register();
|
|
287
|
-
});
|
|
288
|
-
a(this, "declineToIncomingCall", async ({ statusCode: e = Zn } = {}) => new Promise((t, s) => {
|
|
289
|
-
if (!this.isAvailableIncomingCall) {
|
|
290
|
-
s(new Error("no incomingSession"));
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const r = this.incomingSession, o = this.remoteCallerData;
|
|
294
|
-
this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(ie, o), t(r.terminate({ status_code: e }));
|
|
295
|
-
}));
|
|
296
|
-
a(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode: jn }));
|
|
297
|
-
a(this, "removeIncomingSession", () => {
|
|
298
|
-
delete this.incomingSession;
|
|
299
|
-
});
|
|
300
|
-
a(this, "handleNewRTCSession", ({ originator: e, session: t }) => {
|
|
301
|
-
if (e === Qe) {
|
|
302
|
-
this.incomingSession = t;
|
|
303
|
-
const s = this.remoteCallerData;
|
|
304
|
-
t.on(y, (r) => {
|
|
305
|
-
this.removeIncomingSession(), r.originator === te ? this._uaEvents.trigger(ce, s) : this._uaEvents.trigger(ae, s);
|
|
306
|
-
}), this._uaEvents.trigger(oe, s);
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
a(this, "_connect", async (e) => this.createUa(e).then(async () => this._start()));
|
|
310
|
-
a(this, "_createUa", async ({
|
|
311
|
-
displayName: e = "",
|
|
312
|
-
user: t,
|
|
313
|
-
password: s,
|
|
314
|
-
register: r = !1,
|
|
315
|
-
sipServerUrl: o,
|
|
316
|
-
sipWebSocketServerURL: i,
|
|
317
|
-
remoteAddress: c,
|
|
318
|
-
extraHeaders: u = [],
|
|
319
|
-
sdpSemantics: _ = "plan-b",
|
|
320
|
-
sessionTimers: l = !1,
|
|
321
|
-
registerExpires: d = 60 * 5,
|
|
322
|
-
// 5 minutes in sec
|
|
323
|
-
connectionRecoveryMinInterval: S = 2,
|
|
324
|
-
connectionRecoveryMaxInterval: h = 6,
|
|
325
|
-
userAgent: T
|
|
326
|
-
}) => {
|
|
327
|
-
if (!o)
|
|
328
|
-
throw new Error("sipServerUrl is required");
|
|
329
|
-
if (!i)
|
|
330
|
-
throw new Error("sipWebSocketServerURL is required");
|
|
331
|
-
if (r && !t)
|
|
332
|
-
throw new Error("user is required for authorized connection");
|
|
333
|
-
if (r && !s)
|
|
334
|
-
throw new Error("password is required for authorized connection");
|
|
335
|
-
this._connectionConfiguration = {
|
|
336
|
-
sipServerUrl: o,
|
|
337
|
-
displayName: e,
|
|
338
|
-
register: r,
|
|
339
|
-
user: t,
|
|
340
|
-
password: s
|
|
341
|
-
}, this._init({ sipServerUrl: o, sipWebSocketServerURL: i });
|
|
342
|
-
const g = r && t ? t.trim() : `${qn()}`, N = {
|
|
343
|
-
password: s,
|
|
344
|
-
register: r,
|
|
345
|
-
display_name: Je(e),
|
|
346
|
-
user_agent: T,
|
|
347
|
-
sdp_semantics: _,
|
|
348
|
-
sockets: [this.socket],
|
|
349
|
-
uri: this.getSipServerUrl(g),
|
|
350
|
-
session_timers: l,
|
|
351
|
-
register_expires: d,
|
|
352
|
-
connection_recovery_min_interval: S,
|
|
353
|
-
connection_recovery_max_interval: h
|
|
354
|
-
};
|
|
355
|
-
this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!N.register, this.ua = new this.JsSIP.UA(N), this._uaEvents.eachTriggers((m, R) => {
|
|
356
|
-
const v = ke.find((f) => f === R);
|
|
357
|
-
v && this.ua && this.ua.on(v, m);
|
|
358
|
-
});
|
|
359
|
-
const M = [...dn(c), ...u];
|
|
360
|
-
return this.ua.registrator().setExtraHeaders(M), this.ua;
|
|
361
|
-
});
|
|
362
|
-
a(this, "_start", async () => new Promise((e, t) => {
|
|
363
|
-
const { ua: s } = this;
|
|
364
|
-
if (!s) {
|
|
365
|
-
t(new Error("this.ua is not initialized"));
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
const r = () => {
|
|
369
|
-
c(), e(s);
|
|
370
|
-
}, o = (u) => {
|
|
371
|
-
c(), t(u);
|
|
372
|
-
}, i = () => {
|
|
373
|
-
this.isRegisterConfig ? (this.on(L, r), this.on(B, o)) : this.on(V, r), this.on(D, o);
|
|
374
|
-
}, c = () => {
|
|
375
|
-
this.off(L, r), this.off(B, o), this.off(V, r), this.off(D, o);
|
|
376
|
-
};
|
|
377
|
-
i(), this.on(W, this.handleNewRTCSession), s.start();
|
|
378
|
-
}));
|
|
379
|
-
a(this, "_set", async ({ displayName: e, password: t }) => new Promise((s, r) => {
|
|
380
|
-
const { ua: o } = this;
|
|
381
|
-
if (!o) {
|
|
382
|
-
r(new Error("this.ua is not initialized"));
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
let i = !1, c = !1;
|
|
386
|
-
e !== void 0 && e !== this._connectionConfiguration.displayName && (i = o.set("display_name", Je(e)), this._connectionConfiguration.displayName = e), t !== void 0 && t !== this._connectionConfiguration.password && (c = o.set("password", t), this._connectionConfiguration.password = t);
|
|
387
|
-
const u = i || c;
|
|
388
|
-
c && this.isRegisterConfig ? this.register().then(() => {
|
|
389
|
-
s(u);
|
|
390
|
-
}).catch(r) : u ? s(u) : r(u);
|
|
391
|
-
}));
|
|
392
|
-
a(this, "_disconnectWithoutCancelRequests", async () => this._cancelableDisconnect.request());
|
|
393
|
-
a(this, "_disconnect", async () => {
|
|
394
|
-
this.off(W, this.handleNewRTCSession);
|
|
395
|
-
const e = new Promise((t) => {
|
|
396
|
-
this.once(D, () => {
|
|
397
|
-
delete this.ua, t();
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
return this.ua ? (await this._hangUpWithoutCancelRequests(), this.ua ? this.ua.stop() : this._uaEvents.trigger(D, void 0)) : this._uaEvents.trigger(D, void 0), e;
|
|
401
|
-
});
|
|
402
|
-
a(this, "_call", async ({
|
|
403
|
-
number: e,
|
|
404
|
-
mediaStream: t,
|
|
405
|
-
extraHeaders: s = [],
|
|
406
|
-
ontrack: r,
|
|
407
|
-
iceServers: o,
|
|
408
|
-
videoMode: i,
|
|
409
|
-
audioMode: c,
|
|
410
|
-
degradationPreference: u,
|
|
411
|
-
offerToReceiveAudio: _ = !0,
|
|
412
|
-
offerToReceiveVideo: l = !0
|
|
413
|
-
}) => new Promise((d, S) => {
|
|
414
|
-
const { ua: h } = this;
|
|
415
|
-
if (!h) {
|
|
416
|
-
S(new Error("this.ua is not initialized"));
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
this._connectionConfiguration.number = e, this._connectionConfiguration.answer = !1, this._handleCall({ ontrack: r }).then(d).catch(S), this.session = h.call(this.getSipServerUrl(e), {
|
|
420
|
-
extraHeaders: s,
|
|
421
|
-
mediaStream: J(t, {
|
|
422
|
-
videoMode: i,
|
|
423
|
-
audioMode: c
|
|
424
|
-
}),
|
|
425
|
-
eventHandlers: this._sessionEvents.triggers,
|
|
426
|
-
videoMode: i,
|
|
427
|
-
audioMode: c,
|
|
428
|
-
degradationPreference: u,
|
|
429
|
-
pcConfig: {
|
|
430
|
-
iceServers: o
|
|
431
|
-
},
|
|
432
|
-
rtcOfferConstraints: {
|
|
433
|
-
offerToReceiveAudio: _,
|
|
434
|
-
offerToReceiveVideo: l
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
}));
|
|
438
|
-
a(this, "_answer", async ({
|
|
439
|
-
mediaStream: e,
|
|
440
|
-
ontrack: t,
|
|
441
|
-
extraHeaders: s = [],
|
|
442
|
-
iceServers: r,
|
|
443
|
-
videoMode: o,
|
|
444
|
-
audioMode: i,
|
|
445
|
-
degradationPreference: c
|
|
446
|
-
}) => new Promise((u, _) => {
|
|
447
|
-
if (!this.isAvailableIncomingCall) {
|
|
448
|
-
_(new Error("no incomingSession"));
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
this.session = this.incomingSession, this.removeIncomingSession();
|
|
452
|
-
const { session: l } = this;
|
|
453
|
-
if (!l) {
|
|
454
|
-
_(new Error("No session established"));
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
this._sessionEvents.eachTriggers((S, h) => {
|
|
458
|
-
const T = He.find((g) => g === h);
|
|
459
|
-
T && l.on(T, S);
|
|
460
|
-
}), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = l.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(u).catch(_);
|
|
461
|
-
const d = J(e, {
|
|
462
|
-
videoMode: o,
|
|
463
|
-
audioMode: i
|
|
464
|
-
});
|
|
465
|
-
l.answer({
|
|
466
|
-
extraHeaders: s,
|
|
467
|
-
videoMode: o,
|
|
468
|
-
audioMode: i,
|
|
469
|
-
degradationPreference: c,
|
|
470
|
-
mediaStream: d,
|
|
471
|
-
pcConfig: {
|
|
472
|
-
iceServers: r
|
|
473
|
-
}
|
|
474
|
-
});
|
|
475
|
-
}));
|
|
476
|
-
a(this, "_handleCall", async ({ ontrack: e }) => new Promise((t, s) => {
|
|
477
|
-
const r = () => {
|
|
478
|
-
this.onSession(G, l), this.onSession(Y, d);
|
|
479
|
-
}, o = () => {
|
|
480
|
-
this.offSession(G, l), this.offSession(Y, d);
|
|
481
|
-
}, i = () => {
|
|
482
|
-
this.onSession(y, u), this.onSession(F, u);
|
|
483
|
-
}, c = () => {
|
|
484
|
-
this.offSession(y, u), this.offSession(F, u);
|
|
485
|
-
}, u = (S) => {
|
|
486
|
-
o(), c(), s(S);
|
|
487
|
-
};
|
|
488
|
-
let _;
|
|
489
|
-
const l = ({ peerconnection: S }) => {
|
|
490
|
-
_ = S, _.ontrack = (h) => {
|
|
491
|
-
this._sessionEvents.trigger(Ce, _), e && e(h);
|
|
492
|
-
};
|
|
493
|
-
}, d = () => {
|
|
494
|
-
_ && this._sessionEvents.trigger(Te, _), o(), c(), t(_);
|
|
495
|
-
};
|
|
496
|
-
r(), i();
|
|
497
|
-
}));
|
|
498
|
-
a(this, "_restoreSession", () => {
|
|
499
|
-
this._resetPresentation(), delete this._connectionConfiguration.number, delete this.session, this._remoteStreams = {};
|
|
500
|
-
});
|
|
501
|
-
a(this, "_sendDTMF", async (e) => new Promise((t, s) => {
|
|
502
|
-
const { session: r } = this;
|
|
503
|
-
if (!r) {
|
|
504
|
-
s(new Error("No session established"));
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
this.onceSession(Le, ({ originator: o }) => {
|
|
508
|
-
o === te && t();
|
|
509
|
-
}), r.sendDTMF(e, {
|
|
510
|
-
duration: 120,
|
|
511
|
-
interToneGap: 600
|
|
512
|
-
});
|
|
513
|
-
}));
|
|
514
|
-
a(this, "_hangUpWithoutCancelRequests", async () => {
|
|
515
|
-
if (this.ua && this.session) {
|
|
516
|
-
const { session: e } = this;
|
|
517
|
-
this._streamPresentationCurrent && await this.stopPresentation(), this._restoreSession(), e.isEnded() || e.terminate();
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
a(this, "_handleShareState", (e) => {
|
|
521
|
-
switch (e) {
|
|
522
|
-
case yt: {
|
|
523
|
-
this._sessionEvents.trigger(_e, void 0);
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
case bt: {
|
|
527
|
-
this._sessionEvents.trigger(le, void 0);
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
case Un: {
|
|
531
|
-
this._sessionEvents.trigger(de, void 0);
|
|
532
|
-
break;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
a(this, "_maybeTriggerChannels", (e) => {
|
|
537
|
-
const t = e.getHeader(Xe), s = e.getHeader(ze);
|
|
538
|
-
if (t && s) {
|
|
539
|
-
const r = {
|
|
540
|
-
inputChannels: t,
|
|
541
|
-
outputChannels: s
|
|
542
|
-
};
|
|
543
|
-
this._sessionEvents.trigger($, r);
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
a(this, "_handleNotify", (e) => {
|
|
547
|
-
switch (e.cmd) {
|
|
548
|
-
case es: {
|
|
549
|
-
const t = e;
|
|
550
|
-
this._triggerChannelsNotify(t);
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
553
|
-
case ts: {
|
|
554
|
-
const t = e;
|
|
555
|
-
this._triggerWebcastStartedNotify(t);
|
|
556
|
-
break;
|
|
557
|
-
}
|
|
558
|
-
case ns: {
|
|
559
|
-
const t = e;
|
|
560
|
-
this._triggerWebcastStoppedNotify(t);
|
|
561
|
-
break;
|
|
562
|
-
}
|
|
563
|
-
case os: {
|
|
564
|
-
const t = e;
|
|
565
|
-
this._triggerAddedToListModeratorsNotify(t);
|
|
566
|
-
break;
|
|
567
|
-
}
|
|
568
|
-
case is: {
|
|
569
|
-
const t = e;
|
|
570
|
-
this._triggerRemovedFromListModeratorsNotify(t);
|
|
571
|
-
break;
|
|
572
|
-
}
|
|
573
|
-
case as: {
|
|
574
|
-
const t = e;
|
|
575
|
-
this._triggerParticipantMoveRequestToConference(t);
|
|
576
|
-
break;
|
|
577
|
-
}
|
|
578
|
-
case cs: {
|
|
579
|
-
const t = e;
|
|
580
|
-
this._triggerParticipantCancelingWordRequest(t);
|
|
581
|
-
break;
|
|
582
|
-
}
|
|
583
|
-
case us: {
|
|
584
|
-
const t = e;
|
|
585
|
-
this._triggerParticipantMoveRequestToStream(t);
|
|
586
|
-
break;
|
|
587
|
-
}
|
|
588
|
-
case ss: {
|
|
589
|
-
this._triggerAccountChangedNotify();
|
|
590
|
-
break;
|
|
591
|
-
}
|
|
592
|
-
case rs: {
|
|
593
|
-
this._triggerAccountDeletedNotify();
|
|
594
|
-
break;
|
|
595
|
-
}
|
|
596
|
-
case Es: {
|
|
597
|
-
const t = e;
|
|
598
|
-
this._triggerConferenceParticipantTokenIssued(t);
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
default:
|
|
602
|
-
E("unknown cmd", e.cmd);
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
a(this, "_triggerRemovedFromListModeratorsNotify", ({
|
|
606
|
-
conference: e
|
|
607
|
-
}) => {
|
|
608
|
-
const t = {
|
|
609
|
-
conference: e
|
|
610
|
-
};
|
|
611
|
-
this._uaEvents.trigger(
|
|
612
|
-
Oe,
|
|
613
|
-
t
|
|
614
|
-
);
|
|
615
|
-
});
|
|
616
|
-
a(this, "_triggerAddedToListModeratorsNotify", ({ conference: e }) => {
|
|
617
|
-
const t = {
|
|
618
|
-
conference: e
|
|
619
|
-
};
|
|
620
|
-
this._uaEvents.trigger(Me, t);
|
|
621
|
-
});
|
|
622
|
-
a(this, "_triggerWebcastStartedNotify", ({ body: { conference: e, type: t } }) => {
|
|
623
|
-
const s = {
|
|
624
|
-
conference: e,
|
|
625
|
-
type: t
|
|
626
|
-
};
|
|
627
|
-
this._uaEvents.trigger(ve, s);
|
|
628
|
-
});
|
|
629
|
-
a(this, "_triggerWebcastStoppedNotify", ({ body: { conference: e, type: t } }) => {
|
|
630
|
-
const s = {
|
|
631
|
-
conference: e,
|
|
632
|
-
type: t
|
|
633
|
-
};
|
|
634
|
-
this._uaEvents.trigger(ye, s);
|
|
635
|
-
});
|
|
636
|
-
a(this, "_triggerAccountChangedNotify", () => {
|
|
637
|
-
this._uaEvents.trigger(be, void 0);
|
|
638
|
-
});
|
|
639
|
-
a(this, "_triggerAccountDeletedNotify", () => {
|
|
640
|
-
this._uaEvents.trigger(we, void 0);
|
|
641
|
-
});
|
|
642
|
-
a(this, "_triggerConferenceParticipantTokenIssued", ({
|
|
643
|
-
body: { conference: e, participant: t, jwt: s }
|
|
644
|
-
}) => {
|
|
645
|
-
const r = {
|
|
646
|
-
conference: e,
|
|
647
|
-
participant: t,
|
|
648
|
-
jwt: s
|
|
649
|
-
};
|
|
650
|
-
this._uaEvents.trigger(
|
|
651
|
-
Ue,
|
|
652
|
-
r
|
|
653
|
-
);
|
|
654
|
-
});
|
|
655
|
-
a(this, "_triggerChannelsNotify", (e) => {
|
|
656
|
-
const t = e.input, s = e.output, r = {
|
|
657
|
-
inputChannels: t,
|
|
658
|
-
outputChannels: s
|
|
659
|
-
};
|
|
660
|
-
this._uaEvents.trigger(ge, r);
|
|
661
|
-
});
|
|
662
|
-
a(this, "_triggerParticipantMoveRequestToConference", ({
|
|
663
|
-
body: { conference: e }
|
|
664
|
-
}) => {
|
|
665
|
-
const t = {
|
|
666
|
-
conference: e
|
|
667
|
-
};
|
|
668
|
-
this._uaEvents.trigger(Pe, t);
|
|
669
|
-
});
|
|
670
|
-
a(this, "_triggerParticipantCancelingWordRequest", ({
|
|
671
|
-
body: { conference: e }
|
|
672
|
-
}) => {
|
|
673
|
-
const t = {
|
|
674
|
-
conference: e
|
|
675
|
-
};
|
|
676
|
-
this._uaEvents.trigger(pe, t);
|
|
677
|
-
});
|
|
678
|
-
a(this, "_triggerParticipantMoveRequestToStream", ({
|
|
679
|
-
body: { conference: e }
|
|
680
|
-
}) => {
|
|
681
|
-
const t = {
|
|
682
|
-
conference: e
|
|
683
|
-
};
|
|
684
|
-
this._uaEvents.trigger(De, t);
|
|
685
|
-
});
|
|
686
|
-
a(this, "_triggerEnterRoom", (e) => {
|
|
687
|
-
const t = e.getHeader(hn);
|
|
688
|
-
this._sessionEvents.trigger(Se, t);
|
|
689
|
-
});
|
|
690
|
-
a(this, "_triggerShareState", (e) => {
|
|
691
|
-
const t = e.getHeader(H);
|
|
692
|
-
this._sessionEvents.trigger(q, t);
|
|
693
|
-
});
|
|
694
|
-
a(this, "_triggerMainCamControl", (e) => {
|
|
695
|
-
const t = e.getHeader(fn), s = e.getHeader(Ke), r = s === ee.ADMIN_SYNC_FORCED;
|
|
696
|
-
if (t === I.ADMIN_START_MAIN_CAM)
|
|
697
|
-
this._sessionEvents.trigger(Ae, { isSyncForced: r });
|
|
698
|
-
else if (t === I.ADMIN_STOP_MAIN_CAM)
|
|
699
|
-
this._sessionEvents.trigger(Re, { isSyncForced: r });
|
|
700
|
-
else if ((t === I.RESUME_MAIN_CAM || t === I.PAUSE_MAIN_CAM) && s)
|
|
701
|
-
this._sessionEvents.trigger(x, { isSyncForced: r });
|
|
702
|
-
else {
|
|
703
|
-
const o = e.getHeader(Mn);
|
|
704
|
-
this._sessionEvents.trigger(me, {
|
|
705
|
-
mainCam: t,
|
|
706
|
-
resolutionMainCam: o
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
a(this, "_triggerMicControl", (e) => {
|
|
711
|
-
const t = e.getHeader(In), r = e.getHeader(Ke) === ee.ADMIN_SYNC_FORCED;
|
|
712
|
-
t === Z.ADMIN_START_MIC ? this._sessionEvents.trigger(Ie, { isSyncForced: r }) : t === Z.ADMIN_STOP_MIC && this._sessionEvents.trigger(fe, { isSyncForced: r });
|
|
713
|
-
});
|
|
714
|
-
a(this, "_triggerUseLicense", (e) => {
|
|
715
|
-
const t = e.getHeader(An);
|
|
716
|
-
this._sessionEvents.trigger(he, t);
|
|
717
|
-
});
|
|
718
|
-
a(this, "_handleNewInfo", (e) => {
|
|
719
|
-
const { originator: t } = e;
|
|
720
|
-
if (t !== "remote")
|
|
721
|
-
return;
|
|
722
|
-
const { request: s } = e, r = s.getHeader(Sn);
|
|
723
|
-
if (r)
|
|
724
|
-
switch (r) {
|
|
725
|
-
case Tn: {
|
|
726
|
-
this._triggerEnterRoom(s), this._maybeTriggerChannels(s);
|
|
727
|
-
break;
|
|
728
|
-
}
|
|
729
|
-
case vn: {
|
|
730
|
-
this._maybeHandleNotify(s);
|
|
731
|
-
break;
|
|
732
|
-
}
|
|
733
|
-
case K: {
|
|
734
|
-
this._triggerShareState(s);
|
|
735
|
-
break;
|
|
736
|
-
}
|
|
737
|
-
case Ge: {
|
|
738
|
-
this._triggerMainCamControl(s);
|
|
739
|
-
break;
|
|
740
|
-
}
|
|
741
|
-
case mn: {
|
|
742
|
-
this._triggerMicControl(s);
|
|
743
|
-
break;
|
|
744
|
-
}
|
|
745
|
-
case Rn: {
|
|
746
|
-
this._triggerUseLicense(s);
|
|
747
|
-
break;
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
a(this, "_handleSipEvent", ({ request: e }) => {
|
|
752
|
-
this._maybeHandleNotify(e);
|
|
753
|
-
});
|
|
754
|
-
a(this, "_maybeHandleNotify", (e) => {
|
|
755
|
-
const t = e.getHeader(yn);
|
|
756
|
-
if (t) {
|
|
757
|
-
const s = JSON.parse(t);
|
|
758
|
-
this._handleNotify(s);
|
|
759
|
-
}
|
|
760
|
-
});
|
|
761
|
-
a(this, "_handleEnded", (e) => {
|
|
762
|
-
const { originator: t } = e;
|
|
763
|
-
t === Qe && this._sessionEvents.trigger(Ne, e), this._restoreSession();
|
|
764
|
-
});
|
|
765
|
-
this.JsSIP = e, this._sessionEvents = new Ye(vt), this._uaEvents = new Ye(pt), this._cancelableConnect = new O(
|
|
766
|
-
this._connect,
|
|
767
|
-
{
|
|
768
|
-
moduleName: P,
|
|
769
|
-
afterCancelRequest: () => {
|
|
770
|
-
this._cancelableCreateUa.cancelRequest(), this._cancelableDisconnect.cancelRequest();
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
), this._cancelableCreateUa = new O(this._createUa, { moduleName: P }), this._cancelableDisconnect = new O(
|
|
774
|
-
this._disconnect,
|
|
775
|
-
{ moduleName: P }
|
|
776
|
-
), this._cancelableSet = new O(this._set, {
|
|
777
|
-
moduleName: P
|
|
778
|
-
}), this._cancelableCall = new O(
|
|
779
|
-
this._call,
|
|
780
|
-
{ moduleName: P }
|
|
781
|
-
), this._cancelableAnswer = new O(this._answer, { moduleName: P }), this._cancelableSendDTMF = new O(this._sendDTMF, { moduleName: P }), this.onSession(q, this._handleShareState), this.onSession(Be, this._handleNewInfo), this.on(Ee, this._handleSipEvent), this.onSession(y, this._handleEnded), this.onSession(F, this._handleEnded);
|
|
782
|
-
}
|
|
783
|
-
async register() {
|
|
784
|
-
return new Promise((e, t) => {
|
|
785
|
-
this.isRegisterConfig && this.ua ? (this.ua.on(L, e), this.ua.on(B, t), this.ua.register()) : t(new Error("Config is not registered"));
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
async unregister() {
|
|
789
|
-
return new Promise((e, t) => {
|
|
790
|
-
this.isRegistered && this.ua ? (this.ua.on(ue, e), this.ua.unregister()) : t(new Error("ua is not registered"));
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
async sendOptions(e, t, s) {
|
|
794
|
-
if (!this.ua)
|
|
795
|
-
throw new Error("is not connected");
|
|
796
|
-
return new Promise((r, o) => {
|
|
797
|
-
try {
|
|
798
|
-
this.ua.sendOptions(e, t, {
|
|
799
|
-
extraHeaders: s,
|
|
800
|
-
eventHandlers: {
|
|
801
|
-
succeeded: () => {
|
|
802
|
-
r();
|
|
803
|
-
},
|
|
804
|
-
failed: o
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
} catch (i) {
|
|
808
|
-
o(i);
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
async ping(e, t) {
|
|
813
|
-
var r;
|
|
814
|
-
if (!((r = this.ua) != null && r.configuration.uri))
|
|
815
|
-
throw new Error("is not connected");
|
|
816
|
-
const s = this.ua.configuration.uri;
|
|
817
|
-
return this.sendOptions(s, e, t);
|
|
818
|
-
}
|
|
819
|
-
async replaceMediaStream(e, t) {
|
|
820
|
-
if (!this.session)
|
|
821
|
-
throw new Error("No session established");
|
|
822
|
-
return this.session.replaceMediaStream(e, t);
|
|
823
|
-
}
|
|
824
|
-
async askPermissionToEnableCam(e = {}) {
|
|
825
|
-
if (!this.session)
|
|
826
|
-
throw new Error("No session established");
|
|
827
|
-
const t = [kn];
|
|
828
|
-
return this.session.sendInfo(Ge, void 0, {
|
|
829
|
-
noTerminateWhenError: !0,
|
|
830
|
-
...e,
|
|
831
|
-
extraHeaders: t
|
|
832
|
-
}).catch((s) => {
|
|
833
|
-
if (Yn(s))
|
|
834
|
-
throw s;
|
|
835
|
-
});
|
|
836
|
-
}
|
|
837
|
-
get isPendingPresentation() {
|
|
838
|
-
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
839
|
-
}
|
|
840
|
-
async _sendPresentation(e, t, {
|
|
841
|
-
maxBitrate: s,
|
|
842
|
-
degradationPreference: r,
|
|
843
|
-
isNeedReinvite: o = !0,
|
|
844
|
-
isP2P: i = !1
|
|
845
|
-
}) {
|
|
846
|
-
const c = J(t);
|
|
847
|
-
this._streamPresentationCurrent = c;
|
|
848
|
-
const u = i ? [Ln] : [bn], _ = e.sendInfo(K, void 0, {
|
|
849
|
-
extraHeaders: u
|
|
850
|
-
}).then(async () => e.startPresentation(
|
|
851
|
-
c,
|
|
852
|
-
o,
|
|
853
|
-
r
|
|
854
|
-
)).then(async () => {
|
|
855
|
-
const { connection: l } = this;
|
|
856
|
-
if (!l || s === void 0)
|
|
857
|
-
return;
|
|
858
|
-
const d = l.getSenders();
|
|
859
|
-
return Qn(d, t, s);
|
|
860
|
-
}).then(() => t).catch((l) => {
|
|
861
|
-
throw this._sessionEvents.trigger(X, l), l;
|
|
862
|
-
});
|
|
863
|
-
return this.promisePendingStartPresentation = _, _.finally(() => {
|
|
864
|
-
this.promisePendingStartPresentation = void 0;
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
async startPresentation(e, {
|
|
868
|
-
isNeedReinvite: t = !0,
|
|
869
|
-
isP2P: s = !1,
|
|
870
|
-
maxBitrate: r,
|
|
871
|
-
degradationPreference: o
|
|
872
|
-
} = {}) {
|
|
873
|
-
const i = this.establishedSession;
|
|
874
|
-
if (!i)
|
|
875
|
-
throw new Error("No session established");
|
|
876
|
-
if (this._streamPresentationCurrent)
|
|
877
|
-
throw new Error("Presentation is already started");
|
|
878
|
-
return this._sendPresentation(i, e, {
|
|
879
|
-
isNeedReinvite: t,
|
|
880
|
-
isP2P: s,
|
|
881
|
-
maxBitrate: r,
|
|
882
|
-
degradationPreference: o
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
async stopPresentation({
|
|
886
|
-
isP2P: e = !1
|
|
887
|
-
} = {}) {
|
|
888
|
-
const t = this._streamPresentationCurrent;
|
|
889
|
-
let s = this.promisePendingStartPresentation ?? Promise.resolve();
|
|
890
|
-
const r = e ? [Bn] : [wn], o = this.establishedSession;
|
|
891
|
-
return o && t && (s = s.then(async () => o.sendInfo(K, void 0, {
|
|
892
|
-
extraHeaders: r
|
|
893
|
-
})).then(async () => o.stopPresentation(t)).catch((i) => {
|
|
894
|
-
throw this._sessionEvents.trigger(X, i), i;
|
|
895
|
-
})), !o && t && this._sessionEvents.trigger(Fe, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
896
|
-
this._resetPresentation();
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
async updatePresentation(e, {
|
|
900
|
-
isP2P: t = !1,
|
|
901
|
-
maxBitrate: s,
|
|
902
|
-
degradationPreference: r
|
|
903
|
-
} = {}) {
|
|
904
|
-
const o = this.establishedSession;
|
|
905
|
-
if (!o)
|
|
906
|
-
throw new Error("No session established");
|
|
907
|
-
if (!this._streamPresentationCurrent)
|
|
908
|
-
throw new Error("Presentation has not started yet");
|
|
909
|
-
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this._sendPresentation(o, e, {
|
|
910
|
-
isP2P: t,
|
|
911
|
-
maxBitrate: s,
|
|
912
|
-
degradationPreference: r,
|
|
913
|
-
isNeedReinvite: !1
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
_resetPresentation() {
|
|
917
|
-
delete this._streamPresentationCurrent, this.promisePendingStartPresentation = void 0, this.promisePendingStopPresentation = void 0;
|
|
918
|
-
}
|
|
919
|
-
on(e, t) {
|
|
920
|
-
return this._uaEvents.on(e, t);
|
|
921
|
-
}
|
|
922
|
-
once(e, t) {
|
|
923
|
-
return this._uaEvents.once(e, t);
|
|
924
|
-
}
|
|
925
|
-
onceRace(e, t) {
|
|
926
|
-
return this._uaEvents.onceRace(e, t);
|
|
927
|
-
}
|
|
928
|
-
async wait(e) {
|
|
929
|
-
return this._uaEvents.wait(e);
|
|
930
|
-
}
|
|
931
|
-
off(e, t) {
|
|
932
|
-
this._uaEvents.off(e, t);
|
|
933
|
-
}
|
|
934
|
-
onSession(e, t) {
|
|
935
|
-
return this._sessionEvents.on(e, t);
|
|
936
|
-
}
|
|
937
|
-
onceSession(e, t) {
|
|
938
|
-
return this._sessionEvents.once(e, t);
|
|
939
|
-
}
|
|
940
|
-
onceRaceSession(e, t) {
|
|
941
|
-
return this._sessionEvents.onceRace(e, t);
|
|
942
|
-
}
|
|
943
|
-
async waitSession(e) {
|
|
944
|
-
return this._sessionEvents.wait(e);
|
|
945
|
-
}
|
|
946
|
-
offSession(e, t) {
|
|
947
|
-
this._sessionEvents.off(e, t);
|
|
948
|
-
}
|
|
949
|
-
isConfigured() {
|
|
950
|
-
return !!this.ua;
|
|
951
|
-
}
|
|
952
|
-
getConnectionConfiguration() {
|
|
953
|
-
return { ...this._connectionConfiguration };
|
|
954
|
-
}
|
|
955
|
-
getRemoteStreams() {
|
|
956
|
-
if (!this.connection)
|
|
957
|
-
return;
|
|
958
|
-
const t = this.connection.getReceivers().map(({ track: s }) => s);
|
|
959
|
-
return $n(t) ? this._generateStreams(t) : this._generateAudioStreams(t);
|
|
960
|
-
}
|
|
961
|
-
get connection() {
|
|
962
|
-
var t;
|
|
963
|
-
return (t = this.session) == null ? void 0 : t.connection;
|
|
964
|
-
}
|
|
965
|
-
get remoteCallerData() {
|
|
966
|
-
var e, t, s, r, o, i;
|
|
967
|
-
return {
|
|
968
|
-
displayName: (t = (e = this.incomingSession) == null ? void 0 : e.remote_identity) == null ? void 0 : t.display_name,
|
|
969
|
-
host: (r = (s = this.incomingSession) == null ? void 0 : s.remote_identity) == null ? void 0 : r.uri.host,
|
|
970
|
-
incomingNumber: (i = (o = this.incomingSession) == null ? void 0 : o.remote_identity) == null ? void 0 : i.uri.user,
|
|
971
|
-
session: this.incomingSession
|
|
972
|
-
};
|
|
973
|
-
}
|
|
974
|
-
get requested() {
|
|
975
|
-
return this._cancelableConnect.requested || this._cancelableCreateUa.requested || this._cancelableCall.requested || this._cancelableAnswer.requested;
|
|
976
|
-
}
|
|
977
|
-
get establishedSession() {
|
|
978
|
-
return this.session && this.session.isEstablished() ? this.session : void 0;
|
|
979
|
-
}
|
|
980
|
-
get isRegistered() {
|
|
981
|
-
return !!this.ua && this.ua.isRegistered();
|
|
982
|
-
}
|
|
983
|
-
get isRegisterConfig() {
|
|
984
|
-
return !!this.ua && this._isRegisterConfig;
|
|
985
|
-
}
|
|
986
|
-
get isCallActive() {
|
|
987
|
-
return !!(this.ua && this.session);
|
|
988
|
-
}
|
|
989
|
-
get isAvailableIncomingCall() {
|
|
990
|
-
return !!this.incomingSession;
|
|
991
|
-
}
|
|
992
|
-
_init({
|
|
993
|
-
sipServerUrl: e,
|
|
994
|
-
sipWebSocketServerURL: t
|
|
995
|
-
}) {
|
|
996
|
-
this.getSipServerUrl = Vn(e), this.socket = new this.JsSIP.WebSocketInterface(t);
|
|
997
|
-
}
|
|
998
|
-
_generateStream(e, t) {
|
|
999
|
-
const { id: s } = e, r = this._remoteStreams[s] || new MediaStream();
|
|
1000
|
-
return t && r.addTrack(t), r.addTrack(e), this._remoteStreams[s] = r, r;
|
|
1001
|
-
}
|
|
1002
|
-
_generateAudioStream(e) {
|
|
1003
|
-
const { id: t } = e, s = this._remoteStreams[t] || new MediaStream();
|
|
1004
|
-
return s.addTrack(e), this._remoteStreams[t] = s, s;
|
|
1005
|
-
}
|
|
1006
|
-
_generateStreams(e) {
|
|
1007
|
-
const t = [];
|
|
1008
|
-
return e.forEach((s, r) => {
|
|
1009
|
-
if (s.kind === "audio")
|
|
1010
|
-
return;
|
|
1011
|
-
const o = s, i = e[r - 1];
|
|
1012
|
-
let c;
|
|
1013
|
-
i && i.kind === "audio" && (c = i);
|
|
1014
|
-
const u = this._generateStream(o, c);
|
|
1015
|
-
t.push(u);
|
|
1016
|
-
}), t;
|
|
1017
|
-
}
|
|
1018
|
-
_generateAudioStreams(e) {
|
|
1019
|
-
return e.map((s) => this._generateAudioStream(s));
|
|
1020
|
-
}
|
|
1021
|
-
_cancelRequests() {
|
|
1022
|
-
this._cancelActionsRequests(), this._cancelCallRequests(), this._cancelConnectRequests();
|
|
1023
|
-
}
|
|
1024
|
-
_cancelConnectRequests() {
|
|
1025
|
-
this._cancelableConnect.cancelRequest();
|
|
1026
|
-
}
|
|
1027
|
-
_cancelCallRequests() {
|
|
1028
|
-
this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest();
|
|
1029
|
-
}
|
|
1030
|
-
_cancelActionsRequests() {
|
|
1031
|
-
this._cancelableAnswer.cancelRequest(), this._cancelableSendDTMF.cancelRequest();
|
|
1032
|
-
}
|
|
1033
|
-
async waitChannels() {
|
|
1034
|
-
return this.waitSession($);
|
|
1035
|
-
}
|
|
1036
|
-
async waitSyncMediaState() {
|
|
1037
|
-
return this.waitSession(x);
|
|
1038
|
-
}
|
|
1039
|
-
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
1040
|
-
if (!this.session)
|
|
1041
|
-
throw new Error("No session established");
|
|
1042
|
-
const s = `${Xe}: ${e}`, r = `${ze}: ${t}`, o = [
|
|
1043
|
-
s,
|
|
1044
|
-
r
|
|
1045
|
-
];
|
|
1046
|
-
return this.session.sendInfo(Cn, void 0, { extraHeaders: o });
|
|
1047
|
-
}
|
|
1048
|
-
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
1049
|
-
if (!this.session)
|
|
1050
|
-
throw new Error("No session established");
|
|
1051
|
-
const r = `${On}: currentstate`, o = `${Dn}: ${Number(e)}`, i = `${pn}: ${Number(t)}`, c = [
|
|
1052
|
-
r,
|
|
1053
|
-
o,
|
|
1054
|
-
i
|
|
1055
|
-
];
|
|
1056
|
-
return this.session.sendInfo(gn, void 0, {
|
|
1057
|
-
noTerminateWhenError: !0,
|
|
1058
|
-
...s,
|
|
1059
|
-
extraHeaders: c
|
|
1060
|
-
});
|
|
1061
|
-
}
|
|
1062
|
-
async _sendRefusalToTurnOn(e, t = {}) {
|
|
1063
|
-
if (!this.session)
|
|
1064
|
-
throw new Error("No session established");
|
|
1065
|
-
const c = [`${Pn}: ${e === "mic" ? 0 : 1}`];
|
|
1066
|
-
return this.session.sendInfo(Nn, void 0, {
|
|
1067
|
-
noTerminateWhenError: !0,
|
|
1068
|
-
...t,
|
|
1069
|
-
extraHeaders: c
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
async sendRefusalToTurnOnMic(e = {}) {
|
|
1073
|
-
if (!this.session)
|
|
1074
|
-
throw new Error("No session established");
|
|
1075
|
-
return this._sendRefusalToTurnOn("mic", { noTerminateWhenError: !0, ...e });
|
|
1076
|
-
}
|
|
1077
|
-
async sendRefusalToTurnOnCam(e = {}) {
|
|
1078
|
-
if (!this.session)
|
|
1079
|
-
throw new Error("No session established");
|
|
1080
|
-
return this._sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
const Bt = "purgatory", k = (n) => n === Bt, We = (n) => () => (E("getRemoteStreams"), n.getRemoteStreams()), _s = ({ kind: n, readyState: e }) => n === "video" && e === "live", Ft = (n) => ({ track: e }) => {
|
|
1084
|
-
_s(e) && n();
|
|
1085
|
-
}, qe = ({
|
|
1086
|
-
getRemoteStreams: n,
|
|
1087
|
-
setRemoteStreams: e
|
|
1088
|
-
}) => Gt(() => {
|
|
1089
|
-
const t = n();
|
|
1090
|
-
E("remoteStreams", t), t && e(t);
|
|
1091
|
-
}, 200), ls = (n) => async (t) => {
|
|
1
|
+
import { l as c, B as x, N as V, E as P, s as z, S as en } from "./SipConnector-abcad4a1.js";
|
|
2
|
+
import { f as un, g as ln, i as Sn, c as dn, a as mn, d as fn, b as Cn, e as En, h as gn } from "./SipConnector-abcad4a1.js";
|
|
3
|
+
import { debounce as q } from "ts-debounce";
|
|
4
|
+
import { isCanceledError as J } from "@krivega/cancelable-promise";
|
|
5
|
+
import { default as hn } from "debug";
|
|
6
|
+
import "events-constructor";
|
|
7
|
+
const $ = "purgatory", A = (e) => e === $, B = (e) => () => (c("getRemoteStreams"), e.getRemoteStreams()), Q = ({ kind: e, readyState: n }) => e === "video" && n === "live", G = (e) => ({ track: n }) => {
|
|
8
|
+
Q(n) && e();
|
|
9
|
+
}, k = ({
|
|
10
|
+
getRemoteStreams: e,
|
|
11
|
+
setRemoteStreams: n
|
|
12
|
+
}) => q(() => {
|
|
13
|
+
const t = e();
|
|
14
|
+
c("remoteStreams", t), t && n(t);
|
|
15
|
+
}, 200), Z = (e) => async (t) => {
|
|
1092
16
|
const {
|
|
1093
17
|
mediaStream: s,
|
|
1094
18
|
extraHeaders: r,
|
|
1095
19
|
iceServers: o,
|
|
1096
|
-
degradationPreference:
|
|
1097
|
-
setRemoteStreams:
|
|
1098
|
-
onBeforeProgressCall:
|
|
1099
|
-
onSuccessProgressCall:
|
|
1100
|
-
onEnterPurgatory:
|
|
1101
|
-
onEnterConference:
|
|
1102
|
-
onFailProgressCall:
|
|
20
|
+
degradationPreference: a,
|
|
21
|
+
setRemoteStreams: u,
|
|
22
|
+
onBeforeProgressCall: m,
|
|
23
|
+
onSuccessProgressCall: E,
|
|
24
|
+
onEnterPurgatory: C,
|
|
25
|
+
onEnterConference: f,
|
|
26
|
+
onFailProgressCall: T,
|
|
1103
27
|
onFinishProgressCall: h,
|
|
1104
|
-
onEndedCall:
|
|
1105
|
-
} = t, g =
|
|
1106
|
-
setRemoteStreams:
|
|
1107
|
-
getRemoteStreams:
|
|
1108
|
-
}),
|
|
1109
|
-
|
|
1110
|
-
const
|
|
28
|
+
onEndedCall: y
|
|
29
|
+
} = t, g = k({
|
|
30
|
+
setRemoteStreams: u,
|
|
31
|
+
getRemoteStreams: B(e)
|
|
32
|
+
}), _ = G(g);
|
|
33
|
+
c("answerIncomingCall", t);
|
|
34
|
+
const v = async () => e.answerToIncomingCall({
|
|
1111
35
|
mediaStream: s,
|
|
1112
36
|
extraHeaders: r,
|
|
1113
37
|
iceServers: o,
|
|
1114
|
-
degradationPreference:
|
|
1115
|
-
ontrack:
|
|
1116
|
-
}),
|
|
1117
|
-
const { remoteCallerData:
|
|
1118
|
-
return
|
|
38
|
+
degradationPreference: a,
|
|
39
|
+
ontrack: _
|
|
40
|
+
}), p = () => {
|
|
41
|
+
const { remoteCallerData: d } = e;
|
|
42
|
+
return d.incomingNumber;
|
|
1119
43
|
};
|
|
1120
|
-
let
|
|
1121
|
-
const
|
|
1122
|
-
|
|
44
|
+
let M = !1, i;
|
|
45
|
+
const l = (() => (c("subscribeEnterConference: onEnterConference", f), C ?? f ? e.onSession("enterRoom", (d) => {
|
|
46
|
+
c("enterRoom", { _room: d, isSuccessProgressCall: M }), i = d, A(i) ? C && C() : f && f({ isSuccessProgressCall: M });
|
|
1123
47
|
}) : () => {
|
|
1124
|
-
}))(),
|
|
1125
|
-
|
|
1126
|
-
}),
|
|
1127
|
-
throw
|
|
1128
|
-
},
|
|
1129
|
-
|
|
48
|
+
}))(), R = (d) => (c("onSuccess"), M = !0, g(), E && E({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
|
|
49
|
+
l(), y && y();
|
|
50
|
+
}), d), b = (d) => {
|
|
51
|
+
throw c("onFail"), T && T(), l(), d;
|
|
52
|
+
}, O = () => {
|
|
53
|
+
c("onFinish"), h && h();
|
|
1130
54
|
};
|
|
1131
|
-
if (
|
|
1132
|
-
const
|
|
1133
|
-
|
|
55
|
+
if (c("onBeforeProgressCall"), m) {
|
|
56
|
+
const d = p();
|
|
57
|
+
m(d);
|
|
1134
58
|
}
|
|
1135
|
-
return
|
|
1136
|
-
},
|
|
59
|
+
return v().then(R).catch(b).finally(O);
|
|
60
|
+
}, ee = (e) => async (t) => {
|
|
1137
61
|
const {
|
|
1138
62
|
conference: s,
|
|
1139
63
|
mediaStream: r,
|
|
1140
64
|
extraHeaders: o,
|
|
1141
|
-
iceServers:
|
|
1142
|
-
degradationPreference:
|
|
1143
|
-
setRemoteStreams:
|
|
1144
|
-
onBeforeProgressCall:
|
|
1145
|
-
onSuccessProgressCall:
|
|
1146
|
-
onEnterPurgatory:
|
|
1147
|
-
onEnterConference:
|
|
65
|
+
iceServers: a,
|
|
66
|
+
degradationPreference: u,
|
|
67
|
+
setRemoteStreams: m,
|
|
68
|
+
onBeforeProgressCall: E,
|
|
69
|
+
onSuccessProgressCall: C,
|
|
70
|
+
onEnterPurgatory: f,
|
|
71
|
+
onEnterConference: T,
|
|
1148
72
|
onFailProgressCall: h,
|
|
1149
|
-
onFinishProgressCall:
|
|
73
|
+
onFinishProgressCall: y,
|
|
1150
74
|
onEndedCall: g
|
|
1151
|
-
} = t,
|
|
1152
|
-
setRemoteStreams:
|
|
1153
|
-
getRemoteStreams:
|
|
1154
|
-
}),
|
|
1155
|
-
|
|
1156
|
-
const
|
|
75
|
+
} = t, _ = k({
|
|
76
|
+
setRemoteStreams: m,
|
|
77
|
+
getRemoteStreams: B(e)
|
|
78
|
+
}), v = G(_);
|
|
79
|
+
c("callToServer", t);
|
|
80
|
+
const p = async () => (c("startCall"), e.call({
|
|
1157
81
|
mediaStream: r,
|
|
1158
82
|
extraHeaders: o,
|
|
1159
|
-
iceServers:
|
|
1160
|
-
degradationPreference:
|
|
83
|
+
iceServers: a,
|
|
84
|
+
degradationPreference: u,
|
|
1161
85
|
number: s,
|
|
1162
|
-
ontrack:
|
|
86
|
+
ontrack: v
|
|
1163
87
|
}));
|
|
1164
|
-
let
|
|
1165
|
-
const
|
|
1166
|
-
|
|
88
|
+
let M = !1, i;
|
|
89
|
+
const l = (() => (c("subscribeEnterConference: onEnterConference", T), f ?? T ? e.onSession("enterRoom", (d) => {
|
|
90
|
+
c("enterRoom", { _room: d, isSuccessProgressCall: M }), i = d, A(i) ? f && f() : T && T({ isSuccessProgressCall: M });
|
|
1167
91
|
}) : () => {
|
|
1168
|
-
}))(),
|
|
1169
|
-
|
|
1170
|
-
}),
|
|
1171
|
-
throw
|
|
1172
|
-
},
|
|
1173
|
-
|
|
92
|
+
}))(), R = (d) => (c("onSuccess"), M = !0, _(), C && C({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
|
|
93
|
+
l(), g && g();
|
|
94
|
+
}), d), b = (d) => {
|
|
95
|
+
throw c("onFail"), h && h(), l(), d;
|
|
96
|
+
}, O = () => {
|
|
97
|
+
c("onFinish"), y && y();
|
|
1174
98
|
};
|
|
1175
|
-
return
|
|
1176
|
-
},
|
|
1177
|
-
if (!
|
|
1178
|
-
throw
|
|
99
|
+
return c("onBeforeProgressCall"), E && E(s), p().then(R).catch(b).finally(O);
|
|
100
|
+
}, w = (e) => {
|
|
101
|
+
if (!J(e))
|
|
102
|
+
throw e;
|
|
1179
103
|
return !1;
|
|
1180
|
-
},
|
|
104
|
+
}, ne = (e) => async (t) => {
|
|
1181
105
|
const {
|
|
1182
106
|
userAgent: s,
|
|
1183
107
|
sipWebSocketServerURL: r,
|
|
1184
108
|
sipServerUrl: o,
|
|
1185
|
-
remoteAddress:
|
|
1186
|
-
displayName:
|
|
1187
|
-
name:
|
|
1188
|
-
password:
|
|
1189
|
-
isRegisteredUser:
|
|
1190
|
-
sdpSemantics:
|
|
1191
|
-
isDisconnectOnFail:
|
|
109
|
+
remoteAddress: a,
|
|
110
|
+
displayName: u,
|
|
111
|
+
name: m,
|
|
112
|
+
password: E,
|
|
113
|
+
isRegisteredUser: C,
|
|
114
|
+
sdpSemantics: f,
|
|
115
|
+
isDisconnectOnFail: T
|
|
1192
116
|
} = t;
|
|
1193
|
-
return
|
|
117
|
+
return c("connectToServer", t), e.connect({
|
|
1194
118
|
userAgent: s,
|
|
1195
|
-
sdpSemantics:
|
|
119
|
+
sdpSemantics: f,
|
|
1196
120
|
sipWebSocketServerURL: r,
|
|
1197
121
|
sipServerUrl: o,
|
|
1198
|
-
remoteAddress:
|
|
1199
|
-
displayName:
|
|
1200
|
-
password:
|
|
1201
|
-
user:
|
|
1202
|
-
register:
|
|
1203
|
-
}).then(() => (
|
|
1204
|
-
},
|
|
1205
|
-
const { url:
|
|
1206
|
-
let s =
|
|
1207
|
-
return (t ===
|
|
122
|
+
remoteAddress: a,
|
|
123
|
+
displayName: u,
|
|
124
|
+
password: E,
|
|
125
|
+
user: m,
|
|
126
|
+
register: C
|
|
127
|
+
}).then(() => (c("connectToServer then"), !0)).catch(async (h) => (c("connectToServer catch: error", h), T === !0 ? e.disconnect().then(() => w(h)).catch(() => w(h)) : w(h)));
|
|
128
|
+
}, te = (e) => async () => (c("disconnectFromServer"), e.disconnect().then(() => (c("disconnectFromServer: then"), !1)).catch((n) => (c("disconnectFromServer: catch", n), !1))), D = (e) => {
|
|
129
|
+
const { url: n, cause: t } = e;
|
|
130
|
+
let s = n;
|
|
131
|
+
return (t === x || t === V) && (s = `${e.message.to.uri.user}@${e.message.to.uri.host}`), s;
|
|
1208
132
|
};
|
|
1209
|
-
var
|
|
1210
|
-
const
|
|
133
|
+
var j = /* @__PURE__ */ ((e) => (e.CONNECT_SERVER_FAILED = "CONNECT_SERVER_FAILED", e.WRONG_USER_OR_PASSWORD = "WRONG_USER_OR_PASSWORD", e.BAD_MEDIA_ERROR = "BAD_MEDIA_ERROR", e.NOT_FOUND_ERROR = "NOT_FOUND_ERROR", e.WS_CONNECTION_FAILED = "WS_CONNECTION_FAILED", e.CONNECT_SERVER_FAILED_BY_LINK = "CONNECT_SERVER_FAILED_BY_LINK", e))(j || {});
|
|
134
|
+
const se = (e = new Error()) => {
|
|
1211
135
|
var r;
|
|
1212
|
-
const { cause:
|
|
136
|
+
const { cause: n, socket: t } = e;
|
|
1213
137
|
let s = "CONNECT_SERVER_FAILED";
|
|
1214
|
-
switch (
|
|
138
|
+
switch (n) {
|
|
1215
139
|
case "Forbidden": {
|
|
1216
140
|
s = "WRONG_USER_OR_PASSWORD";
|
|
1217
141
|
break;
|
|
1218
142
|
}
|
|
1219
|
-
case
|
|
143
|
+
case x: {
|
|
1220
144
|
s = "BAD_MEDIA_ERROR";
|
|
1221
145
|
break;
|
|
1222
146
|
}
|
|
1223
|
-
case
|
|
147
|
+
case V: {
|
|
1224
148
|
s = "NOT_FOUND_ERROR";
|
|
1225
149
|
break;
|
|
1226
150
|
}
|
|
1227
151
|
default:
|
|
1228
|
-
t && ((r = t == null ? void 0 : t._ws) == null ? void 0 : r.readyState) === 3 ? s = "WS_CONNECTION_FAILED" :
|
|
152
|
+
t && ((r = t == null ? void 0 : t._ws) == null ? void 0 : r.readyState) === 3 ? s = "WS_CONNECTION_FAILED" : D(e) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
|
|
1229
153
|
}
|
|
1230
154
|
return s;
|
|
1231
|
-
},
|
|
1232
|
-
const { code:
|
|
1233
|
-
return s && (o.message = s), r && (o.link = r),
|
|
1234
|
-
},
|
|
155
|
+
}, re = (e = new Error()) => {
|
|
156
|
+
const { code: n, cause: t, message: s } = e, r = D(e), o = {};
|
|
157
|
+
return s && (o.message = s), r && (o.link = r), n && (o.code = n), t && (o.cause = t), o;
|
|
158
|
+
}, oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1235
159
|
__proto__: null,
|
|
1236
|
-
EErrorTypes:
|
|
1237
|
-
getLinkError:
|
|
1238
|
-
getTypeFromError:
|
|
1239
|
-
getValuesFromError:
|
|
1240
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1241
|
-
sessionId:
|
|
1242
|
-
remoteAddress:
|
|
160
|
+
EErrorTypes: j,
|
|
161
|
+
getLinkError: D,
|
|
162
|
+
getTypeFromError: se,
|
|
163
|
+
getValuesFromError: re
|
|
164
|
+
}, Symbol.toStringTag, { value: "Module" })), ce = ({
|
|
165
|
+
sessionId: e,
|
|
166
|
+
remoteAddress: n,
|
|
1243
167
|
isMutedAudio: t,
|
|
1244
168
|
isMutedVideo: s,
|
|
1245
169
|
isRegistered: r,
|
|
1246
170
|
isPresentationCall: o
|
|
1247
171
|
}) => {
|
|
1248
|
-
const
|
|
1249
|
-
return
|
|
1250
|
-
},
|
|
1251
|
-
appName:
|
|
1252
|
-
appVersion:
|
|
172
|
+
const a = [], u = t ? "0" : "1", m = s ? "0" : "1";
|
|
173
|
+
return a.push(`X-Vinteo-Mic-State: ${u}`, `X-Vinteo-MainCam-State: ${m}`), r || a.push("X-Vinteo-Purgatory-Call: yes"), e && a.push(`X-Vinteo-Session: ${e}`), o && a.push("X-Vinteo-Presentation-Call: yes"), n && a.push(`X-Vinteo-Remote: ${n}`), a;
|
|
174
|
+
}, ae = ({
|
|
175
|
+
appName: e,
|
|
176
|
+
appVersion: n,
|
|
1253
177
|
browserName: t,
|
|
1254
178
|
browserVersion: s
|
|
1255
179
|
}) => {
|
|
1256
|
-
const r = `${
|
|
180
|
+
const r = `${e} ${n}`;
|
|
1257
181
|
return `ChromeNew - ${t ? `${t} ${s}, ${r}` : r}`;
|
|
1258
|
-
},
|
|
1259
|
-
isUnifiedSdpSemantic:
|
|
1260
|
-
appVersion:
|
|
182
|
+
}, ie = ({
|
|
183
|
+
isUnifiedSdpSemantic: e,
|
|
184
|
+
appVersion: n,
|
|
1261
185
|
browserName: t,
|
|
1262
186
|
browserVersion: s,
|
|
1263
187
|
appName: r
|
|
1264
|
-
}) =>
|
|
1265
|
-
if (
|
|
1266
|
-
return
|
|
1267
|
-
},
|
|
188
|
+
}) => e ? ae({ appVersion: n, browserName: t, browserVersion: s, appName: r }) : "Chrome", ue = (e) => async () => {
|
|
189
|
+
if (e.isCallActive)
|
|
190
|
+
return c("askPermissionToEnableCam"), e.askPermissionToEnableCam();
|
|
191
|
+
}, le = (e) => (t) => (c("onMustStopPresentation"), e.onSession("mustStopPresentation", t)), Se = (e) => (t) => (c("onUseLicense"), e.onSession("useLicense", t)), de = (e) => async ({
|
|
1268
192
|
isEnabledCam: t,
|
|
1269
193
|
isEnabledMic: s
|
|
1270
194
|
}) => {
|
|
1271
|
-
if (
|
|
1272
|
-
return
|
|
1273
|
-
},
|
|
1274
|
-
if (
|
|
1275
|
-
return
|
|
1276
|
-
|
|
1277
|
-
});
|
|
1278
|
-
},
|
|
1279
|
-
if (
|
|
1280
|
-
return
|
|
1281
|
-
|
|
1282
|
-
});
|
|
1283
|
-
},
|
|
1284
|
-
maxBitrate:
|
|
1285
|
-
sipConnector:
|
|
195
|
+
if (e.isCallActive)
|
|
196
|
+
return c("sendMediaState"), e.sendMediaState({ cam: t, mic: s });
|
|
197
|
+
}, me = (e) => async () => {
|
|
198
|
+
if (e.isCallActive)
|
|
199
|
+
return c("sendRefusalToTurnOnCam"), e.sendRefusalToTurnOnCam().catch((t) => {
|
|
200
|
+
c("sendRefusalToTurnOnCam: error", t);
|
|
201
|
+
});
|
|
202
|
+
}, fe = (e) => async () => {
|
|
203
|
+
if (e.isCallActive)
|
|
204
|
+
return c("sendRefusalToTurnOnMic"), e.sendRefusalToTurnOnMic().catch((t) => {
|
|
205
|
+
c("sendRefusalToTurnOnMic: error", t);
|
|
206
|
+
});
|
|
207
|
+
}, Ce = 1e6, Ee = ({
|
|
208
|
+
maxBitrate: e = Ce,
|
|
209
|
+
sipConnector: n
|
|
1286
210
|
}) => async ({
|
|
1287
211
|
mediaStream: s,
|
|
1288
212
|
isP2P: r = !1
|
|
1289
|
-
}) => (
|
|
213
|
+
}) => (c("startPresentation"), n.startPresentation(s, {
|
|
1290
214
|
isP2P: r,
|
|
1291
|
-
maxBitrate:
|
|
1292
|
-
})),
|
|
215
|
+
maxBitrate: e
|
|
216
|
+
})), ge = ({ sipConnector: e }) => async ({ isP2P: t = !1 } = {}) => (c("stopShareSipConnector"), e.stopPresentation({
|
|
1293
217
|
isP2P: t
|
|
1294
|
-
}).catch(
|
|
1295
|
-
sipConnector:
|
|
1296
|
-
maxBitrate:
|
|
218
|
+
}).catch(c)), Re = 1e6, he = ({
|
|
219
|
+
sipConnector: e,
|
|
220
|
+
maxBitrate: n = Re
|
|
1297
221
|
}) => async ({
|
|
1298
222
|
mediaStream: s,
|
|
1299
223
|
isP2P: r = !1
|
|
1300
|
-
}) => (
|
|
224
|
+
}) => (c("updatePresentation"), e.updatePresentation(s, {
|
|
1301
225
|
isP2P: r,
|
|
1302
|
-
maxBitrate:
|
|
1303
|
-
})),
|
|
1304
|
-
|
|
1305
|
-
|
|
226
|
+
maxBitrate: n
|
|
227
|
+
})), ye = "ERROR_NOT_RUNNING", Te = (e) => {
|
|
228
|
+
const n = new Error("Promise was not running");
|
|
229
|
+
return n.basePromise = e, n.id = ye, n.name = "Not running", n;
|
|
230
|
+
}, _e = async (e, n) => e.reduce(
|
|
231
|
+
async (t, s) => t.then(async ({ success: r, errors: o, results: a }) => (!n || n(s) ? s() : Promise.reject(Te(s))).then((u) => ({
|
|
232
|
+
errors: o,
|
|
233
|
+
success: [...r, u],
|
|
234
|
+
results: [...a, u],
|
|
235
|
+
isSuccessful: !0,
|
|
236
|
+
isError: !1
|
|
237
|
+
})).catch((u) => ({
|
|
238
|
+
success: r,
|
|
239
|
+
errors: [...o, u],
|
|
240
|
+
results: [...a, u],
|
|
241
|
+
isSuccessful: !1,
|
|
242
|
+
isError: !0
|
|
243
|
+
}))),
|
|
244
|
+
Promise.resolve({
|
|
245
|
+
success: [],
|
|
246
|
+
errors: [],
|
|
247
|
+
results: [],
|
|
248
|
+
isSuccessful: !1,
|
|
249
|
+
isError: !1
|
|
250
|
+
})
|
|
251
|
+
), Me = (e) => (n) => [...n].map((s) => async () => e(s)), be = async ({
|
|
252
|
+
accumulatedKeys: e,
|
|
253
|
+
sendKey: n,
|
|
1306
254
|
canRunTask: t
|
|
1307
255
|
}) => {
|
|
1308
|
-
const r =
|
|
1309
|
-
return
|
|
1310
|
-
},
|
|
1311
|
-
const
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
256
|
+
const r = Me(n)(e);
|
|
257
|
+
return _e(r, t);
|
|
258
|
+
}, Ne = (e) => (t) => (c("onStartMainCam"), e.onSession("admin-start-main-cam", t)), Oe = (e) => (t) => (c("onStartMic"), e.onSession("admin-start-mic", t)), ve = (e) => (t) => (c("onStopMainCam"), e.onSession("admin-stop-main-cam", t)), pe = (e) => (t) => (c("onStopMic"), e.onSession("admin-stop-mic", t)), Ae = ({ sipConnector: e }) => {
|
|
259
|
+
const n = (y, g) => ({ isSyncForced: _ = !1 }) => {
|
|
260
|
+
if (_) {
|
|
261
|
+
y();
|
|
1314
262
|
return;
|
|
1315
263
|
}
|
|
1316
264
|
g();
|
|
1317
|
-
}, t =
|
|
1318
|
-
let
|
|
1319
|
-
}, c = () => {
|
|
265
|
+
}, t = Ne(e), s = ve(e), r = Oe(e), o = pe(e);
|
|
266
|
+
let a = () => {
|
|
1320
267
|
}, u = () => {
|
|
1321
|
-
},
|
|
268
|
+
}, m = () => {
|
|
269
|
+
}, E = () => {
|
|
1322
270
|
};
|
|
1323
|
-
const
|
|
1324
|
-
onStartMainCamForced:
|
|
271
|
+
const C = ({
|
|
272
|
+
onStartMainCamForced: y,
|
|
1325
273
|
onStartMainCamNotForced: g,
|
|
1326
|
-
onStopMainCamForced:
|
|
1327
|
-
onStopMainCamNotForced:
|
|
1328
|
-
onStartMicForced:
|
|
1329
|
-
onStartMicNotForced:
|
|
1330
|
-
onStopMicForced:
|
|
1331
|
-
onStopMicNotForced:
|
|
274
|
+
onStopMainCamForced: _,
|
|
275
|
+
onStopMainCamNotForced: v,
|
|
276
|
+
onStartMicForced: p,
|
|
277
|
+
onStartMicNotForced: M,
|
|
278
|
+
onStopMicForced: i,
|
|
279
|
+
onStopMicNotForced: S
|
|
1332
280
|
}) => {
|
|
1333
|
-
const
|
|
1334
|
-
|
|
281
|
+
const l = n(
|
|
282
|
+
y,
|
|
1335
283
|
g
|
|
1336
284
|
);
|
|
1337
|
-
|
|
1338
|
-
const
|
|
1339
|
-
|
|
1340
|
-
|
|
285
|
+
a = t(l);
|
|
286
|
+
const R = n(
|
|
287
|
+
_,
|
|
288
|
+
v
|
|
1341
289
|
);
|
|
1342
|
-
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1345
|
-
const
|
|
1346
|
-
|
|
1347
|
-
},
|
|
1348
|
-
|
|
290
|
+
u = s(R);
|
|
291
|
+
const b = n(p, M);
|
|
292
|
+
m = r(b);
|
|
293
|
+
const O = n(i, S);
|
|
294
|
+
E = o(O);
|
|
295
|
+
}, f = () => {
|
|
296
|
+
a(), u(), m(), E();
|
|
1349
297
|
};
|
|
1350
298
|
return {
|
|
1351
|
-
start: (
|
|
1352
|
-
|
|
299
|
+
start: (y) => {
|
|
300
|
+
C(y);
|
|
1353
301
|
},
|
|
1354
302
|
stop: () => {
|
|
1355
|
-
|
|
303
|
+
f();
|
|
1356
304
|
}
|
|
1357
305
|
};
|
|
1358
|
-
},
|
|
306
|
+
}, rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1359
307
|
__proto__: null,
|
|
1360
|
-
PURGATORY_CONFERENCE_NUMBER:
|
|
1361
|
-
createSyncMediaState:
|
|
1362
|
-
error:
|
|
1363
|
-
getExtraHeaders:
|
|
1364
|
-
getUserAgent:
|
|
1365
|
-
hasPurgatory:
|
|
1366
|
-
resolveAnswerIncomingCall:
|
|
1367
|
-
resolveAskPermissionToEnableCam:
|
|
1368
|
-
resolveCallToServer:
|
|
1369
|
-
resolveConnectToServer:
|
|
1370
|
-
resolveDisconnectFromServer:
|
|
1371
|
-
resolveGetRemoteStreams:
|
|
1372
|
-
resolveOnMustStopPresentation:
|
|
1373
|
-
resolveOnUseLicense:
|
|
1374
|
-
resolveSendMediaState:
|
|
1375
|
-
resolveSendRefusalToTurnOnCam:
|
|
1376
|
-
resolveSendRefusalToTurnOnMic:
|
|
1377
|
-
resolveStartPresentation:
|
|
1378
|
-
resolveStopShareSipConnector:
|
|
1379
|
-
resolveUpdatePresentation:
|
|
1380
|
-
resolveUpdateRemoteStreams:
|
|
1381
|
-
sendDTMFAccumulated:
|
|
1382
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1383
|
-
const t =
|
|
308
|
+
PURGATORY_CONFERENCE_NUMBER: $,
|
|
309
|
+
createSyncMediaState: Ae,
|
|
310
|
+
error: oe,
|
|
311
|
+
getExtraHeaders: ce,
|
|
312
|
+
getUserAgent: ie,
|
|
313
|
+
hasPurgatory: A,
|
|
314
|
+
resolveAnswerIncomingCall: Z,
|
|
315
|
+
resolveAskPermissionToEnableCam: ue,
|
|
316
|
+
resolveCallToServer: ee,
|
|
317
|
+
resolveConnectToServer: ne,
|
|
318
|
+
resolveDisconnectFromServer: te,
|
|
319
|
+
resolveGetRemoteStreams: B,
|
|
320
|
+
resolveOnMustStopPresentation: le,
|
|
321
|
+
resolveOnUseLicense: Se,
|
|
322
|
+
resolveSendMediaState: de,
|
|
323
|
+
resolveSendRefusalToTurnOnCam: me,
|
|
324
|
+
resolveSendRefusalToTurnOnMic: fe,
|
|
325
|
+
resolveStartPresentation: Ee,
|
|
326
|
+
resolveStopShareSipConnector: ge,
|
|
327
|
+
resolveUpdatePresentation: he,
|
|
328
|
+
resolveUpdateRemoteStreams: k,
|
|
329
|
+
sendDTMFAccumulated: be
|
|
330
|
+
}, Symbol.toStringTag, { value: "Module" })), Pe = (e) => [...e.keys()].map((n) => e.get(n)), we = (e, n) => Pe(e).find((t) => t.type === n), Ie = async (e) => e.getStats().then((n) => {
|
|
331
|
+
const t = we(n, "codec");
|
|
1384
332
|
return t == null ? void 0 : t.mimeType;
|
|
1385
|
-
}),
|
|
333
|
+
}), Be = (e) => e.find((n) => {
|
|
1386
334
|
var t;
|
|
1387
|
-
return ((t =
|
|
1388
|
-
}),
|
|
1389
|
-
const
|
|
1390
|
-
return
|
|
1391
|
-
},
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
335
|
+
return ((t = n == null ? void 0 : n.track) == null ? void 0 : t.kind) === "video";
|
|
336
|
+
}), X = (e, n) => e !== void 0 && n !== void 0 && e.toLowerCase().includes(n.toLowerCase()), ke = "ERROR_NOT_RUNNING", De = (e) => {
|
|
337
|
+
const n = new Error("Promise was not running");
|
|
338
|
+
return n.basePromise = e, n.id = ke, n.name = "Not running", n;
|
|
339
|
+
}, Fe = async (e, n) => e.reduce(
|
|
340
|
+
async (t, s) => t.then(async ({ success: r, errors: o, results: a }) => (!n || n(s) ? s() : Promise.reject(De(s))).then((u) => ({
|
|
341
|
+
errors: o,
|
|
342
|
+
success: [...r, u],
|
|
343
|
+
results: [...a, u],
|
|
344
|
+
isSuccessful: !0,
|
|
345
|
+
isError: !1
|
|
346
|
+
})).catch((u) => ({
|
|
347
|
+
success: r,
|
|
348
|
+
errors: [...o, u],
|
|
349
|
+
results: [...a, u],
|
|
350
|
+
isSuccessful: !1,
|
|
351
|
+
isError: !0
|
|
352
|
+
}))),
|
|
353
|
+
Promise.resolve({
|
|
354
|
+
success: [],
|
|
355
|
+
errors: [],
|
|
356
|
+
results: [],
|
|
357
|
+
isSuccessful: !1,
|
|
358
|
+
isError: !1
|
|
359
|
+
})
|
|
360
|
+
), Ue = new Error("Stack is empty"), Le = new Error("Promise is not actual"), xe = new Error(
|
|
361
|
+
"stackPromises only works with functions that returns a Promise"
|
|
362
|
+
), Ve = ({
|
|
363
|
+
noRejectIsNotActual: e = !1,
|
|
364
|
+
noRunIsNotActual: n = !1
|
|
365
|
+
} = {}) => {
|
|
366
|
+
const t = [], s = [], r = ({ task: i, index: S }) => {
|
|
367
|
+
s.push({ task: i, index: S });
|
|
368
|
+
}, o = (i, { task: S, index: l }) => {
|
|
369
|
+
const R = s.find(({ task: b, index: O }) => S === b && l === O);
|
|
370
|
+
if (!R)
|
|
371
|
+
throw new Error("Task not found");
|
|
372
|
+
if (R.promise)
|
|
373
|
+
throw new Error("Task is already running");
|
|
374
|
+
R.promise = i;
|
|
375
|
+
}, a = ({
|
|
376
|
+
task: i,
|
|
377
|
+
index: S
|
|
378
|
+
}) => {
|
|
379
|
+
const l = s.find(({ task: R, index: b }) => i === R && S === b);
|
|
380
|
+
if (l)
|
|
381
|
+
return l.promise;
|
|
382
|
+
}, u = ({ task: i }) => {
|
|
383
|
+
const S = s.at(-1);
|
|
384
|
+
return (S == null ? void 0 : S.task) === i;
|
|
385
|
+
}, m = ({ task: i, index: S }) => (r({ task: i, index: S }), async () => {
|
|
386
|
+
let l = a({ task: i, index: S });
|
|
387
|
+
const R = u({ task: i });
|
|
388
|
+
return !l && n && !R ? Promise.resolve() : (l || (l = i({ isActual: R }), o(l, { task: i, index: S })), l);
|
|
389
|
+
}), E = ({
|
|
390
|
+
resolve: i,
|
|
391
|
+
reject: S
|
|
392
|
+
}) => ({ results: l, isSuccessful: R }) => {
|
|
393
|
+
const b = l.length, O = t.length;
|
|
394
|
+
if (b === O) {
|
|
395
|
+
const d = l.at(-1);
|
|
396
|
+
if (R) {
|
|
397
|
+
i(d);
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
S(d);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (e) {
|
|
404
|
+
const d = l.at(-1);
|
|
405
|
+
i(d);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
S(Le);
|
|
409
|
+
};
|
|
410
|
+
let C = !1;
|
|
411
|
+
const f = () => {
|
|
412
|
+
C = !0;
|
|
413
|
+
}, T = () => {
|
|
414
|
+
C = !1;
|
|
415
|
+
}, h = () => C, y = async () => (f(), Fe(t, h)), g = async () => {
|
|
416
|
+
if (t.length === 0)
|
|
417
|
+
throw Ue;
|
|
418
|
+
return new Promise((i, S) => {
|
|
419
|
+
const l = E({ resolve: i, reject: S });
|
|
420
|
+
y().then(l).catch(l);
|
|
421
|
+
});
|
|
422
|
+
}, _ = (i) => {
|
|
423
|
+
if (typeof i != "function")
|
|
424
|
+
throw xe;
|
|
425
|
+
const S = t.length;
|
|
426
|
+
return t.push(m({ task: i, index: S })), g;
|
|
427
|
+
}, v = async (i) => (_(i), g()), p = () => {
|
|
428
|
+
t.length = 0, s.length = 0;
|
|
429
|
+
}, M = () => {
|
|
430
|
+
T(), p();
|
|
431
|
+
};
|
|
432
|
+
return g.add = _, g.run = v, g.stop = M, g;
|
|
433
|
+
}, $e = 1e6, N = (e) => e * $e, K = N(0.06), Ge = N(4), je = (e) => e <= 64 ? K : e <= 128 ? N(0.12) : e <= 256 ? N(0.25) : e <= 384 ? N(0.32) : e <= 426 ? N(0.38) : e <= 640 ? N(0.5) : e <= 848 ? N(0.7) : e <= 1280 ? N(1) : e <= 1920 ? N(2) : Ge, Xe = "av1", Ke = (e) => X(e, Xe), We = 0.6, W = (e, n) => Ke(n) ? e * We : e, He = (e) => W(K, e), H = (e, n) => {
|
|
434
|
+
const t = je(e);
|
|
435
|
+
return W(t, n);
|
|
436
|
+
}, Y = Ve(), Ye = async () => Y().catch((e) => {
|
|
437
|
+
c("videoSendingBalancer: error", e);
|
|
438
|
+
}), ze = async (e) => (Y.add(e), Ye()), F = async ({
|
|
439
|
+
sender: e,
|
|
440
|
+
scaleResolutionDownBy: n,
|
|
1396
441
|
maxBitrate: t,
|
|
1397
442
|
onSetParameters: s
|
|
1398
|
-
}) =>
|
|
1399
|
-
const r =
|
|
1400
|
-
return
|
|
1401
|
-
sender:
|
|
443
|
+
}) => ze(async () => z(e, { scaleResolutionDownBy: n, maxBitrate: t }, s)), qe = async ({ sender: e, codec: n }, t) => {
|
|
444
|
+
const r = He(n);
|
|
445
|
+
return F({
|
|
446
|
+
sender: e,
|
|
1402
447
|
maxBitrate: r,
|
|
1403
448
|
onSetParameters: t,
|
|
1404
449
|
scaleResolutionDownBy: 200
|
|
1405
450
|
});
|
|
1406
|
-
},
|
|
1407
|
-
const
|
|
1408
|
-
return
|
|
1409
|
-
sender:
|
|
1410
|
-
maxBitrate:
|
|
451
|
+
}, I = async ({ sender: e, track: n, codec: t }, s) => {
|
|
452
|
+
const a = n.getSettings().width, u = H(a, t);
|
|
453
|
+
return F({
|
|
454
|
+
sender: e,
|
|
455
|
+
maxBitrate: u,
|
|
1411
456
|
onSetParameters: s,
|
|
1412
457
|
scaleResolutionDownBy: 1
|
|
1413
458
|
});
|
|
1414
|
-
},
|
|
1415
|
-
sender:
|
|
1416
|
-
track:
|
|
459
|
+
}, Je = async ({
|
|
460
|
+
sender: e,
|
|
461
|
+
track: n,
|
|
1417
462
|
resolution: t,
|
|
1418
463
|
codec: s
|
|
1419
464
|
}, r) => {
|
|
1420
|
-
const o =
|
|
1421
|
-
return
|
|
1422
|
-
sender:
|
|
1423
|
-
maxBitrate:
|
|
465
|
+
const o = n.getSettings(), a = o.width, u = o.height, [m, E] = t.split("x"), C = a / Number(m), f = u / Number(E), h = Math.max(C, f, 1), y = H(Number(m), s);
|
|
466
|
+
return F({
|
|
467
|
+
sender: e,
|
|
468
|
+
maxBitrate: y,
|
|
1424
469
|
onSetParameters: r,
|
|
1425
470
|
scaleResolutionDownBy: h
|
|
1426
471
|
});
|
|
1427
|
-
},
|
|
1428
|
-
mainCam:
|
|
1429
|
-
resolutionMainCam:
|
|
472
|
+
}, Qe = async ({
|
|
473
|
+
mainCam: e,
|
|
474
|
+
resolutionMainCam: n,
|
|
1430
475
|
sender: t,
|
|
1431
476
|
track: s,
|
|
1432
477
|
codec: r
|
|
1433
478
|
}, o) => {
|
|
1434
|
-
switch (
|
|
1435
|
-
case
|
|
1436
|
-
return
|
|
1437
|
-
case
|
|
1438
|
-
return
|
|
1439
|
-
case
|
|
1440
|
-
return
|
|
1441
|
-
{ sender: t, track: s, codec: r, resolution:
|
|
479
|
+
switch (e) {
|
|
480
|
+
case P.PAUSE_MAIN_CAM:
|
|
481
|
+
return qe({ sender: t, codec: r }, o);
|
|
482
|
+
case P.RESUME_MAIN_CAM:
|
|
483
|
+
return I({ sender: t, track: s, codec: r }, o);
|
|
484
|
+
case P.MAX_MAIN_CAM_RESOLUTION:
|
|
485
|
+
return n !== void 0 ? Je(
|
|
486
|
+
{ sender: t, track: s, codec: r, resolution: n },
|
|
1442
487
|
o
|
|
1443
|
-
) :
|
|
488
|
+
) : I({ sender: t, track: s, codec: r }, o);
|
|
1444
489
|
default:
|
|
1445
|
-
return
|
|
490
|
+
return I({ sender: t, track: s, codec: r }, o);
|
|
1446
491
|
}
|
|
1447
|
-
},
|
|
492
|
+
}, U = {
|
|
1448
493
|
isChanged: !1,
|
|
1449
494
|
parameters: {
|
|
1450
495
|
encodings: [{}],
|
|
@@ -1453,54 +498,54 @@ const Ts = (n = new Error()) => {
|
|
|
1453
498
|
headerExtensions: [],
|
|
1454
499
|
rtcp: {}
|
|
1455
500
|
}
|
|
1456
|
-
},
|
|
1457
|
-
mainCam:
|
|
1458
|
-
resolutionMainCam:
|
|
501
|
+
}, L = async ({
|
|
502
|
+
mainCam: e,
|
|
503
|
+
resolutionMainCam: n,
|
|
1459
504
|
connection: t,
|
|
1460
505
|
onSetParameters: s,
|
|
1461
506
|
ignoreForCodec: r
|
|
1462
507
|
}) => {
|
|
1463
|
-
const o = t.getSenders(),
|
|
1464
|
-
if (!(
|
|
1465
|
-
return
|
|
1466
|
-
const
|
|
1467
|
-
return
|
|
1468
|
-
{ mainCam:
|
|
508
|
+
const o = t.getSenders(), a = Be(o);
|
|
509
|
+
if (!(a != null && a.track))
|
|
510
|
+
return U;
|
|
511
|
+
const u = await Ie(a);
|
|
512
|
+
return X(u, r) ? U : Qe(
|
|
513
|
+
{ mainCam: e, resolutionMainCam: n, sender: a, codec: u, track: a.track },
|
|
1469
514
|
s
|
|
1470
515
|
);
|
|
1471
|
-
},
|
|
1472
|
-
ignoreForCodec:
|
|
516
|
+
}, on = (e, {
|
|
517
|
+
ignoreForCodec: n,
|
|
1473
518
|
onSetParameters: t
|
|
1474
519
|
} = {}) => {
|
|
1475
520
|
const s = async () => {
|
|
1476
|
-
const { connection:
|
|
1477
|
-
if (!
|
|
521
|
+
const { connection: m } = e;
|
|
522
|
+
if (!m)
|
|
1478
523
|
throw new Error("connection is not exist");
|
|
1479
|
-
return
|
|
1480
|
-
connection:
|
|
524
|
+
return L({
|
|
525
|
+
connection: m,
|
|
1481
526
|
onSetParameters: t,
|
|
1482
|
-
ignoreForCodec:
|
|
527
|
+
ignoreForCodec: n
|
|
1483
528
|
});
|
|
1484
529
|
};
|
|
1485
530
|
let r = s;
|
|
1486
|
-
const o = async (
|
|
1487
|
-
const { mainCam:
|
|
1488
|
-
if (!
|
|
531
|
+
const o = async (m) => (r = async () => {
|
|
532
|
+
const { mainCam: E, resolutionMainCam: C } = m, { connection: f } = e;
|
|
533
|
+
if (!f)
|
|
1489
534
|
throw new Error("connection is not exist");
|
|
1490
|
-
return
|
|
1491
|
-
mainCam:
|
|
1492
|
-
resolutionMainCam:
|
|
1493
|
-
connection:
|
|
535
|
+
return L({
|
|
536
|
+
mainCam: E,
|
|
537
|
+
resolutionMainCam: C,
|
|
538
|
+
connection: f,
|
|
1494
539
|
onSetParameters: t,
|
|
1495
|
-
ignoreForCodec:
|
|
540
|
+
ignoreForCodec: n
|
|
1496
541
|
});
|
|
1497
542
|
}, r());
|
|
1498
543
|
return {
|
|
1499
544
|
subscribe: () => {
|
|
1500
|
-
|
|
545
|
+
e.onSession("main-cam-control", o);
|
|
1501
546
|
},
|
|
1502
547
|
unsubscribe: () => {
|
|
1503
|
-
|
|
548
|
+
e.offSession("main-cam-control", o);
|
|
1504
549
|
},
|
|
1505
550
|
balanceByTrack: s,
|
|
1506
551
|
resetMainCamControl() {
|
|
@@ -1512,19 +557,19 @@ const Ts = (n = new Error()) => {
|
|
|
1512
557
|
};
|
|
1513
558
|
};
|
|
1514
559
|
export {
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
560
|
+
P as EEventsMainCAM,
|
|
561
|
+
un as EEventsMic,
|
|
562
|
+
ln as EEventsSyncMediaState,
|
|
563
|
+
Sn as EUseLicense,
|
|
564
|
+
dn as causes,
|
|
565
|
+
mn as constants,
|
|
566
|
+
hn as debug,
|
|
567
|
+
en as default,
|
|
568
|
+
fn as disableDebug,
|
|
569
|
+
Cn as enableDebug,
|
|
570
|
+
En as eventNames,
|
|
571
|
+
Ie as getCodecFromSender,
|
|
572
|
+
gn as hasCanceledCallError,
|
|
573
|
+
on as resolveVideoSendingBalancer,
|
|
574
|
+
rn as tools
|
|
1530
575
|
};
|