sip-connector 12.0.0 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SipConnector-Dq5DrJxd.js → SipConnector-BxDInUHC.js} +141 -140
- package/dist/SipConnector-Ds1fhzNg.cjs +1 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +12 -11
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
- package/dist/SipConnector-BWx586hI.cjs +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var It = Object.defineProperty;
|
|
2
2
|
var ft = (s, e, t) => e in s ? It(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var o = (s, e, t) => ft(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { CancelableRequest as g, isCanceledError as
|
|
4
|
+
import { CancelableRequest as g, isCanceledError as Pt } from "@krivega/cancelable-promise";
|
|
5
5
|
import Me from "events-constructor";
|
|
6
6
|
import { repeatedCallsAsync as ve } from "repeated-calls";
|
|
7
7
|
import V from "debug";
|
|
8
|
-
const
|
|
8
|
+
const mt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code", Dt = "Internal Error", pt = "Busy", ke = "Rejected", Mt = "Redirected", vt = "Unavailable", yt = "Not Found", wt = "Address Incomplete", bt = "Incompatible SDP", Ut = "Missing SDP", Lt = "Authentication Error", Be = "Terminated", Ht = "WebRTC Error", qe = "Canceled", Wt = "No Answer", kt = "Expires", Bt = "No ACK", qt = "Dialog Error", Ft = "User Denied Media Access", xt = "Bad Media Description", Vt = "RTP Timeout", hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9
9
|
__proto__: null,
|
|
10
10
|
ADDRESS_INCOMPLETE: wt,
|
|
11
11
|
AUTHENTICATION_ERROR: Lt,
|
|
@@ -13,7 +13,7 @@ const Pt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code",
|
|
|
13
13
|
BUSY: pt,
|
|
14
14
|
BYE: Be,
|
|
15
15
|
CANCELED: qe,
|
|
16
|
-
CONNECTION_ERROR:
|
|
16
|
+
CONNECTION_ERROR: mt,
|
|
17
17
|
DIALOG_ERROR: qt,
|
|
18
18
|
EXPIRES: kt,
|
|
19
19
|
INCOMPATIBLE_SDP: bt,
|
|
@@ -30,7 +30,7 @@ const Pt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code",
|
|
|
30
30
|
UNAVAILABLE: vt,
|
|
31
31
|
USER_DENIED_MEDIA_ACCESS: Ft,
|
|
32
32
|
WEBRTC_ERROR: Ht
|
|
33
|
-
}, Symbol.toStringTag, { value: "Module" })), Y = "incomingCall", G = "declinedIncomingCall", $ = "failedIncomingCall", J = "terminatedIncomingCall", W = "connecting",
|
|
33
|
+
}, Symbol.toStringTag, { value: "Module" })), Y = "incomingCall", G = "declinedIncomingCall", $ = "failedIncomingCall", J = "terminatedIncomingCall", W = "connecting", P = "connected", N = "disconnected", v = "newRTCSession", m = "registered", X = "unregistered", O = "registrationFailed", Fe = "newMessage", z = "sipEvent", Q = "availableSecondRemoteStream", j = "notAvailableSecondRemoteStream", K = "mustStopPresentation", y = "shareState", Z = "enterRoom", ee = "useLicense", te = "peerconnection:confirmed", ne = "peerconnection:ontrack", w = "channels", se = "channels:notify", ie = "ended:fromserver", oe = "main-cam-control", re = "admin-stop-main-cam", ae = "admin-start-main-cam", ce = "admin-stop-mic", _e = "admin-start-mic", b = "admin-force-sync-media-state", Ee = "participant:added-to-list-moderators", he = "participant:removed-from-list-moderators", de = "participant:move-request-to-stream", le = "participant:move-request-to-spectators", Te = "participant:move-request-to-participants", ue = "participation:accepting-word-request", Se = "participation:cancelling-word-request", Ne = "webcast:started", ge = "webcast:stopped", Ce = "account:changed", Ae = "account:deleted", Re = "conference:participant-token-issued", D = "ended", xe = "sending", Ve = "reinvite", Ye = "replaces", Ge = "refer", $e = "progress", Je = "accepted", U = "confirmed", L = "peerconnection", R = "failed", Xe = "muted", ze = "unmuted", Ie = "newDTMF", fe = "newInfo", Qe = "hold", je = "unhold", Ke = "update", Ze = "sdp", et = "icecandidate", tt = "getusermediafailed", nt = "peerconnection:createofferfailed", st = "peerconnection:createanswerfailed", it = "peerconnection:setlocaldescriptionfailed", ot = "peerconnection:setremotedescriptionfailed", rt = "presentation:start", at = "presentation:started", ct = "presentation:end", Pe = "presentation:ended", H = "presentation:failed", _t = "SPECTATOR", Et = "PARTICIPANT", ht = 1e6, ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
34
34
|
__proto__: null,
|
|
35
35
|
ACCEPTED: Je,
|
|
36
36
|
ACCOUNT_CHANGED: Ce,
|
|
@@ -45,7 +45,7 @@ const Pt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code",
|
|
|
45
45
|
CHANNELS_NOTIFY: se,
|
|
46
46
|
CONFERENCE_PARTICIPANT_TOKEN_ISSUED: Re,
|
|
47
47
|
CONFIRMED: U,
|
|
48
|
-
CONNECTED:
|
|
48
|
+
CONNECTED: P,
|
|
49
49
|
CONNECTING: W,
|
|
50
50
|
DECLINED_INCOMING_CALL: G,
|
|
51
51
|
DISCONNECTED: N,
|
|
@@ -66,13 +66,13 @@ const Pt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code",
|
|
|
66
66
|
NEW_MESSAGE: Fe,
|
|
67
67
|
NEW_RTC_SESSION: v,
|
|
68
68
|
NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: j,
|
|
69
|
-
ONE_MEGABIT_IN_BITS:
|
|
69
|
+
ONE_MEGABIT_IN_BITS: ht,
|
|
70
70
|
PARTICIPANT: Et,
|
|
71
71
|
PARTICIPANT_ADDED_TO_LIST_MODERATORS: Ee,
|
|
72
72
|
PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS: Te,
|
|
73
73
|
PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS: le,
|
|
74
|
-
PARTICIPANT_MOVE_REQUEST_TO_STREAM:
|
|
75
|
-
PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:
|
|
74
|
+
PARTICIPANT_MOVE_REQUEST_TO_STREAM: de,
|
|
75
|
+
PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: he,
|
|
76
76
|
PARTICIPATION_ACCEPTING_WORD_REQUEST: ue,
|
|
77
77
|
PARTICIPATION_CANCELLING_WORD_REQUEST: Se,
|
|
78
78
|
PEER_CONNECTION: L,
|
|
@@ -83,13 +83,13 @@ const Pt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code",
|
|
|
83
83
|
PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED: it,
|
|
84
84
|
PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED: ot,
|
|
85
85
|
PRESENTATION_END: ct,
|
|
86
|
-
PRESENTATION_ENDED:
|
|
86
|
+
PRESENTATION_ENDED: Pe,
|
|
87
87
|
PRESENTATION_FAILED: H,
|
|
88
88
|
PRESENTATION_START: rt,
|
|
89
89
|
PRESENTATION_STARTED: at,
|
|
90
90
|
PROGRESS: $e,
|
|
91
91
|
REFER: Ge,
|
|
92
|
-
REGISTERED:
|
|
92
|
+
REGISTERED: m,
|
|
93
93
|
REGISTRATION_FAILED: O,
|
|
94
94
|
REINVITE: Ve,
|
|
95
95
|
REPLACES: Ye,
|
|
@@ -106,14 +106,14 @@ const Pt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code",
|
|
|
106
106
|
USE_LICENSE: ee,
|
|
107
107
|
WEBCAST_STARTED: Ne,
|
|
108
108
|
WEBCAST_STOPPED: ge
|
|
109
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
109
|
+
}, Symbol.toStringTag, { value: "Module" })), dt = [
|
|
110
110
|
Y,
|
|
111
111
|
G,
|
|
112
112
|
J,
|
|
113
113
|
$,
|
|
114
114
|
ue,
|
|
115
115
|
Se,
|
|
116
|
-
|
|
116
|
+
de,
|
|
117
117
|
se,
|
|
118
118
|
Re,
|
|
119
119
|
Ce,
|
|
@@ -121,13 +121,13 @@ const Pt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code",
|
|
|
121
121
|
Ne,
|
|
122
122
|
ge,
|
|
123
123
|
Ee,
|
|
124
|
-
|
|
125
|
-
],
|
|
124
|
+
he
|
|
125
|
+
], me = [
|
|
126
126
|
W,
|
|
127
|
-
|
|
127
|
+
P,
|
|
128
128
|
N,
|
|
129
129
|
v,
|
|
130
|
-
|
|
130
|
+
m,
|
|
131
131
|
X,
|
|
132
132
|
O,
|
|
133
133
|
Fe,
|
|
@@ -180,25 +180,25 @@ const Pt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code",
|
|
|
180
180
|
rt,
|
|
181
181
|
at,
|
|
182
182
|
ct,
|
|
183
|
-
|
|
183
|
+
Pe,
|
|
184
184
|
H
|
|
185
|
-
], Tt = [...
|
|
185
|
+
], Tt = [...me, ...dt], ut = [
|
|
186
186
|
...Oe,
|
|
187
187
|
...lt
|
|
188
|
-
],
|
|
188
|
+
], ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
189
189
|
__proto__: null,
|
|
190
190
|
SESSION_EVENT_NAMES: ut,
|
|
191
191
|
SESSION_JSSIP_EVENT_NAMES: Oe,
|
|
192
192
|
SESSION_SYNTHETICS_EVENT_NAMES: lt,
|
|
193
193
|
UA_EVENT_NAMES: Tt,
|
|
194
|
-
UA_JSSIP_EVENT_NAMES:
|
|
195
|
-
UA_SYNTHETICS_EVENT_NAMES:
|
|
194
|
+
UA_JSSIP_EVENT_NAMES: me,
|
|
195
|
+
UA_SYNTHETICS_EVENT_NAMES: dt
|
|
196
196
|
}, Symbol.toStringTag, { value: "Module" })), Yt = (s) => {
|
|
197
197
|
const e = [];
|
|
198
198
|
return s && e.push(`X-Vinteo-Remote: ${s}`), e;
|
|
199
|
-
}, Gt = "content-type", $t = "x-webrtc-enter-room", p = "application/vinteo.webrtc.sharedesktop", Jt = "application/vinteo.webrtc.roomname", Xt = "application/vinteo.webrtc.channels", zt = "application/vinteo.webrtc.mediastate", Qt = "application/vinteo.webrtc.refusal", ye = "application/vinteo.webrtc.maincam", jt = "application/vinteo.webrtc.mic", Kt = "application/vinteo.webrtc.uselic", Zt = "X-WEBRTC-USE-LICENSE", en = "X-WEBRTC-PARTICIPANT-NAME", we = "X-WEBRTC-INPUT-CHANNELS", be = "X-WEBRTC-OUTPUT-CHANNELS", tn = "X-WEBRTC-MAINCAM", nn = "X-WEBRTC-MIC", Ue = "X-WEBRTC-SYNC", sn = "X-WEBRTC-MAINCAM-RESOLUTION", on = "X-WEBRTC-MEDIA-STATE", rn = "X-Vinteo-Media-Type", an = "X-Vinteo-MainCam-State", cn = "X-Vinteo-Mic-State", _n = "application/vinteo.webrtc.partstate", En = "X-WEBRTC-PARTSTATE",
|
|
199
|
+
}, Gt = "content-type", $t = "x-webrtc-enter-room", p = "application/vinteo.webrtc.sharedesktop", Jt = "application/vinteo.webrtc.roomname", Xt = "application/vinteo.webrtc.channels", zt = "application/vinteo.webrtc.mediastate", Qt = "application/vinteo.webrtc.refusal", ye = "application/vinteo.webrtc.maincam", jt = "application/vinteo.webrtc.mic", Kt = "application/vinteo.webrtc.uselic", Zt = "X-WEBRTC-USE-LICENSE", en = "X-WEBRTC-PARTICIPANT-NAME", we = "X-WEBRTC-INPUT-CHANNELS", be = "X-WEBRTC-OUTPUT-CHANNELS", tn = "X-WEBRTC-MAINCAM", nn = "X-WEBRTC-MIC", Ue = "X-WEBRTC-SYNC", sn = "X-WEBRTC-MAINCAM-RESOLUTION", on = "X-WEBRTC-MEDIA-STATE", rn = "X-Vinteo-Media-Type", an = "X-Vinteo-MainCam-State", cn = "X-Vinteo-Mic-State", _n = "application/vinteo.webrtc.partstate", En = "X-WEBRTC-PARTSTATE", hn = "application/vinteo.webrtc.notify", dn = "X-VINTEO-NOTIFY", I = "x-webrtc-share-state", ln = `${I}: LETMESTARTPRESENTATION`, Tn = `${I}: STOPPRESENTATION`, St = "YOUCANRECEIVECONTENT", Nt = "CONTENTEND", gt = "YOUMUSTSTOPSENDCONTENT", un = `${I}: ${gt}`, Sn = `${I}: ${St}`, Nn = `${I}: ${Nt}`, gn = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", Cn = `${gn}: LETMESTARTMAINCAM`, De = "sip-connector", B = V(De), Ts = () => {
|
|
200
200
|
V.enable(De);
|
|
201
|
-
},
|
|
201
|
+
}, us = () => {
|
|
202
202
|
V.enable(`-${De}`);
|
|
203
203
|
}, An = (s, e) => {
|
|
204
204
|
s.getVideoTracks().forEach((n) => {
|
|
@@ -214,48 +214,48 @@ const Pt = "Connection Error", We = "Request Timeout", Ot = "SIP Failure Code",
|
|
|
214
214
|
const i = t === "recvonly" ? [] : s.getAudioTracks(), r = e === "recvonly" ? [] : s.getVideoTracks(), a = [...i, ...r], c = new MediaStream(a);
|
|
215
215
|
return c.getTracks = () => [...c.getAudioTracks(), ...c.getVideoTracks()], n && n !== "none" && An(c, n), c;
|
|
216
216
|
};
|
|
217
|
-
var f = /* @__PURE__ */ ((s) => (s.PAUSE_MAIN_CAM = "PAUSEMAINCAM", s.RESUME_MAIN_CAM = "RESUMEMAINCAM", s.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", s.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", s.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", s))(f || {}), q = /* @__PURE__ */ ((s) => (s.ADMIN_STOP_MIC = "ADMINSTOPMIC", s.ADMIN_START_MIC = "ADMINSTARTMIC", s))(q || {}), F = /* @__PURE__ */ ((s) => (s.ADMIN_SYNC_FORCED = "1", s.ADMIN_SYNC_NOT_FORCED = "0", s))(F || {}), Rn = /* @__PURE__ */ ((s) => (s.AUDIO = "AUDIO", s.VIDEO = "VIDEO", s.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", s))(Rn || {});
|
|
218
|
-
function
|
|
217
|
+
var f = /* @__PURE__ */ ((s) => (s.PAUSE_MAIN_CAM = "PAUSEMAINCAM", s.RESUME_MAIN_CAM = "RESUMEMAINCAM", s.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", s.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", s.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", s))(f || {}), q = /* @__PURE__ */ ((s) => (s.ADMIN_STOP_MIC = "ADMINSTOPMIC", s.ADMIN_START_MIC = "ADMINSTARTMIC", s))(q || {}), F = /* @__PURE__ */ ((s) => (s.ADMIN_SYNC_FORCED = "1", s.ADMIN_SYNC_NOT_FORCED = "0", s))(F || {}), Rn = /* @__PURE__ */ ((s) => (s.AUDIO = "AUDIO", s.VIDEO = "VIDEO", s.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", s))(Rn || {}), In = /* @__PURE__ */ ((s) => (s.VP8 = "video/VP8", s.VP9 = "video/VP9", s.H264 = "video/H264", s.AV1 = "video/AV1", s.rtx = "video/rtx", s.red = "video/red", s.flexfec03 = "video/flexfec-03", s))(In || {});
|
|
218
|
+
function fn(s) {
|
|
219
219
|
return (e) => `sip:${e}@${s}`;
|
|
220
220
|
}
|
|
221
|
-
const
|
|
221
|
+
const Pn = (s, e) => () => Math.floor(Math.random() * (e - s)) + s, Le = (s) => s.trim().replaceAll(" ", "_"), mn = Pn(1e5, 99999999), On = (s) => s.some((t) => {
|
|
222
222
|
const { kind: n } = t;
|
|
223
223
|
return n === "video";
|
|
224
|
-
}),
|
|
224
|
+
}), Dn = "Error decline with 603", pn = 1006, Mn = (s) => typeof s == "object" && s !== null && "code" in s && s.code === pn, vn = (s) => s.message === Dn, yn = (s, e) => s.find((t) => t.track && e.getTracks().includes(t.track)), wn = (s, e) => (s.degradationPreference = e.degradationPreference, s), bn = (s, e) => {
|
|
225
225
|
s.encodings === void 0 && (s.encodings = []);
|
|
226
226
|
for (let t = s.encodings.length; t < e; t += 1)
|
|
227
227
|
s.encodings.push({});
|
|
228
228
|
return s;
|
|
229
|
-
}, Ct = (s) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== s,
|
|
230
|
-
if (
|
|
229
|
+
}, Ct = (s) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== s, Un = Ct(), Ln = (s, e) => {
|
|
230
|
+
if (Un(s, e))
|
|
231
231
|
return s;
|
|
232
|
-
},
|
|
233
|
-
const t = s.maxBitrate, n =
|
|
232
|
+
}, Hn = (s, e) => {
|
|
233
|
+
const t = s.maxBitrate, n = Ln(e, t);
|
|
234
234
|
return n !== void 0 && (s.maxBitrate = n), s;
|
|
235
|
-
}, At = 1,
|
|
235
|
+
}, At = 1, Wn = Ct(
|
|
236
236
|
At
|
|
237
|
-
),
|
|
237
|
+
), kn = (s, e) => {
|
|
238
238
|
const t = s === void 0 ? void 0 : Math.max(s, At);
|
|
239
|
-
if (t !== void 0 &&
|
|
239
|
+
if (t !== void 0 && Wn(
|
|
240
240
|
t,
|
|
241
241
|
e
|
|
242
242
|
))
|
|
243
243
|
return t;
|
|
244
|
-
},
|
|
245
|
-
const t = s.scaleResolutionDownBy, n =
|
|
244
|
+
}, Bn = (s, e) => {
|
|
245
|
+
const t = s.scaleResolutionDownBy, n = kn(
|
|
246
246
|
e,
|
|
247
247
|
t
|
|
248
248
|
);
|
|
249
249
|
return n !== void 0 && (s.scaleResolutionDownBy = n), s;
|
|
250
|
-
},
|
|
250
|
+
}, qn = (s, e) => {
|
|
251
251
|
var n;
|
|
252
252
|
const t = ((n = e.encodings) == null ? void 0 : n.length) ?? 0;
|
|
253
|
-
return
|
|
253
|
+
return bn(s, t), s.encodings.forEach((i, r) => {
|
|
254
254
|
const a = ((e == null ? void 0 : e.encodings) ?? [])[r], c = a == null ? void 0 : a.maxBitrate, E = a == null ? void 0 : a.scaleResolutionDownBy;
|
|
255
|
-
|
|
255
|
+
Hn(i, c), Bn(i, E);
|
|
256
256
|
}), s;
|
|
257
|
-
},
|
|
258
|
-
var t, n, i, r, a, c, E,
|
|
257
|
+
}, Fn = (s, e) => {
|
|
258
|
+
var t, n, i, r, a, c, E, h;
|
|
259
259
|
if (((t = s.codecs) == null ? void 0 : t.length) !== ((n = e.codecs) == null ? void 0 : n.length))
|
|
260
260
|
return !0;
|
|
261
261
|
for (let _ = 0; _ < (((i = s.codecs) == null ? void 0 : i.length) ?? 0); _++)
|
|
@@ -266,19 +266,19 @@ const fn = (s, e) => () => Math.floor(Math.random() * (e - s)) + s, Le = (s) =>
|
|
|
266
266
|
for (let _ = 0; _ < (((c = s.headerExtensions) == null ? void 0 : c.length) ?? 0); _++)
|
|
267
267
|
if (JSON.stringify(s.headerExtensions[_]) !== JSON.stringify(e.headerExtensions[_]))
|
|
268
268
|
return !0;
|
|
269
|
-
if (((E = s.encodings) == null ? void 0 : E.length) !== ((
|
|
269
|
+
if (((E = s.encodings) == null ? void 0 : E.length) !== ((h = e.encodings) == null ? void 0 : h.length))
|
|
270
270
|
return !0;
|
|
271
271
|
for (let _ = 0; _ < (s.encodings.length ?? 0); _++)
|
|
272
272
|
if (JSON.stringify(s.encodings[_]) !== JSON.stringify(e.encodings[_]))
|
|
273
273
|
return !0;
|
|
274
274
|
return s.rtcp.cname !== e.rtcp.cname || s.rtcp.reducedSize !== e.rtcp.reducedSize || s.degradationPreference !== e.degradationPreference;
|
|
275
|
-
},
|
|
275
|
+
}, xn = async (s, e) => {
|
|
276
276
|
const t = s.getParameters(), n = JSON.parse(JSON.stringify(t));
|
|
277
|
-
|
|
278
|
-
const i =
|
|
277
|
+
qn(t, e), wn(t, e);
|
|
278
|
+
const i = Fn(n, t);
|
|
279
279
|
return i && await s.setParameters(t), { parameters: t, isChanged: i };
|
|
280
|
-
},
|
|
281
|
-
const { isChanged: n, parameters: i } = await
|
|
280
|
+
}, Vn = async (s, e, t) => {
|
|
281
|
+
const { isChanged: n, parameters: i } = await xn(s, {
|
|
282
282
|
encodings: [
|
|
283
283
|
{
|
|
284
284
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -287,15 +287,15 @@ const fn = (s, e) => () => Math.floor(Math.random() * (e - s)) + s, Le = (s) =>
|
|
|
287
287
|
]
|
|
288
288
|
});
|
|
289
289
|
return n && t && t(i), { isChanged: n, parameters: i };
|
|
290
|
-
},
|
|
291
|
-
const n =
|
|
290
|
+
}, Yn = async (s, e, t) => {
|
|
291
|
+
const n = yn(s, e);
|
|
292
292
|
if (n)
|
|
293
|
-
return
|
|
294
|
-
},
|
|
293
|
+
return Vn(n, { maxBitrate: t });
|
|
294
|
+
}, Gn = 486, $n = 487, x = "local", He = "remote", Jn = 3, Xn = 1, Ss = (s = new Error()) => {
|
|
295
295
|
const { originator: e, cause: t } = s;
|
|
296
|
-
return
|
|
297
|
-
}, C = "SipConnector",
|
|
298
|
-
class
|
|
296
|
+
return Pt(s) ? !0 : typeof t == "string" ? t === We || t === ke || e === x && (t === qe || t === Be) : !1;
|
|
297
|
+
}, C = "SipConnector", zn = "channels", Qn = "WebcastStarted", jn = "WebcastStopped", Kn = "accountChanged", Zn = "accountDeleted", es = "addedToListModerators", ts = "removedFromListModerators", ns = "ParticipationRequestAccepted", ss = "ParticipationRequestRejected", is = "ParticipantMovedToWebcast", os = "ConferenceParticipantTokenIssued";
|
|
298
|
+
class Ns {
|
|
299
299
|
constructor({ JsSIP: e }) {
|
|
300
300
|
o(this, "_isRegisterConfig", !1);
|
|
301
301
|
o(this, "_connectionConfiguration", {});
|
|
@@ -339,7 +339,7 @@ class Ss {
|
|
|
339
339
|
}
|
|
340
340
|
return this.register();
|
|
341
341
|
});
|
|
342
|
-
o(this, "declineToIncomingCall", async ({ statusCode: e =
|
|
342
|
+
o(this, "declineToIncomingCall", async ({ statusCode: e = $n } = {}) => new Promise((t, n) => {
|
|
343
343
|
if (!this.isAvailableIncomingCall) {
|
|
344
344
|
n(new Error("no incomingSession"));
|
|
345
345
|
return;
|
|
@@ -347,14 +347,14 @@ class Ss {
|
|
|
347
347
|
const i = this.incomingSession, r = this.remoteCallerData;
|
|
348
348
|
this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(G, r), t(i.terminate({ status_code: e }));
|
|
349
349
|
}));
|
|
350
|
-
o(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode:
|
|
350
|
+
o(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode: Gn }));
|
|
351
351
|
o(this, "removeIncomingSession", () => {
|
|
352
352
|
delete this.incomingSession;
|
|
353
353
|
});
|
|
354
|
-
o(this, "_connectWithDuplicatedCalls", async (e, { callLimit: t =
|
|
354
|
+
o(this, "_connectWithDuplicatedCalls", async (e, { callLimit: t = Jn } = {}) => {
|
|
355
355
|
const n = async () => this._cancelableConnect.request(e), i = (r) => {
|
|
356
|
-
var
|
|
357
|
-
const c = !!((
|
|
356
|
+
var h;
|
|
357
|
+
const c = !!((h = this.ua) != null && h.isConnected()) && this.hasEqualConnectionConfiguration(e), E = !!r && !Mn(r);
|
|
358
358
|
return c || E;
|
|
359
359
|
};
|
|
360
360
|
return this._cancelableConnectWithRepeatedCalls = ve({
|
|
@@ -391,24 +391,24 @@ class Ss {
|
|
|
391
391
|
sessionTimers: a,
|
|
392
392
|
registerExpires: c,
|
|
393
393
|
connectionRecoveryMinInterval: E,
|
|
394
|
-
connectionRecoveryMaxInterval:
|
|
394
|
+
connectionRecoveryMaxInterval: h,
|
|
395
395
|
userAgent: _,
|
|
396
396
|
displayName: l = "",
|
|
397
|
-
register:
|
|
397
|
+
register: d = !1,
|
|
398
398
|
extraHeaders: T = []
|
|
399
399
|
}) => {
|
|
400
400
|
if (!n)
|
|
401
401
|
throw new Error("sipServerUrl is required");
|
|
402
402
|
if (!i)
|
|
403
403
|
throw new Error("sipWebSocketServerURL is required");
|
|
404
|
-
if (
|
|
404
|
+
if (d && !e)
|
|
405
405
|
throw new Error("user is required for authorized connection");
|
|
406
|
-
if (
|
|
406
|
+
if (d && !t)
|
|
407
407
|
throw new Error("password is required for authorized connection");
|
|
408
408
|
this._connectionConfiguration = {
|
|
409
409
|
sipServerUrl: n,
|
|
410
410
|
displayName: l,
|
|
411
|
-
register:
|
|
411
|
+
register: d,
|
|
412
412
|
user: e,
|
|
413
413
|
password: t
|
|
414
414
|
};
|
|
@@ -418,15 +418,15 @@ class Ss {
|
|
|
418
418
|
sipWebSocketServerURL: i,
|
|
419
419
|
password: t,
|
|
420
420
|
displayName: l,
|
|
421
|
-
register:
|
|
421
|
+
register: d,
|
|
422
422
|
sessionTimers: a,
|
|
423
423
|
registerExpires: c,
|
|
424
424
|
connectionRecoveryMinInterval: E,
|
|
425
|
-
connectionRecoveryMaxInterval:
|
|
425
|
+
connectionRecoveryMaxInterval: h,
|
|
426
426
|
userAgent: _
|
|
427
427
|
});
|
|
428
|
-
return this.getSipServerUrl = S.getSipServerUrl, this.socket = S.socket, this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!
|
|
429
|
-
const pe =
|
|
428
|
+
return this.getSipServerUrl = S.getSipServerUrl, this.socket = S.socket, this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!d, this.ua = this._createUa({ ...u, remoteAddress: r, extraHeaders: T }), this._uaEvents.eachTriggers((A, k) => {
|
|
429
|
+
const pe = me.find((Rt) => Rt === k);
|
|
430
430
|
pe && this.ua && this.ua.on(pe, A);
|
|
431
431
|
}), this.ua;
|
|
432
432
|
});
|
|
@@ -449,9 +449,9 @@ class Ss {
|
|
|
449
449
|
}, r = (E) => {
|
|
450
450
|
c(), t(E);
|
|
451
451
|
}, a = () => {
|
|
452
|
-
this.isRegisterConfig ? (this.on(
|
|
452
|
+
this.isRegisterConfig ? (this.on(m, i), this.on(O, r)) : this.on(P, i), this.on(N, r);
|
|
453
453
|
}, c = () => {
|
|
454
|
-
this.off(
|
|
454
|
+
this.off(m, i), this.off(O, r), this.off(P, i), this.off(N, r);
|
|
455
455
|
};
|
|
456
456
|
a(), this.on(v, this.handleNewRTCSession), n.start();
|
|
457
457
|
}));
|
|
@@ -466,8 +466,8 @@ class Ss {
|
|
|
466
466
|
const E = a || c;
|
|
467
467
|
c && this.isRegisterConfig ? this.register().then(() => {
|
|
468
468
|
n(E);
|
|
469
|
-
}).catch((
|
|
470
|
-
i(
|
|
469
|
+
}).catch((h) => {
|
|
470
|
+
i(h);
|
|
471
471
|
}) : E ? n(E) : i(new Error("nothing changed"));
|
|
472
472
|
}));
|
|
473
473
|
o(this, "_disconnectWithoutCancelRequests", async () => this._cancelableDisconnect.request());
|
|
@@ -489,10 +489,10 @@ class Ss {
|
|
|
489
489
|
videoMode: a,
|
|
490
490
|
audioMode: c,
|
|
491
491
|
contentHint: E,
|
|
492
|
-
offerToReceiveAudio:
|
|
492
|
+
offerToReceiveAudio: h = !0,
|
|
493
493
|
offerToReceiveVideo: _ = !0,
|
|
494
494
|
sendEncodings: l,
|
|
495
|
-
onAddedTransceiver:
|
|
495
|
+
onAddedTransceiver: d
|
|
496
496
|
}) => new Promise((T, u) => {
|
|
497
497
|
const { ua: S } = this;
|
|
498
498
|
if (!S) {
|
|
@@ -515,11 +515,11 @@ class Ss {
|
|
|
515
515
|
iceServers: r
|
|
516
516
|
},
|
|
517
517
|
rtcOfferConstraints: {
|
|
518
|
-
offerToReceiveAudio:
|
|
518
|
+
offerToReceiveAudio: h,
|
|
519
519
|
offerToReceiveVideo: _
|
|
520
520
|
},
|
|
521
521
|
sendEncodings: l,
|
|
522
|
-
onAddedTransceiver:
|
|
522
|
+
onAddedTransceiver: d
|
|
523
523
|
});
|
|
524
524
|
}));
|
|
525
525
|
o(this, "_answer", async ({
|
|
@@ -531,22 +531,22 @@ class Ss {
|
|
|
531
531
|
audioMode: a,
|
|
532
532
|
contentHint: c,
|
|
533
533
|
sendEncodings: E,
|
|
534
|
-
onAddedTransceiver:
|
|
534
|
+
onAddedTransceiver: h
|
|
535
535
|
}) => new Promise((_, l) => {
|
|
536
536
|
if (!this.isAvailableIncomingCall) {
|
|
537
537
|
l(new Error("no incomingSession"));
|
|
538
538
|
return;
|
|
539
539
|
}
|
|
540
540
|
this.session = this.incomingSession, this.removeIncomingSession();
|
|
541
|
-
const { session:
|
|
542
|
-
if (!
|
|
541
|
+
const { session: d } = this;
|
|
542
|
+
if (!d) {
|
|
543
543
|
l(new Error("No session established"));
|
|
544
544
|
return;
|
|
545
545
|
}
|
|
546
546
|
this._sessionEvents.eachTriggers((u, S) => {
|
|
547
547
|
const A = Oe.find((k) => k === S);
|
|
548
|
-
A &&
|
|
549
|
-
}), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number =
|
|
548
|
+
A && d.on(A, u);
|
|
549
|
+
}), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = d.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(_).catch((u) => {
|
|
550
550
|
l(u);
|
|
551
551
|
});
|
|
552
552
|
const T = M(e, {
|
|
@@ -554,7 +554,7 @@ class Ss {
|
|
|
554
554
|
audioMode: a,
|
|
555
555
|
contentHint: c
|
|
556
556
|
});
|
|
557
|
-
|
|
557
|
+
d.answer({
|
|
558
558
|
extraHeaders: n,
|
|
559
559
|
videoMode: r,
|
|
560
560
|
audioMode: a,
|
|
@@ -563,7 +563,7 @@ class Ss {
|
|
|
563
563
|
iceServers: i
|
|
564
564
|
},
|
|
565
565
|
sendEncodings: E,
|
|
566
|
-
onAddedTransceiver:
|
|
566
|
+
onAddedTransceiver: h
|
|
567
567
|
});
|
|
568
568
|
}));
|
|
569
569
|
o(this, "_handleCall", async ({ ontrack: e }) => new Promise((t, n) => {
|
|
@@ -575,16 +575,16 @@ class Ss {
|
|
|
575
575
|
this.onSession(R, E), this.onSession(D, E);
|
|
576
576
|
}, c = () => {
|
|
577
577
|
this.offSession(R, E), this.offSession(D, E);
|
|
578
|
-
}, E = (
|
|
579
|
-
r(), c(), n(
|
|
578
|
+
}, E = (d) => {
|
|
579
|
+
r(), c(), n(d);
|
|
580
580
|
};
|
|
581
|
-
let
|
|
582
|
-
const _ = ({ peerconnection:
|
|
583
|
-
|
|
584
|
-
this._sessionEvents.trigger(ne,
|
|
581
|
+
let h;
|
|
582
|
+
const _ = ({ peerconnection: d }) => {
|
|
583
|
+
h = d, h.ontrack = (T) => {
|
|
584
|
+
this._sessionEvents.trigger(ne, h), e && e(T);
|
|
585
585
|
};
|
|
586
586
|
}, l = () => {
|
|
587
|
-
|
|
587
|
+
h && this._sessionEvents.trigger(te, h), r(), c(), t(h);
|
|
588
588
|
};
|
|
589
589
|
i(), a();
|
|
590
590
|
}));
|
|
@@ -645,55 +645,55 @@ class Ss {
|
|
|
645
645
|
});
|
|
646
646
|
o(this, "_handleNotify", (e) => {
|
|
647
647
|
switch (e.cmd) {
|
|
648
|
-
case
|
|
648
|
+
case zn: {
|
|
649
649
|
const t = e;
|
|
650
650
|
this._triggerChannelsNotify(t);
|
|
651
651
|
break;
|
|
652
652
|
}
|
|
653
|
-
case
|
|
653
|
+
case Qn: {
|
|
654
654
|
const t = e;
|
|
655
655
|
this._triggerWebcastStartedNotify(t);
|
|
656
656
|
break;
|
|
657
657
|
}
|
|
658
|
-
case
|
|
658
|
+
case jn: {
|
|
659
659
|
const t = e;
|
|
660
660
|
this._triggerWebcastStoppedNotify(t);
|
|
661
661
|
break;
|
|
662
662
|
}
|
|
663
|
-
case
|
|
663
|
+
case es: {
|
|
664
664
|
const t = e;
|
|
665
665
|
this._triggerAddedToListModeratorsNotify(t);
|
|
666
666
|
break;
|
|
667
667
|
}
|
|
668
|
-
case
|
|
668
|
+
case ts: {
|
|
669
669
|
const t = e;
|
|
670
670
|
this._triggerRemovedFromListModeratorsNotify(t);
|
|
671
671
|
break;
|
|
672
672
|
}
|
|
673
|
-
case
|
|
673
|
+
case ns: {
|
|
674
674
|
const t = e;
|
|
675
675
|
this._triggerParticipationAcceptingWordRequest(t);
|
|
676
676
|
break;
|
|
677
677
|
}
|
|
678
|
-
case
|
|
678
|
+
case ss: {
|
|
679
679
|
const t = e;
|
|
680
680
|
this._triggerParticipationCancellingWordRequest(t);
|
|
681
681
|
break;
|
|
682
682
|
}
|
|
683
|
-
case
|
|
683
|
+
case is: {
|
|
684
684
|
const t = e;
|
|
685
685
|
this._triggerParticipantMoveRequestToStream(t);
|
|
686
686
|
break;
|
|
687
687
|
}
|
|
688
|
-
case
|
|
688
|
+
case Kn: {
|
|
689
689
|
this._triggerAccountChangedNotify();
|
|
690
690
|
break;
|
|
691
691
|
}
|
|
692
|
-
case
|
|
692
|
+
case Zn: {
|
|
693
693
|
this._triggerAccountDeletedNotify();
|
|
694
694
|
break;
|
|
695
695
|
}
|
|
696
|
-
case
|
|
696
|
+
case os: {
|
|
697
697
|
const t = e;
|
|
698
698
|
this._triggerConferenceParticipantTokenIssued(t);
|
|
699
699
|
break;
|
|
@@ -709,7 +709,7 @@ class Ss {
|
|
|
709
709
|
conference: e
|
|
710
710
|
};
|
|
711
711
|
this._uaEvents.trigger(
|
|
712
|
-
|
|
712
|
+
he,
|
|
713
713
|
t
|
|
714
714
|
);
|
|
715
715
|
});
|
|
@@ -781,7 +781,7 @@ class Ss {
|
|
|
781
781
|
const t = {
|
|
782
782
|
conference: e
|
|
783
783
|
};
|
|
784
|
-
this._uaEvents.trigger(
|
|
784
|
+
this._uaEvents.trigger(de, t);
|
|
785
785
|
});
|
|
786
786
|
o(this, "_triggerEnterRoom", (e) => {
|
|
787
787
|
const t = e.getHeader($t), n = e.getHeader(en);
|
|
@@ -831,7 +831,7 @@ class Ss {
|
|
|
831
831
|
this._triggerEnterRoom(n), this._maybeTriggerChannels(n);
|
|
832
832
|
break;
|
|
833
833
|
}
|
|
834
|
-
case
|
|
834
|
+
case hn: {
|
|
835
835
|
this._maybeHandleNotify(n);
|
|
836
836
|
break;
|
|
837
837
|
}
|
|
@@ -861,7 +861,7 @@ class Ss {
|
|
|
861
861
|
this._maybeHandleNotify(e);
|
|
862
862
|
});
|
|
863
863
|
o(this, "_maybeHandleNotify", (e) => {
|
|
864
|
-
const t = e.getHeader(
|
|
864
|
+
const t = e.getHeader(dn);
|
|
865
865
|
if (t) {
|
|
866
866
|
const n = JSON.parse(t);
|
|
867
867
|
this._handleNotify(n);
|
|
@@ -894,7 +894,7 @@ class Ss {
|
|
|
894
894
|
}
|
|
895
895
|
async register() {
|
|
896
896
|
return new Promise((e, t) => {
|
|
897
|
-
this.isRegisterConfig && this.ua ? (this.ua.on(
|
|
897
|
+
this.isRegisterConfig && this.ua ? (this.ua.on(m, e), this.ua.on(O, t), this.ua.register()) : t(new Error("Config is not registered"));
|
|
898
898
|
});
|
|
899
899
|
}
|
|
900
900
|
async unregister() {
|
|
@@ -937,20 +937,20 @@ class Ss {
|
|
|
937
937
|
extraHeaders: a
|
|
938
938
|
}) {
|
|
939
939
|
return new Promise((c, E) => {
|
|
940
|
-
const { configuration:
|
|
940
|
+
const { configuration: h } = this.createUaConfiguration({
|
|
941
941
|
sipWebSocketServerURL: i,
|
|
942
942
|
displayName: t,
|
|
943
943
|
userAgent: e,
|
|
944
944
|
sipServerUrl: n
|
|
945
|
-
}), _ = this._createUa({ ...
|
|
945
|
+
}), _ = this._createUa({ ...h, remoteAddress: r, extraHeaders: a }), l = () => {
|
|
946
946
|
const T = new Error("Telephony is not available");
|
|
947
947
|
E(T);
|
|
948
948
|
};
|
|
949
949
|
_.once(N, l);
|
|
950
|
-
const
|
|
950
|
+
const d = () => {
|
|
951
951
|
_.removeAllListeners(), _.once(N, c), _.stop();
|
|
952
952
|
};
|
|
953
|
-
_.once(
|
|
953
|
+
_.once(P, d), _.start();
|
|
954
954
|
});
|
|
955
955
|
}
|
|
956
956
|
async replaceMediaStream(e, t) {
|
|
@@ -968,7 +968,7 @@ class Ss {
|
|
|
968
968
|
...e,
|
|
969
969
|
extraHeaders: t
|
|
970
970
|
}).catch((n) => {
|
|
971
|
-
if (
|
|
971
|
+
if (vn(n))
|
|
972
972
|
throw n;
|
|
973
973
|
});
|
|
974
974
|
}
|
|
@@ -980,7 +980,7 @@ class Ss {
|
|
|
980
980
|
stream: t,
|
|
981
981
|
presentationOptions: n,
|
|
982
982
|
options: i = {
|
|
983
|
-
callLimit:
|
|
983
|
+
callLimit: Xn
|
|
984
984
|
}
|
|
985
985
|
}) {
|
|
986
986
|
const r = async () => this._sendPresentation(e, t, n), a = () => !!this._streamPresentationCurrent;
|
|
@@ -1006,13 +1006,13 @@ class Ss {
|
|
|
1006
1006
|
sessionTimers: c = !1,
|
|
1007
1007
|
registerExpires: E = 60 * 5,
|
|
1008
1008
|
// 5 minutes in sec
|
|
1009
|
-
connectionRecoveryMinInterval:
|
|
1009
|
+
connectionRecoveryMinInterval: h = 2,
|
|
1010
1010
|
connectionRecoveryMaxInterval: _ = 6,
|
|
1011
1011
|
userAgent: l
|
|
1012
1012
|
}) {
|
|
1013
1013
|
if (a && !t)
|
|
1014
1014
|
throw new Error("password is required for authorized connection");
|
|
1015
|
-
const
|
|
1015
|
+
const d = a && e ? e.trim() : `${mn()}`, T = fn(r), u = T(d), S = new this.JsSIP.WebSocketInterface(n);
|
|
1016
1016
|
return {
|
|
1017
1017
|
configuration: {
|
|
1018
1018
|
password: t,
|
|
@@ -1024,7 +1024,7 @@ class Ss {
|
|
|
1024
1024
|
sockets: [S],
|
|
1025
1025
|
session_timers: c,
|
|
1026
1026
|
register_expires: E,
|
|
1027
|
-
connection_recovery_min_interval:
|
|
1027
|
+
connection_recovery_min_interval: h,
|
|
1028
1028
|
connection_recovery_max_interval: _
|
|
1029
1029
|
},
|
|
1030
1030
|
helpers: {
|
|
@@ -1034,28 +1034,28 @@ class Ss {
|
|
|
1034
1034
|
};
|
|
1035
1035
|
}
|
|
1036
1036
|
async _sendPresentation(e, t, {
|
|
1037
|
-
maxBitrate: n =
|
|
1037
|
+
maxBitrate: n = ht,
|
|
1038
1038
|
isNeedReinvite: i = !0,
|
|
1039
1039
|
isP2P: r = !1,
|
|
1040
1040
|
contentHint: a = "detail",
|
|
1041
1041
|
sendEncodings: c,
|
|
1042
1042
|
onAddedTransceiver: E
|
|
1043
1043
|
}) {
|
|
1044
|
-
const
|
|
1045
|
-
this._streamPresentationCurrent =
|
|
1044
|
+
const h = M(t, { contentHint: a });
|
|
1045
|
+
this._streamPresentationCurrent = h;
|
|
1046
1046
|
const _ = r ? [Sn] : [ln], l = e.sendInfo(p, void 0, {
|
|
1047
1047
|
extraHeaders: _
|
|
1048
|
-
}).then(async () => e.startPresentation(
|
|
1048
|
+
}).then(async () => e.startPresentation(h, i, {
|
|
1049
1049
|
sendEncodings: c,
|
|
1050
1050
|
onAddedTransceiver: E
|
|
1051
1051
|
})).then(async () => {
|
|
1052
|
-
const { connection:
|
|
1053
|
-
if (!
|
|
1052
|
+
const { connection: d } = this;
|
|
1053
|
+
if (!d || n === void 0)
|
|
1054
1054
|
return;
|
|
1055
|
-
const T =
|
|
1056
|
-
await
|
|
1057
|
-
}).then(() => t).catch((
|
|
1058
|
-
throw this._removeStreamPresentationCurrent(), this._sessionEvents.trigger(H,
|
|
1055
|
+
const T = d.getSenders();
|
|
1056
|
+
await Yn(T, t, n);
|
|
1057
|
+
}).then(() => t).catch((d) => {
|
|
1058
|
+
throw this._removeStreamPresentationCurrent(), this._sessionEvents.trigger(H, d), d;
|
|
1059
1059
|
});
|
|
1060
1060
|
return this.promisePendingStartPresentation = l, l.finally(() => {
|
|
1061
1061
|
this.promisePendingStartPresentation = void 0;
|
|
@@ -1069,13 +1069,13 @@ class Ss {
|
|
|
1069
1069
|
sendEncodings: a,
|
|
1070
1070
|
onAddedTransceiver: c
|
|
1071
1071
|
} = {}, E) {
|
|
1072
|
-
const
|
|
1073
|
-
if (!
|
|
1072
|
+
const h = this.establishedSession;
|
|
1073
|
+
if (!h)
|
|
1074
1074
|
throw new Error("No session established");
|
|
1075
1075
|
if (this._streamPresentationCurrent)
|
|
1076
1076
|
throw new Error("Presentation is already started");
|
|
1077
|
-
return n && await this.sendMustStopPresentation(
|
|
1078
|
-
session:
|
|
1077
|
+
return n && await this.sendMustStopPresentation(h), this._sendPresentationWithDuplicatedCalls({
|
|
1078
|
+
session: h,
|
|
1079
1079
|
stream: e,
|
|
1080
1080
|
presentationOptions: {
|
|
1081
1081
|
isNeedReinvite: t,
|
|
@@ -1104,7 +1104,7 @@ class Ss {
|
|
|
1104
1104
|
extraHeaders: i
|
|
1105
1105
|
})).then(async () => r.stopPresentation(t)).catch((a) => {
|
|
1106
1106
|
throw this._sessionEvents.trigger(H, a), a;
|
|
1107
|
-
})), !r && t && this._sessionEvents.trigger(
|
|
1107
|
+
})), !r && t && this._sessionEvents.trigger(Pe, t), this.promisePendingStopPresentation = n, n.finally(() => {
|
|
1108
1108
|
this._resetPresentation();
|
|
1109
1109
|
});
|
|
1110
1110
|
}
|
|
@@ -1178,7 +1178,7 @@ class Ss {
|
|
|
1178
1178
|
if (!this.connection)
|
|
1179
1179
|
return;
|
|
1180
1180
|
const t = this.connection.getReceivers().map(({ track: n }) => n);
|
|
1181
|
-
return
|
|
1181
|
+
return On(t) ? this._generateStreams(t) : this._generateAudioStreams(t);
|
|
1182
1182
|
}
|
|
1183
1183
|
get connection() {
|
|
1184
1184
|
var t;
|
|
@@ -1308,20 +1308,21 @@ export {
|
|
|
1308
1308
|
yt as N,
|
|
1309
1309
|
le as P,
|
|
1310
1310
|
ke as R,
|
|
1311
|
-
|
|
1311
|
+
Ns as S,
|
|
1312
1312
|
Tt as U,
|
|
1313
|
-
|
|
1313
|
+
xn as a,
|
|
1314
1314
|
Te as b,
|
|
1315
|
-
|
|
1315
|
+
hs as c,
|
|
1316
1316
|
ds as d,
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1317
|
+
ls as e,
|
|
1318
|
+
us as f,
|
|
1319
|
+
Ts as g,
|
|
1320
|
+
Ss as h,
|
|
1321
1321
|
q as i,
|
|
1322
1322
|
F as j,
|
|
1323
1323
|
Rn as k,
|
|
1324
1324
|
B as l,
|
|
1325
|
-
|
|
1326
|
-
|
|
1325
|
+
In as m,
|
|
1326
|
+
ut as n,
|
|
1327
|
+
Vn as s
|
|
1327
1328
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Mt=Object.defineProperty;var pt=(s,e,t)=>e in s?Mt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var o=(s,e,t)=>pt(s,typeof e!="symbol"?e+"":e,t);const C=require("@krivega/cancelable-promise"),be=require("events-constructor"),we=require("repeated-calls"),G=require("debug"),vt="Connection Error",Be="Request Timeout",yt="SIP Failure Code",bt="Internal Error",wt="Busy",$="Rejected",Ut="Redirected",Lt="Unavailable",Fe="Not Found",Ht="Address Incomplete",Wt="Incompatible SDP",qt="Missing SDP",kt="Authentication Error",Ve="Terminated",Bt="WebRTC Error",xe="Canceled",Ft="No Answer",Vt="Expires",xt="No ACK",Yt="Dialog Error",Gt="User Denied Media Access",Ye="Bad Media Description",$t="RTP Timeout",Jt=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:Ht,AUTHENTICATION_ERROR:kt,BAD_MEDIA_DESCRIPTION:Ye,BUSY:wt,BYE:Ve,CANCELED:xe,CONNECTION_ERROR:vt,DIALOG_ERROR:Yt,EXPIRES:Vt,INCOMPATIBLE_SDP:Wt,INTERNAL_ERROR:bt,MISSING_SDP:qt,NOT_FOUND:Fe,NO_ACK:xt,NO_ANSWER:Ft,REDIRECTED:Ut,REJECTED:$,REQUEST_TIMEOUT:Be,RTP_TIMEOUT:$t,SIP_FAILURE_CODE:yt,UNAVAILABLE:Lt,USER_DENIED_MEDIA_ACCESS:Gt,WEBRTC_ERROR:Bt},Symbol.toStringTag,{value:"Module"})),J="incomingCall",X="declinedIncomingCall",Q="failedIncomingCall",z="terminatedIncomingCall",B="connecting",P="connected",N="disconnected",y="newRTCSession",O="registered",j="unregistered",m="registrationFailed",Ge="newMessage",K="sipEvent",Z="availableSecondRemoteStream",ee="notAvailableSecondRemoteStream",te="mustStopPresentation",b="shareState",ne="enterRoom",se="useLicense",ie="peerconnection:confirmed",oe="peerconnection:ontrack",w="channels",re="channels:notify",ae="ended:fromserver",ce="main-cam-control",Ee="admin-stop-main-cam",_e="admin-start-main-cam",le="admin-stop-mic",de="admin-start-mic",U="admin-force-sync-media-state",he="participant:added-to-list-moderators",Te="participant:removed-from-list-moderators",ue="participant:move-request-to-stream",F="participant:move-request-to-spectators",V="participant:move-request-to-participants",Se="participation:accepting-word-request",Ne="participation:cancelling-word-request",Ce="webcast:started",ge="webcast:stopped",Ae="account:changed",Re="account:deleted",Ie="conference:participant-token-issued",D="ended",$e="sending",Je="reinvite",Xe="replaces",Qe="refer",ze="progress",je="accepted",L="confirmed",H="peerconnection",R="failed",Ke="muted",Ze="unmuted",fe="newDTMF",Pe="newInfo",et="hold",tt="unhold",nt="update",st="sdp",it="icecandidate",ot="getusermediafailed",rt="peerconnection:createofferfailed",at="peerconnection:createanswerfailed",ct="peerconnection:setlocaldescriptionfailed",Et="peerconnection:setremotedescriptionfailed",_t="presentation:start",lt="presentation:started",dt="presentation:end",Oe="presentation:ended",W="presentation:failed",ht="SPECTATOR",Tt="PARTICIPANT",ut=1e6,Xt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:je,ACCOUNT_CHANGED:Ae,ACCOUNT_DELETED:Re,ADMIN_FORCE_SYNC_MEDIA_STATE:U,ADMIN_START_MAIN_CAM:_e,ADMIN_START_MIC:de,ADMIN_STOP_MAIN_CAM:Ee,ADMIN_STOP_MIC:le,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Z,CHANNELS:w,CHANNELS_NOTIFY:re,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:Ie,CONFIRMED:L,CONNECTED:P,CONNECTING:B,DECLINED_INCOMING_CALL:X,DISCONNECTED:N,ENDED:D,ENDED_FROM_SERVER:ae,ENTER_ROOM:ne,FAILED:R,FAILED_INCOMING_CALL:Q,GET_USER_MEDIA_FAILED:ot,HOLD:et,ICE_CANDIDATE:it,INCOMING_CALL:J,MAIN_CAM_CONTROL:ce,MUST_STOP_PRESENTATION_EVENT:te,MUTED:Ke,NEW_DTMF:fe,NEW_INFO:Pe,NEW_MESSAGE:Ge,NEW_RTC_SESSION:y,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:ee,ONE_MEGABIT_IN_BITS:ut,PARTICIPANT:Tt,PARTICIPANT_ADDED_TO_LIST_MODERATORS:he,PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS:V,PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS:F,PARTICIPANT_MOVE_REQUEST_TO_STREAM:ue,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:Te,PARTICIPATION_ACCEPTING_WORD_REQUEST:Se,PARTICIPATION_CANCELLING_WORD_REQUEST:Ne,PEER_CONNECTION:H,PEER_CONNECTION_CONFIRMED:ie,PEER_CONNECTION_CREATE_ANSWER_FAILED:at,PEER_CONNECTION_CREATE_OFFER_FAILED:rt,PEER_CONNECTION_ONTRACK:oe,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:ct,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:Et,PRESENTATION_END:dt,PRESENTATION_ENDED:Oe,PRESENTATION_FAILED:W,PRESENTATION_START:_t,PRESENTATION_STARTED:lt,PROGRESS:ze,REFER:Qe,REGISTERED:O,REGISTRATION_FAILED:m,REINVITE:Je,REPLACES:Xe,SDP:st,SENDING:$e,SHARE_STATE:b,SIP_EVENT:K,SPECTATOR:ht,TERMINATED_INCOMING_CALL:z,UNHOLD:tt,UNMUTED:Ze,UNREGISTERED:j,UPDATE:nt,USE_LICENSE:se,WEBCAST_STARTED:Ce,WEBCAST_STOPPED:ge},Symbol.toStringTag,{value:"Module"})),St=[J,X,z,Q,Se,Ne,ue,re,Ie,Ae,Re,Ce,ge,he,Te],me=[B,P,N,y,O,j,m,Ge,K],Nt=[Z,ee,te,b,ne,se,ie,oe,w,ae,ce,_e,Ee,le,de,U,F,V],De=[D,B,$e,Je,Xe,Qe,ze,je,L,H,R,Ke,Ze,fe,Pe,et,tt,nt,st,it,ot,rt,at,ct,Et,_t,lt,dt,Oe,W],Me=[...me,...St],pe=[...De,...Nt],Qt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:pe,SESSION_JSSIP_EVENT_NAMES:De,SESSION_SYNTHETICS_EVENT_NAMES:Nt,UA_EVENT_NAMES:Me,UA_JSSIP_EVENT_NAMES:me,UA_SYNTHETICS_EVENT_NAMES:St},Symbol.toStringTag,{value:"Module"})),zt=s=>{const e=[];return s&&e.push(`X-Vinteo-Remote: ${s}`),e},jt="content-type",Kt="x-webrtc-enter-room",M="application/vinteo.webrtc.sharedesktop",Zt="application/vinteo.webrtc.roomname",en="application/vinteo.webrtc.channels",tn="application/vinteo.webrtc.mediastate",nn="application/vinteo.webrtc.refusal",Ue="application/vinteo.webrtc.maincam",sn="application/vinteo.webrtc.mic",on="application/vinteo.webrtc.uselic",rn="X-WEBRTC-USE-LICENSE",an="X-WEBRTC-PARTICIPANT-NAME",Le="X-WEBRTC-INPUT-CHANNELS",He="X-WEBRTC-OUTPUT-CHANNELS",cn="X-WEBRTC-MAINCAM",En="X-WEBRTC-MIC",We="X-WEBRTC-SYNC",_n="X-WEBRTC-MAINCAM-RESOLUTION",ln="X-WEBRTC-MEDIA-STATE",dn="X-Vinteo-Media-Type",hn="X-Vinteo-MainCam-State",Tn="X-Vinteo-Mic-State",un="application/vinteo.webrtc.partstate",Sn="X-WEBRTC-PARTSTATE",Nn="application/vinteo.webrtc.notify",Cn="X-VINTEO-NOTIFY",f="x-webrtc-share-state",gn=`${f}: LETMESTARTPRESENTATION`,An=`${f}: STOPPRESENTATION`,Ct="YOUCANRECEIVECONTENT",gt="CONTENTEND",At="YOUMUSTSTOPSENDCONTENT",Rn=`${f}: ${At}`,In=`${f}: ${Ct}`,fn=`${f}: ${gt}`,Pn="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",On=`${Pn}: LETMESTARTMAINCAM`,ve="sip-connector",v=G(ve),mn=()=>{G.enable(ve)},Dn=()=>{G.enable(`-${ve}`)},Mn=(s,e)=>{s.getVideoTracks().forEach(n=>{"contentHint"in n&&n.contentHint!==e&&(n.contentHint=e)})},p=(s,{videoMode:e,audioMode:t,contentHint:n}={})=>{if(!s||e==="recvonly"&&t==="recvonly")return;const i=t==="recvonly"?[]:s.getAudioTracks(),r=e==="recvonly"?[]:s.getVideoTracks(),a=[...i,...r],c=new MediaStream(a);return c.getTracks=()=>[...c.getAudioTracks(),...c.getVideoTracks()],n&&n!=="none"&&Mn(c,n),c};var I=(s=>(s.PAUSE_MAIN_CAM="PAUSEMAINCAM",s.RESUME_MAIN_CAM="RESUMEMAINCAM",s.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",s.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",s.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",s))(I||{}),q=(s=>(s.ADMIN_STOP_MIC="ADMINSTOPMIC",s.ADMIN_START_MIC="ADMINSTARTMIC",s))(q||{}),k=(s=>(s.ADMIN_SYNC_FORCED="1",s.ADMIN_SYNC_NOT_FORCED="0",s))(k||{}),Rt=(s=>(s.AUDIO="AUDIO",s.VIDEO="VIDEO",s.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",s))(Rt||{}),It=(s=>(s.VP8="video/VP8",s.VP9="video/VP9",s.H264="video/H264",s.AV1="video/AV1",s.rtx="video/rtx",s.red="video/red",s.flexfec03="video/flexfec-03",s))(It||{});function pn(s){return e=>`sip:${e}@${s}`}const vn=(s,e)=>()=>Math.floor(Math.random()*(e-s))+s,qe=s=>s.trim().replaceAll(" ","_"),yn=vn(1e5,99999999),bn=s=>s.some(t=>{const{kind:n}=t;return n==="video"}),wn="Error decline with 603",Un=1006,Ln=s=>typeof s=="object"&&s!==null&&"code"in s&&s.code===Un,Hn=s=>s.message===wn,Wn=(s,e)=>s.find(t=>t.track&&e.getTracks().includes(t.track)),qn=(s,e)=>(s.degradationPreference=e.degradationPreference,s),kn=(s,e)=>{s.encodings===void 0&&(s.encodings=[]);for(let t=s.encodings.length;t<e;t+=1)s.encodings.push({});return s},ft=s=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==s,Bn=ft(),Fn=(s,e)=>{if(Bn(s,e))return s},Vn=(s,e)=>{const t=s.maxBitrate,n=Fn(e,t);return n!==void 0&&(s.maxBitrate=n),s},Pt=1,xn=ft(Pt),Yn=(s,e)=>{const t=s===void 0?void 0:Math.max(s,Pt);if(t!==void 0&&xn(t,e))return t},Gn=(s,e)=>{const t=s.scaleResolutionDownBy,n=Yn(e,t);return n!==void 0&&(s.scaleResolutionDownBy=n),s},$n=(s,e)=>{var n;const t=((n=e.encodings)==null?void 0:n.length)??0;return kn(s,t),s.encodings.forEach((i,r)=>{const a=((e==null?void 0:e.encodings)??[])[r],c=a==null?void 0:a.maxBitrate,_=a==null?void 0:a.scaleResolutionDownBy;Vn(i,c),Gn(i,_)}),s},Jn=(s,e)=>{var t,n,i,r,a,c,_,l;if(((t=s.codecs)==null?void 0:t.length)!==((n=e.codecs)==null?void 0:n.length))return!0;for(let E=0;E<(((i=s.codecs)==null?void 0:i.length)??0);E++)if(JSON.stringify(s.codecs[E])!==JSON.stringify(e.codecs[E]))return!0;if(((r=s.headerExtensions)==null?void 0:r.length)!==((a=e.headerExtensions)==null?void 0:a.length))return!0;for(let E=0;E<(((c=s.headerExtensions)==null?void 0:c.length)??0);E++)if(JSON.stringify(s.headerExtensions[E])!==JSON.stringify(e.headerExtensions[E]))return!0;if(((_=s.encodings)==null?void 0:_.length)!==((l=e.encodings)==null?void 0:l.length))return!0;for(let E=0;E<(s.encodings.length??0);E++)if(JSON.stringify(s.encodings[E])!==JSON.stringify(e.encodings[E]))return!0;return s.rtcp.cname!==e.rtcp.cname||s.rtcp.reducedSize!==e.rtcp.reducedSize||s.degradationPreference!==e.degradationPreference},Ot=async(s,e)=>{const t=s.getParameters(),n=JSON.parse(JSON.stringify(t));$n(t,e),qn(t,e);const i=Jn(n,t);return i&&await s.setParameters(t),{parameters:t,isChanged:i}},mt=async(s,e,t)=>{const{isChanged:n,parameters:i}=await Ot(s,{encodings:[{scaleResolutionDownBy:e.scaleResolutionDownBy,maxBitrate:e.maxBitrate}]});return n&&t&&t(i),{isChanged:n,parameters:i}},Xn=async(s,e,t)=>{const n=Wn(s,e);if(n)return mt(n,{maxBitrate:t})},Qn=486,zn=487,Y="local",ke="remote",jn=3,Kn=1,Zn=(s=new Error)=>{const{originator:e,cause:t}=s;return C.isCanceledError(s)?!0:typeof t=="string"?t===Be||t===$||e===Y&&(t===xe||t===Ve):!1},g="SipConnector",es="channels",ts="WebcastStarted",ns="WebcastStopped",ss="accountChanged",is="accountDeleted",os="addedToListModerators",rs="removedFromListModerators",as="ParticipationRequestAccepted",cs="ParticipationRequestRejected",Es="ParticipantMovedToWebcast",_s="ConferenceParticipantTokenIssued";class ls{constructor({JsSIP:e}){o(this,"_isRegisterConfig",!1);o(this,"_connectionConfiguration",{});o(this,"_remoteStreams",{});o(this,"JsSIP");o(this,"_sessionEvents");o(this,"_uaEvents");o(this,"_cancelableConnect");o(this,"_cancelableConnectWithRepeatedCalls");o(this,"_cancelableSendPresentationWithRepeatedCalls");o(this,"_cancelableInitUa");o(this,"_cancelableDisconnect");o(this,"_cancelableSet");o(this,"_cancelableCall");o(this,"_cancelableAnswer");o(this,"_cancelableSendDTMF");o(this,"getSipServerUrl",e=>e);o(this,"promisePendingStartPresentation");o(this,"promisePendingStopPresentation");o(this,"ua");o(this,"session");o(this,"incomingSession");o(this,"_streamPresentationCurrent");o(this,"socket");o(this,"connect",async(e,t)=>(this._cancelRequests(),this._connectWithDuplicatedCalls(e,t)));o(this,"initUa",async e=>this._cancelableInitUa.request(e));o(this,"set",async e=>this._cancelableSet.request(e));o(this,"call",async e=>this._cancelableCall.request(e));o(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));o(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));o(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));o(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));o(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(B,void 0);try{await this.unregister()}catch(e){v("tryRegister",e)}return this.register()});o(this,"declineToIncomingCall",async({statusCode:e=zn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const i=this.incomingSession,r=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(X,r),t(i.terminate({status_code:e}))}));o(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:Qn}));o(this,"removeIncomingSession",()=>{delete this.incomingSession});o(this,"_connectWithDuplicatedCalls",async(e,{callLimit:t=jn}={})=>{const n=async()=>this._cancelableConnect.request(e),i=r=>{var l;const c=!!((l=this.ua)!=null&&l.isConnected())&&this.hasEqualConnectionConfiguration(e),_=!!r&&!Ln(r);return c||_};return this._cancelableConnectWithRepeatedCalls=we.repeatedCallsAsync({targetFunction:n,isComplete:i,callLimit:t,isRejectAsValid:!0,isCheckBeforeCall:!1,onAfterCancel:()=>{this._cancelableConnect.cancelRequest()}}),this._cancelableConnectWithRepeatedCalls.then(r=>{if(r instanceof this.JsSIP.UA)return r;throw r})});o(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===ke){this.incomingSession=t;const n=this.remoteCallerData;t.on(R,i=>{this.removeIncomingSession(),i.originator===Y?this._uaEvents.trigger(z,n):this._uaEvents.trigger(Q,n)}),this._uaEvents.trigger(J,n)}});o(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));o(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:i,remoteAddress:r,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:l,userAgent:E,displayName:h="",register:d=!1,extraHeaders:T=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!i)throw new Error("sipWebSocketServerURL is required");if(d&&!e)throw new Error("user is required for authorized connection");if(d&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:h,register:d,user:e,password:t};const{configuration:u,helpers:S}=this.createUaConfiguration({user:e,sipServerUrl:n,sipWebSocketServerURL:i,password:t,displayName:h,register:d,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:l,userAgent:E});return this.getSipServerUrl=S.getSipServerUrl,this.socket=S.socket,this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!d,this.ua=this._createUa({...u,remoteAddress:r,extraHeaders:T}),this._uaEvents.eachTriggers((A,x)=>{const ye=me.find(Dt=>Dt===x);ye&&this.ua&&this.ua.on(ye,A)}),this.ua});o(this,"_createUa",({remoteAddress:e,extraHeaders:t=[],...n})=>{const i=new this.JsSIP.UA(n),a=[...e?zt(e):[],...t];return a.length>0&&i.registrator().setExtraHeaders(a),i});o(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const i=()=>{c(),e(n)},r=_=>{c(),t(_)},a=()=>{this.isRegisterConfig?(this.on(O,i),this.on(m,r)):this.on(P,i),this.on(N,r)},c=()=>{this.off(O,i),this.off(m,r),this.off(P,i),this.off(N,r)};a(),this.on(y,this.handleNewRTCSession),n.start()}));o(this,"_set",async({displayName:e,password:t})=>new Promise((n,i)=>{const{ua:r}=this;if(!r){i(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=r.set("display_name",qe(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=r.set("password",t),this._connectionConfiguration.password=t);const _=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(_)}).catch(l=>{i(l)}):_?n(_):i(new Error("nothing changed"))}));o(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());o(this,"_disconnect",async()=>{this.off(y,this.handleNewRTCSession);const e=new Promise(t=>{this.once(N,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(N,void 0)):this._uaEvents.trigger(N,void 0),e});o(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:i,iceServers:r,videoMode:a,audioMode:c,contentHint:_,offerToReceiveAudio:l=!0,offerToReceiveVideo:E=!0,sendEncodings:h,onAddedTransceiver:d})=>new Promise((T,u)=>{const{ua:S}=this;if(!S){u(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:i}).then(T).catch(A=>{u(A)}),this.session=S.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:p(t,{videoMode:a,audioMode:c,contentHint:_}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,pcConfig:{iceServers:r},rtcOfferConstraints:{offerToReceiveAudio:l,offerToReceiveVideo:E},sendEncodings:h,onAddedTransceiver:d})}));o(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:i,videoMode:r,audioMode:a,contentHint:c,sendEncodings:_,onAddedTransceiver:l})=>new Promise((E,h)=>{if(!this.isAvailableIncomingCall){h(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:d}=this;if(!d){h(new Error("No session established"));return}this._sessionEvents.eachTriggers((u,S)=>{const A=De.find(x=>x===S);A&&d.on(A,u)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=d.remote_identity.uri.user,this._handleCall({ontrack:t}).then(E).catch(u=>{h(u)});const T=p(e,{videoMode:r,audioMode:a,contentHint:c});d.answer({extraHeaders:n,videoMode:r,audioMode:a,mediaStream:T,pcConfig:{iceServers:i},sendEncodings:_,onAddedTransceiver:l})}));o(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const i=()=>{this.onSession(H,E),this.onSession(L,h)},r=()=>{this.offSession(H,E),this.offSession(L,h)},a=()=>{this.onSession(R,_),this.onSession(D,_)},c=()=>{this.offSession(R,_),this.offSession(D,_)},_=d=>{r(),c(),n(d)};let l;const E=({peerconnection:d})=>{l=d,l.ontrack=T=>{this._sessionEvents.trigger(oe,l),e&&e(T)}},h=()=>{l&&this._sessionEvents.trigger(ie,l),r(),c(),t(l)};i(),a()}));o(this,"_restoreSession",()=>{this._cancelRequestsAndResetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});o(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:i}=this;if(!i){n(new Error("No session established"));return}this.onceSession(fe,({originator:r})=>{r===Y&&t()}),i.sendDTMF(e,{duration:120,interToneGap:600})}));o(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;if(this._streamPresentationCurrent)try{await this.stopPresentation()}catch(t){v("error stop presentation: ",t)}if(this._restoreSession(),!e.isEnded())return e.terminateAsync()}});o(this,"_handleShareState",e=>{switch(e){case Ct:{this._sessionEvents.trigger(Z,void 0);break}case gt:{this._sessionEvents.trigger(ee,void 0);break}case At:{this._sessionEvents.trigger(te,void 0);break}}});o(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(Le),n=e.getHeader(He);if(t&&n){const i={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(w,i)}});o(this,"_handleNotify",e=>{switch(e.cmd){case es:{const t=e;this._triggerChannelsNotify(t);break}case ts:{const t=e;this._triggerWebcastStartedNotify(t);break}case ns:{const t=e;this._triggerWebcastStoppedNotify(t);break}case os:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case rs:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case as:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case cs:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case Es:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case ss:{this._triggerAccountChangedNotify();break}case is:{this._triggerAccountDeletedNotify();break}case _s:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:v("unknown cmd",e.cmd)}});o(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Te,t)});o(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(he,t)});o(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Ce,n)});o(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(ge,n)});o(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Ae,void 0)});o(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(Re,void 0)});o(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const i={conference:e,participant:t,jwt:n};this._uaEvents.trigger(Ie,i)});o(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,i={inputChannels:t,outputChannels:n};this._uaEvents.trigger(re,i)});o(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Se,t)});o(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Ne,t)});o(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(ue,t)});o(this,"_triggerEnterRoom",e=>{const t=e.getHeader(Kt),n=e.getHeader(an);this._sessionEvents.trigger(ne,{room:t,participantName:n})});o(this,"_triggerShareState",e=>{const t=e.getHeader(f);this._sessionEvents.trigger(b,t)});o(this,"_maybeTriggerParticipantMoveRequest",e=>{const t=e.getHeader(Sn);t===ht&&this._sessionEvents.trigger(F,void 0),t===Tt&&this._sessionEvents.trigger(V,void 0)});o(this,"_triggerMainCamControl",e=>{const t=e.getHeader(cn),n=e.getHeader(We),i=n===k.ADMIN_SYNC_FORCED;if(t===I.ADMIN_START_MAIN_CAM){this._sessionEvents.trigger(_e,{isSyncForced:i});return}if(t===I.ADMIN_STOP_MAIN_CAM){this._sessionEvents.trigger(Ee,{isSyncForced:i});return}(t===I.RESUME_MAIN_CAM||t===I.PAUSE_MAIN_CAM)&&n&&this._sessionEvents.trigger(U,{isSyncForced:i});const r=e.getHeader(_n);this._sessionEvents.trigger(ce,{mainCam:t,resolutionMainCam:r})});o(this,"_triggerMicControl",e=>{const t=e.getHeader(En),i=e.getHeader(We)===k.ADMIN_SYNC_FORCED;t===q.ADMIN_START_MIC?this._sessionEvents.trigger(de,{isSyncForced:i}):t===q.ADMIN_STOP_MIC&&this._sessionEvents.trigger(le,{isSyncForced:i})});o(this,"_triggerUseLicense",e=>{const t=e.getHeader(rn);this._sessionEvents.trigger(se,t)});o(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,i=n.getHeader(jt);if(i)switch(i){case Zt:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case Nn:{this._maybeHandleNotify(n);break}case M:{this._triggerShareState(n);break}case Ue:{this._triggerMainCamControl(n);break}case sn:{this._triggerMicControl(n);break}case on:{this._triggerUseLicense(n);break}case un:{this._maybeTriggerParticipantMoveRequest(n);break}}});o(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});o(this,"_maybeHandleNotify",e=>{const t=e.getHeader(Cn);if(t){const n=JSON.parse(t);this._handleNotify(n)}});o(this,"_handleEnded",e=>{const{originator:t}=e;t===ke&&this._sessionEvents.trigger(ae,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new be(pe),this._uaEvents=new be(Me),this._cancelableConnect=new C.CancelableRequest(this._connect,{moduleName:g,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new C.CancelableRequest(this._initUa,{moduleName:g}),this._cancelableDisconnect=new C.CancelableRequest(this._disconnect,{moduleName:g}),this._cancelableSet=new C.CancelableRequest(this._set,{moduleName:g}),this._cancelableCall=new C.CancelableRequest(this._call,{moduleName:g}),this._cancelableAnswer=new C.CancelableRequest(this._answer,{moduleName:g}),this._cancelableSendDTMF=new C.CancelableRequest(this._sendDTMF,{moduleName:g}),this.onSession(b,this._handleShareState),this.onSession(Pe,this._handleNewInfo),this.on(K,this._handleSipEvent),this.onSession(R,this._handleEnded),this.onSession(D,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(O,e),this.ua.on(m,t),this.ua.register()):t(new Error("Config is not registered"))})}async unregister(){return new Promise((e,t)=>{this.isRegistered&&this.ua?(this.ua.on(j,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,n){if(!this.ua)throw new Error("is not connected");return new Promise((i,r)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{i()},failed:r}})}catch(a){r(a)}})}async ping(e,t){var i;if(!((i=this.ua)!=null&&i.configuration.uri))throw new Error("is not connected");const n=this.ua.configuration.uri;return this.sendOptions(n,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:n,sipWebSocketServerURL:i,remoteAddress:r,extraHeaders:a}){return new Promise((c,_)=>{const{configuration:l}=this.createUaConfiguration({sipWebSocketServerURL:i,displayName:t,userAgent:e,sipServerUrl:n}),E=this._createUa({...l,remoteAddress:r,extraHeaders:a}),h=()=>{const T=new Error("Telephony is not available");_(T)};E.once(N,h);const d=()=>{E.removeAllListeners(),E.once(N,c),E.stop()};E.once(P,d),E.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");const{contentHint:n}=t??{},i=p(e,{contentHint:n});return this.session.replaceMediaStream(i,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[On];return this.session.sendInfo(Ue,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(Hn(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentationWithDuplicatedCalls({session:e,stream:t,presentationOptions:n,options:i={callLimit:Kn}}){const r=async()=>this._sendPresentation(e,t,n),a=()=>!!this._streamPresentationCurrent;return this._cancelableSendPresentationWithRepeatedCalls=we.repeatedCallsAsync({targetFunction:r,isComplete:a,isRejectAsValid:!0,...i}),this._cancelableSendPresentationWithRepeatedCalls.then(c=>c)}hasEqualConnectionConfiguration(e){var i;const{configuration:t}=this.createUaConfiguration(e),n=(i=this.ua)==null?void 0:i.configuration;return(n==null?void 0:n.password)===t.password&&(n==null?void 0:n.register)===t.register&&(n==null?void 0:n.uri.toString())===t.uri&&(n==null?void 0:n.display_name)===t.display_name&&(n==null?void 0:n.user_agent)===t.user_agent&&(n==null?void 0:n.sockets)===t.sockets&&(n==null?void 0:n.session_timers)===t.session_timers&&(n==null?void 0:n.register_expires)===t.register_expires&&(n==null?void 0:n.connection_recovery_min_interval)===t.connection_recovery_min_interval&&(n==null?void 0:n.connection_recovery_max_interval)===t.connection_recovery_max_interval}createUaConfiguration({user:e,password:t,sipWebSocketServerURL:n,displayName:i="",sipServerUrl:r,register:a=!1,sessionTimers:c=!1,registerExpires:_=60*5,connectionRecoveryMinInterval:l=2,connectionRecoveryMaxInterval:E=6,userAgent:h}){if(a&&!t)throw new Error("password is required for authorized connection");const d=a&&e?e.trim():`${yn()}`,T=pn(r),u=T(d),S=new this.JsSIP.WebSocketInterface(n);return{configuration:{password:t,register:a,uri:u,display_name:qe(i),user_agent:h,sdp_semantics:"unified-plan",sockets:[S],session_timers:c,register_expires:_,connection_recovery_min_interval:l,connection_recovery_max_interval:E},helpers:{socket:S,getSipServerUrl:T}}}async _sendPresentation(e,t,{maxBitrate:n=ut,isNeedReinvite:i=!0,isP2P:r=!1,contentHint:a="detail",sendEncodings:c,onAddedTransceiver:_}){const l=p(t,{contentHint:a});this._streamPresentationCurrent=l;const E=r?[In]:[gn],h=e.sendInfo(M,void 0,{extraHeaders:E}).then(async()=>e.startPresentation(l,i,{sendEncodings:c,onAddedTransceiver:_})).then(async()=>{const{connection:d}=this;if(!d||n===void 0)return;const T=d.getSenders();await Xn(T,t,n)}).then(()=>t).catch(d=>{throw this._removeStreamPresentationCurrent(),this._sessionEvents.trigger(W,d),d});return this.promisePendingStartPresentation=h,h.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t,isP2P:n,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:c}={},_){const l=this.establishedSession;if(!l)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return n&&await this.sendMustStopPresentation(l),this._sendPresentationWithDuplicatedCalls({session:l,stream:e,presentationOptions:{isNeedReinvite:t,isP2P:n,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:c},options:_})}async sendMustStopPresentation(e){await e.sendInfo(M,void 0,{extraHeaders:[Rn]})}async stopPresentation({isP2P:e=!1}={}){this._cancelSendPresentationWithRepeatedCalls();const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const i=e?[fn]:[An],r=this.establishedSession;return r&&t&&(n=n.then(async()=>r.sendInfo(M,void 0,{extraHeaders:i})).then(async()=>r.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(W,a),a})),!r&&t&&this._sessionEvents.trigger(Oe,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t,maxBitrate:n,contentHint:i,sendEncodings:r,onAddedTransceiver:a}={}){const c=this.establishedSession;if(!c)throw new Error("No session established");if(!this._streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this._sendPresentation(c,e,{isP2P:t,maxBitrate:n,contentHint:i,isNeedReinvite:!1,sendEncodings:r,onAddedTransceiver:a})}_removeStreamPresentationCurrent(){delete this._streamPresentationCurrent}_resetPresentation(){this._removeStreamPresentationCurrent(),this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}_cancelRequestsAndResetPresentation(){this._cancelSendPresentationWithRepeatedCalls(),this._resetPresentation()}on(e,t){return this._uaEvents.on(e,t)}once(e,t){return this._uaEvents.once(e,t)}onceRace(e,t){return this._uaEvents.onceRace(e,t)}async wait(e){return this._uaEvents.wait(e)}off(e,t){this._uaEvents.off(e,t)}onSession(e,t){return this._sessionEvents.on(e,t)}onceSession(e,t){return this._sessionEvents.once(e,t)}onceRaceSession(e,t){return this._sessionEvents.onceRace(e,t)}async waitSession(e){return this._sessionEvents.wait(e)}offSession(e,t){this._sessionEvents.off(e,t)}isConfigured(){return!!this.ua}getConnectionConfiguration(){return{...this._connectionConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:n})=>n);return bn(t)?this._generateStreams(t):this._generateAudioStreams(t)}get connection(){var t;return(t=this.session)==null?void 0:t.connection}get remoteCallerData(){var e,t,n,i,r,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(i=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:i.uri.host,incomingNumber:(a=(r=this.incomingSession)==null?void 0:r.remote_identity)==null?void 0:a.uri.user,session:this.incomingSession}}get requested(){return this._cancelableConnect.requested||this._cancelableInitUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){var e;return(e=this.session)!=null&&e.isEstablished()?this.session:void 0}get isRegistered(){return!!this.ua&&this.ua.isRegistered()}get isRegisterConfig(){return!!this.ua&&this._isRegisterConfig}get isCallActive(){return!!(this.ua&&this.session)}get isAvailableIncomingCall(){return!!this.incomingSession}_generateStream(e,t){const{id:n}=e,i=this._remoteStreams[n]||new MediaStream;return t&&i.addTrack(t),i.addTrack(e),this._remoteStreams[n]=i,i}_generateAudioStream(e){const{id:t}=e,n=this._remoteStreams[t]||new MediaStream;return n.addTrack(e),this._remoteStreams[t]=n,n}_generateStreams(e){const t=[];return e.forEach((n,i)=>{if(n.kind==="audio")return;const r=n,a=e[i-1];let c;a&&a.kind==="audio"&&(c=a);const _=this._generateStream(r,c);t.push(_)}),t}_generateAudioStreams(e){return e.map(n=>this._generateAudioStream(n))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectWithRepeatedCalls()}_cancelConnectWithRepeatedCalls(){var e;(e=this._cancelableConnectWithRepeatedCalls)==null||e.cancel()}_cancelSendPresentationWithRepeatedCalls(){var e;(e=this._cancelableSendPresentationWithRepeatedCalls)==null||e.cancel()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(w)}async waitSyncMediaState(){return this.waitSession(U)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${Le}: ${e}`,i=`${He}: ${t}`,r=[n,i];return this.session.sendInfo(en,void 0,{extraHeaders:r})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const i=`${ln}: currentstate`,r=`${hn}: ${Number(e)}`,a=`${Tn}: ${Number(t)}`,c=[i,r,a];return this.session.sendInfo(tn,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${dn}: ${e==="mic"?0:1}`];return this.session.sendInfo(nn,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}}exports.BAD_MEDIA_DESCRIPTION=Ye;exports.EEventsMainCAM=I;exports.EEventsMic=q;exports.EEventsSyncMediaState=k;exports.EMimeTypesVideoCodecs=It;exports.EUseLicense=Rt;exports.NOT_FOUND=Fe;exports.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS=V;exports.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS=F;exports.REJECTED=$;exports.SESSION_EVENT_NAMES=pe;exports.SipConnector=ls;exports.UA_EVENT_NAMES=Me;exports.causes=Jt;exports.constants=Xt;exports.disableDebug=Dn;exports.enableDebug=mn;exports.eventNames=Qt;exports.hasCanceledCallError=Zn;exports.logger=v;exports.setEncodingsToSender=mt;exports.setParametersToSender=Ot;
|
package/dist/doMock.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var b=(o,t,e)=>t in o?k(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var r=(o,t,e)=>b(o,typeof t!="symbol"?t+"":t,e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("./SipConnector-BWx586hI.cjs"),D=require("@krivega/jssip/lib/NameAddrHeader"),L=require("@krivega/jssip/lib/URI"),F=require("node:events"),V=require("@krivega/jssip/lib/SIPMessage"),C=require("webrtc-mock"),I=require("events-constructor"),T=require("@krivega/jssip");class y extends V.IncomingRequest{constructor(e){super();r(this,"headers");this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)||""}}class z{constructor({originator:t="local",eventHandlers:e}){r(this,"originator");r(this,"_connection");r(this,"_events");r(this,"_remote_identity");r(this,"_mutedOptions",{audio:!1,video:!1});this.originator=t,this._events=new I(g.SESSION_EVENT_NAMES),this.initEvents(e)}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}set data(t){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}get connection(){return this._connection}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get remote_identity(){return this._remote_identity}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(t){throw new Error("Method not implemented.")}terminate(t){throw new Error("Method not implemented.")}async sendInfo(t,e,n){throw new Error("Method not implemented.")}hold(t,e){throw new Error("Method not implemented.")}unhold(t,e){throw new Error("Method not implemented.")}async renegotiate(t,e){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(t){throw new Error("Method not implemented.")}unmute(t){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(t,e){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(t,e){throw new Error("Method not implemented.")}addListener(t,e){throw new Error("Method not implemented.")}once(t,e){throw new Error("Method not implemented.")}removeListener(t,e){throw new Error("Method not implemented.")}off(t,e){throw new Error("Method not implemented.")}removeAllListeners(t){throw new Error("Method not implemented.")}setMaxListeners(t){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(t){throw new Error("Method not implemented.")}rawListeners(t){throw new Error("Method not implemented.")}emit(t,...e){throw new Error("Method not implemented.")}listenerCount(t){throw new Error("Method not implemented.")}prependListener(t,e){throw new Error("Method not implemented.")}prependOnceListener(t,e){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(t=[]){Object.entries(t).forEach(([e,n])=>this.on(e,n))}on(t,e){return this._events.on(t,e),this}trigger(t,e){this._events.trigger(t,e)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(t){return t}async updatePresentation(t){return t}async stopPresentation(t){return t}isEstablished(){return!0}}class x{constructor({track:t}={}){r(this,"dtmf",null);r(this,"track",null);r(this,"transport",null);r(this,"transform",null);r(this,"_parameters",{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}});r(this,"_parametersGets");this.track=t??null}async getStats(){throw new Error("Method not implemented.")}async replaceTrack(t){this.track=t??null}async setParameters(t){if(t!==this._parametersGets)throw new Error("Failed to execute 'setParameters' on 'RTCRtpSender': Read-only field modified in setParameters().");const{transactionId:e}=this._parameters;this._parameters={...this._parameters,...t,transactionId:`${Number(e)+1}`}}getParameters(){return this._parametersGets={...this._parameters},this._parametersGets}setStreams(){throw new Error("Method not implemented.")}}class U{constructor(t,e){r(this,"_senders",[]);r(this,"_receivers",[]);r(this,"canTrickleIceCandidates");r(this,"connectionState");r(this,"currentLocalDescription");r(this,"currentRemoteDescription");r(this,"iceConnectionState");r(this,"iceGatheringState");r(this,"idpErrorInfo");r(this,"idpLoginUrl");r(this,"localDescription");r(this,"onconnectionstatechange");r(this,"ondatachannel");r(this,"onicecandidate");r(this,"onicecandidateerror",null);r(this,"oniceconnectionstatechange");r(this,"onicegatheringstatechange");r(this,"onnegotiationneeded");r(this,"onsignalingstatechange");r(this,"ontrack");r(this,"peerIdentity");r(this,"pendingLocalDescription");r(this,"pendingRemoteDescription");r(this,"remoteDescription");r(this,"sctp",null);r(this,"signalingState");r(this,"getReceivers",()=>this._receivers);r(this,"getSenders",()=>this._senders);r(this,"addTrack",t=>{const e=new x({track:t});return this._senders.push(e),e});this._receivers=e.map(n=>({track:n}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(t){throw new Error("Method not implemented.")}addTransceiver(t,e){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(t,e){throw new Error("Method not implemented.")}createDataChannel(t,e){throw new Error("Method not implemented.")}async createOffer(t,e,n){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(t){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(t){throw new Error("Method not implemented.")}setConfiguration(t){throw new Error("Method not implemented.")}async setLocalDescription(t){throw new Error("Method not implemented.")}async setRemoteDescription(t){throw new Error("Method not implemented.")}addEventListener(t,e,n){throw new Error("Method not implemented.")}removeEventListener(t,e,n){throw new Error("Method not implemented.")}dispatchEvent(t){throw new Error("Method not implemented.")}}function q(o){const t=o.match(/(purgatory)|[\d.]+/g);if(!t)throw new Error("wrong sip url");return t[0]}const w=400,N="777",H=o=>o.getVideoTracks().length>0,a=class a extends z{constructor({url:e="",mediaStream:n,eventHandlers:i,originator:d}){super({originator:d,eventHandlers:i});r(this,"url");r(this,"status_code");r(this,"_isEnded",!1);r(this,"answer",jest.fn(({mediaStream:e})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(e),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},w)}));this.url=e,this.initPeerconnection(n)}static setStartPresentationError(e,{count:n=Number.POSITIVE_INFINITY}={}){this.startPresentationError=e,this.countStartPresentationError=n}static resetStartPresentationError(){this.startPresentationError=void 0,this.countStartPresentationError=Number.POSITIVE_INFINITY,this.countStartsPresentation=0}async startPresentation(e){if(a.countStartsPresentation+=1,a.startPresentationError&&a.countStartsPresentation<a.countStartPresentationError)throw a.startPresentationError;return super.startPresentation(e)}initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const n=C.createAudioMediaStreamTrackMock();n.id="mainaudio1";const i=[n];if(H(e)){const u=C.createVideoMediaStreamTrackMock();u.id="mainvideo1",i.push(u)}this._connection=new U(void 0,i),this._addStream(e),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},w)}connect(e){const n=q(e);setTimeout(()=>{this.url.includes(N)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:g.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",{room:n})},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},w)}terminate({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e}),this._isEnded=!1,this}async terminateAsync({status_code:e}={}){this.terminate({status_code:e})}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}_addStream(e,n="getTracks"){e[n]().forEach(i=>this.connection.addTrack(i))}_forEachSenders(e){const n=this.connection.getSenders();for(const i of n)e(i);return n}_toggleMuteAudio(e){this._forEachSenders(({track:n})=>{n&&n.kind==="audio"&&(n.enabled=!e)})}_toggleMuteVideo(e){this._forEachSenders(({track:n})=>{n&&n.kind==="video"&&(n.enabled=!e)})}mute(e){e.audio&&(this._mutedOptions.audio=!0,this._toggleMuteAudio(this._mutedOptions.audio)),e.video&&(this._mutedOptions.video=!0,this._toggleMuteVideo(this._mutedOptions.video)),this._onmute(e)}unmute(e){e.audio&&(this._mutedOptions.audio=!1),e.video&&(this._mutedOptions.video=!1),this.trigger("unmuted",e)}isMuted(){return this._mutedOptions}async replaceMediaStream(e){return e}_onmute({audio:e,video:n}){this.trigger("muted",{audio:e,video:n})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(e){this.trigger("newInfo",e)}};r(a,"startPresentationError"),r(a,"countStartPresentationError",Number.POSITIVE_INFINITY),r(a,"countStartsPresentation",0);let l=a;class Y{constructor(){r(this,"extraHeaders",[])}setExtraHeaders(t){this.extraHeaders=t}setExtraContactParams(){}}const c="PASSWORD_CORRECT",f="PASSWORD_CORRECT_2",P="NAME_INCORRECT",m=400,s=class s{constructor(t){r(this,"_events");r(this,"_startedTimeout");r(this,"_stopedTimeout");r(this,"session");r(this,"_isRegistered");r(this,"_isConnected");r(this,"configuration");r(this,"_registrator");r(this,"call",jest.fn((t,e)=>{const{mediaStream:n,eventHandlers:i}=e;return this.session=new l({url:t,mediaStream:n,eventHandlers:i,originator:"local"}),this.session.connect(t),this.session}));this._events=new I(g.UA_EVENT_NAMES);const[e,n]=t.uri.split(":"),[i,d]=n.split("@"),u={...t,uri:new T.URI(e,i,d)};this.configuration=u,this._registrator=new Y}static setStartError(t,{count:e=Number.POSITIVE_INFINITY}={}){this.startError=t,this.countStartError=e}static resetStartError(){this.startError=void 0,this.countStartError=Number.POSITIVE_INFINITY,this.countStarts=0}static setAvailableTelephony(){this.isAvailableTelephony=!0}static setNotAvailableTelephony(){this.isAvailableTelephony=!1}isConnected(){return!!this._isConnected}start(){if(s.countStarts+=1,s.startError&&s.countStarts<s.countStartError){this.trigger("disconnected",s.startError);return}this.register()}stop(){this._startedTimeout&&clearTimeout(this._startedTimeout),this._stopedTimeout&&clearTimeout(this._stopedTimeout),this.unregister(),this.isStarted()?this._stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:new Error("stoped")})},m):this.trigger("disconnected",{error:new Error("stoped")})}on(t,e){return this._events.on(t,e),this}once(t,e){return this._events.once(t,e),this}off(t,e){return this._events.off(t,e),this}removeAllListeners(){return this._events.removeEventHandlers(),this}trigger(t,e){this._events.trigger(t,e)}terminateSessions(){this.session.terminate()}set(t,e){return this.configuration[t]=e,!0}register(){this._startedTimeout&&clearTimeout(this._startedTimeout);const{password:t,register:e,uri:n}=this.configuration;e&&n.user.includes(P)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},m)):!this._isRegistered&&e&&(t===c||t===f)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},m)):e&&t!==c&&t!==f&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},m)),s.isAvailableTelephony?(this.trigger("connected"),this._isConnected=!0):this.stop()}unregister(){this._isRegistered=!1,this._isConnected=!1,this.trigger("unregistered")}isRegistered(){return!!this._isRegistered}isStarted(){return this.configuration&&(this.configuration.register&&!!this._isRegistered||!this.configuration.register&&!!this._isConnected)}registrator(){return this._registrator}newSipEvent(t){this.trigger("sipEvent",t)}};r(s,"isAvailableTelephony",!0),r(s,"startError"),r(s,"countStartError",Number.POSITIVE_INFINITY),r(s,"countStarts",0);let M=s;class j{constructor(t){r(this,"url");this.url=t}}class B extends F.EventEmitter{constructor(e,n){super();r(this,"contentType");r(this,"body");this.contentType=e,this.body=n}}const S="remote",G=(o,t)=>{const e=new y(t),n={originator:S,request:e,info:new B("","")};o.newInfo(n)},K=(o,t)=>{const n={request:new y(t)};o.newSipEvent(n)},$=(o,{incomingNumber:t="1234",displayName:e,host:n})=>{const i=new l({originator:S}),d=new L("sip",t,n);i._remote_identity=new D(d,e),o.trigger("newRTCSession",{originator:S,session:i})},J=(o,t)=>{t?o.trigger("failed",t):o.trigger("failed",o)},A={triggerNewInfo:G,triggerNewSipEvent:K,triggerIncomingSession:$,triggerFailIncomingSession:J,WebSocketInterface:j,UA:M,C:{INVITE:"INVITE"}},_="user",h="displayName",p="SIP_SERVER_URL",R="SIP_WEB_SOCKET_SERVER_URL",X=new A.WebSocketInterface(R),v={userAgent:"Chrome",sipServerUrl:p,sipWebSocketServerURL:R},Q={...v},O={...v,user:_,password:c,register:!0},Z={...O,displayName:h},ee={...v,displayName:h,register:!1},E={session_timers:!1,sockets:[X],user_agent:"Chrome",sdp_semantics:"unified-plan",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},te={...E,password:c,uri:new T.URI("sip",_,p),display_name:"",register:!0},re={...E,password:c,uri:new T.URI("sip",_,p),display_name:h,register:!0},ne={...E,display_name:h,register:!1},oe={...E,display_name:"",register:!1},W="10.10.10.10",ie=[`X-Vinteo-Remote: ${W}`],se=()=>new g.SipConnector({JsSIP:A});exports.FAILED_CONFERENCE_NUMBER=N;exports.NAME_INCORRECT=P;exports.PASSWORD_CORRECT=c;exports.PASSWORD_CORRECT_2=f;exports.SIP_SERVER_URL=p;exports.SIP_WEB_SOCKET_SERVER_URL=R;exports.dataForConnectionWithAuthorization=O;exports.dataForConnectionWithAuthorizationWithDisplayName=Z;exports.dataForConnectionWithoutAuthorization=ee;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=Q;exports.default=se;exports.displayName=h;exports.extraHeadersRemoteAddress=ie;exports.remoteAddress=W;exports.uaConfigurationWithAuthorization=te;exports.uaConfigurationWithAuthorizationWithDisplayName=re;exports.uaConfigurationWithoutAuthorization=ne;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=oe;exports.user=_;
|
|
1
|
+
"use strict";var k=Object.defineProperty;var b=(o,t,e)=>t in o?k(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var r=(o,t,e)=>b(o,typeof t!="symbol"?t+"":t,e);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("./SipConnector-Ds1fhzNg.cjs"),D=require("@krivega/jssip/lib/NameAddrHeader"),L=require("@krivega/jssip/lib/URI"),F=require("node:events"),V=require("@krivega/jssip/lib/SIPMessage"),C=require("webrtc-mock"),I=require("events-constructor"),T=require("@krivega/jssip");class y extends V.IncomingRequest{constructor(e){super();r(this,"headers");this.headers=new Headers(e)}getHeader(e){return this.headers.get(e)||""}}class z{constructor({originator:t="local",eventHandlers:e}){r(this,"originator");r(this,"_connection");r(this,"_events");r(this,"_remote_identity");r(this,"_mutedOptions",{audio:!1,video:!1});this.originator=t,this._events=new I(g.SESSION_EVENT_NAMES),this.initEvents(e)}get C(){throw new Error("Method not implemented.")}get causes(){throw new Error("Method not implemented.")}get id(){throw new Error("Method not implemented.")}set data(t){throw new Error("Method not implemented.")}get data(){throw new Error("Method not implemented.")}get connection(){return this._connection}get contact(){throw new Error("Method not implemented.")}get direction(){throw new Error("Method not implemented.")}get local_identity(){throw new Error("Method not implemented.")}get remote_identity(){return this._remote_identity}get start_time(){throw new Error("Method not implemented.")}get end_time(){throw new Error("Method not implemented.")}get status(){throw new Error("Method not implemented.")}isInProgress(){throw new Error("Method not implemented.")}isEnded(){throw new Error("Method not implemented.")}isReadyToReOffer(){throw new Error("Method not implemented.")}answer(t){throw new Error("Method not implemented.")}terminate(t){throw new Error("Method not implemented.")}async sendInfo(t,e,n){throw new Error("Method not implemented.")}hold(t,e){throw new Error("Method not implemented.")}unhold(t,e){throw new Error("Method not implemented.")}async renegotiate(t,e){throw new Error("Method not implemented.")}isOnHold(){throw new Error("Method not implemented.")}mute(t){throw new Error("Method not implemented.")}unmute(t){throw new Error("Method not implemented.")}isMuted(){throw new Error("Method not implemented.")}refer(t,e){throw new Error("Method not implemented.")}resetLocalMedia(){throw new Error("Method not implemented.")}async replaceMediaStream(t,e){throw new Error("Method not implemented.")}addListener(t,e){throw new Error("Method not implemented.")}once(t,e){throw new Error("Method not implemented.")}removeListener(t,e){throw new Error("Method not implemented.")}off(t,e){throw new Error("Method not implemented.")}removeAllListeners(t){throw new Error("Method not implemented.")}setMaxListeners(t){throw new Error("Method not implemented.")}getMaxListeners(){throw new Error("Method not implemented.")}listeners(t){throw new Error("Method not implemented.")}rawListeners(t){throw new Error("Method not implemented.")}emit(t,...e){throw new Error("Method not implemented.")}listenerCount(t){throw new Error("Method not implemented.")}prependListener(t,e){throw new Error("Method not implemented.")}prependOnceListener(t,e){throw new Error("Method not implemented.")}eventNames(){throw new Error("Method not implemented.")}initEvents(t=[]){Object.entries(t).forEach(([e,n])=>this.on(e,n))}on(t,e){return this._events.on(t,e),this}trigger(t,e){this._events.trigger(t,e)}sendDTMF(){this.trigger("newDTMF",{originator:this.originator})}async startPresentation(t){return t}async updatePresentation(t){return t}async stopPresentation(t){return t}isEstablished(){return!0}}class x{constructor({track:t}={}){r(this,"dtmf",null);r(this,"track",null);r(this,"transport",null);r(this,"transform",null);r(this,"_parameters",{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}});r(this,"_parametersGets");this.track=t??null}async getStats(){throw new Error("Method not implemented.")}async replaceTrack(t){this.track=t??null}async setParameters(t){if(t!==this._parametersGets)throw new Error("Failed to execute 'setParameters' on 'RTCRtpSender': Read-only field modified in setParameters().");const{transactionId:e}=this._parameters;this._parameters={...this._parameters,...t,transactionId:`${Number(e)+1}`}}getParameters(){return this._parametersGets={...this._parameters},this._parametersGets}setStreams(){throw new Error("Method not implemented.")}}class U{constructor(t,e){r(this,"_senders",[]);r(this,"_receivers",[]);r(this,"canTrickleIceCandidates");r(this,"connectionState");r(this,"currentLocalDescription");r(this,"currentRemoteDescription");r(this,"iceConnectionState");r(this,"iceGatheringState");r(this,"idpErrorInfo");r(this,"idpLoginUrl");r(this,"localDescription");r(this,"onconnectionstatechange");r(this,"ondatachannel");r(this,"onicecandidate");r(this,"onicecandidateerror",null);r(this,"oniceconnectionstatechange");r(this,"onicegatheringstatechange");r(this,"onnegotiationneeded");r(this,"onsignalingstatechange");r(this,"ontrack");r(this,"peerIdentity");r(this,"pendingLocalDescription");r(this,"pendingRemoteDescription");r(this,"remoteDescription");r(this,"sctp",null);r(this,"signalingState");r(this,"getReceivers",()=>this._receivers);r(this,"getSenders",()=>this._senders);r(this,"addTrack",t=>{const e=new x({track:t});return this._senders.push(e),e});this._receivers=e.map(n=>({track:n}))}getRemoteStreams(){throw new Error("Method not implemented.")}async addIceCandidate(t){throw new Error("Method not implemented.")}addTransceiver(t,e){throw new Error("Method not implemented.")}close(){throw new Error("Method not implemented.")}restartIce(){throw new Error("Method not implemented.")}async createAnswer(t,e){throw new Error("Method not implemented.")}createDataChannel(t,e){throw new Error("Method not implemented.")}async createOffer(t,e,n){throw new Error("Method not implemented.")}getConfiguration(){throw new Error("Method not implemented.")}async getIdentityAssertion(){throw new Error("Method not implemented.")}async getStats(t){throw new Error("Method not implemented.")}getTransceivers(){throw new Error("Method not implemented.")}removeTrack(t){throw new Error("Method not implemented.")}setConfiguration(t){throw new Error("Method not implemented.")}async setLocalDescription(t){throw new Error("Method not implemented.")}async setRemoteDescription(t){throw new Error("Method not implemented.")}addEventListener(t,e,n){throw new Error("Method not implemented.")}removeEventListener(t,e,n){throw new Error("Method not implemented.")}dispatchEvent(t){throw new Error("Method not implemented.")}}function q(o){const t=o.match(/(purgatory)|[\d.]+/g);if(!t)throw new Error("wrong sip url");return t[0]}const w=400,N="777",H=o=>o.getVideoTracks().length>0,a=class a extends z{constructor({url:e="",mediaStream:n,eventHandlers:i,originator:d}){super({originator:d,eventHandlers:i});r(this,"url");r(this,"status_code");r(this,"_isEnded",!1);r(this,"answer",jest.fn(({mediaStream:e})=>{if(this.originator!=="remote")throw new Error("answer available only for remote sessions");this.initPeerconnection(e),setTimeout(()=>{this.trigger("connecting"),setTimeout(()=>{this.trigger("accepted")},100),setTimeout(()=>{this.trigger("confirmed")},200)},w)}));this.url=e,this.initPeerconnection(n)}static setStartPresentationError(e,{count:n=Number.POSITIVE_INFINITY}={}){this.startPresentationError=e,this.countStartPresentationError=n}static resetStartPresentationError(){this.startPresentationError=void 0,this.countStartPresentationError=Number.POSITIVE_INFINITY,this.countStartsPresentation=0}async startPresentation(e){if(a.countStartsPresentation+=1,a.startPresentationError&&a.countStartsPresentation<a.countStartPresentationError)throw a.startPresentationError;return super.startPresentation(e)}initPeerconnection(e){return e?(this.createPeerconnection(e),!0):!1}createPeerconnection(e){const n=C.createAudioMediaStreamTrackMock();n.id="mainaudio1";const i=[n];if(H(e)){const u=C.createVideoMediaStreamTrackMock();u.id="mainvideo1",i.push(u)}this._connection=new U(void 0,i),this._addStream(e),setTimeout(()=>{this.trigger("peerconnection",{peerconnection:this.connection})},w)}connect(e){const n=q(e);setTimeout(()=>{this.url.includes(N)?this.trigger("failed",{originator:"remote",message:"IncomingResponse",cause:g.REJECTED}):(this.trigger("connecting"),setTimeout(()=>{this.trigger("enterRoom",{room:n})},100),setTimeout(()=>{this.trigger("accepted")},200),setTimeout(()=>{this.trigger("confirmed")},300))},w)}terminate({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e}),this._isEnded=!1,this}async terminateAsync({status_code:e}={}){this.terminate({status_code:e})}terminateRemote({status_code:e}={}){return this.status_code=e,this.trigger("ended",{status_code:e,originator:"remote"}),this}_addStream(e,n="getTracks"){e[n]().forEach(i=>this.connection.addTrack(i))}_forEachSenders(e){const n=this.connection.getSenders();for(const i of n)e(i);return n}_toggleMuteAudio(e){this._forEachSenders(({track:n})=>{n&&n.kind==="audio"&&(n.enabled=!e)})}_toggleMuteVideo(e){this._forEachSenders(({track:n})=>{n&&n.kind==="video"&&(n.enabled=!e)})}mute(e){e.audio&&(this._mutedOptions.audio=!0,this._toggleMuteAudio(this._mutedOptions.audio)),e.video&&(this._mutedOptions.video=!0,this._toggleMuteVideo(this._mutedOptions.video)),this._onmute(e)}unmute(e){e.audio&&(this._mutedOptions.audio=!1),e.video&&(this._mutedOptions.video=!1),this.trigger("unmuted",e)}isMuted(){return this._mutedOptions}async replaceMediaStream(e){return e}_onmute({audio:e,video:n}){this.trigger("muted",{audio:e,video:n})}async sendInfo(){}isEnded(){return this._isEnded}newInfo(e){this.trigger("newInfo",e)}};r(a,"startPresentationError"),r(a,"countStartPresentationError",Number.POSITIVE_INFINITY),r(a,"countStartsPresentation",0);let l=a;class Y{constructor(){r(this,"extraHeaders",[])}setExtraHeaders(t){this.extraHeaders=t}setExtraContactParams(){}}const c="PASSWORD_CORRECT",f="PASSWORD_CORRECT_2",P="NAME_INCORRECT",m=400,s=class s{constructor(t){r(this,"_events");r(this,"_startedTimeout");r(this,"_stopedTimeout");r(this,"session");r(this,"_isRegistered");r(this,"_isConnected");r(this,"configuration");r(this,"_registrator");r(this,"call",jest.fn((t,e)=>{const{mediaStream:n,eventHandlers:i}=e;return this.session=new l({url:t,mediaStream:n,eventHandlers:i,originator:"local"}),this.session.connect(t),this.session}));this._events=new I(g.UA_EVENT_NAMES);const[e,n]=t.uri.split(":"),[i,d]=n.split("@"),u={...t,uri:new T.URI(e,i,d)};this.configuration=u,this._registrator=new Y}static setStartError(t,{count:e=Number.POSITIVE_INFINITY}={}){this.startError=t,this.countStartError=e}static resetStartError(){this.startError=void 0,this.countStartError=Number.POSITIVE_INFINITY,this.countStarts=0}static setAvailableTelephony(){this.isAvailableTelephony=!0}static setNotAvailableTelephony(){this.isAvailableTelephony=!1}isConnected(){return!!this._isConnected}start(){if(s.countStarts+=1,s.startError&&s.countStarts<s.countStartError){this.trigger("disconnected",s.startError);return}this.register()}stop(){this._startedTimeout&&clearTimeout(this._startedTimeout),this._stopedTimeout&&clearTimeout(this._stopedTimeout),this.unregister(),this.isStarted()?this._stopedTimeout=setTimeout(()=>{this.trigger("disconnected",{error:new Error("stoped")})},m):this.trigger("disconnected",{error:new Error("stoped")})}on(t,e){return this._events.on(t,e),this}once(t,e){return this._events.once(t,e),this}off(t,e){return this._events.off(t,e),this}removeAllListeners(){return this._events.removeEventHandlers(),this}trigger(t,e){this._events.trigger(t,e)}terminateSessions(){this.session.terminate()}set(t,e){return this.configuration[t]=e,!0}register(){this._startedTimeout&&clearTimeout(this._startedTimeout);const{password:t,register:e,uri:n}=this.configuration;e&&n.user.includes(P)?(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Request Timeout"})},m)):!this._isRegistered&&e&&(t===c||t===f)?(this._isRegistered=!0,this._startedTimeout=setTimeout(()=>{this.trigger("registered")},m)):e&&t!==c&&t!==f&&(this._isRegistered=!1,this._isConnected=!1,this._startedTimeout=setTimeout(()=>{this.trigger("registrationFailed",{response:null,cause:"Wrong credentials"})},m)),s.isAvailableTelephony?(this.trigger("connected"),this._isConnected=!0):this.stop()}unregister(){this._isRegistered=!1,this._isConnected=!1,this.trigger("unregistered")}isRegistered(){return!!this._isRegistered}isStarted(){return this.configuration&&(this.configuration.register&&!!this._isRegistered||!this.configuration.register&&!!this._isConnected)}registrator(){return this._registrator}newSipEvent(t){this.trigger("sipEvent",t)}};r(s,"isAvailableTelephony",!0),r(s,"startError"),r(s,"countStartError",Number.POSITIVE_INFINITY),r(s,"countStarts",0);let M=s;class j{constructor(t){r(this,"url");this.url=t}}class B extends F.EventEmitter{constructor(e,n){super();r(this,"contentType");r(this,"body");this.contentType=e,this.body=n}}const S="remote",G=(o,t)=>{const e=new y(t),n={originator:S,request:e,info:new B("","")};o.newInfo(n)},K=(o,t)=>{const n={request:new y(t)};o.newSipEvent(n)},$=(o,{incomingNumber:t="1234",displayName:e,host:n})=>{const i=new l({originator:S}),d=new L("sip",t,n);i._remote_identity=new D(d,e),o.trigger("newRTCSession",{originator:S,session:i})},J=(o,t)=>{t?o.trigger("failed",t):o.trigger("failed",o)},A={triggerNewInfo:G,triggerNewSipEvent:K,triggerIncomingSession:$,triggerFailIncomingSession:J,WebSocketInterface:j,UA:M,C:{INVITE:"INVITE"}},_="user",h="displayName",p="SIP_SERVER_URL",R="SIP_WEB_SOCKET_SERVER_URL",X=new A.WebSocketInterface(R),v={userAgent:"Chrome",sipServerUrl:p,sipWebSocketServerURL:R},Q={...v},O={...v,user:_,password:c,register:!0},Z={...O,displayName:h},ee={...v,displayName:h,register:!1},E={session_timers:!1,sockets:[X],user_agent:"Chrome",sdp_semantics:"unified-plan",register_expires:300,connection_recovery_max_interval:6,connection_recovery_min_interval:2},te={...E,password:c,uri:new T.URI("sip",_,p),display_name:"",register:!0},re={...E,password:c,uri:new T.URI("sip",_,p),display_name:h,register:!0},ne={...E,display_name:h,register:!1},oe={...E,display_name:"",register:!1},W="10.10.10.10",ie=[`X-Vinteo-Remote: ${W}`],se=()=>new g.SipConnector({JsSIP:A});exports.FAILED_CONFERENCE_NUMBER=N;exports.NAME_INCORRECT=P;exports.PASSWORD_CORRECT=c;exports.PASSWORD_CORRECT_2=f;exports.SIP_SERVER_URL=p;exports.SIP_WEB_SOCKET_SERVER_URL=R;exports.dataForConnectionWithAuthorization=O;exports.dataForConnectionWithAuthorizationWithDisplayName=Z;exports.dataForConnectionWithoutAuthorization=ee;exports.dataForConnectionWithoutAuthorizationWithoutDisplayName=Q;exports.default=se;exports.displayName=h;exports.extraHeadersRemoteAddress=ie;exports.remoteAddress=W;exports.uaConfigurationWithAuthorization=te;exports.uaConfigurationWithAuthorizationWithDisplayName=re;exports.uaConfigurationWithoutAuthorization=ne;exports.uaConfigurationWithoutAuthorizationWithoutDisplayName=oe;exports.user=_;
|
package/dist/doMock.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var y = Object.defineProperty;
|
|
2
2
|
var N = (o, t, e) => t in o ? y(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
3
|
var r = (o, t, e) => N(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import {
|
|
4
|
+
import { n as P, R as O, U as k, S as A } from "./SipConnector-BxDInUHC.js";
|
|
5
5
|
import b from "@krivega/jssip/lib/NameAddrHeader";
|
|
6
6
|
import D from "@krivega/jssip/lib/URI";
|
|
7
7
|
import { EventEmitter as L } from "node:events";
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Q=Object.defineProperty;var J=(n,e,t)=>e in n?Q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var l=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./SipConnector-BWx586hI.cjs"),Z=require("sequent-promises"),ee=require("stack-promises"),ne=require("@krivega/cancelable-promise"),te=require("repeated-calls"),re=require("ts-debounce"),se=require("debug"),L=n=>{const{url:e,cause:t}=n;let r=e;return(t===s.BAD_MEDIA_DESCRIPTION||t===s.NOT_FOUND)&&(r=`${n.message.to.uri.user}@${n.message.to.uri.host}`),r};var q=(n=>(n.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",n.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",n.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",n.NOT_FOUND_ERROR="NOT_FOUND_ERROR",n.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",n.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",n))(q||{});const oe=(n=new Error)=>{var o;const{cause:e,socket:t}=n;let r="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case s.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case s.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t&&((o=t==null?void 0:t._ws)==null?void 0:o.readyState)===3?r="WS_CONNECTION_FAILED":L(n)&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},ce=n=>{let e="";try{e=JSON.stringify(n)}catch(t){s.logger("failed to stringify message",t)}return e},ie=(n=new Error)=>{const{code:e,cause:t,message:r}=n,o=L(n),c={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?c.message=ce(r):r&&(c.message=String(r)),o&&(c.link=o),e&&(c.code=e),t&&(c.cause=t),c},ae=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:q,getLinkError:L,getTypeFromError:oe,getValuesFromError:ie},Symbol.toStringTag,{value:"Module"})),ue=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:r,isRegistered:o,isPresentationCall:c})=>{const i=[],a=t?"0":"1",u=r?"0":"1";return i.push(`X-Vinteo-Mic-State: ${a}`,`X-Vinteo-MainCam-State: ${u}`),o||i.push("X-Vinteo-Purgatory-Call: yes"),n&&i.push(`X-Vinteo-Session: ${n}`),c&&i.push("X-Vinteo-Presentation-Call: yes"),e&&i.push(`X-Vinteo-Remote: ${e}`),i},le="[@*!|]",de="_",ge=n=>{let e=n;return e=e.replaceAll(new RegExp(le,"g"),de),e},Se=({appName:n,appVersion:e,browserName:t,browserVersion:r})=>{const c=`${ge(n)} ${e}`;return`ChromeNew - ${t?`${t} ${r}, ${c}`:c}`},Ce=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:r,appName:o})=>n?Se({appVersion:e,browserName:t,browserVersion:r,appName:o}):"Chrome",H="purgatory",B=n=>n===H,me=n=>e=>[...e].map(r=>async()=>n(r)),fe=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const o=me(e)(n);return Z.sequentPromises(o,t)},he=n=>t=>(s.logger("onStartMainCam"),n.onSession("admin-start-main-cam",t)),Re=n=>t=>(s.logger("onStartMic"),n.onSession("admin-start-mic",t)),Ee=n=>t=>(s.logger("onStopMainCam"),n.onSession("admin-stop-main-cam",t)),pe=n=>t=>(s.logger("onStopMic"),n.onSession("admin-stop-mic",t)),ye=({sipConnector:n})=>{const e=(m,R)=>({isSyncForced:E=!1})=>{if(E){m();return}R()},t=he(n),r=Ee(n),o=Re(n),c=pe(n);let i=()=>{},a=()=>{},u=()=>{},g=()=>{};const C=({onStartMainCamForced:m,onStartMainCamNotForced:R,onStopMainCamForced:E,onStopMainCamNotForced:M,onStartMicForced:_,onStartMicNotForced:A,onStopMicForced:v,onStopMicNotForced:O})=>{const p=e(m,R);i=t(p);const y=e(E,M);a=r(y);const D=e(_,A);u=o(D);const b=e(v,O);g=c(b)},S=()=>{i(),a(),u(),g()};return{start:m=>{C(m)},stop:()=>{S()}}},Te=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:H,createSyncMediaState:ye,error:ae,getExtraHeaders:ue,getUserAgent:Ce,hasPurgatory:B,sendDTMFAccumulated:fe},Symbol.toStringTag,{value:"Module"})),Me=n=>[...n.keys()].map(e=>n.get(e)),be=(n,e)=>Me(n).find(t=>t.type===e),X=async n=>n.getStats().then(e=>{const t=be(e,"codec");return t==null?void 0:t.mimeType}),_e=n=>n.find(e=>{var t;return((t=e==null?void 0:e.track)==null?void 0:t.kind)==="video"}),j=(n,e)=>n!==void 0&&e!==void 0&&n.toLowerCase().includes(e.toLowerCase()),Ae=1e6,f=n=>n*Ae,W=f(.06),ve=f(4),Oe=n=>n<=64?W:n<=128?f(.12):n<=256?f(.25):n<=384?f(.32):n<=426?f(.38):n<=640?f(.5):n<=848?f(.7):n<=1280?f(1):n<=1920?f(2):ve,Ne="av1",Pe=n=>j(n,Ne),Be=.6,G=(n,e)=>Pe(e)?n*Be:n,De=n=>G(W,n),K=(n,e)=>{const t=Oe(n);return G(t,e)},Ie=1,Y=({videoTrack:n,targetSize:e,codec:t})=>{const r=n.getSettings(),o=r.width,c=r.height,i=o/e.width,a=c/e.height,u=Math.max(i,a,Ie),g=K(e.width,t);return{scaleResolutionDownBy:u,maxBitrate:g}},z=ee.createStackPromises(),we=async()=>z().catch(n=>{s.logger("videoSendingBalancer: error",n)}),Fe=async n=>(z.add(n),we()),V=async({sender:n,scaleResolutionDownBy:e,maxBitrate:t,onSetParameters:r})=>Fe(async()=>s.setEncodingsToSender(n,{scaleResolutionDownBy:e,maxBitrate:t},r)),ke=async({sender:n,codec:e},t)=>{const o=De(e);return V({sender:n,maxBitrate:o,onSetParameters:t,scaleResolutionDownBy:200})},k=async({sender:n,videoTrack:e,codec:t},r)=>{const i=e.getSettings().width,a=K(i,t);return V({sender:n,maxBitrate:a,onSetParameters:r,scaleResolutionDownBy:1})},Ue=async({sender:n,videoTrack:e,resolution:t,codec:r},o)=>{const[c,i]=t.split("x"),{maxBitrate:a,scaleResolutionDownBy:u}=Y({videoTrack:e,codec:r,targetSize:{width:Number(c),height:Number(i)}});return V({sender:n,maxBitrate:a,onSetParameters:o,scaleResolutionDownBy:u})},Le=async({mainCam:n,resolutionMainCam:e,sender:t,videoTrack:r,codec:o},c)=>{switch(n){case s.EEventsMainCAM.PAUSE_MAIN_CAM:return ke({sender:t,codec:o},c);case s.EEventsMainCAM.RESUME_MAIN_CAM:return k({sender:t,videoTrack:r,codec:o},c);case s.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return e!==void 0?Ue({sender:t,videoTrack:r,codec:o,resolution:e},c):k({sender:t,videoTrack:r,codec:o},c);default:return k({sender:t,videoTrack:r,codec:o},c)}},x={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},$=async({mainCam:n,resolutionMainCam:e,connection:t,onSetParameters:r,ignoreForCodec:o})=>{const c=t.getSenders(),i=_e(c);if(!(i!=null&&i.track))return x;const a=await X(i);return j(a,o)?x:Le({mainCam:n,resolutionMainCam:e,sender:i,codec:a,videoTrack:i.track},r)},Ve=(n,{ignoreForCodec:e,onSetParameters:t}={})=>{const r=async()=>{const{connection:u}=n;if(!u)throw new Error("connection is not exist");return $({connection:u,onSetParameters:t,ignoreForCodec:e})};let o=r;const c=async u=>(o=async()=>{const{mainCam:g,resolutionMainCam:C}=u,{connection:S}=n;if(!S)throw new Error("connection is not exist");return $({mainCam:g,resolutionMainCam:C,connection:S,onSetParameters:t,ignoreForCodec:e})},o());return{subscribe:()=>{n.onSession("main-cam-control",c)},unsubscribe:()=>{n.offSession("main-cam-control",c)},balanceByTrack:r,resetMainCamControl(){o=r},async reBalance(){return o()}}},xe=n=>n.getVideoTracks()[0],N=({mediaStream:n,simulcastEncodings:e,sendEncodings:t})=>{if(e&&e.length>0){const r=t??[],o=xe(n);return e.forEach((c,i)=>{const a=r[i]??{},{maxBitrate:u,scaleResolutionDownBy:g}=Y({videoTrack:o,targetSize:{width:c.width,height:c.height}});a.maxBitrate=u,a.scaleResolutionDownBy=g,r[i]=a}),r}return t},$e=(n,e)=>[...n,...e].filter((o,c,i)=>c===i.findIndex(a=>a.clockRate===o.clockRate&&a.mimeType===o.mimeType&&a.channels===o.channels&&a.sdpFmtpLine===o.sdpFmtpLine)),qe=n=>{const e=RTCRtpSender.getCapabilities(n),t=RTCRtpReceiver.getCapabilities(n),r=e===null?[]:e.codecs,o=t===null?[]:t.codecs;return $e(r,o)},He=(n,e)=>e===void 0||e.length===0?n:n.sort((t,r)=>{const o=e.indexOf(t.mimeType),c=e.indexOf(r.mimeType),i=o===-1?Number.MAX_VALUE:o,a=c===-1?Number.MAX_VALUE:c;return i-a}),Xe=(n,e)=>e===void 0||e.length===0?n:n.filter(t=>!e.includes(t.mimeType)),P=(n,{preferredMimeTypesVideoCodecs:e,excludeMimeTypesVideoCodecs:t})=>async r=>{var o;if(typeof r.setCodecPreferences=="function"&&((o=r.sender.track)==null?void 0:o.kind)==="video"&&(e!==void 0&&(e==null?void 0:e.length)>0||t!==void 0&&(t==null?void 0:t.length)>0)){const c=qe("video"),i=Xe(c,t),a=He(i,e);r.setCodecPreferences(a)}Object.keys(n).length>0&&await s.setParametersToSender(r.sender,n)},U=n=>{if(!ne.isCanceledError(n)&&!te.hasCanceledError(n))throw n;return{isSuccessful:!1}},je=({kind:n,readyState:e})=>n==="video"&&e==="live";class We{constructor(e,{preferredMimeTypesVideoCodecs:t,excludeMimeTypesVideoCodecs:r}={}){l(this,"sipConnector");l(this,"preferredMimeTypesVideoCodecs");l(this,"excludeMimeTypesVideoCodecs");l(this,"connectToServer",async e=>{const{userAgent:t,sipWebSocketServerURL:r,sipServerUrl:o,remoteAddress:c,displayName:i,name:a,password:u,isRegisteredUser:g,isDisconnectOnFail:C}=e;return s.logger("connectToServer",e),this.sipConnector.connect({userAgent:t,sipWebSocketServerURL:r,sipServerUrl:o,remoteAddress:c,displayName:i,password:u,user:a,register:g}).then(S=>(s.logger("connectToServer then"),{ua:S,isSuccessful:!0})).catch(async S=>(s.logger("connectToServer catch: error",S),C===!0?this.sipConnector.disconnect().then(()=>U(S)).catch(()=>U(S)):U(S)))});l(this,"callToServer",async e=>{const{conference:t,mediaStream:r,extraHeaders:o,iceServers:c,contentHint:i,simulcastEncodings:a,degradationPreference:u,sendEncodings:g,setRemoteStreams:C,onBeforeProgressCall:S,onSuccessProgressCall:T,onEnterPurgatory:h,onEnterConference:m,onFailProgressCall:R,onFinishProgressCall:E,onEndedCall:M}=e,_=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:C}),A=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:_}),v=P({degradationPreference:u},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});s.logger("callToServer",e);const O=async()=>(s.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:o,iceServers:c,contentHint:i,sendEncodings:N({mediaStream:r,simulcastEncodings:a,sendEncodings:g}),number:t,onAddedTransceiver:v,ontrack:A}));let p=!1,y;const b=(s.logger("subscribeEnterConference: onEnterConference",m),h??m?this.sipConnector.onSession("enterRoom",({room:d})=>{s.logger("enterRoom",{_room:d,isSuccessProgressCall:p}),y=d,B(y)?h&&h():m&&m({isSuccessProgressCall:p})}):()=>{}),I=d=>(s.logger("onSuccess"),p=!0,_(),T&&T({isPurgatory:B(y)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{b(),M&&M()}),d),w=d=>{throw s.logger("onFail"),R&&R(),b(),d},F=()=>{s.logger("onFinish"),E&&E()};return s.logger("onBeforeProgressCall"),S&&S(t),O().then(I).catch(d=>w(d)).finally(F)});l(this,"disconnectFromServer",async()=>this.sipConnector.disconnect().then(()=>(s.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(s.logger("disconnectFromServer: catch",e),{isSuccessful:!1})));l(this,"answerIncomingCall",async e=>{const{mediaStream:t,extraHeaders:r,iceServers:o,contentHint:c,simulcastEncodings:i,degradationPreference:a,sendEncodings:u,setRemoteStreams:g,onBeforeProgressCall:C,onSuccessProgressCall:S,onEnterPurgatory:T,onEnterConference:h,onFailProgressCall:m,onFinishProgressCall:R,onEndedCall:E}=e,M=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:g}),_=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:M}),A=P({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});s.logger("answerIncomingCall",e);const v=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:r,iceServers:o,contentHint:c,sendEncodings:N({mediaStream:t,simulcastEncodings:i,sendEncodings:u}),onAddedTransceiver:A,ontrack:_}),O=()=>{const{remoteCallerData:d}=this.sipConnector;return d.incomingNumber};let p=!1,y;const b=(s.logger("subscribeEnterConference: onEnterConference",h),T??h?this.sipConnector.onSession("enterRoom",d=>{s.logger("enterRoom",{_room:d,isSuccessProgressCall:p}),y=d,B(y)?T&&T():h&&h({isSuccessProgressCall:p})}):()=>{}),I=d=>(s.logger("onSuccess"),p=!0,M(),S&&S({isPurgatory:B(y)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{b(),E&&E()}),d),w=d=>{throw s.logger("onFail"),m&&m(),b(),d},F=()=>{s.logger("onFinish"),R&&R()};if(s.logger("onBeforeProgressCall"),C){const d=O();C(d)}return v().then(I).catch(d=>w(d)).finally(F)});l(this,"updatePresentation",async({mediaStream:e,isP2P:t,maxBitrate:r,contentHint:o,simulcastEncodings:c,degradationPreference:i,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g})=>{const C=P({degradationPreference:i},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return s.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,maxBitrate:r,contentHint:o,sendEncodings:N({mediaStream:e,simulcastEncodings:c,sendEncodings:a}),onAddedTransceiver:C})});l(this,"startPresentation",async({mediaStream:e,isP2P:t,maxBitrate:r,contentHint:o,simulcastEncodings:c,degradationPreference:i,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g},C)=>{const S=P({degradationPreference:i},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return s.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,maxBitrate:r,contentHint:o,sendEncodings:N({mediaStream:e,simulcastEncodings:c,sendEncodings:a}),onAddedTransceiver:S},C)});l(this,"stopShareSipConnector",async({isP2P:e=!1}={})=>(s.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{s.logger(t)})));l(this,"sendRefusalToTurnOnMic",async()=>{if(this.sipConnector.isCallActive)return s.logger("sendRefusalToTurnOnMic"),this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{s.logger("sendRefusalToTurnOnMic: error",e)})});l(this,"sendRefusalToTurnOnCam",async()=>{if(this.sipConnector.isCallActive)return s.logger("sendRefusalToTurnOnCam"),this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{s.logger("sendRefusalToTurnOnCam: error",e)})});l(this,"sendMediaState",async({isEnabledCam:e,isEnabledMic:t})=>{if(this.sipConnector.isCallActive)return s.logger("sendMediaState"),this.sipConnector.sendMediaState({cam:e,mic:t})});l(this,"replaceMediaStream",async(e,{deleteExisting:t,addMissing:r,forceRenegotiation:o,contentHint:c,simulcastEncodings:i,degradationPreference:a,sendEncodings:u}={})=>{const g=P({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});return s.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:r,forceRenegotiation:o,contentHint:c,sendEncodings:N({mediaStream:e,simulcastEncodings:i,sendEncodings:u}),onAddedTransceiver:g})});l(this,"askPermissionToEnableCam",async()=>{if(this.sipConnector.isCallActive)return s.logger("askPermissionToEnableCam"),this.sipConnector.askPermissionToEnableCam()});l(this,"resolveHandleReadyRemoteStreamsDebounced",({onReadyRemoteStreams:e})=>re.debounce(()=>{const t=this.sipConnector.getRemoteStreams();s.logger("remoteStreams",t),t&&e(t)},200));l(this,"resolveHandleReadyRemoteStreams",({onReadyRemoteStreams:e})=>({track:t})=>{je(t)&&e()});l(this,"getRemoteStreams",()=>(s.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams()));l(this,"onUseLicense",e=>(s.logger("onUseLicense"),this.sipConnector.onSession("useLicense",e)));l(this,"onMustStopPresentation",e=>(s.logger("onMustStopPresentation"),this.sipConnector.onSession("mustStopPresentation",e)));l(this,"onMoveToSpectators",e=>(s.logger("onMoveToSpectators"),this.sipConnector.onSession(s.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS,e)));l(this,"onMoveToParticipants",e=>(s.logger("onMoveToParticipants"),this.sipConnector.onSession(s.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS,e)));this.sipConnector=e,this.preferredMimeTypesVideoCodecs=t,this.excludeMimeTypesVideoCodecs=r}}exports.EEventsMainCAM=s.EEventsMainCAM;exports.EEventsMic=s.EEventsMic;exports.EEventsSyncMediaState=s.EEventsSyncMediaState;exports.EUseLicense=s.EUseLicense;exports.causes=s.causes;exports.constants=s.constants;exports.default=s.SipConnector;exports.disableDebug=s.disableDebug;exports.enableDebug=s.enableDebug;exports.eventNames=s.eventNames;exports.hasCanceledCallError=s.hasCanceledCallError;exports.setParametersToSender=s.setParametersToSender;exports.debug=se;exports.SipConnectorFacade=We;exports.getCodecFromSender=X;exports.resolveVideoSendingBalancer=Ve;exports.tools=Te;
|
|
1
|
+
"use strict";var Q=Object.defineProperty;var J=(n,e,t)=>e in n?Q(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var l=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./SipConnector-Ds1fhzNg.cjs"),Z=require("sequent-promises"),ee=require("stack-promises"),ne=require("@krivega/cancelable-promise"),te=require("repeated-calls"),re=require("ts-debounce"),se=require("debug"),L=n=>{const{url:e,cause:t}=n;let r=e;return(t===s.BAD_MEDIA_DESCRIPTION||t===s.NOT_FOUND)&&(r=`${n.message.to.uri.user}@${n.message.to.uri.host}`),r};var q=(n=>(n.CONNECT_SERVER_FAILED="CONNECT_SERVER_FAILED",n.WRONG_USER_OR_PASSWORD="WRONG_USER_OR_PASSWORD",n.BAD_MEDIA_ERROR="BAD_MEDIA_ERROR",n.NOT_FOUND_ERROR="NOT_FOUND_ERROR",n.WS_CONNECTION_FAILED="WS_CONNECTION_FAILED",n.CONNECT_SERVER_FAILED_BY_LINK="CONNECT_SERVER_FAILED_BY_LINK",n))(q||{});const oe=(n=new Error)=>{var o;const{cause:e,socket:t}=n;let r="CONNECT_SERVER_FAILED";switch(e){case"Forbidden":{r="WRONG_USER_OR_PASSWORD";break}case s.BAD_MEDIA_DESCRIPTION:{r="BAD_MEDIA_ERROR";break}case s.NOT_FOUND:{r="NOT_FOUND_ERROR";break}default:t&&((o=t==null?void 0:t._ws)==null?void 0:o.readyState)===3?r="WS_CONNECTION_FAILED":L(n)&&(r="CONNECT_SERVER_FAILED_BY_LINK")}return r},ce=n=>{let e="";try{e=JSON.stringify(n)}catch(t){s.logger("failed to stringify message",t)}return e},ie=(n=new Error)=>{const{code:e,cause:t,message:r}=n,o=L(n),c={code:"",cause:"",message:""};return typeof r=="object"&&r!==null?c.message=ce(r):r&&(c.message=String(r)),o&&(c.link=o),e&&(c.code=e),t&&(c.cause=t),c},ae=Object.freeze(Object.defineProperty({__proto__:null,EErrorTypes:q,getLinkError:L,getTypeFromError:oe,getValuesFromError:ie},Symbol.toStringTag,{value:"Module"})),ue=({sessionId:n,remoteAddress:e,isMutedAudio:t,isMutedVideo:r,isRegistered:o,isPresentationCall:c})=>{const i=[],a=t?"0":"1",u=r?"0":"1";return i.push(`X-Vinteo-Mic-State: ${a}`,`X-Vinteo-MainCam-State: ${u}`),o||i.push("X-Vinteo-Purgatory-Call: yes"),n&&i.push(`X-Vinteo-Session: ${n}`),c&&i.push("X-Vinteo-Presentation-Call: yes"),e&&i.push(`X-Vinteo-Remote: ${e}`),i},le="[@*!|]",de="_",ge=n=>{let e=n;return e=e.replaceAll(new RegExp(le,"g"),de),e},Se=({appName:n,appVersion:e,browserName:t,browserVersion:r})=>{const c=`${ge(n)} ${e}`;return`ChromeNew - ${t?`${t} ${r}, ${c}`:c}`},Ce=({isUnifiedSdpSemantic:n,appVersion:e,browserName:t,browserVersion:r,appName:o})=>n?Se({appVersion:e,browserName:t,browserVersion:r,appName:o}):"Chrome",H="purgatory",B=n=>n===H,me=n=>e=>[...e].map(r=>async()=>n(r)),fe=async({accumulatedKeys:n,sendKey:e,canRunTask:t})=>{const o=me(e)(n);return Z.sequentPromises(o,t)},he=n=>t=>(s.logger("onStartMainCam"),n.onSession("admin-start-main-cam",t)),Re=n=>t=>(s.logger("onStartMic"),n.onSession("admin-start-mic",t)),Ee=n=>t=>(s.logger("onStopMainCam"),n.onSession("admin-stop-main-cam",t)),pe=n=>t=>(s.logger("onStopMic"),n.onSession("admin-stop-mic",t)),ye=({sipConnector:n})=>{const e=(m,R)=>({isSyncForced:E=!1})=>{if(E){m();return}R()},t=he(n),r=Ee(n),o=Re(n),c=pe(n);let i=()=>{},a=()=>{},u=()=>{},g=()=>{};const C=({onStartMainCamForced:m,onStartMainCamNotForced:R,onStopMainCamForced:E,onStopMainCamNotForced:M,onStartMicForced:_,onStartMicNotForced:A,onStopMicForced:v,onStopMicNotForced:O})=>{const p=e(m,R);i=t(p);const y=e(E,M);a=r(y);const D=e(_,A);u=o(D);const b=e(v,O);g=c(b)},S=()=>{i(),a(),u(),g()};return{start:m=>{C(m)},stop:()=>{S()}}},Te=Object.freeze(Object.defineProperty({__proto__:null,PURGATORY_CONFERENCE_NUMBER:H,createSyncMediaState:ye,error:ae,getExtraHeaders:ue,getUserAgent:Ce,hasPurgatory:B,sendDTMFAccumulated:fe},Symbol.toStringTag,{value:"Module"})),Me=n=>[...n.keys()].map(e=>n.get(e)),be=(n,e)=>Me(n).find(t=>t.type===e),X=async n=>n.getStats().then(e=>{const t=be(e,"codec");return t==null?void 0:t.mimeType}),_e=n=>n.find(e=>{var t;return((t=e==null?void 0:e.track)==null?void 0:t.kind)==="video"}),j=(n,e)=>n!==void 0&&e!==void 0&&n.toLowerCase().includes(e.toLowerCase()),Ae=1e6,f=n=>n*Ae,W=f(.06),ve=f(4),Oe=n=>n<=64?W:n<=128?f(.12):n<=256?f(.25):n<=384?f(.32):n<=426?f(.38):n<=640?f(.5):n<=848?f(.7):n<=1280?f(1):n<=1920?f(2):ve,Ne="av1",Pe=n=>j(n,Ne),Be=.6,G=(n,e)=>Pe(e)?n*Be:n,De=n=>G(W,n),K=(n,e)=>{const t=Oe(n);return G(t,e)},Ie=1,Y=({videoTrack:n,targetSize:e,codec:t})=>{const r=n.getSettings(),o=r.width,c=r.height,i=o/e.width,a=c/e.height,u=Math.max(i,a,Ie),g=K(e.width,t);return{scaleResolutionDownBy:u,maxBitrate:g}},z=ee.createStackPromises(),we=async()=>z().catch(n=>{s.logger("videoSendingBalancer: error",n)}),Fe=async n=>(z.add(n),we()),V=async({sender:n,scaleResolutionDownBy:e,maxBitrate:t,onSetParameters:r})=>Fe(async()=>s.setEncodingsToSender(n,{scaleResolutionDownBy:e,maxBitrate:t},r)),ke=async({sender:n,codec:e},t)=>{const o=De(e);return V({sender:n,maxBitrate:o,onSetParameters:t,scaleResolutionDownBy:200})},k=async({sender:n,videoTrack:e,codec:t},r)=>{const i=e.getSettings().width,a=K(i,t);return V({sender:n,maxBitrate:a,onSetParameters:r,scaleResolutionDownBy:1})},Ue=async({sender:n,videoTrack:e,resolution:t,codec:r},o)=>{const[c,i]=t.split("x"),{maxBitrate:a,scaleResolutionDownBy:u}=Y({videoTrack:e,codec:r,targetSize:{width:Number(c),height:Number(i)}});return V({sender:n,maxBitrate:a,onSetParameters:o,scaleResolutionDownBy:u})},Le=async({mainCam:n,resolutionMainCam:e,sender:t,videoTrack:r,codec:o},c)=>{switch(n){case s.EEventsMainCAM.PAUSE_MAIN_CAM:return ke({sender:t,codec:o},c);case s.EEventsMainCAM.RESUME_MAIN_CAM:return k({sender:t,videoTrack:r,codec:o},c);case s.EEventsMainCAM.MAX_MAIN_CAM_RESOLUTION:return e!==void 0?Ue({sender:t,videoTrack:r,codec:o,resolution:e},c):k({sender:t,videoTrack:r,codec:o},c);default:return k({sender:t,videoTrack:r,codec:o},c)}},x={isChanged:!1,parameters:{encodings:[{}],transactionId:"0",codecs:[],headerExtensions:[],rtcp:{}}},$=async({mainCam:n,resolutionMainCam:e,connection:t,onSetParameters:r,ignoreForCodec:o})=>{const c=t.getSenders(),i=_e(c);if(!(i!=null&&i.track))return x;const a=await X(i);return j(a,o)?x:Le({mainCam:n,resolutionMainCam:e,sender:i,codec:a,videoTrack:i.track},r)},Ve=(n,{ignoreForCodec:e,onSetParameters:t}={})=>{const r=async()=>{const{connection:u}=n;if(!u)throw new Error("connection is not exist");return $({connection:u,onSetParameters:t,ignoreForCodec:e})};let o=r;const c=async u=>(o=async()=>{const{mainCam:g,resolutionMainCam:C}=u,{connection:S}=n;if(!S)throw new Error("connection is not exist");return $({mainCam:g,resolutionMainCam:C,connection:S,onSetParameters:t,ignoreForCodec:e})},o());return{subscribe:()=>{n.onSession("main-cam-control",c)},unsubscribe:()=>{n.offSession("main-cam-control",c)},balanceByTrack:r,resetMainCamControl(){o=r},async reBalance(){return o()}}},xe=n=>n.getVideoTracks()[0],N=({mediaStream:n,simulcastEncodings:e,sendEncodings:t})=>{if(e&&e.length>0){const r=t??[],o=xe(n);return e.forEach((c,i)=>{const a=r[i]??{},{maxBitrate:u,scaleResolutionDownBy:g}=Y({videoTrack:o,targetSize:{width:c.width,height:c.height}});a.maxBitrate=u,a.scaleResolutionDownBy=g,r[i]=a}),r}return t},$e=(n,e)=>[...n,...e].filter((o,c,i)=>c===i.findIndex(a=>a.clockRate===o.clockRate&&a.mimeType===o.mimeType&&a.channels===o.channels&&a.sdpFmtpLine===o.sdpFmtpLine)),qe=n=>{const e=RTCRtpSender.getCapabilities(n),t=RTCRtpReceiver.getCapabilities(n),r=e===null?[]:e.codecs,o=t===null?[]:t.codecs;return $e(r,o)},He=(n,e)=>e===void 0||e.length===0?n:n.sort((t,r)=>{const o=e.indexOf(t.mimeType),c=e.indexOf(r.mimeType),i=o===-1?Number.MAX_VALUE:o,a=c===-1?Number.MAX_VALUE:c;return i-a}),Xe=(n,e)=>e===void 0||e.length===0?n:n.filter(t=>!e.includes(t.mimeType)),P=(n,{preferredMimeTypesVideoCodecs:e,excludeMimeTypesVideoCodecs:t})=>async r=>{var o;if(typeof r.setCodecPreferences=="function"&&((o=r.sender.track)==null?void 0:o.kind)==="video"&&(e!==void 0&&(e==null?void 0:e.length)>0||t!==void 0&&(t==null?void 0:t.length)>0)){const c=qe("video"),i=Xe(c,t),a=He(i,e);r.setCodecPreferences(a)}Object.keys(n).length>0&&await s.setParametersToSender(r.sender,n)},U=n=>{if(!ne.isCanceledError(n)&&!te.hasCanceledError(n))throw n;return{isSuccessful:!1}},je=({kind:n,readyState:e})=>n==="video"&&e==="live";class We{constructor(e,{preferredMimeTypesVideoCodecs:t,excludeMimeTypesVideoCodecs:r}={}){l(this,"sipConnector");l(this,"preferredMimeTypesVideoCodecs");l(this,"excludeMimeTypesVideoCodecs");l(this,"connectToServer",async e=>{const{userAgent:t,sipWebSocketServerURL:r,sipServerUrl:o,remoteAddress:c,displayName:i,name:a,password:u,isRegisteredUser:g,isDisconnectOnFail:C}=e;return s.logger("connectToServer",e),this.sipConnector.connect({userAgent:t,sipWebSocketServerURL:r,sipServerUrl:o,remoteAddress:c,displayName:i,password:u,user:a,register:g}).then(S=>(s.logger("connectToServer then"),{ua:S,isSuccessful:!0})).catch(async S=>(s.logger("connectToServer catch: error",S),C===!0?this.sipConnector.disconnect().then(()=>U(S)).catch(()=>U(S)):U(S)))});l(this,"callToServer",async e=>{const{conference:t,mediaStream:r,extraHeaders:o,iceServers:c,contentHint:i,simulcastEncodings:a,degradationPreference:u,sendEncodings:g,setRemoteStreams:C,onBeforeProgressCall:S,onSuccessProgressCall:T,onEnterPurgatory:h,onEnterConference:m,onFailProgressCall:R,onFinishProgressCall:E,onEndedCall:M}=e,_=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:C}),A=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:_}),v=P({degradationPreference:u},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});s.logger("callToServer",e);const O=async()=>(s.logger("startCall"),this.sipConnector.call({mediaStream:r,extraHeaders:o,iceServers:c,contentHint:i,sendEncodings:N({mediaStream:r,simulcastEncodings:a,sendEncodings:g}),number:t,onAddedTransceiver:v,ontrack:A}));let p=!1,y;const b=(s.logger("subscribeEnterConference: onEnterConference",m),h??m?this.sipConnector.onSession("enterRoom",({room:d})=>{s.logger("enterRoom",{_room:d,isSuccessProgressCall:p}),y=d,B(y)?h&&h():m&&m({isSuccessProgressCall:p})}):()=>{}),I=d=>(s.logger("onSuccess"),p=!0,_(),T&&T({isPurgatory:B(y)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{b(),M&&M()}),d),w=d=>{throw s.logger("onFail"),R&&R(),b(),d},F=()=>{s.logger("onFinish"),E&&E()};return s.logger("onBeforeProgressCall"),S&&S(t),O().then(I).catch(d=>w(d)).finally(F)});l(this,"disconnectFromServer",async()=>this.sipConnector.disconnect().then(()=>(s.logger("disconnectFromServer: then"),{isSuccessful:!0})).catch(e=>(s.logger("disconnectFromServer: catch",e),{isSuccessful:!1})));l(this,"answerIncomingCall",async e=>{const{mediaStream:t,extraHeaders:r,iceServers:o,contentHint:c,simulcastEncodings:i,degradationPreference:a,sendEncodings:u,setRemoteStreams:g,onBeforeProgressCall:C,onSuccessProgressCall:S,onEnterPurgatory:T,onEnterConference:h,onFailProgressCall:m,onFinishProgressCall:R,onEndedCall:E}=e,M=this.resolveHandleReadyRemoteStreamsDebounced({onReadyRemoteStreams:g}),_=this.resolveHandleReadyRemoteStreams({onReadyRemoteStreams:M}),A=P({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});s.logger("answerIncomingCall",e);const v=async()=>this.sipConnector.answerToIncomingCall({mediaStream:t,extraHeaders:r,iceServers:o,contentHint:c,sendEncodings:N({mediaStream:t,simulcastEncodings:i,sendEncodings:u}),onAddedTransceiver:A,ontrack:_}),O=()=>{const{remoteCallerData:d}=this.sipConnector;return d.incomingNumber};let p=!1,y;const b=(s.logger("subscribeEnterConference: onEnterConference",h),T??h?this.sipConnector.onSession("enterRoom",d=>{s.logger("enterRoom",{_room:d,isSuccessProgressCall:p}),y=d,B(y)?T&&T():h&&h({isSuccessProgressCall:p})}):()=>{}),I=d=>(s.logger("onSuccess"),p=!0,M(),S&&S({isPurgatory:B(y)}),this.sipConnector.onceRaceSession(["ended","failed"],()=>{b(),E&&E()}),d),w=d=>{throw s.logger("onFail"),m&&m(),b(),d},F=()=>{s.logger("onFinish"),R&&R()};if(s.logger("onBeforeProgressCall"),C){const d=O();C(d)}return v().then(I).catch(d=>w(d)).finally(F)});l(this,"updatePresentation",async({mediaStream:e,isP2P:t,maxBitrate:r,contentHint:o,simulcastEncodings:c,degradationPreference:i,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g})=>{const C=P({degradationPreference:i},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return s.logger("updatePresentation"),this.sipConnector.updatePresentation(e,{isP2P:t,maxBitrate:r,contentHint:o,sendEncodings:N({mediaStream:e,simulcastEncodings:c,sendEncodings:a}),onAddedTransceiver:C})});l(this,"startPresentation",async({mediaStream:e,isP2P:t,maxBitrate:r,contentHint:o,simulcastEncodings:c,degradationPreference:i,sendEncodings:a,preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g},C)=>{const S=P({degradationPreference:i},{preferredMimeTypesVideoCodecs:u,excludeMimeTypesVideoCodecs:g});return s.logger("startPresentation"),this.sipConnector.startPresentation(e,{isP2P:t,maxBitrate:r,contentHint:o,sendEncodings:N({mediaStream:e,simulcastEncodings:c,sendEncodings:a}),onAddedTransceiver:S},C)});l(this,"stopShareSipConnector",async({isP2P:e=!1}={})=>(s.logger("stopShareSipConnector"),this.sipConnector.stopPresentation({isP2P:e}).catch(t=>{s.logger(t)})));l(this,"sendRefusalToTurnOnMic",async()=>{if(this.sipConnector.isCallActive)return s.logger("sendRefusalToTurnOnMic"),this.sipConnector.sendRefusalToTurnOnMic().catch(e=>{s.logger("sendRefusalToTurnOnMic: error",e)})});l(this,"sendRefusalToTurnOnCam",async()=>{if(this.sipConnector.isCallActive)return s.logger("sendRefusalToTurnOnCam"),this.sipConnector.sendRefusalToTurnOnCam().catch(e=>{s.logger("sendRefusalToTurnOnCam: error",e)})});l(this,"sendMediaState",async({isEnabledCam:e,isEnabledMic:t})=>{if(this.sipConnector.isCallActive)return s.logger("sendMediaState"),this.sipConnector.sendMediaState({cam:e,mic:t})});l(this,"replaceMediaStream",async(e,{deleteExisting:t,addMissing:r,forceRenegotiation:o,contentHint:c,simulcastEncodings:i,degradationPreference:a,sendEncodings:u}={})=>{const g=P({degradationPreference:a},{preferredMimeTypesVideoCodecs:this.preferredMimeTypesVideoCodecs,excludeMimeTypesVideoCodecs:this.excludeMimeTypesVideoCodecs});return s.logger("replaceMediaStream"),this.sipConnector.replaceMediaStream(e,{deleteExisting:t,addMissing:r,forceRenegotiation:o,contentHint:c,sendEncodings:N({mediaStream:e,simulcastEncodings:i,sendEncodings:u}),onAddedTransceiver:g})});l(this,"askPermissionToEnableCam",async()=>{if(this.sipConnector.isCallActive)return s.logger("askPermissionToEnableCam"),this.sipConnector.askPermissionToEnableCam()});l(this,"resolveHandleReadyRemoteStreamsDebounced",({onReadyRemoteStreams:e})=>re.debounce(()=>{const t=this.sipConnector.getRemoteStreams();s.logger("remoteStreams",t),t&&e(t)},200));l(this,"resolveHandleReadyRemoteStreams",({onReadyRemoteStreams:e})=>({track:t})=>{je(t)&&e()});l(this,"getRemoteStreams",()=>(s.logger("getRemoteStreams"),this.sipConnector.getRemoteStreams()));l(this,"onUseLicense",e=>(s.logger("onUseLicense"),this.sipConnector.onSession("useLicense",e)));l(this,"onMustStopPresentation",e=>(s.logger("onMustStopPresentation"),this.sipConnector.onSession("mustStopPresentation",e)));l(this,"onMoveToSpectators",e=>(s.logger("onMoveToSpectators"),this.sipConnector.onSession(s.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS,e)));l(this,"onMoveToParticipants",e=>(s.logger("onMoveToParticipants"),this.sipConnector.onSession(s.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS,e)));this.sipConnector=e,this.preferredMimeTypesVideoCodecs=t,this.excludeMimeTypesVideoCodecs=r}}exports.EEventsMainCAM=s.EEventsMainCAM;exports.EEventsMic=s.EEventsMic;exports.EEventsSyncMediaState=s.EEventsSyncMediaState;exports.EMimeTypesVideoCodecs=s.EMimeTypesVideoCodecs;exports.EUseLicense=s.EUseLicense;exports.causes=s.causes;exports.constants=s.constants;exports.default=s.SipConnector;exports.disableDebug=s.disableDebug;exports.enableDebug=s.enableDebug;exports.eventNames=s.eventNames;exports.hasCanceledCallError=s.hasCanceledCallError;exports.setParametersToSender=s.setParametersToSender;exports.debug=se;exports.SipConnectorFacade=We;exports.getCodecFromSender=X;exports.resolveVideoSendingBalancer=Ve;exports.tools=Te;
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var Z = Object.defineProperty;
|
|
2
2
|
var ee = (n, e, t) => e in n ? Z(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
3
|
var l = (n, e, t) => ee(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { B as X, N as j, l as i, E as k, s as ne, a as te, P as se, b as re, S as Je } from "./SipConnector-
|
|
5
|
-
import { i as ln, j as dn,
|
|
4
|
+
import { B as X, N as j, l as i, E as k, s as ne, a as te, P as se, b as re, S as Je } from "./SipConnector-BxDInUHC.js";
|
|
5
|
+
import { i as ln, j as dn, m as Sn, k as mn, c as Cn, d as fn, f as hn, g as Rn, e as gn, h as pn } from "./SipConnector-BxDInUHC.js";
|
|
6
6
|
import { sequentPromises as oe } from "sequent-promises";
|
|
7
7
|
import { createStackPromises as ce } from "stack-promises";
|
|
8
8
|
import { isCanceledError as ie } from "@krivega/cancelable-promise";
|
|
9
9
|
import { hasCanceledError as ae } from "repeated-calls";
|
|
10
10
|
import { debounce as ue } from "ts-debounce";
|
|
11
|
-
import { default as
|
|
11
|
+
import { default as En } from "debug";
|
|
12
12
|
const x = (n) => {
|
|
13
13
|
const { url: e, cause: t } = n;
|
|
14
14
|
let s = e;
|
|
@@ -644,17 +644,18 @@ export {
|
|
|
644
644
|
k as EEventsMainCAM,
|
|
645
645
|
ln as EEventsMic,
|
|
646
646
|
dn as EEventsSyncMediaState,
|
|
647
|
-
Sn as
|
|
647
|
+
Sn as EMimeTypesVideoCodecs,
|
|
648
|
+
mn as EUseLicense,
|
|
648
649
|
cn as SipConnectorFacade,
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
650
|
+
Cn as causes,
|
|
651
|
+
fn as constants,
|
|
652
|
+
En as debug,
|
|
652
653
|
Je as default,
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
654
|
+
hn as disableDebug,
|
|
655
|
+
Rn as enableDebug,
|
|
656
|
+
gn as eventNames,
|
|
656
657
|
Ne as getCodecFromSender,
|
|
657
|
-
|
|
658
|
+
pn as hasCanceledCallError,
|
|
658
659
|
on as resolveVideoSendingBalancer,
|
|
659
660
|
te as setParametersToSender,
|
|
660
661
|
rn as tools
|
package/dist/types.d.ts
CHANGED
|
@@ -54,3 +54,12 @@ export type TSize = {
|
|
|
54
54
|
height: number;
|
|
55
55
|
};
|
|
56
56
|
export type TSimulcastEncodings = TSize[];
|
|
57
|
+
export declare enum EMimeTypesVideoCodecs {
|
|
58
|
+
VP8 = "video/VP8",
|
|
59
|
+
VP9 = "video/VP9",
|
|
60
|
+
H264 = "video/H264",
|
|
61
|
+
AV1 = "video/AV1",
|
|
62
|
+
rtx = "video/rtx",
|
|
63
|
+
red = "video/red",
|
|
64
|
+
flexfec03 = "video/flexfec-03"
|
|
65
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var Dt=Object.defineProperty;var Mt=(s,e,t)=>e in s?Dt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var o=(s,e,t)=>Mt(s,typeof e!="symbol"?e+"":e,t);const C=require("@krivega/cancelable-promise"),be=require("events-constructor"),we=require("repeated-calls"),G=require("debug"),pt="Connection Error",Be="Request Timeout",vt="SIP Failure Code",yt="Internal Error",bt="Busy",$="Rejected",wt="Redirected",Ut="Unavailable",Fe="Not Found",Lt="Address Incomplete",Ht="Incompatible SDP",Wt="Missing SDP",qt="Authentication Error",Ve="Terminated",kt="WebRTC Error",xe="Canceled",Bt="No Answer",Ft="Expires",Vt="No ACK",xt="Dialog Error",Yt="User Denied Media Access",Ye="Bad Media Description",Gt="RTP Timeout",$t=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_INCOMPLETE:Lt,AUTHENTICATION_ERROR:qt,BAD_MEDIA_DESCRIPTION:Ye,BUSY:bt,BYE:Ve,CANCELED:xe,CONNECTION_ERROR:pt,DIALOG_ERROR:xt,EXPIRES:Ft,INCOMPATIBLE_SDP:Ht,INTERNAL_ERROR:yt,MISSING_SDP:Wt,NOT_FOUND:Fe,NO_ACK:Vt,NO_ANSWER:Bt,REDIRECTED:wt,REJECTED:$,REQUEST_TIMEOUT:Be,RTP_TIMEOUT:Gt,SIP_FAILURE_CODE:vt,UNAVAILABLE:Ut,USER_DENIED_MEDIA_ACCESS:Yt,WEBRTC_ERROR:kt},Symbol.toStringTag,{value:"Module"})),J="incomingCall",X="declinedIncomingCall",Q="failedIncomingCall",z="terminatedIncomingCall",B="connecting",P="connected",N="disconnected",y="newRTCSession",m="registered",j="unregistered",O="registrationFailed",Ge="newMessage",K="sipEvent",Z="availableSecondRemoteStream",ee="notAvailableSecondRemoteStream",te="mustStopPresentation",b="shareState",ne="enterRoom",se="useLicense",ie="peerconnection:confirmed",oe="peerconnection:ontrack",w="channels",re="channels:notify",ae="ended:fromserver",ce="main-cam-control",Ee="admin-stop-main-cam",_e="admin-start-main-cam",le="admin-stop-mic",de="admin-start-mic",U="admin-force-sync-media-state",he="participant:added-to-list-moderators",Te="participant:removed-from-list-moderators",ue="participant:move-request-to-stream",F="participant:move-request-to-spectators",V="participant:move-request-to-participants",Se="participation:accepting-word-request",Ne="participation:cancelling-word-request",Ce="webcast:started",ge="webcast:stopped",Ae="account:changed",Re="account:deleted",Ie="conference:participant-token-issued",D="ended",$e="sending",Je="reinvite",Xe="replaces",Qe="refer",ze="progress",je="accepted",L="confirmed",H="peerconnection",R="failed",Ke="muted",Ze="unmuted",fe="newDTMF",Pe="newInfo",et="hold",tt="unhold",nt="update",st="sdp",it="icecandidate",ot="getusermediafailed",rt="peerconnection:createofferfailed",at="peerconnection:createanswerfailed",ct="peerconnection:setlocaldescriptionfailed",Et="peerconnection:setremotedescriptionfailed",_t="presentation:start",lt="presentation:started",dt="presentation:end",me="presentation:ended",W="presentation:failed",ht="SPECTATOR",Tt="PARTICIPANT",ut=1e6,Jt=Object.freeze(Object.defineProperty({__proto__:null,ACCEPTED:je,ACCOUNT_CHANGED:Ae,ACCOUNT_DELETED:Re,ADMIN_FORCE_SYNC_MEDIA_STATE:U,ADMIN_START_MAIN_CAM:_e,ADMIN_START_MIC:de,ADMIN_STOP_MAIN_CAM:Ee,ADMIN_STOP_MIC:le,AVAILABLE_SECOND_REMOTE_STREAM_EVENT:Z,CHANNELS:w,CHANNELS_NOTIFY:re,CONFERENCE_PARTICIPANT_TOKEN_ISSUED:Ie,CONFIRMED:L,CONNECTED:P,CONNECTING:B,DECLINED_INCOMING_CALL:X,DISCONNECTED:N,ENDED:D,ENDED_FROM_SERVER:ae,ENTER_ROOM:ne,FAILED:R,FAILED_INCOMING_CALL:Q,GET_USER_MEDIA_FAILED:ot,HOLD:et,ICE_CANDIDATE:it,INCOMING_CALL:J,MAIN_CAM_CONTROL:ce,MUST_STOP_PRESENTATION_EVENT:te,MUTED:Ke,NEW_DTMF:fe,NEW_INFO:Pe,NEW_MESSAGE:Ge,NEW_RTC_SESSION:y,NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT:ee,ONE_MEGABIT_IN_BITS:ut,PARTICIPANT:Tt,PARTICIPANT_ADDED_TO_LIST_MODERATORS:he,PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS:V,PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS:F,PARTICIPANT_MOVE_REQUEST_TO_STREAM:ue,PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:Te,PARTICIPATION_ACCEPTING_WORD_REQUEST:Se,PARTICIPATION_CANCELLING_WORD_REQUEST:Ne,PEER_CONNECTION:H,PEER_CONNECTION_CONFIRMED:ie,PEER_CONNECTION_CREATE_ANSWER_FAILED:at,PEER_CONNECTION_CREATE_OFFER_FAILED:rt,PEER_CONNECTION_ONTRACK:oe,PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED:ct,PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:Et,PRESENTATION_END:dt,PRESENTATION_ENDED:me,PRESENTATION_FAILED:W,PRESENTATION_START:_t,PRESENTATION_STARTED:lt,PROGRESS:ze,REFER:Qe,REGISTERED:m,REGISTRATION_FAILED:O,REINVITE:Je,REPLACES:Xe,SDP:st,SENDING:$e,SHARE_STATE:b,SIP_EVENT:K,SPECTATOR:ht,TERMINATED_INCOMING_CALL:z,UNHOLD:tt,UNMUTED:Ze,UNREGISTERED:j,UPDATE:nt,USE_LICENSE:se,WEBCAST_STARTED:Ce,WEBCAST_STOPPED:ge},Symbol.toStringTag,{value:"Module"})),St=[J,X,z,Q,Se,Ne,ue,re,Ie,Ae,Re,Ce,ge,he,Te],Oe=[B,P,N,y,m,j,O,Ge,K],Nt=[Z,ee,te,b,ne,se,ie,oe,w,ae,ce,_e,Ee,le,de,U,F,V],De=[D,B,$e,Je,Xe,Qe,ze,je,L,H,R,Ke,Ze,fe,Pe,et,tt,nt,st,it,ot,rt,at,ct,Et,_t,lt,dt,me,W],Me=[...Oe,...St],pe=[...De,...Nt],Xt=Object.freeze(Object.defineProperty({__proto__:null,SESSION_EVENT_NAMES:pe,SESSION_JSSIP_EVENT_NAMES:De,SESSION_SYNTHETICS_EVENT_NAMES:Nt,UA_EVENT_NAMES:Me,UA_JSSIP_EVENT_NAMES:Oe,UA_SYNTHETICS_EVENT_NAMES:St},Symbol.toStringTag,{value:"Module"})),Qt=s=>{const e=[];return s&&e.push(`X-Vinteo-Remote: ${s}`),e},zt="content-type",jt="x-webrtc-enter-room",M="application/vinteo.webrtc.sharedesktop",Kt="application/vinteo.webrtc.roomname",Zt="application/vinteo.webrtc.channels",en="application/vinteo.webrtc.mediastate",tn="application/vinteo.webrtc.refusal",Ue="application/vinteo.webrtc.maincam",nn="application/vinteo.webrtc.mic",sn="application/vinteo.webrtc.uselic",on="X-WEBRTC-USE-LICENSE",rn="X-WEBRTC-PARTICIPANT-NAME",Le="X-WEBRTC-INPUT-CHANNELS",He="X-WEBRTC-OUTPUT-CHANNELS",an="X-WEBRTC-MAINCAM",cn="X-WEBRTC-MIC",We="X-WEBRTC-SYNC",En="X-WEBRTC-MAINCAM-RESOLUTION",_n="X-WEBRTC-MEDIA-STATE",ln="X-Vinteo-Media-Type",dn="X-Vinteo-MainCam-State",hn="X-Vinteo-Mic-State",Tn="application/vinteo.webrtc.partstate",un="X-WEBRTC-PARTSTATE",Sn="application/vinteo.webrtc.notify",Nn="X-VINTEO-NOTIFY",f="x-webrtc-share-state",Cn=`${f}: LETMESTARTPRESENTATION`,gn=`${f}: STOPPRESENTATION`,Ct="YOUCANRECEIVECONTENT",gt="CONTENTEND",At="YOUMUSTSTOPSENDCONTENT",An=`${f}: ${At}`,Rn=`${f}: ${Ct}`,In=`${f}: ${gt}`,fn="X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE",Pn=`${fn}: LETMESTARTMAINCAM`,ve="sip-connector",v=G(ve),mn=()=>{G.enable(ve)},On=()=>{G.enable(`-${ve}`)},Dn=(s,e)=>{s.getVideoTracks().forEach(n=>{"contentHint"in n&&n.contentHint!==e&&(n.contentHint=e)})},p=(s,{videoMode:e,audioMode:t,contentHint:n}={})=>{if(!s||e==="recvonly"&&t==="recvonly")return;const i=t==="recvonly"?[]:s.getAudioTracks(),r=e==="recvonly"?[]:s.getVideoTracks(),a=[...i,...r],c=new MediaStream(a);return c.getTracks=()=>[...c.getAudioTracks(),...c.getVideoTracks()],n&&n!=="none"&&Dn(c,n),c};var I=(s=>(s.PAUSE_MAIN_CAM="PAUSEMAINCAM",s.RESUME_MAIN_CAM="RESUMEMAINCAM",s.MAX_MAIN_CAM_RESOLUTION="MAXMAINCAMRESOLUTION",s.ADMIN_STOP_MAIN_CAM="ADMINSTOPMAINCAM",s.ADMIN_START_MAIN_CAM="ADMINSTARTMAINCAM",s))(I||{}),q=(s=>(s.ADMIN_STOP_MIC="ADMINSTOPMIC",s.ADMIN_START_MIC="ADMINSTARTMIC",s))(q||{}),k=(s=>(s.ADMIN_SYNC_FORCED="1",s.ADMIN_SYNC_NOT_FORCED="0",s))(k||{}),Rt=(s=>(s.AUDIO="AUDIO",s.VIDEO="VIDEO",s.AUDIOPLUSPRESENTATION="AUDIOPLUSPRESENTATION",s))(Rt||{});function Mn(s){return e=>`sip:${e}@${s}`}const pn=(s,e)=>()=>Math.floor(Math.random()*(e-s))+s,qe=s=>s.trim().replaceAll(" ","_"),vn=pn(1e5,99999999),yn=s=>s.some(t=>{const{kind:n}=t;return n==="video"}),bn="Error decline with 603",wn=1006,Un=s=>typeof s=="object"&&s!==null&&"code"in s&&s.code===wn,Ln=s=>s.message===bn,Hn=(s,e)=>s.find(t=>t.track&&e.getTracks().includes(t.track)),Wn=(s,e)=>(s.degradationPreference=e.degradationPreference,s),qn=(s,e)=>{s.encodings===void 0&&(s.encodings=[]);for(let t=s.encodings.length;t<e;t+=1)s.encodings.push({});return s},It=s=>(e,t)=>t!==void 0&&e!==t||t===void 0&&e!==s,kn=It(),Bn=(s,e)=>{if(kn(s,e))return s},Fn=(s,e)=>{const t=s.maxBitrate,n=Bn(e,t);return n!==void 0&&(s.maxBitrate=n),s},ft=1,Vn=It(ft),xn=(s,e)=>{const t=s===void 0?void 0:Math.max(s,ft);if(t!==void 0&&Vn(t,e))return t},Yn=(s,e)=>{const t=s.scaleResolutionDownBy,n=xn(e,t);return n!==void 0&&(s.scaleResolutionDownBy=n),s},Gn=(s,e)=>{var n;const t=((n=e.encodings)==null?void 0:n.length)??0;return qn(s,t),s.encodings.forEach((i,r)=>{const a=((e==null?void 0:e.encodings)??[])[r],c=a==null?void 0:a.maxBitrate,_=a==null?void 0:a.scaleResolutionDownBy;Fn(i,c),Yn(i,_)}),s},$n=(s,e)=>{var t,n,i,r,a,c,_,l;if(((t=s.codecs)==null?void 0:t.length)!==((n=e.codecs)==null?void 0:n.length))return!0;for(let E=0;E<(((i=s.codecs)==null?void 0:i.length)??0);E++)if(JSON.stringify(s.codecs[E])!==JSON.stringify(e.codecs[E]))return!0;if(((r=s.headerExtensions)==null?void 0:r.length)!==((a=e.headerExtensions)==null?void 0:a.length))return!0;for(let E=0;E<(((c=s.headerExtensions)==null?void 0:c.length)??0);E++)if(JSON.stringify(s.headerExtensions[E])!==JSON.stringify(e.headerExtensions[E]))return!0;if(((_=s.encodings)==null?void 0:_.length)!==((l=e.encodings)==null?void 0:l.length))return!0;for(let E=0;E<(s.encodings.length??0);E++)if(JSON.stringify(s.encodings[E])!==JSON.stringify(e.encodings[E]))return!0;return s.rtcp.cname!==e.rtcp.cname||s.rtcp.reducedSize!==e.rtcp.reducedSize||s.degradationPreference!==e.degradationPreference},Pt=async(s,e)=>{const t=s.getParameters(),n=JSON.parse(JSON.stringify(t));Gn(t,e),Wn(t,e);const i=$n(n,t);return i&&await s.setParameters(t),{parameters:t,isChanged:i}},mt=async(s,e,t)=>{const{isChanged:n,parameters:i}=await Pt(s,{encodings:[{scaleResolutionDownBy:e.scaleResolutionDownBy,maxBitrate:e.maxBitrate}]});return n&&t&&t(i),{isChanged:n,parameters:i}},Jn=async(s,e,t)=>{const n=Hn(s,e);if(n)return mt(n,{maxBitrate:t})},Xn=486,Qn=487,Y="local",ke="remote",zn=3,jn=1,Kn=(s=new Error)=>{const{originator:e,cause:t}=s;return C.isCanceledError(s)?!0:typeof t=="string"?t===Be||t===$||e===Y&&(t===xe||t===Ve):!1},g="SipConnector",Zn="channels",es="WebcastStarted",ts="WebcastStopped",ns="accountChanged",ss="accountDeleted",is="addedToListModerators",os="removedFromListModerators",rs="ParticipationRequestAccepted",as="ParticipationRequestRejected",cs="ParticipantMovedToWebcast",Es="ConferenceParticipantTokenIssued";class _s{constructor({JsSIP:e}){o(this,"_isRegisterConfig",!1);o(this,"_connectionConfiguration",{});o(this,"_remoteStreams",{});o(this,"JsSIP");o(this,"_sessionEvents");o(this,"_uaEvents");o(this,"_cancelableConnect");o(this,"_cancelableConnectWithRepeatedCalls");o(this,"_cancelableSendPresentationWithRepeatedCalls");o(this,"_cancelableInitUa");o(this,"_cancelableDisconnect");o(this,"_cancelableSet");o(this,"_cancelableCall");o(this,"_cancelableAnswer");o(this,"_cancelableSendDTMF");o(this,"getSipServerUrl",e=>e);o(this,"promisePendingStartPresentation");o(this,"promisePendingStopPresentation");o(this,"ua");o(this,"session");o(this,"incomingSession");o(this,"_streamPresentationCurrent");o(this,"socket");o(this,"connect",async(e,t)=>(this._cancelRequests(),this._connectWithDuplicatedCalls(e,t)));o(this,"initUa",async e=>this._cancelableInitUa.request(e));o(this,"set",async e=>this._cancelableSet.request(e));o(this,"call",async e=>this._cancelableCall.request(e));o(this,"disconnect",async()=>(this._cancelRequests(),this._disconnectWithoutCancelRequests()));o(this,"answerToIncomingCall",async e=>this._cancelableAnswer.request(e));o(this,"sendDTMF",async e=>this._cancelableSendDTMF.request(e));o(this,"hangUp",async()=>(this._cancelRequests(),this._hangUpWithoutCancelRequests()));o(this,"tryRegister",async()=>{if(!this.isRegisterConfig)throw new Error("Config is not registered");this._uaEvents.trigger(B,void 0);try{await this.unregister()}catch(e){v("tryRegister",e)}return this.register()});o(this,"declineToIncomingCall",async({statusCode:e=Qn}={})=>new Promise((t,n)=>{if(!this.isAvailableIncomingCall){n(new Error("no incomingSession"));return}const i=this.incomingSession,r=this.remoteCallerData;this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest(),this.removeIncomingSession(),this._uaEvents.trigger(X,r),t(i.terminate({status_code:e}))}));o(this,"busyIncomingCall",async()=>this.declineToIncomingCall({statusCode:Xn}));o(this,"removeIncomingSession",()=>{delete this.incomingSession});o(this,"_connectWithDuplicatedCalls",async(e,{callLimit:t=zn}={})=>{const n=async()=>this._cancelableConnect.request(e),i=r=>{var l;const c=!!((l=this.ua)!=null&&l.isConnected())&&this.hasEqualConnectionConfiguration(e),_=!!r&&!Un(r);return c||_};return this._cancelableConnectWithRepeatedCalls=we.repeatedCallsAsync({targetFunction:n,isComplete:i,callLimit:t,isRejectAsValid:!0,isCheckBeforeCall:!1,onAfterCancel:()=>{this._cancelableConnect.cancelRequest()}}),this._cancelableConnectWithRepeatedCalls.then(r=>{if(r instanceof this.JsSIP.UA)return r;throw r})});o(this,"handleNewRTCSession",({originator:e,session:t})=>{if(e===ke){this.incomingSession=t;const n=this.remoteCallerData;t.on(R,i=>{this.removeIncomingSession(),i.originator===Y?this._uaEvents.trigger(z,n):this._uaEvents.trigger(Q,n)}),this._uaEvents.trigger(J,n)}});o(this,"_connect",async e=>this.initUa(e).then(async()=>this._start()));o(this,"_initUa",async({user:e,password:t,sipServerUrl:n,sipWebSocketServerURL:i,remoteAddress:r,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:l,userAgent:E,displayName:h="",register:d=!1,extraHeaders:T=[]})=>{if(!n)throw new Error("sipServerUrl is required");if(!i)throw new Error("sipWebSocketServerURL is required");if(d&&!e)throw new Error("user is required for authorized connection");if(d&&!t)throw new Error("password is required for authorized connection");this._connectionConfiguration={sipServerUrl:n,displayName:h,register:d,user:e,password:t};const{configuration:u,helpers:S}=this.createUaConfiguration({user:e,sipServerUrl:n,sipWebSocketServerURL:i,password:t,displayName:h,register:d,sessionTimers:a,registerExpires:c,connectionRecoveryMinInterval:_,connectionRecoveryMaxInterval:l,userAgent:E});return this.getSipServerUrl=S.getSipServerUrl,this.socket=S.socket,this.ua&&await this._disconnectWithoutCancelRequests(),this._isRegisterConfig=!!d,this.ua=this._createUa({...u,remoteAddress:r,extraHeaders:T}),this._uaEvents.eachTriggers((A,x)=>{const ye=Oe.find(Ot=>Ot===x);ye&&this.ua&&this.ua.on(ye,A)}),this.ua});o(this,"_createUa",({remoteAddress:e,extraHeaders:t=[],...n})=>{const i=new this.JsSIP.UA(n),a=[...e?Qt(e):[],...t];return a.length>0&&i.registrator().setExtraHeaders(a),i});o(this,"_start",async()=>new Promise((e,t)=>{const{ua:n}=this;if(!n){t(new Error("this.ua is not initialized"));return}const i=()=>{c(),e(n)},r=_=>{c(),t(_)},a=()=>{this.isRegisterConfig?(this.on(m,i),this.on(O,r)):this.on(P,i),this.on(N,r)},c=()=>{this.off(m,i),this.off(O,r),this.off(P,i),this.off(N,r)};a(),this.on(y,this.handleNewRTCSession),n.start()}));o(this,"_set",async({displayName:e,password:t})=>new Promise((n,i)=>{const{ua:r}=this;if(!r){i(new Error("this.ua is not initialized"));return}let a=!1,c=!1;e!==void 0&&e!==this._connectionConfiguration.displayName&&(a=r.set("display_name",qe(e)),this._connectionConfiguration.displayName=e),t!==void 0&&t!==this._connectionConfiguration.password&&(c=r.set("password",t),this._connectionConfiguration.password=t);const _=a||c;c&&this.isRegisterConfig?this.register().then(()=>{n(_)}).catch(l=>{i(l)}):_?n(_):i(new Error("nothing changed"))}));o(this,"_disconnectWithoutCancelRequests",async()=>this._cancelableDisconnect.request());o(this,"_disconnect",async()=>{this.off(y,this.handleNewRTCSession);const e=new Promise(t=>{this.once(N,()=>{delete this.ua,t()})});return this.ua?(await this._hangUpWithoutCancelRequests(),this.ua?this.ua.stop():this._uaEvents.trigger(N,void 0)):this._uaEvents.trigger(N,void 0),e});o(this,"_call",async({number:e,mediaStream:t,extraHeaders:n=[],ontrack:i,iceServers:r,videoMode:a,audioMode:c,contentHint:_,offerToReceiveAudio:l=!0,offerToReceiveVideo:E=!0,sendEncodings:h,onAddedTransceiver:d})=>new Promise((T,u)=>{const{ua:S}=this;if(!S){u(new Error("this.ua is not initialized"));return}this._connectionConfiguration.number=e,this._connectionConfiguration.answer=!1,this._handleCall({ontrack:i}).then(T).catch(A=>{u(A)}),this.session=S.call(this.getSipServerUrl(e),{extraHeaders:n,mediaStream:p(t,{videoMode:a,audioMode:c,contentHint:_}),eventHandlers:this._sessionEvents.triggers,videoMode:a,audioMode:c,pcConfig:{iceServers:r},rtcOfferConstraints:{offerToReceiveAudio:l,offerToReceiveVideo:E},sendEncodings:h,onAddedTransceiver:d})}));o(this,"_answer",async({mediaStream:e,ontrack:t,extraHeaders:n=[],iceServers:i,videoMode:r,audioMode:a,contentHint:c,sendEncodings:_,onAddedTransceiver:l})=>new Promise((E,h)=>{if(!this.isAvailableIncomingCall){h(new Error("no incomingSession"));return}this.session=this.incomingSession,this.removeIncomingSession();const{session:d}=this;if(!d){h(new Error("No session established"));return}this._sessionEvents.eachTriggers((u,S)=>{const A=De.find(x=>x===S);A&&d.on(A,u)}),this._connectionConfiguration.answer=!0,this._connectionConfiguration.number=d.remote_identity.uri.user,this._handleCall({ontrack:t}).then(E).catch(u=>{h(u)});const T=p(e,{videoMode:r,audioMode:a,contentHint:c});d.answer({extraHeaders:n,videoMode:r,audioMode:a,mediaStream:T,pcConfig:{iceServers:i},sendEncodings:_,onAddedTransceiver:l})}));o(this,"_handleCall",async({ontrack:e})=>new Promise((t,n)=>{const i=()=>{this.onSession(H,E),this.onSession(L,h)},r=()=>{this.offSession(H,E),this.offSession(L,h)},a=()=>{this.onSession(R,_),this.onSession(D,_)},c=()=>{this.offSession(R,_),this.offSession(D,_)},_=d=>{r(),c(),n(d)};let l;const E=({peerconnection:d})=>{l=d,l.ontrack=T=>{this._sessionEvents.trigger(oe,l),e&&e(T)}},h=()=>{l&&this._sessionEvents.trigger(ie,l),r(),c(),t(l)};i(),a()}));o(this,"_restoreSession",()=>{this._cancelRequestsAndResetPresentation(),delete this._connectionConfiguration.number,delete this.session,this._remoteStreams={}});o(this,"_sendDTMF",async e=>new Promise((t,n)=>{const{session:i}=this;if(!i){n(new Error("No session established"));return}this.onceSession(fe,({originator:r})=>{r===Y&&t()}),i.sendDTMF(e,{duration:120,interToneGap:600})}));o(this,"_hangUpWithoutCancelRequests",async()=>{if(this.ua&&this.session){const{session:e}=this;if(this._streamPresentationCurrent)try{await this.stopPresentation()}catch(t){v("error stop presentation: ",t)}if(this._restoreSession(),!e.isEnded())return e.terminateAsync()}});o(this,"_handleShareState",e=>{switch(e){case Ct:{this._sessionEvents.trigger(Z,void 0);break}case gt:{this._sessionEvents.trigger(ee,void 0);break}case At:{this._sessionEvents.trigger(te,void 0);break}}});o(this,"_maybeTriggerChannels",e=>{const t=e.getHeader(Le),n=e.getHeader(He);if(t&&n){const i={inputChannels:t,outputChannels:n};this._sessionEvents.trigger(w,i)}});o(this,"_handleNotify",e=>{switch(e.cmd){case Zn:{const t=e;this._triggerChannelsNotify(t);break}case es:{const t=e;this._triggerWebcastStartedNotify(t);break}case ts:{const t=e;this._triggerWebcastStoppedNotify(t);break}case is:{const t=e;this._triggerAddedToListModeratorsNotify(t);break}case os:{const t=e;this._triggerRemovedFromListModeratorsNotify(t);break}case rs:{const t=e;this._triggerParticipationAcceptingWordRequest(t);break}case as:{const t=e;this._triggerParticipationCancellingWordRequest(t);break}case cs:{const t=e;this._triggerParticipantMoveRequestToStream(t);break}case ns:{this._triggerAccountChangedNotify();break}case ss:{this._triggerAccountDeletedNotify();break}case Es:{const t=e;this._triggerConferenceParticipantTokenIssued(t);break}default:v("unknown cmd",e.cmd)}});o(this,"_triggerRemovedFromListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(Te,t)});o(this,"_triggerAddedToListModeratorsNotify",({conference:e})=>{const t={conference:e};this._uaEvents.trigger(he,t)});o(this,"_triggerWebcastStartedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(Ce,n)});o(this,"_triggerWebcastStoppedNotify",({body:{conference:e,type:t}})=>{const n={conference:e,type:t};this._uaEvents.trigger(ge,n)});o(this,"_triggerAccountChangedNotify",()=>{this._uaEvents.trigger(Ae,void 0)});o(this,"_triggerAccountDeletedNotify",()=>{this._uaEvents.trigger(Re,void 0)});o(this,"_triggerConferenceParticipantTokenIssued",({body:{conference:e,participant:t,jwt:n}})=>{const i={conference:e,participant:t,jwt:n};this._uaEvents.trigger(Ie,i)});o(this,"_triggerChannelsNotify",e=>{const t=e.input,n=e.output,i={inputChannels:t,outputChannels:n};this._uaEvents.trigger(re,i)});o(this,"_triggerParticipationAcceptingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Se,t)});o(this,"_triggerParticipationCancellingWordRequest",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(Ne,t)});o(this,"_triggerParticipantMoveRequestToStream",({body:{conference:e}})=>{const t={conference:e};this._uaEvents.trigger(ue,t)});o(this,"_triggerEnterRoom",e=>{const t=e.getHeader(jt),n=e.getHeader(rn);this._sessionEvents.trigger(ne,{room:t,participantName:n})});o(this,"_triggerShareState",e=>{const t=e.getHeader(f);this._sessionEvents.trigger(b,t)});o(this,"_maybeTriggerParticipantMoveRequest",e=>{const t=e.getHeader(un);t===ht&&this._sessionEvents.trigger(F,void 0),t===Tt&&this._sessionEvents.trigger(V,void 0)});o(this,"_triggerMainCamControl",e=>{const t=e.getHeader(an),n=e.getHeader(We),i=n===k.ADMIN_SYNC_FORCED;if(t===I.ADMIN_START_MAIN_CAM){this._sessionEvents.trigger(_e,{isSyncForced:i});return}if(t===I.ADMIN_STOP_MAIN_CAM){this._sessionEvents.trigger(Ee,{isSyncForced:i});return}(t===I.RESUME_MAIN_CAM||t===I.PAUSE_MAIN_CAM)&&n&&this._sessionEvents.trigger(U,{isSyncForced:i});const r=e.getHeader(En);this._sessionEvents.trigger(ce,{mainCam:t,resolutionMainCam:r})});o(this,"_triggerMicControl",e=>{const t=e.getHeader(cn),i=e.getHeader(We)===k.ADMIN_SYNC_FORCED;t===q.ADMIN_START_MIC?this._sessionEvents.trigger(de,{isSyncForced:i}):t===q.ADMIN_STOP_MIC&&this._sessionEvents.trigger(le,{isSyncForced:i})});o(this,"_triggerUseLicense",e=>{const t=e.getHeader(on);this._sessionEvents.trigger(se,t)});o(this,"_handleNewInfo",e=>{const{originator:t}=e;if(t!=="remote")return;const{request:n}=e,i=n.getHeader(zt);if(i)switch(i){case Kt:{this._triggerEnterRoom(n),this._maybeTriggerChannels(n);break}case Sn:{this._maybeHandleNotify(n);break}case M:{this._triggerShareState(n);break}case Ue:{this._triggerMainCamControl(n);break}case nn:{this._triggerMicControl(n);break}case sn:{this._triggerUseLicense(n);break}case Tn:{this._maybeTriggerParticipantMoveRequest(n);break}}});o(this,"_handleSipEvent",({request:e})=>{this._maybeHandleNotify(e)});o(this,"_maybeHandleNotify",e=>{const t=e.getHeader(Nn);if(t){const n=JSON.parse(t);this._handleNotify(n)}});o(this,"_handleEnded",e=>{const{originator:t}=e;t===ke&&this._sessionEvents.trigger(ae,e),this._restoreSession()});this.JsSIP=e,this._sessionEvents=new be(pe),this._uaEvents=new be(Me),this._cancelableConnect=new C.CancelableRequest(this._connect,{moduleName:g,afterCancelRequest:()=>{this._cancelableInitUa.cancelRequest(),this._cancelableDisconnect.cancelRequest()}}),this._cancelableInitUa=new C.CancelableRequest(this._initUa,{moduleName:g}),this._cancelableDisconnect=new C.CancelableRequest(this._disconnect,{moduleName:g}),this._cancelableSet=new C.CancelableRequest(this._set,{moduleName:g}),this._cancelableCall=new C.CancelableRequest(this._call,{moduleName:g}),this._cancelableAnswer=new C.CancelableRequest(this._answer,{moduleName:g}),this._cancelableSendDTMF=new C.CancelableRequest(this._sendDTMF,{moduleName:g}),this.onSession(b,this._handleShareState),this.onSession(Pe,this._handleNewInfo),this.on(K,this._handleSipEvent),this.onSession(R,this._handleEnded),this.onSession(D,this._handleEnded)}async register(){return new Promise((e,t)=>{this.isRegisterConfig&&this.ua?(this.ua.on(m,e),this.ua.on(O,t),this.ua.register()):t(new Error("Config is not registered"))})}async unregister(){return new Promise((e,t)=>{this.isRegistered&&this.ua?(this.ua.on(j,e),this.ua.unregister()):t(new Error("ua is not registered"))})}async sendOptions(e,t,n){if(!this.ua)throw new Error("is not connected");return new Promise((i,r)=>{try{this.ua.sendOptions(e,t,{extraHeaders:n,eventHandlers:{succeeded:()=>{i()},failed:r}})}catch(a){r(a)}})}async ping(e,t){var i;if(!((i=this.ua)!=null&&i.configuration.uri))throw new Error("is not connected");const n=this.ua.configuration.uri;return this.sendOptions(n,e,t)}async checkTelephony({userAgent:e,displayName:t,sipServerUrl:n,sipWebSocketServerURL:i,remoteAddress:r,extraHeaders:a}){return new Promise((c,_)=>{const{configuration:l}=this.createUaConfiguration({sipWebSocketServerURL:i,displayName:t,userAgent:e,sipServerUrl:n}),E=this._createUa({...l,remoteAddress:r,extraHeaders:a}),h=()=>{const T=new Error("Telephony is not available");_(T)};E.once(N,h);const d=()=>{E.removeAllListeners(),E.once(N,c),E.stop()};E.once(P,d),E.start()})}async replaceMediaStream(e,t){if(!this.session)throw new Error("No session established");const{contentHint:n}=t??{},i=p(e,{contentHint:n});return this.session.replaceMediaStream(i,t)}async askPermissionToEnableCam(e={}){if(!this.session)throw new Error("No session established");const t=[Pn];return this.session.sendInfo(Ue,void 0,{noTerminateWhenError:!0,...e,extraHeaders:t}).catch(n=>{if(Ln(n))throw n})}get isPendingPresentation(){return!!this.promisePendingStartPresentation||!!this.promisePendingStopPresentation}async _sendPresentationWithDuplicatedCalls({session:e,stream:t,presentationOptions:n,options:i={callLimit:jn}}){const r=async()=>this._sendPresentation(e,t,n),a=()=>!!this._streamPresentationCurrent;return this._cancelableSendPresentationWithRepeatedCalls=we.repeatedCallsAsync({targetFunction:r,isComplete:a,isRejectAsValid:!0,...i}),this._cancelableSendPresentationWithRepeatedCalls.then(c=>c)}hasEqualConnectionConfiguration(e){var i;const{configuration:t}=this.createUaConfiguration(e),n=(i=this.ua)==null?void 0:i.configuration;return(n==null?void 0:n.password)===t.password&&(n==null?void 0:n.register)===t.register&&(n==null?void 0:n.uri.toString())===t.uri&&(n==null?void 0:n.display_name)===t.display_name&&(n==null?void 0:n.user_agent)===t.user_agent&&(n==null?void 0:n.sockets)===t.sockets&&(n==null?void 0:n.session_timers)===t.session_timers&&(n==null?void 0:n.register_expires)===t.register_expires&&(n==null?void 0:n.connection_recovery_min_interval)===t.connection_recovery_min_interval&&(n==null?void 0:n.connection_recovery_max_interval)===t.connection_recovery_max_interval}createUaConfiguration({user:e,password:t,sipWebSocketServerURL:n,displayName:i="",sipServerUrl:r,register:a=!1,sessionTimers:c=!1,registerExpires:_=60*5,connectionRecoveryMinInterval:l=2,connectionRecoveryMaxInterval:E=6,userAgent:h}){if(a&&!t)throw new Error("password is required for authorized connection");const d=a&&e?e.trim():`${vn()}`,T=Mn(r),u=T(d),S=new this.JsSIP.WebSocketInterface(n);return{configuration:{password:t,register:a,uri:u,display_name:qe(i),user_agent:h,sdp_semantics:"unified-plan",sockets:[S],session_timers:c,register_expires:_,connection_recovery_min_interval:l,connection_recovery_max_interval:E},helpers:{socket:S,getSipServerUrl:T}}}async _sendPresentation(e,t,{maxBitrate:n=ut,isNeedReinvite:i=!0,isP2P:r=!1,contentHint:a="detail",sendEncodings:c,onAddedTransceiver:_}){const l=p(t,{contentHint:a});this._streamPresentationCurrent=l;const E=r?[Rn]:[Cn],h=e.sendInfo(M,void 0,{extraHeaders:E}).then(async()=>e.startPresentation(l,i,{sendEncodings:c,onAddedTransceiver:_})).then(async()=>{const{connection:d}=this;if(!d||n===void 0)return;const T=d.getSenders();await Jn(T,t,n)}).then(()=>t).catch(d=>{throw this._removeStreamPresentationCurrent(),this._sessionEvents.trigger(W,d),d});return this.promisePendingStartPresentation=h,h.finally(()=>{this.promisePendingStartPresentation=void 0})}async startPresentation(e,{isNeedReinvite:t,isP2P:n,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:c}={},_){const l=this.establishedSession;if(!l)throw new Error("No session established");if(this._streamPresentationCurrent)throw new Error("Presentation is already started");return n&&await this.sendMustStopPresentation(l),this._sendPresentationWithDuplicatedCalls({session:l,stream:e,presentationOptions:{isNeedReinvite:t,isP2P:n,maxBitrate:i,contentHint:r,sendEncodings:a,onAddedTransceiver:c},options:_})}async sendMustStopPresentation(e){await e.sendInfo(M,void 0,{extraHeaders:[An]})}async stopPresentation({isP2P:e=!1}={}){this._cancelSendPresentationWithRepeatedCalls();const t=this._streamPresentationCurrent;let n=this.promisePendingStartPresentation??Promise.resolve();const i=e?[In]:[gn],r=this.establishedSession;return r&&t&&(n=n.then(async()=>r.sendInfo(M,void 0,{extraHeaders:i})).then(async()=>r.stopPresentation(t)).catch(a=>{throw this._sessionEvents.trigger(W,a),a})),!r&&t&&this._sessionEvents.trigger(me,t),this.promisePendingStopPresentation=n,n.finally(()=>{this._resetPresentation()})}async updatePresentation(e,{isP2P:t,maxBitrate:n,contentHint:i,sendEncodings:r,onAddedTransceiver:a}={}){const c=this.establishedSession;if(!c)throw new Error("No session established");if(!this._streamPresentationCurrent)throw new Error("Presentation has not started yet");return this.promisePendingStartPresentation&&await this.promisePendingStartPresentation,this._sendPresentation(c,e,{isP2P:t,maxBitrate:n,contentHint:i,isNeedReinvite:!1,sendEncodings:r,onAddedTransceiver:a})}_removeStreamPresentationCurrent(){delete this._streamPresentationCurrent}_resetPresentation(){this._removeStreamPresentationCurrent(),this.promisePendingStartPresentation=void 0,this.promisePendingStopPresentation=void 0}_cancelRequestsAndResetPresentation(){this._cancelSendPresentationWithRepeatedCalls(),this._resetPresentation()}on(e,t){return this._uaEvents.on(e,t)}once(e,t){return this._uaEvents.once(e,t)}onceRace(e,t){return this._uaEvents.onceRace(e,t)}async wait(e){return this._uaEvents.wait(e)}off(e,t){this._uaEvents.off(e,t)}onSession(e,t){return this._sessionEvents.on(e,t)}onceSession(e,t){return this._sessionEvents.once(e,t)}onceRaceSession(e,t){return this._sessionEvents.onceRace(e,t)}async waitSession(e){return this._sessionEvents.wait(e)}offSession(e,t){this._sessionEvents.off(e,t)}isConfigured(){return!!this.ua}getConnectionConfiguration(){return{...this._connectionConfiguration}}getRemoteStreams(){if(!this.connection)return;const t=this.connection.getReceivers().map(({track:n})=>n);return yn(t)?this._generateStreams(t):this._generateAudioStreams(t)}get connection(){var t;return(t=this.session)==null?void 0:t.connection}get remoteCallerData(){var e,t,n,i,r,a;return{displayName:(t=(e=this.incomingSession)==null?void 0:e.remote_identity)==null?void 0:t.display_name,host:(i=(n=this.incomingSession)==null?void 0:n.remote_identity)==null?void 0:i.uri.host,incomingNumber:(a=(r=this.incomingSession)==null?void 0:r.remote_identity)==null?void 0:a.uri.user,session:this.incomingSession}}get requested(){return this._cancelableConnect.requested||this._cancelableInitUa.requested||this._cancelableCall.requested||this._cancelableAnswer.requested}get establishedSession(){var e;return(e=this.session)!=null&&e.isEstablished()?this.session:void 0}get isRegistered(){return!!this.ua&&this.ua.isRegistered()}get isRegisterConfig(){return!!this.ua&&this._isRegisterConfig}get isCallActive(){return!!(this.ua&&this.session)}get isAvailableIncomingCall(){return!!this.incomingSession}_generateStream(e,t){const{id:n}=e,i=this._remoteStreams[n]||new MediaStream;return t&&i.addTrack(t),i.addTrack(e),this._remoteStreams[n]=i,i}_generateAudioStream(e){const{id:t}=e,n=this._remoteStreams[t]||new MediaStream;return n.addTrack(e),this._remoteStreams[t]=n,n}_generateStreams(e){const t=[];return e.forEach((n,i)=>{if(n.kind==="audio")return;const r=n,a=e[i-1];let c;a&&a.kind==="audio"&&(c=a);const _=this._generateStream(r,c);t.push(_)}),t}_generateAudioStreams(e){return e.map(n=>this._generateAudioStream(n))}_cancelRequests(){this._cancelActionsRequests(),this._cancelCallRequests(),this._cancelConnectWithRepeatedCalls()}_cancelConnectWithRepeatedCalls(){var e;(e=this._cancelableConnectWithRepeatedCalls)==null||e.cancel()}_cancelSendPresentationWithRepeatedCalls(){var e;(e=this._cancelableSendPresentationWithRepeatedCalls)==null||e.cancel()}_cancelCallRequests(){this._cancelableCall.cancelRequest(),this._cancelableAnswer.cancelRequest()}_cancelActionsRequests(){this._cancelableAnswer.cancelRequest(),this._cancelableSendDTMF.cancelRequest()}async waitChannels(){return this.waitSession(w)}async waitSyncMediaState(){return this.waitSession(U)}async sendChannels({inputChannels:e,outputChannels:t}){if(!this.session)throw new Error("No session established");const n=`${Le}: ${e}`,i=`${He}: ${t}`,r=[n,i];return this.session.sendInfo(Zt,void 0,{extraHeaders:r})}async sendMediaState({cam:e,mic:t},n={}){if(!this.session)throw new Error("No session established");const i=`${_n}: currentstate`,r=`${dn}: ${Number(e)}`,a=`${hn}: ${Number(t)}`,c=[i,r,a];return this.session.sendInfo(en,void 0,{noTerminateWhenError:!0,...n,extraHeaders:c})}async _sendRefusalToTurnOn(e,t={}){if(!this.session)throw new Error("No session established");const c=[`${ln}: ${e==="mic"?0:1}`];return this.session.sendInfo(tn,void 0,{noTerminateWhenError:!0,...t,extraHeaders:c})}async sendRefusalToTurnOnMic(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("mic",{noTerminateWhenError:!0,...e})}async sendRefusalToTurnOnCam(e={}){if(!this.session)throw new Error("No session established");return this._sendRefusalToTurnOn("cam",{noTerminateWhenError:!0,...e})}}exports.BAD_MEDIA_DESCRIPTION=Ye;exports.EEventsMainCAM=I;exports.EEventsMic=q;exports.EEventsSyncMediaState=k;exports.EUseLicense=Rt;exports.NOT_FOUND=Fe;exports.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS=V;exports.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS=F;exports.REJECTED=$;exports.SESSION_EVENT_NAMES=pe;exports.SipConnector=_s;exports.UA_EVENT_NAMES=Me;exports.causes=$t;exports.constants=Jt;exports.disableDebug=On;exports.enableDebug=mn;exports.eventNames=Xt;exports.hasCanceledCallError=Kn;exports.logger=v;exports.setEncodingsToSender=mt;exports.setParametersToSender=Pt;
|