sip-connector 7.0.10 → 8.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-BA8w-WR5.cjs +1 -0
- package/dist/{SipConnector-3gRIidBJ.js → SipConnector-C5s0hhzA.js} +434 -396
- package/dist/SipConnector.d.ts +8 -3
- package/dist/__fixtures__/Session.mock.d.ts +9 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +114 -102
- package/dist/index.cjs +1 -1
- package/dist/index.js +33 -35
- package/dist/tools/__fixtures__/connectToServer.d.ts +0 -10
- package/dist/tools/connectToServer.d.ts +0 -1
- package/dist/types.d.ts +0 -1
- package/package.json +1 -1
- package/dist/SipConnector-3pnvrFP5.cjs +0 -1
|
@@ -2,97 +2,97 @@ var At = Object.defineProperty;
|
|
|
2
2
|
var Rt = (r, e, t) => e in r ? At(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var i = (r, e, t) => Rt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { CancelableRequest as N, isCanceledError as It } from "@krivega/cancelable-promise";
|
|
5
|
-
import
|
|
6
|
-
import { repeatedCallsAsync as
|
|
5
|
+
import Pe from "events-constructor";
|
|
6
|
+
import { repeatedCallsAsync as Oe } from "repeated-calls";
|
|
7
7
|
import B from "debug";
|
|
8
|
-
const
|
|
8
|
+
const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code", pt = "Internal Error", Pt = "Busy", Le = "Rejected", Ot = "Redirected", Dt = "Unavailable", Mt = "Not Found", vt = "Address Incomplete", yt = "Incompatible SDP", bt = "Missing SDP", wt = "Authentication Error", He = "Terminated", Ut = "WebRTC Error", We = "Canceled", Lt = "No Answer", Ht = "Expires", Wt = "No ACK", kt = "Dialog Error", qt = "User Denied Media Access", Ft = "Bad Media Description", Bt = "RTP Timeout", ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
9
9
|
__proto__: null,
|
|
10
|
-
ADDRESS_INCOMPLETE:
|
|
11
|
-
AUTHENTICATION_ERROR:
|
|
12
|
-
BAD_MEDIA_DESCRIPTION:
|
|
10
|
+
ADDRESS_INCOMPLETE: vt,
|
|
11
|
+
AUTHENTICATION_ERROR: wt,
|
|
12
|
+
BAD_MEDIA_DESCRIPTION: Ft,
|
|
13
13
|
BUSY: Pt,
|
|
14
14
|
BYE: He,
|
|
15
15
|
CANCELED: We,
|
|
16
|
-
CONNECTION_ERROR:
|
|
17
|
-
DIALOG_ERROR:
|
|
18
|
-
EXPIRES:
|
|
19
|
-
INCOMPATIBLE_SDP:
|
|
20
|
-
INTERNAL_ERROR:
|
|
16
|
+
CONNECTION_ERROR: mt,
|
|
17
|
+
DIALOG_ERROR: kt,
|
|
18
|
+
EXPIRES: Ht,
|
|
19
|
+
INCOMPATIBLE_SDP: yt,
|
|
20
|
+
INTERNAL_ERROR: pt,
|
|
21
21
|
MISSING_SDP: bt,
|
|
22
|
-
NOT_FOUND:
|
|
23
|
-
NO_ACK:
|
|
24
|
-
NO_ANSWER:
|
|
25
|
-
REDIRECTED:
|
|
22
|
+
NOT_FOUND: Mt,
|
|
23
|
+
NO_ACK: Wt,
|
|
24
|
+
NO_ANSWER: Lt,
|
|
25
|
+
REDIRECTED: Ot,
|
|
26
26
|
REJECTED: Le,
|
|
27
27
|
REQUEST_TIMEOUT: Ue,
|
|
28
|
-
RTP_TIMEOUT:
|
|
29
|
-
SIP_FAILURE_CODE:
|
|
30
|
-
UNAVAILABLE:
|
|
31
|
-
USER_DENIED_MEDIA_ACCESS:
|
|
32
|
-
WEBRTC_ERROR:
|
|
33
|
-
}, Symbol.toStringTag, { value: "Module" })), V = "incomingCall", Y = "declinedIncomingCall", x = "failedIncomingCall", G = "terminatedIncomingCall",
|
|
28
|
+
RTP_TIMEOUT: Bt,
|
|
29
|
+
SIP_FAILURE_CODE: ft,
|
|
30
|
+
UNAVAILABLE: Dt,
|
|
31
|
+
USER_DENIED_MEDIA_ACCESS: qt,
|
|
32
|
+
WEBRTC_ERROR: Ut
|
|
33
|
+
}, Symbol.toStringTag, { value: "Module" })), V = "incomingCall", Y = "declinedIncomingCall", x = "failedIncomingCall", G = "terminatedIncomingCall", L = "connecting", m = "connected", S = "disconnected", D = "newRTCSession", f = "registered", $ = "unregistered", p = "registrationFailed", ke = "newMessage", X = "sipEvent", J = "availableSecondRemoteStream", z = "notAvailableSecondRemoteStream", Q = "mustStopPresentation", M = "shareState", j = "enterRoom", K = "useLicense", Z = "peerconnection:confirmed", ee = "peerconnection:ontrack", v = "channels", te = "channels:notify", ne = "ended:fromserver", se = "main-cam-control", ie = "admin-stop-main-cam", re = "admin-start-main-cam", oe = "admin-stop-mic", ae = "admin-start-mic", y = "admin-force-sync-media-state", ce = "participant:added-to-list-moderators", _e = "participant:removed-from-list-moderators", Ee = "participant:move-request-to-stream", he = "participant:move-request-to-spectators", le = "participation:accepting-word-request", de = "participation:cancelling-word-request", Te = "webcast:started", Se = "webcast:stopped", ue = "account:changed", Ce = "account:deleted", Ne = "conference:participant-token-issued", P = "ended", qe = "sending", Fe = "reinvite", Be = "replaces", Ve = "refer", Ye = "progress", xe = "accepted", b = "confirmed", w = "peerconnection", A = "failed", Ge = "muted", $e = "unmuted", ge = "newDTMF", Ae = "newInfo", Xe = "hold", Je = "unhold", ze = "update", Qe = "sdp", je = "icecandidate", Ke = "getusermediafailed", Ze = "peerconnection:createofferfailed", et = "peerconnection:createanswerfailed", tt = "peerconnection:setlocaldescriptionfailed", nt = "peerconnection:setremotedescriptionfailed", st = "presentation:start", it = "presentation:started", rt = "presentation:end", Re = "presentation:ended", U = "presentation:failed", ot = "SPECTATOR", ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
34
34
|
__proto__: null,
|
|
35
35
|
ACCEPTED: xe,
|
|
36
36
|
ACCOUNT_CHANGED: ue,
|
|
37
|
-
ACCOUNT_DELETED:
|
|
38
|
-
ADMIN_FORCE_SYNC_MEDIA_STATE:
|
|
37
|
+
ACCOUNT_DELETED: Ce,
|
|
38
|
+
ADMIN_FORCE_SYNC_MEDIA_STATE: y,
|
|
39
39
|
ADMIN_START_MAIN_CAM: re,
|
|
40
40
|
ADMIN_START_MIC: ae,
|
|
41
41
|
ADMIN_STOP_MAIN_CAM: ie,
|
|
42
42
|
ADMIN_STOP_MIC: oe,
|
|
43
43
|
AVAILABLE_SECOND_REMOTE_STREAM_EVENT: J,
|
|
44
|
-
CHANNELS:
|
|
44
|
+
CHANNELS: v,
|
|
45
45
|
CHANNELS_NOTIFY: te,
|
|
46
|
-
CONFERENCE_PARTICIPANT_TOKEN_ISSUED:
|
|
46
|
+
CONFERENCE_PARTICIPANT_TOKEN_ISSUED: Ne,
|
|
47
47
|
CONFIRMED: b,
|
|
48
|
-
CONNECTED:
|
|
49
|
-
CONNECTING:
|
|
48
|
+
CONNECTED: m,
|
|
49
|
+
CONNECTING: L,
|
|
50
50
|
DECLINED_INCOMING_CALL: Y,
|
|
51
|
-
DISCONNECTED:
|
|
51
|
+
DISCONNECTED: S,
|
|
52
52
|
ENDED: P,
|
|
53
|
-
ENDED_FROM_SERVER:
|
|
53
|
+
ENDED_FROM_SERVER: ne,
|
|
54
54
|
ENTER_ROOM: j,
|
|
55
|
-
FAILED:
|
|
55
|
+
FAILED: A,
|
|
56
56
|
FAILED_INCOMING_CALL: x,
|
|
57
57
|
GET_USER_MEDIA_FAILED: Ke,
|
|
58
58
|
HOLD: Xe,
|
|
59
59
|
ICE_CANDIDATE: je,
|
|
60
60
|
INCOMING_CALL: V,
|
|
61
|
-
MAIN_CAM_CONTROL:
|
|
61
|
+
MAIN_CAM_CONTROL: se,
|
|
62
62
|
MUST_STOP_PRESENTATION_EVENT: Q,
|
|
63
63
|
MUTED: Ge,
|
|
64
64
|
NEW_DTMF: ge,
|
|
65
65
|
NEW_INFO: Ae,
|
|
66
66
|
NEW_MESSAGE: ke,
|
|
67
|
-
NEW_RTC_SESSION:
|
|
67
|
+
NEW_RTC_SESSION: D,
|
|
68
68
|
NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: z,
|
|
69
69
|
PARTICIPANT_ADDED_TO_LIST_MODERATORS: ce,
|
|
70
70
|
PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS: he,
|
|
71
|
-
PARTICIPANT_MOVE_REQUEST_TO_STREAM:
|
|
72
|
-
PARTICIPANT_REMOVED_FROM_LIST_MODERATORS:
|
|
73
|
-
PARTICIPATION_ACCEPTING_WORD_REQUEST:
|
|
74
|
-
PARTICIPATION_CANCELLING_WORD_REQUEST:
|
|
75
|
-
PEER_CONNECTION:
|
|
71
|
+
PARTICIPANT_MOVE_REQUEST_TO_STREAM: Ee,
|
|
72
|
+
PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: _e,
|
|
73
|
+
PARTICIPATION_ACCEPTING_WORD_REQUEST: le,
|
|
74
|
+
PARTICIPATION_CANCELLING_WORD_REQUEST: de,
|
|
75
|
+
PEER_CONNECTION: w,
|
|
76
76
|
PEER_CONNECTION_CONFIRMED: Z,
|
|
77
77
|
PEER_CONNECTION_CREATE_ANSWER_FAILED: et,
|
|
78
78
|
PEER_CONNECTION_CREATE_OFFER_FAILED: Ze,
|
|
79
79
|
PEER_CONNECTION_ONTRACK: ee,
|
|
80
80
|
PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED: tt,
|
|
81
|
-
PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED:
|
|
81
|
+
PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED: nt,
|
|
82
82
|
PRESENTATION_END: rt,
|
|
83
83
|
PRESENTATION_ENDED: Re,
|
|
84
|
-
PRESENTATION_FAILED:
|
|
85
|
-
PRESENTATION_START:
|
|
84
|
+
PRESENTATION_FAILED: U,
|
|
85
|
+
PRESENTATION_START: st,
|
|
86
86
|
PRESENTATION_STARTED: it,
|
|
87
87
|
PROGRESS: Ye,
|
|
88
88
|
REFER: Ve,
|
|
89
|
-
REGISTERED:
|
|
90
|
-
REGISTRATION_FAILED:
|
|
89
|
+
REGISTERED: f,
|
|
90
|
+
REGISTRATION_FAILED: p,
|
|
91
91
|
REINVITE: Fe,
|
|
92
92
|
REPLACES: Be,
|
|
93
93
|
SDP: Qe,
|
|
94
94
|
SENDING: qe,
|
|
95
|
-
SHARE_STATE:
|
|
95
|
+
SHARE_STATE: M,
|
|
96
96
|
SIP_EVENT: X,
|
|
97
97
|
SPECTATOR: ot,
|
|
98
98
|
TERMINATED_INCOMING_CALL: G,
|
|
@@ -108,48 +108,48 @@ const ft = "Connection Error", Ue = "Request Timeout", pt = "SIP Failure Code",
|
|
|
108
108
|
Y,
|
|
109
109
|
G,
|
|
110
110
|
x,
|
|
111
|
-
de,
|
|
112
111
|
le,
|
|
113
|
-
|
|
112
|
+
de,
|
|
113
|
+
Ee,
|
|
114
114
|
te,
|
|
115
|
-
Ce,
|
|
116
|
-
ue,
|
|
117
115
|
Ne,
|
|
116
|
+
ue,
|
|
117
|
+
Ce,
|
|
118
118
|
Te,
|
|
119
119
|
Se,
|
|
120
120
|
ce,
|
|
121
|
-
|
|
121
|
+
_e
|
|
122
122
|
], Ie = [
|
|
123
|
-
|
|
123
|
+
L,
|
|
124
|
+
m,
|
|
125
|
+
S,
|
|
126
|
+
D,
|
|
124
127
|
f,
|
|
125
|
-
u,
|
|
126
|
-
M,
|
|
127
|
-
p,
|
|
128
128
|
$,
|
|
129
|
-
|
|
129
|
+
p,
|
|
130
130
|
ke,
|
|
131
131
|
X
|
|
132
132
|
], ct = [
|
|
133
133
|
J,
|
|
134
134
|
z,
|
|
135
135
|
Q,
|
|
136
|
-
|
|
136
|
+
M,
|
|
137
137
|
j,
|
|
138
138
|
K,
|
|
139
139
|
Z,
|
|
140
140
|
ee,
|
|
141
|
-
|
|
142
|
-
se,
|
|
141
|
+
v,
|
|
143
142
|
ne,
|
|
143
|
+
se,
|
|
144
144
|
re,
|
|
145
145
|
ie,
|
|
146
146
|
oe,
|
|
147
147
|
ae,
|
|
148
|
-
|
|
148
|
+
y,
|
|
149
149
|
he
|
|
150
150
|
], me = [
|
|
151
151
|
P,
|
|
152
|
-
|
|
152
|
+
L,
|
|
153
153
|
qe,
|
|
154
154
|
Fe,
|
|
155
155
|
Be,
|
|
@@ -157,8 +157,8 @@ const ft = "Connection Error", Ue = "Request Timeout", pt = "SIP Failure Code",
|
|
|
157
157
|
Ye,
|
|
158
158
|
xe,
|
|
159
159
|
b,
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
w,
|
|
161
|
+
A,
|
|
162
162
|
Ge,
|
|
163
163
|
$e,
|
|
164
164
|
ge,
|
|
@@ -172,78 +172,78 @@ const ft = "Connection Error", Ue = "Request Timeout", pt = "SIP Failure Code",
|
|
|
172
172
|
Ze,
|
|
173
173
|
et,
|
|
174
174
|
tt,
|
|
175
|
-
st,
|
|
176
175
|
nt,
|
|
176
|
+
st,
|
|
177
177
|
it,
|
|
178
178
|
rt,
|
|
179
179
|
Re,
|
|
180
|
-
|
|
181
|
-
],
|
|
180
|
+
U
|
|
181
|
+
], _t = [...Ie, ...at], Et = [
|
|
182
182
|
...me,
|
|
183
183
|
...ct
|
|
184
|
-
],
|
|
184
|
+
], ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
185
185
|
__proto__: null,
|
|
186
|
-
SESSION_EVENT_NAMES:
|
|
186
|
+
SESSION_EVENT_NAMES: Et,
|
|
187
187
|
SESSION_JSSIP_EVENT_NAMES: me,
|
|
188
188
|
SESSION_SYNTHETICS_EVENT_NAMES: ct,
|
|
189
|
-
UA_EVENT_NAMES:
|
|
189
|
+
UA_EVENT_NAMES: _t,
|
|
190
190
|
UA_JSSIP_EVENT_NAMES: Ie,
|
|
191
191
|
UA_SYNTHETICS_EVENT_NAMES: at
|
|
192
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
192
|
+
}, Symbol.toStringTag, { value: "Module" })), Vt = (r) => {
|
|
193
193
|
const e = [];
|
|
194
194
|
return r && e.push(`X-Vinteo-Remote: ${r}`), e;
|
|
195
|
-
},
|
|
195
|
+
}, Yt = "content-type", xt = "x-webrtc-enter-room", O = "application/vinteo.webrtc.sharedesktop", Gt = "application/vinteo.webrtc.roomname", $t = "application/vinteo.webrtc.channels", Xt = "application/vinteo.webrtc.mediastate", Jt = "application/vinteo.webrtc.refusal", De = "application/vinteo.webrtc.maincam", zt = "application/vinteo.webrtc.mic", Qt = "application/vinteo.webrtc.uselic", jt = "X-WEBRTC-USE-LICENSE", Kt = "X-WEBRTC-PARTICIPANT-NAME", Me = "X-WEBRTC-INPUT-CHANNELS", ve = "X-WEBRTC-OUTPUT-CHANNELS", Zt = "X-WEBRTC-MAINCAM", en = "X-WEBRTC-MIC", ye = "X-WEBRTC-SYNC", tn = "X-WEBRTC-MAINCAM-RESOLUTION", nn = "X-WEBRTC-MEDIA-STATE", sn = "X-Vinteo-Media-Type", rn = "X-Vinteo-MainCam-State", on = "X-Vinteo-Mic-State", an = "application/vinteo.webrtc.partstate", cn = "X-WEBRTC-PARTSTATE", _n = "application/vinteo.webrtc.notify", En = "X-VINTEO-NOTIFY", R = "x-webrtc-share-state", hn = `${R}: LETMESTARTPRESENTATION`, ln = `${R}: STOPPRESENTATION`, ht = "YOUCANRECEIVECONTENT", lt = "CONTENTEND", dt = "YOUMUSTSTOPSENDCONTENT", dn = `${R}: ${dt}`, Tn = `${R}: ${ht}`, Sn = `${R}: ${lt}`, un = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", Cn = `${un}: LETMESTARTMAINCAM`, fe = "sip-connector", H = B(fe), is = () => {
|
|
196
196
|
B.enable(fe);
|
|
197
|
-
},
|
|
197
|
+
}, rs = () => {
|
|
198
198
|
B.enable(`-${fe}`);
|
|
199
199
|
};
|
|
200
|
-
var
|
|
201
|
-
function
|
|
200
|
+
var I = /* @__PURE__ */ ((r) => (r.PAUSE_MAIN_CAM = "PAUSEMAINCAM", r.RESUME_MAIN_CAM = "RESUMEMAINCAM", r.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", r.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", r.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", r))(I || {}), k = /* @__PURE__ */ ((r) => (r.ADMIN_STOP_MIC = "ADMINSTOPMIC", r.ADMIN_START_MIC = "ADMINSTARTMIC", r))(k || {}), q = /* @__PURE__ */ ((r) => (r.ADMIN_SYNC_FORCED = "1", r.ADMIN_SYNC_NOT_FORCED = "0", r))(q || {}), Nn = /* @__PURE__ */ ((r) => (r.AUDIO = "AUDIO", r.VIDEO = "VIDEO", r.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", r))(Nn || {});
|
|
201
|
+
function gn(r) {
|
|
202
202
|
return (e) => `sip:${e}@${r}`;
|
|
203
203
|
}
|
|
204
|
-
const
|
|
204
|
+
const An = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, be = (r) => r.trim().replaceAll(" ", "_"), Rn = An(1e5, 99999999), W = (r, {
|
|
205
205
|
videoMode: e,
|
|
206
206
|
audioMode: t
|
|
207
207
|
} = {}) => {
|
|
208
208
|
if (!r || e === "recvonly" && t === "recvonly")
|
|
209
209
|
return;
|
|
210
|
-
const
|
|
210
|
+
const n = t === "recvonly" ? [] : r.getAudioTracks(), s = e === "recvonly" ? [] : r.getVideoTracks(), o = [...n, ...s], a = new MediaStream(o);
|
|
211
211
|
return a.getTracks = () => [...a.getAudioTracks(), ...a.getVideoTracks()], a;
|
|
212
|
-
},
|
|
213
|
-
const { kind:
|
|
214
|
-
return
|
|
215
|
-
}),
|
|
212
|
+
}, In = (r) => r.some((t) => {
|
|
213
|
+
const { kind: n } = t;
|
|
214
|
+
return n === "video";
|
|
215
|
+
}), mn = "Error decline with 603", fn = 1006, pn = (r) => typeof r == "object" && r !== null && "code" in r && r.code === fn, Pn = (r) => r.message === mn, On = (r, e) => r.find((t) => t.track && e.getTracks().includes(t.track)), Tt = 1, St = (r) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== r, Dn = St(
|
|
216
216
|
Tt
|
|
217
|
-
),
|
|
217
|
+
), Mn = (r, e) => {
|
|
218
218
|
const t = r === void 0 ? void 0 : Math.max(r, Tt);
|
|
219
|
-
if (t !== void 0 &&
|
|
219
|
+
if (t !== void 0 && Dn(
|
|
220
220
|
t,
|
|
221
221
|
e
|
|
222
222
|
))
|
|
223
223
|
return t;
|
|
224
|
-
},
|
|
225
|
-
if (
|
|
224
|
+
}, vn = St(), yn = (r, e) => {
|
|
225
|
+
if (vn(r, e))
|
|
226
226
|
return r;
|
|
227
|
-
},
|
|
228
|
-
const
|
|
229
|
-
(
|
|
230
|
-
const [
|
|
227
|
+
}, bn = async (r, e, t) => {
|
|
228
|
+
const n = r.getParameters();
|
|
229
|
+
(n.encodings === void 0 || n.encodings.length === 0) && (n.encodings = [{}]);
|
|
230
|
+
const [s] = n.encodings, o = s.scaleResolutionDownBy, a = Mn(
|
|
231
231
|
e.scaleResolutionDownBy,
|
|
232
232
|
o
|
|
233
233
|
);
|
|
234
234
|
let c = !1;
|
|
235
|
-
a !== void 0 && (
|
|
236
|
-
const _ =
|
|
237
|
-
return E !== void 0 && (
|
|
238
|
-
},
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
return
|
|
242
|
-
},
|
|
235
|
+
a !== void 0 && (n.encodings[0].scaleResolutionDownBy = a, c = !0);
|
|
236
|
+
const _ = s.maxBitrate, E = yn(e.maxBitrate, _);
|
|
237
|
+
return E !== void 0 && (n.encodings[0].maxBitrate = E, c = !0), c ? (t && t(n), r.setParameters(n).then(() => ({ parameters: n, isChanged: c }))) : { parameters: n, isChanged: c };
|
|
238
|
+
}, wn = async (r, e, t) => {
|
|
239
|
+
const n = On(r, e);
|
|
240
|
+
if (n)
|
|
241
|
+
return bn(n, { maxBitrate: t });
|
|
242
|
+
}, Un = 486, Ln = 487, F = "local", we = "remote", Hn = 3, Wn = 1, os = (r = new Error()) => {
|
|
243
243
|
const { originator: e, cause: t } = r;
|
|
244
244
|
return It(r) ? !0 : typeof t == "string" ? t === Ue || t === Le || e === F && (t === We || t === He) : !1;
|
|
245
|
-
},
|
|
246
|
-
class
|
|
245
|
+
}, g = "SipConnector", kn = "channels", qn = "WebcastStarted", Fn = "WebcastStopped", Bn = "accountChanged", Vn = "accountDeleted", Yn = "addedToListModerators", xn = "removedFromListModerators", Gn = "ParticipationRequestAccepted", $n = "ParticipationRequestRejected", Xn = "ParticipantMovedToWebcast", Jn = "ConferenceParticipantTokenIssued";
|
|
246
|
+
class as {
|
|
247
247
|
constructor({ JsSIP: e }) {
|
|
248
248
|
i(this, "_isRegisterConfig", !1);
|
|
249
249
|
i(this, "_connectionConfiguration", {});
|
|
@@ -253,6 +253,7 @@ class an {
|
|
|
253
253
|
i(this, "_uaEvents");
|
|
254
254
|
i(this, "_cancelableConnect");
|
|
255
255
|
i(this, "_cancelableConnectWithRepeatedCalls");
|
|
256
|
+
i(this, "_cancelableSendPresentationWithRepeatedCalls");
|
|
256
257
|
i(this, "_cancelableInitUa");
|
|
257
258
|
i(this, "_cancelableDisconnect");
|
|
258
259
|
i(this, "_cancelableSet");
|
|
@@ -278,35 +279,35 @@ class an {
|
|
|
278
279
|
i(this, "tryRegister", async () => {
|
|
279
280
|
if (!this.isRegisterConfig)
|
|
280
281
|
throw new Error("Config is not registered");
|
|
281
|
-
this._uaEvents.trigger(
|
|
282
|
+
this._uaEvents.trigger(L, void 0);
|
|
282
283
|
try {
|
|
283
284
|
await this.unregister();
|
|
284
285
|
} catch (e) {
|
|
285
|
-
|
|
286
|
+
H("tryRegister", e);
|
|
286
287
|
}
|
|
287
288
|
return this.register();
|
|
288
289
|
});
|
|
289
|
-
i(this, "declineToIncomingCall", async ({ statusCode: e =
|
|
290
|
+
i(this, "declineToIncomingCall", async ({ statusCode: e = Ln } = {}) => new Promise((t, n) => {
|
|
290
291
|
if (!this.isAvailableIncomingCall) {
|
|
291
|
-
|
|
292
|
+
n(new Error("no incomingSession"));
|
|
292
293
|
return;
|
|
293
294
|
}
|
|
294
|
-
const
|
|
295
|
-
this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(Y, o), t(
|
|
295
|
+
const s = this.incomingSession, o = this.remoteCallerData;
|
|
296
|
+
this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(Y, o), t(s.terminate({ status_code: e }));
|
|
296
297
|
}));
|
|
297
|
-
i(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode:
|
|
298
|
+
i(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode: Un }));
|
|
298
299
|
i(this, "removeIncomingSession", () => {
|
|
299
300
|
delete this.incomingSession;
|
|
300
301
|
});
|
|
301
|
-
i(this, "_connectWithDuplicatedCalls", async (e, { callLimit: t =
|
|
302
|
-
let
|
|
303
|
-
const
|
|
302
|
+
i(this, "_connectWithDuplicatedCalls", async (e, { callLimit: t = Hn } = {}) => {
|
|
303
|
+
let n = !0;
|
|
304
|
+
const s = async () => (n = !1, this._cancelableConnect.request(e)), o = (a) => {
|
|
304
305
|
var h;
|
|
305
|
-
const c = !!((h = this.ua) != null && h.isConnected()), _ = !
|
|
306
|
+
const c = !!((h = this.ua) != null && h.isConnected()), _ = !n && c && this.hasEqualConnectionConfiguration(e), E = !!a && !pn(a);
|
|
306
307
|
return _ || E;
|
|
307
308
|
};
|
|
308
|
-
return this._cancelableConnectWithRepeatedCalls =
|
|
309
|
-
targetFunction:
|
|
309
|
+
return this._cancelableConnectWithRepeatedCalls = Oe({
|
|
310
|
+
targetFunction: s,
|
|
310
311
|
isComplete: o,
|
|
311
312
|
callLimit: t,
|
|
312
313
|
isRejectAsValid: !0,
|
|
@@ -320,131 +321,129 @@ class an {
|
|
|
320
321
|
});
|
|
321
322
|
});
|
|
322
323
|
i(this, "handleNewRTCSession", ({ originator: e, session: t }) => {
|
|
323
|
-
if (e ===
|
|
324
|
+
if (e === we) {
|
|
324
325
|
this.incomingSession = t;
|
|
325
|
-
const
|
|
326
|
-
t.on(
|
|
327
|
-
this.removeIncomingSession(),
|
|
328
|
-
}), this._uaEvents.trigger(V,
|
|
326
|
+
const n = this.remoteCallerData;
|
|
327
|
+
t.on(A, (s) => {
|
|
328
|
+
this.removeIncomingSession(), s.originator === F ? this._uaEvents.trigger(G, n) : this._uaEvents.trigger(x, n);
|
|
329
|
+
}), this._uaEvents.trigger(V, n);
|
|
329
330
|
}
|
|
330
331
|
});
|
|
331
332
|
i(this, "_connect", async (e) => this.initUa(e).then(async () => this._start()));
|
|
332
333
|
i(this, "_initUa", async ({
|
|
333
334
|
user: e,
|
|
334
335
|
password: t,
|
|
335
|
-
sipServerUrl:
|
|
336
|
-
sipWebSocketServerURL:
|
|
336
|
+
sipServerUrl: n,
|
|
337
|
+
sipWebSocketServerURL: s,
|
|
337
338
|
remoteAddress: o,
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
userAgent: l,
|
|
339
|
+
sessionTimers: a,
|
|
340
|
+
registerExpires: c,
|
|
341
|
+
connectionRecoveryMinInterval: _,
|
|
342
|
+
connectionRecoveryMaxInterval: E,
|
|
343
|
+
userAgent: h,
|
|
344
344
|
displayName: d = "",
|
|
345
|
-
register:
|
|
346
|
-
extraHeaders:
|
|
345
|
+
register: l = !1,
|
|
346
|
+
extraHeaders: T = []
|
|
347
347
|
}) => {
|
|
348
|
-
if (!s)
|
|
349
|
-
throw new Error("sipServerUrl is required");
|
|
350
348
|
if (!n)
|
|
349
|
+
throw new Error("sipServerUrl is required");
|
|
350
|
+
if (!s)
|
|
351
351
|
throw new Error("sipWebSocketServerURL is required");
|
|
352
|
-
if (
|
|
352
|
+
if (l && !e)
|
|
353
353
|
throw new Error("user is required for authorized connection");
|
|
354
|
-
if (
|
|
354
|
+
if (l && !t)
|
|
355
355
|
throw new Error("password is required for authorized connection");
|
|
356
356
|
this._connectionConfiguration = {
|
|
357
|
-
sipServerUrl:
|
|
357
|
+
sipServerUrl: n,
|
|
358
358
|
displayName: d,
|
|
359
|
-
register:
|
|
359
|
+
register: l,
|
|
360
360
|
user: e,
|
|
361
361
|
password: t
|
|
362
362
|
};
|
|
363
|
-
const { configuration:
|
|
363
|
+
const { configuration: u, helpers: C } = this.createUaConfiguration({
|
|
364
364
|
user: e,
|
|
365
|
-
sipServerUrl:
|
|
366
|
-
sipWebSocketServerURL:
|
|
365
|
+
sipServerUrl: n,
|
|
366
|
+
sipWebSocketServerURL: s,
|
|
367
367
|
password: t,
|
|
368
368
|
displayName: d,
|
|
369
|
-
register:
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
userAgent: l
|
|
369
|
+
register: l,
|
|
370
|
+
sessionTimers: a,
|
|
371
|
+
registerExpires: c,
|
|
372
|
+
connectionRecoveryMinInterval: _,
|
|
373
|
+
connectionRecoveryMaxInterval: E,
|
|
374
|
+
userAgent: h
|
|
376
375
|
});
|
|
377
|
-
this.getSipServerUrl =
|
|
378
|
-
const pe = Ie.find((gt) => gt ===
|
|
379
|
-
pe && this.ua && this.ua.on(pe,
|
|
376
|
+
this.getSipServerUrl = C.getSipServerUrl, this.socket = C.socket, this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!l, this.ua = this._createUa(u), this._uaEvents.eachTriggers((Ct, Nt) => {
|
|
377
|
+
const pe = Ie.find((gt) => gt === Nt);
|
|
378
|
+
pe && this.ua && this.ua.on(pe, Ct);
|
|
380
379
|
});
|
|
381
|
-
const ut = [...
|
|
380
|
+
const ut = [...Vt(o), ...T];
|
|
382
381
|
return this.ua.registrator().setExtraHeaders(ut), this.ua;
|
|
383
382
|
});
|
|
384
383
|
i(this, "_createUa", (e) => new this.JsSIP.UA(e));
|
|
385
384
|
i(this, "_start", async () => new Promise((e, t) => {
|
|
386
|
-
const { ua:
|
|
387
|
-
if (!
|
|
385
|
+
const { ua: n } = this;
|
|
386
|
+
if (!n) {
|
|
388
387
|
t(new Error("this.ua is not initialized"));
|
|
389
388
|
return;
|
|
390
389
|
}
|
|
391
|
-
const
|
|
392
|
-
c(), e(
|
|
390
|
+
const s = () => {
|
|
391
|
+
c(), e(n);
|
|
393
392
|
}, o = (_) => {
|
|
394
393
|
c(), t(_);
|
|
395
394
|
}, a = () => {
|
|
396
|
-
this.isRegisterConfig ? (this.on(
|
|
395
|
+
this.isRegisterConfig ? (this.on(f, s), this.on(p, o)) : this.on(m, s), this.on(S, o);
|
|
397
396
|
}, c = () => {
|
|
398
|
-
this.off(
|
|
397
|
+
this.off(f, s), this.off(p, o), this.off(m, s), this.off(S, o);
|
|
399
398
|
};
|
|
400
|
-
a(), this.on(
|
|
399
|
+
a(), this.on(D, this.handleNewRTCSession), n.start();
|
|
401
400
|
}));
|
|
402
|
-
i(this, "_set", async ({ displayName: e, password: t }) => new Promise((
|
|
401
|
+
i(this, "_set", async ({ displayName: e, password: t }) => new Promise((n, s) => {
|
|
403
402
|
const { ua: o } = this;
|
|
404
403
|
if (!o) {
|
|
405
|
-
|
|
404
|
+
s(new Error("this.ua is not initialized"));
|
|
406
405
|
return;
|
|
407
406
|
}
|
|
408
407
|
let a = !1, c = !1;
|
|
409
|
-
e !== void 0 && e !== this._connectionConfiguration.displayName && (a = o.set("display_name",
|
|
408
|
+
e !== void 0 && e !== this._connectionConfiguration.displayName && (a = o.set("display_name", be(e)), this._connectionConfiguration.displayName = e), t !== void 0 && t !== this._connectionConfiguration.password && (c = o.set("password", t), this._connectionConfiguration.password = t);
|
|
410
409
|
const _ = a || c;
|
|
411
410
|
c && this.isRegisterConfig ? this.register().then(() => {
|
|
412
|
-
|
|
411
|
+
n(_);
|
|
413
412
|
}).catch((E) => {
|
|
414
|
-
|
|
415
|
-
}) : _ ?
|
|
413
|
+
s(E);
|
|
414
|
+
}) : _ ? n(_) : s(new Error("nothing changed"));
|
|
416
415
|
}));
|
|
417
416
|
i(this, "_disconnectWithoutCancelRequests", async () => this._cancelableDisconnect.request());
|
|
418
417
|
i(this, "_disconnect", async () => {
|
|
419
|
-
this.off(
|
|
418
|
+
this.off(D, this.handleNewRTCSession);
|
|
420
419
|
const e = new Promise((t) => {
|
|
421
|
-
this.once(
|
|
420
|
+
this.once(S, () => {
|
|
422
421
|
delete this.ua, t();
|
|
423
422
|
});
|
|
424
423
|
});
|
|
425
|
-
return this.ua ? (await this._hangUpWithoutCancelRequests(), this.ua ? this.ua.stop() : this._uaEvents.trigger(
|
|
424
|
+
return this.ua ? (await this._hangUpWithoutCancelRequests(), this.ua ? this.ua.stop() : this._uaEvents.trigger(S, void 0)) : this._uaEvents.trigger(S, void 0), e;
|
|
426
425
|
});
|
|
427
426
|
i(this, "_call", async ({
|
|
428
427
|
number: e,
|
|
429
428
|
mediaStream: t,
|
|
430
|
-
extraHeaders:
|
|
431
|
-
ontrack:
|
|
429
|
+
extraHeaders: n = [],
|
|
430
|
+
ontrack: s,
|
|
432
431
|
iceServers: o,
|
|
433
432
|
videoMode: a,
|
|
434
433
|
audioMode: c,
|
|
435
434
|
degradationPreference: _,
|
|
436
435
|
offerToReceiveAudio: E = !0,
|
|
437
436
|
offerToReceiveVideo: h = !0
|
|
438
|
-
}) => new Promise((
|
|
437
|
+
}) => new Promise((d, l) => {
|
|
439
438
|
const { ua: T } = this;
|
|
440
439
|
if (!T) {
|
|
441
|
-
|
|
440
|
+
l(new Error("this.ua is not initialized"));
|
|
442
441
|
return;
|
|
443
442
|
}
|
|
444
|
-
this._connectionConfiguration.number = e, this._connectionConfiguration.answer = !1, this._handleCall({ ontrack:
|
|
445
|
-
|
|
443
|
+
this._connectionConfiguration.number = e, this._connectionConfiguration.answer = !1, this._handleCall({ ontrack: s }).then(d).catch((u) => {
|
|
444
|
+
l(u);
|
|
446
445
|
}), this.session = T.call(this.getSipServerUrl(e), {
|
|
447
|
-
extraHeaders:
|
|
446
|
+
extraHeaders: n,
|
|
448
447
|
mediaStream: W(t, {
|
|
449
448
|
videoMode: a,
|
|
450
449
|
audioMode: c
|
|
@@ -465,8 +464,8 @@ class an {
|
|
|
465
464
|
i(this, "_answer", async ({
|
|
466
465
|
mediaStream: e,
|
|
467
466
|
ontrack: t,
|
|
468
|
-
extraHeaders:
|
|
469
|
-
iceServers:
|
|
467
|
+
extraHeaders: n = [],
|
|
468
|
+
iceServers: s,
|
|
470
469
|
videoMode: o,
|
|
471
470
|
audioMode: a,
|
|
472
471
|
degradationPreference: c
|
|
@@ -481,61 +480,61 @@ class an {
|
|
|
481
480
|
E(new Error("No session established"));
|
|
482
481
|
return;
|
|
483
482
|
}
|
|
484
|
-
this._sessionEvents.eachTriggers((
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
}), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = h.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(_).catch((
|
|
488
|
-
E(
|
|
483
|
+
this._sessionEvents.eachTriggers((l, T) => {
|
|
484
|
+
const u = me.find((C) => C === T);
|
|
485
|
+
u && h.on(u, l);
|
|
486
|
+
}), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = h.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(_).catch((l) => {
|
|
487
|
+
E(l);
|
|
489
488
|
});
|
|
490
|
-
const
|
|
489
|
+
const d = W(e, {
|
|
491
490
|
videoMode: o,
|
|
492
491
|
audioMode: a
|
|
493
492
|
});
|
|
494
493
|
h.answer({
|
|
495
|
-
extraHeaders:
|
|
494
|
+
extraHeaders: n,
|
|
496
495
|
videoMode: o,
|
|
497
496
|
audioMode: a,
|
|
498
497
|
degradationPreference: c,
|
|
499
|
-
mediaStream:
|
|
498
|
+
mediaStream: d,
|
|
500
499
|
pcConfig: {
|
|
501
|
-
iceServers:
|
|
500
|
+
iceServers: s
|
|
502
501
|
}
|
|
503
502
|
});
|
|
504
503
|
}));
|
|
505
|
-
i(this, "_handleCall", async ({ ontrack: e }) => new Promise((t,
|
|
506
|
-
const
|
|
507
|
-
this.onSession(
|
|
504
|
+
i(this, "_handleCall", async ({ ontrack: e }) => new Promise((t, n) => {
|
|
505
|
+
const s = () => {
|
|
506
|
+
this.onSession(w, h), this.onSession(b, d);
|
|
508
507
|
}, o = () => {
|
|
509
|
-
this.offSession(
|
|
508
|
+
this.offSession(w, h), this.offSession(b, d);
|
|
510
509
|
}, a = () => {
|
|
511
|
-
this.onSession(
|
|
510
|
+
this.onSession(A, _), this.onSession(P, _);
|
|
512
511
|
}, c = () => {
|
|
513
|
-
this.offSession(
|
|
514
|
-
}, _ = (
|
|
515
|
-
o(), c(),
|
|
512
|
+
this.offSession(A, _), this.offSession(P, _);
|
|
513
|
+
}, _ = (l) => {
|
|
514
|
+
o(), c(), n(l);
|
|
516
515
|
};
|
|
517
516
|
let E;
|
|
518
|
-
const h = ({ peerconnection:
|
|
519
|
-
E =
|
|
517
|
+
const h = ({ peerconnection: l }) => {
|
|
518
|
+
E = l, E.ontrack = (T) => {
|
|
520
519
|
this._sessionEvents.trigger(ee, E), e && e(T);
|
|
521
520
|
};
|
|
522
|
-
},
|
|
521
|
+
}, d = () => {
|
|
523
522
|
E && this._sessionEvents.trigger(Z, E), o(), c(), t(E);
|
|
524
523
|
};
|
|
525
|
-
|
|
524
|
+
s(), a();
|
|
526
525
|
}));
|
|
527
526
|
i(this, "_restoreSession", () => {
|
|
528
|
-
this.
|
|
527
|
+
this._cancelRequestsAndResetPresentation(), delete this._connectionConfiguration.number, delete this.session, this._remoteStreams = {};
|
|
529
528
|
});
|
|
530
|
-
i(this, "_sendDTMF", async (e) => new Promise((t,
|
|
531
|
-
const { session:
|
|
532
|
-
if (!
|
|
533
|
-
|
|
529
|
+
i(this, "_sendDTMF", async (e) => new Promise((t, n) => {
|
|
530
|
+
const { session: s } = this;
|
|
531
|
+
if (!s) {
|
|
532
|
+
n(new Error("No session established"));
|
|
534
533
|
return;
|
|
535
534
|
}
|
|
536
535
|
this.onceSession(ge, ({ originator: o }) => {
|
|
537
536
|
o === F && t();
|
|
538
|
-
}),
|
|
537
|
+
}), s.sendDTMF(e, {
|
|
539
538
|
duration: 120,
|
|
540
539
|
interToneGap: 600
|
|
541
540
|
});
|
|
@@ -543,7 +542,13 @@ class an {
|
|
|
543
542
|
i(this, "_hangUpWithoutCancelRequests", async () => {
|
|
544
543
|
if (this.ua && this.session) {
|
|
545
544
|
const { session: e } = this;
|
|
546
|
-
if (this._streamPresentationCurrent
|
|
545
|
+
if (this._streamPresentationCurrent)
|
|
546
|
+
try {
|
|
547
|
+
await this.stopPresentation();
|
|
548
|
+
} catch (t) {
|
|
549
|
+
H("error stop presentation: ", t);
|
|
550
|
+
}
|
|
551
|
+
if (this._restoreSession(), !e.isEnded())
|
|
547
552
|
return e.terminateAsync();
|
|
548
553
|
}
|
|
549
554
|
});
|
|
@@ -553,83 +558,83 @@ class an {
|
|
|
553
558
|
this._sessionEvents.trigger(J, void 0);
|
|
554
559
|
break;
|
|
555
560
|
}
|
|
556
|
-
case
|
|
561
|
+
case lt: {
|
|
557
562
|
this._sessionEvents.trigger(z, void 0);
|
|
558
563
|
break;
|
|
559
564
|
}
|
|
560
|
-
case
|
|
565
|
+
case dt: {
|
|
561
566
|
this._sessionEvents.trigger(Q, void 0);
|
|
562
567
|
break;
|
|
563
568
|
}
|
|
564
569
|
}
|
|
565
570
|
});
|
|
566
571
|
i(this, "_maybeTriggerChannels", (e) => {
|
|
567
|
-
const t = e.getHeader(
|
|
568
|
-
if (t &&
|
|
569
|
-
const
|
|
572
|
+
const t = e.getHeader(Me), n = e.getHeader(ve);
|
|
573
|
+
if (t && n) {
|
|
574
|
+
const s = {
|
|
570
575
|
inputChannels: t,
|
|
571
|
-
outputChannels:
|
|
576
|
+
outputChannels: n
|
|
572
577
|
};
|
|
573
|
-
this._sessionEvents.trigger(
|
|
578
|
+
this._sessionEvents.trigger(v, s);
|
|
574
579
|
}
|
|
575
580
|
});
|
|
576
581
|
i(this, "_handleNotify", (e) => {
|
|
577
582
|
switch (e.cmd) {
|
|
578
|
-
case
|
|
583
|
+
case kn: {
|
|
579
584
|
const t = e;
|
|
580
585
|
this._triggerChannelsNotify(t);
|
|
581
586
|
break;
|
|
582
587
|
}
|
|
583
|
-
case
|
|
588
|
+
case qn: {
|
|
584
589
|
const t = e;
|
|
585
590
|
this._triggerWebcastStartedNotify(t);
|
|
586
591
|
break;
|
|
587
592
|
}
|
|
588
|
-
case
|
|
593
|
+
case Fn: {
|
|
589
594
|
const t = e;
|
|
590
595
|
this._triggerWebcastStoppedNotify(t);
|
|
591
596
|
break;
|
|
592
597
|
}
|
|
593
|
-
case
|
|
598
|
+
case Yn: {
|
|
594
599
|
const t = e;
|
|
595
600
|
this._triggerAddedToListModeratorsNotify(t);
|
|
596
601
|
break;
|
|
597
602
|
}
|
|
598
|
-
case
|
|
603
|
+
case xn: {
|
|
599
604
|
const t = e;
|
|
600
605
|
this._triggerRemovedFromListModeratorsNotify(t);
|
|
601
606
|
break;
|
|
602
607
|
}
|
|
603
|
-
case
|
|
608
|
+
case Gn: {
|
|
604
609
|
const t = e;
|
|
605
610
|
this._triggerParticipationAcceptingWordRequest(t);
|
|
606
611
|
break;
|
|
607
612
|
}
|
|
608
|
-
case
|
|
613
|
+
case $n: {
|
|
609
614
|
const t = e;
|
|
610
615
|
this._triggerParticipationCancellingWordRequest(t);
|
|
611
616
|
break;
|
|
612
617
|
}
|
|
613
|
-
case
|
|
618
|
+
case Xn: {
|
|
614
619
|
const t = e;
|
|
615
620
|
this._triggerParticipantMoveRequestToStream(t);
|
|
616
621
|
break;
|
|
617
622
|
}
|
|
618
|
-
case
|
|
623
|
+
case Bn: {
|
|
619
624
|
this._triggerAccountChangedNotify();
|
|
620
625
|
break;
|
|
621
626
|
}
|
|
622
|
-
case
|
|
627
|
+
case Vn: {
|
|
623
628
|
this._triggerAccountDeletedNotify();
|
|
624
629
|
break;
|
|
625
630
|
}
|
|
626
|
-
case
|
|
631
|
+
case Jn: {
|
|
627
632
|
const t = e;
|
|
628
633
|
this._triggerConferenceParticipantTokenIssued(t);
|
|
629
634
|
break;
|
|
630
635
|
}
|
|
631
636
|
default:
|
|
632
|
-
|
|
637
|
+
H("unknown cmd", e.cmd);
|
|
633
638
|
}
|
|
634
639
|
});
|
|
635
640
|
i(this, "_triggerRemovedFromListModeratorsNotify", ({
|
|
@@ -639,7 +644,7 @@ class an {
|
|
|
639
644
|
conference: e
|
|
640
645
|
};
|
|
641
646
|
this._uaEvents.trigger(
|
|
642
|
-
|
|
647
|
+
_e,
|
|
643
648
|
t
|
|
644
649
|
);
|
|
645
650
|
});
|
|
@@ -650,44 +655,44 @@ class an {
|
|
|
650
655
|
this._uaEvents.trigger(ce, t);
|
|
651
656
|
});
|
|
652
657
|
i(this, "_triggerWebcastStartedNotify", ({ body: { conference: e, type: t } }) => {
|
|
653
|
-
const
|
|
658
|
+
const n = {
|
|
654
659
|
conference: e,
|
|
655
660
|
type: t
|
|
656
661
|
};
|
|
657
|
-
this._uaEvents.trigger(Te,
|
|
662
|
+
this._uaEvents.trigger(Te, n);
|
|
658
663
|
});
|
|
659
664
|
i(this, "_triggerWebcastStoppedNotify", ({ body: { conference: e, type: t } }) => {
|
|
660
|
-
const
|
|
665
|
+
const n = {
|
|
661
666
|
conference: e,
|
|
662
667
|
type: t
|
|
663
668
|
};
|
|
664
|
-
this._uaEvents.trigger(Se,
|
|
669
|
+
this._uaEvents.trigger(Se, n);
|
|
665
670
|
});
|
|
666
671
|
i(this, "_triggerAccountChangedNotify", () => {
|
|
667
672
|
this._uaEvents.trigger(ue, void 0);
|
|
668
673
|
});
|
|
669
674
|
i(this, "_triggerAccountDeletedNotify", () => {
|
|
670
|
-
this._uaEvents.trigger(
|
|
675
|
+
this._uaEvents.trigger(Ce, void 0);
|
|
671
676
|
});
|
|
672
677
|
i(this, "_triggerConferenceParticipantTokenIssued", ({
|
|
673
|
-
body: { conference: e, participant: t, jwt:
|
|
678
|
+
body: { conference: e, participant: t, jwt: n }
|
|
674
679
|
}) => {
|
|
675
|
-
const
|
|
680
|
+
const s = {
|
|
676
681
|
conference: e,
|
|
677
682
|
participant: t,
|
|
678
|
-
jwt:
|
|
683
|
+
jwt: n
|
|
679
684
|
};
|
|
680
685
|
this._uaEvents.trigger(
|
|
681
|
-
|
|
682
|
-
|
|
686
|
+
Ne,
|
|
687
|
+
s
|
|
683
688
|
);
|
|
684
689
|
});
|
|
685
690
|
i(this, "_triggerChannelsNotify", (e) => {
|
|
686
|
-
const t = e.input,
|
|
691
|
+
const t = e.input, n = e.output, s = {
|
|
687
692
|
inputChannels: t,
|
|
688
|
-
outputChannels:
|
|
693
|
+
outputChannels: n
|
|
689
694
|
};
|
|
690
|
-
this._uaEvents.trigger(te,
|
|
695
|
+
this._uaEvents.trigger(te, s);
|
|
691
696
|
});
|
|
692
697
|
i(this, "_triggerParticipationAcceptingWordRequest", ({
|
|
693
698
|
body: { conference: e }
|
|
@@ -695,7 +700,7 @@ class an {
|
|
|
695
700
|
const t = {
|
|
696
701
|
conference: e
|
|
697
702
|
};
|
|
698
|
-
this._uaEvents.trigger(
|
|
703
|
+
this._uaEvents.trigger(le, t);
|
|
699
704
|
});
|
|
700
705
|
i(this, "_triggerParticipationCancellingWordRequest", ({
|
|
701
706
|
body: { conference: e }
|
|
@@ -703,7 +708,7 @@ class an {
|
|
|
703
708
|
const t = {
|
|
704
709
|
conference: e
|
|
705
710
|
};
|
|
706
|
-
this._uaEvents.trigger(
|
|
711
|
+
this._uaEvents.trigger(de, t);
|
|
707
712
|
});
|
|
708
713
|
i(this, "_triggerParticipantMoveRequestToStream", ({
|
|
709
714
|
body: { conference: e }
|
|
@@ -711,77 +716,77 @@ class an {
|
|
|
711
716
|
const t = {
|
|
712
717
|
conference: e
|
|
713
718
|
};
|
|
714
|
-
this._uaEvents.trigger(
|
|
719
|
+
this._uaEvents.trigger(Ee, t);
|
|
715
720
|
});
|
|
716
721
|
i(this, "_triggerEnterRoom", (e) => {
|
|
717
|
-
const t = e.getHeader(
|
|
718
|
-
this._sessionEvents.trigger(j, { room: t, participantName:
|
|
722
|
+
const t = e.getHeader(xt), n = e.getHeader(Kt);
|
|
723
|
+
this._sessionEvents.trigger(j, { room: t, participantName: n });
|
|
719
724
|
});
|
|
720
725
|
i(this, "_triggerShareState", (e) => {
|
|
721
|
-
const t = e.getHeader(
|
|
722
|
-
this._sessionEvents.trigger(
|
|
726
|
+
const t = e.getHeader(R);
|
|
727
|
+
this._sessionEvents.trigger(M, t);
|
|
723
728
|
});
|
|
724
729
|
i(this, "_maybeTriggerParticipantMoveRequestToSpectators", (e) => {
|
|
725
|
-
e.getHeader(
|
|
730
|
+
e.getHeader(cn) === ot && this._sessionEvents.trigger(he, void 0);
|
|
726
731
|
});
|
|
727
732
|
i(this, "_triggerMainCamControl", (e) => {
|
|
728
|
-
const t = e.getHeader(
|
|
729
|
-
if (t ===
|
|
730
|
-
this._sessionEvents.trigger(re, { isSyncForced:
|
|
733
|
+
const t = e.getHeader(Zt), n = e.getHeader(ye), s = n === q.ADMIN_SYNC_FORCED;
|
|
734
|
+
if (t === I.ADMIN_START_MAIN_CAM) {
|
|
735
|
+
this._sessionEvents.trigger(re, { isSyncForced: s });
|
|
731
736
|
return;
|
|
732
737
|
}
|
|
733
|
-
if (t ===
|
|
734
|
-
this._sessionEvents.trigger(ie, { isSyncForced:
|
|
738
|
+
if (t === I.ADMIN_STOP_MAIN_CAM) {
|
|
739
|
+
this._sessionEvents.trigger(ie, { isSyncForced: s });
|
|
735
740
|
return;
|
|
736
741
|
}
|
|
737
|
-
(t ===
|
|
738
|
-
const o = e.getHeader(
|
|
739
|
-
this._sessionEvents.trigger(
|
|
742
|
+
(t === I.RESUME_MAIN_CAM || t === I.PAUSE_MAIN_CAM) && n && this._sessionEvents.trigger(y, { isSyncForced: s });
|
|
743
|
+
const o = e.getHeader(tn);
|
|
744
|
+
this._sessionEvents.trigger(se, {
|
|
740
745
|
mainCam: t,
|
|
741
746
|
resolutionMainCam: o
|
|
742
747
|
});
|
|
743
748
|
});
|
|
744
749
|
i(this, "_triggerMicControl", (e) => {
|
|
745
|
-
const t = e.getHeader(
|
|
746
|
-
t === k.ADMIN_START_MIC ? this._sessionEvents.trigger(ae, { isSyncForced:
|
|
750
|
+
const t = e.getHeader(en), s = e.getHeader(ye) === q.ADMIN_SYNC_FORCED;
|
|
751
|
+
t === k.ADMIN_START_MIC ? this._sessionEvents.trigger(ae, { isSyncForced: s }) : t === k.ADMIN_STOP_MIC && this._sessionEvents.trigger(oe, { isSyncForced: s });
|
|
747
752
|
});
|
|
748
753
|
i(this, "_triggerUseLicense", (e) => {
|
|
749
|
-
const t = e.getHeader(
|
|
754
|
+
const t = e.getHeader(jt);
|
|
750
755
|
this._sessionEvents.trigger(K, t);
|
|
751
756
|
});
|
|
752
757
|
i(this, "_handleNewInfo", (e) => {
|
|
753
758
|
const { originator: t } = e;
|
|
754
759
|
if (t !== "remote")
|
|
755
760
|
return;
|
|
756
|
-
const { request:
|
|
757
|
-
if (
|
|
758
|
-
switch (
|
|
759
|
-
case
|
|
760
|
-
this._triggerEnterRoom(
|
|
761
|
+
const { request: n } = e, s = n.getHeader(Yt);
|
|
762
|
+
if (s)
|
|
763
|
+
switch (s) {
|
|
764
|
+
case Gt: {
|
|
765
|
+
this._triggerEnterRoom(n), this._maybeTriggerChannels(n);
|
|
761
766
|
break;
|
|
762
767
|
}
|
|
763
|
-
case
|
|
764
|
-
this._maybeHandleNotify(
|
|
768
|
+
case _n: {
|
|
769
|
+
this._maybeHandleNotify(n);
|
|
765
770
|
break;
|
|
766
771
|
}
|
|
767
|
-
case
|
|
768
|
-
this._triggerShareState(
|
|
772
|
+
case O: {
|
|
773
|
+
this._triggerShareState(n);
|
|
769
774
|
break;
|
|
770
775
|
}
|
|
771
|
-
case
|
|
772
|
-
this._triggerMainCamControl(
|
|
776
|
+
case De: {
|
|
777
|
+
this._triggerMainCamControl(n);
|
|
773
778
|
break;
|
|
774
779
|
}
|
|
775
|
-
case
|
|
776
|
-
this._triggerMicControl(
|
|
780
|
+
case zt: {
|
|
781
|
+
this._triggerMicControl(n);
|
|
777
782
|
break;
|
|
778
783
|
}
|
|
779
|
-
case
|
|
780
|
-
this._triggerUseLicense(
|
|
784
|
+
case Qt: {
|
|
785
|
+
this._triggerUseLicense(n);
|
|
781
786
|
break;
|
|
782
787
|
}
|
|
783
|
-
case
|
|
784
|
-
this._maybeTriggerParticipantMoveRequestToSpectators(
|
|
788
|
+
case an: {
|
|
789
|
+
this._maybeTriggerParticipantMoveRequestToSpectators(n);
|
|
785
790
|
break;
|
|
786
791
|
}
|
|
787
792
|
}
|
|
@@ -790,40 +795,40 @@ class an {
|
|
|
790
795
|
this._maybeHandleNotify(e);
|
|
791
796
|
});
|
|
792
797
|
i(this, "_maybeHandleNotify", (e) => {
|
|
793
|
-
const t = e.getHeader(
|
|
798
|
+
const t = e.getHeader(En);
|
|
794
799
|
if (t) {
|
|
795
|
-
const
|
|
796
|
-
this._handleNotify(
|
|
800
|
+
const n = JSON.parse(t);
|
|
801
|
+
this._handleNotify(n);
|
|
797
802
|
}
|
|
798
803
|
});
|
|
799
804
|
i(this, "_handleEnded", (e) => {
|
|
800
805
|
const { originator: t } = e;
|
|
801
|
-
t ===
|
|
806
|
+
t === we && this._sessionEvents.trigger(ne, e), this._restoreSession();
|
|
802
807
|
});
|
|
803
|
-
this.JsSIP = e, this._sessionEvents = new
|
|
808
|
+
this.JsSIP = e, this._sessionEvents = new Pe(Et), this._uaEvents = new Pe(_t), this._cancelableConnect = new N(
|
|
804
809
|
this._connect,
|
|
805
810
|
{
|
|
806
|
-
moduleName:
|
|
811
|
+
moduleName: g,
|
|
807
812
|
afterCancelRequest: () => {
|
|
808
813
|
this._cancelableInitUa.cancelRequest(), this._cancelableDisconnect.cancelRequest();
|
|
809
814
|
}
|
|
810
815
|
}
|
|
811
816
|
), this._cancelableInitUa = new N(
|
|
812
817
|
this._initUa,
|
|
813
|
-
{ moduleName:
|
|
818
|
+
{ moduleName: g }
|
|
814
819
|
), this._cancelableDisconnect = new N(
|
|
815
820
|
this._disconnect,
|
|
816
|
-
{ moduleName:
|
|
821
|
+
{ moduleName: g }
|
|
817
822
|
), this._cancelableSet = new N(this._set, {
|
|
818
|
-
moduleName:
|
|
823
|
+
moduleName: g
|
|
819
824
|
}), this._cancelableCall = new N(
|
|
820
825
|
this._call,
|
|
821
|
-
{ moduleName:
|
|
822
|
-
), this._cancelableAnswer = new N(this._answer, { moduleName:
|
|
826
|
+
{ moduleName: g }
|
|
827
|
+
), this._cancelableAnswer = new N(this._answer, { moduleName: g }), this._cancelableSendDTMF = new N(this._sendDTMF, { moduleName: g }), this.onSession(M, this._handleShareState), this.onSession(Ae, this._handleNewInfo), this.on(X, this._handleSipEvent), this.onSession(A, this._handleEnded), this.onSession(P, this._handleEnded);
|
|
823
828
|
}
|
|
824
829
|
async register() {
|
|
825
830
|
return new Promise((e, t) => {
|
|
826
|
-
this.isRegisterConfig && this.ua ? (this.ua.on(
|
|
831
|
+
this.isRegisterConfig && this.ua ? (this.ua.on(f, e), this.ua.on(p, t), this.ua.register()) : t(new Error("Config is not registered"));
|
|
827
832
|
});
|
|
828
833
|
}
|
|
829
834
|
async unregister() {
|
|
@@ -831,16 +836,16 @@ class an {
|
|
|
831
836
|
this.isRegistered && this.ua ? (this.ua.on($, e), this.ua.unregister()) : t(new Error("ua is not registered"));
|
|
832
837
|
});
|
|
833
838
|
}
|
|
834
|
-
async sendOptions(e, t,
|
|
839
|
+
async sendOptions(e, t, n) {
|
|
835
840
|
if (!this.ua)
|
|
836
841
|
throw new Error("is not connected");
|
|
837
|
-
return new Promise((
|
|
842
|
+
return new Promise((s, o) => {
|
|
838
843
|
try {
|
|
839
844
|
this.ua.sendOptions(e, t, {
|
|
840
|
-
extraHeaders:
|
|
845
|
+
extraHeaders: n,
|
|
841
846
|
eventHandlers: {
|
|
842
847
|
succeeded: () => {
|
|
843
|
-
|
|
848
|
+
s();
|
|
844
849
|
},
|
|
845
850
|
failed: o
|
|
846
851
|
}
|
|
@@ -851,35 +856,33 @@ class an {
|
|
|
851
856
|
});
|
|
852
857
|
}
|
|
853
858
|
async ping(e, t) {
|
|
854
|
-
var
|
|
855
|
-
if (!((
|
|
859
|
+
var s;
|
|
860
|
+
if (!((s = this.ua) != null && s.configuration.uri))
|
|
856
861
|
throw new Error("is not connected");
|
|
857
|
-
const
|
|
858
|
-
return this.sendOptions(
|
|
862
|
+
const n = this.ua.configuration.uri;
|
|
863
|
+
return this.sendOptions(n, e, t);
|
|
859
864
|
}
|
|
860
865
|
async checkTelephony({
|
|
861
866
|
userAgent: e,
|
|
862
867
|
displayName: t,
|
|
863
|
-
sipServerUrl:
|
|
864
|
-
sipWebSocketServerURL:
|
|
865
|
-
sdpSemantics: o
|
|
868
|
+
sipServerUrl: n,
|
|
869
|
+
sipWebSocketServerURL: s
|
|
866
870
|
}) {
|
|
867
|
-
return new Promise((
|
|
868
|
-
const { configuration:
|
|
869
|
-
sipWebSocketServerURL:
|
|
871
|
+
return new Promise((o, a) => {
|
|
872
|
+
const { configuration: c } = this.createUaConfiguration({
|
|
873
|
+
sipWebSocketServerURL: s,
|
|
870
874
|
displayName: t,
|
|
871
|
-
sdpSemantics: o,
|
|
872
875
|
userAgent: e,
|
|
873
|
-
sipServerUrl:
|
|
874
|
-
}),
|
|
876
|
+
sipServerUrl: n
|
|
877
|
+
}), _ = this._createUa(c), E = () => {
|
|
875
878
|
const d = new Error("Telephony is not available");
|
|
876
|
-
|
|
879
|
+
a(d);
|
|
877
880
|
};
|
|
878
|
-
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
+
_.once(S, E);
|
|
882
|
+
const h = () => {
|
|
883
|
+
_.removeAllListeners(), _.once(S, o), _.stop();
|
|
881
884
|
};
|
|
882
|
-
|
|
885
|
+
_.once(m, h), _.start();
|
|
883
886
|
});
|
|
884
887
|
}
|
|
885
888
|
async replaceMediaStream(e, t) {
|
|
@@ -890,84 +893,103 @@ class an {
|
|
|
890
893
|
async askPermissionToEnableCam(e = {}) {
|
|
891
894
|
if (!this.session)
|
|
892
895
|
throw new Error("No session established");
|
|
893
|
-
const t = [
|
|
894
|
-
return this.session.sendInfo(
|
|
896
|
+
const t = [Cn];
|
|
897
|
+
return this.session.sendInfo(De, void 0, {
|
|
895
898
|
noTerminateWhenError: !0,
|
|
896
899
|
...e,
|
|
897
900
|
extraHeaders: t
|
|
898
|
-
}).catch((
|
|
899
|
-
if (
|
|
900
|
-
throw
|
|
901
|
+
}).catch((n) => {
|
|
902
|
+
if (Pn(n))
|
|
903
|
+
throw n;
|
|
901
904
|
});
|
|
902
905
|
}
|
|
903
906
|
get isPendingPresentation() {
|
|
904
907
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
905
908
|
}
|
|
909
|
+
async _sendPresentationWithDuplicatedCalls({
|
|
910
|
+
session: e,
|
|
911
|
+
stream: t,
|
|
912
|
+
presentationOptions: n,
|
|
913
|
+
options: s = {
|
|
914
|
+
callLimit: Wn
|
|
915
|
+
}
|
|
916
|
+
}) {
|
|
917
|
+
const o = async () => this._sendPresentation(e, t, n), a = () => !!this._streamPresentationCurrent;
|
|
918
|
+
return this._cancelableSendPresentationWithRepeatedCalls = Oe({
|
|
919
|
+
targetFunction: o,
|
|
920
|
+
isComplete: a,
|
|
921
|
+
isRejectAsValid: !0,
|
|
922
|
+
...s
|
|
923
|
+
}), this._cancelableSendPresentationWithRepeatedCalls.then((c) => {
|
|
924
|
+
if (c instanceof MediaStream)
|
|
925
|
+
return c;
|
|
926
|
+
throw c;
|
|
927
|
+
});
|
|
928
|
+
}
|
|
906
929
|
hasEqualConnectionConfiguration(e) {
|
|
907
|
-
var
|
|
908
|
-
const { configuration: t } = this.createUaConfiguration(e),
|
|
909
|
-
return (
|
|
930
|
+
var s;
|
|
931
|
+
const { configuration: t } = this.createUaConfiguration(e), n = (s = this.ua) == null ? void 0 : s.configuration;
|
|
932
|
+
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;
|
|
910
933
|
}
|
|
911
934
|
createUaConfiguration({
|
|
912
935
|
user: e,
|
|
913
936
|
password: t,
|
|
914
|
-
sipWebSocketServerURL:
|
|
915
|
-
displayName:
|
|
937
|
+
sipWebSocketServerURL: n,
|
|
938
|
+
displayName: s = "",
|
|
916
939
|
sipServerUrl: o,
|
|
917
940
|
register: a = !1,
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
registerExpires: E = 60 * 5,
|
|
941
|
+
sessionTimers: c = !1,
|
|
942
|
+
registerExpires: _ = 60 * 5,
|
|
921
943
|
// 5 minutes in sec
|
|
922
|
-
connectionRecoveryMinInterval:
|
|
923
|
-
connectionRecoveryMaxInterval:
|
|
944
|
+
connectionRecoveryMinInterval: E = 2,
|
|
945
|
+
connectionRecoveryMaxInterval: h = 6,
|
|
924
946
|
userAgent: d
|
|
925
947
|
}) {
|
|
926
948
|
if (a && !t)
|
|
927
949
|
throw new Error("password is required for authorized connection");
|
|
928
|
-
const
|
|
950
|
+
const l = a && e ? e.trim() : `${Rn()}`, T = gn(o), u = T(l), C = new this.JsSIP.WebSocketInterface(n);
|
|
929
951
|
return {
|
|
930
952
|
configuration: {
|
|
931
953
|
password: t,
|
|
932
954
|
register: a,
|
|
933
|
-
uri:
|
|
934
|
-
display_name:
|
|
955
|
+
uri: u,
|
|
956
|
+
display_name: be(s),
|
|
935
957
|
user_agent: d,
|
|
936
|
-
sdp_semantics:
|
|
937
|
-
sockets: [
|
|
938
|
-
session_timers:
|
|
939
|
-
register_expires:
|
|
940
|
-
connection_recovery_min_interval:
|
|
941
|
-
connection_recovery_max_interval:
|
|
958
|
+
sdp_semantics: "unified-plan",
|
|
959
|
+
sockets: [C],
|
|
960
|
+
session_timers: c,
|
|
961
|
+
register_expires: _,
|
|
962
|
+
connection_recovery_min_interval: E,
|
|
963
|
+
connection_recovery_max_interval: h
|
|
942
964
|
},
|
|
943
965
|
helpers: {
|
|
944
|
-
socket:
|
|
945
|
-
getSipServerUrl:
|
|
966
|
+
socket: C,
|
|
967
|
+
getSipServerUrl: T
|
|
946
968
|
}
|
|
947
969
|
};
|
|
948
970
|
}
|
|
949
971
|
async _sendPresentation(e, t, {
|
|
950
|
-
maxBitrate:
|
|
951
|
-
degradationPreference:
|
|
972
|
+
maxBitrate: n,
|
|
973
|
+
degradationPreference: s,
|
|
952
974
|
isNeedReinvite: o = !0,
|
|
953
975
|
isP2P: a = !1
|
|
954
976
|
}) {
|
|
955
977
|
const c = W(t);
|
|
956
978
|
this._streamPresentationCurrent = c;
|
|
957
|
-
const _ = a ? [
|
|
979
|
+
const _ = a ? [Tn] : [hn], E = e.sendInfo(O, void 0, {
|
|
958
980
|
extraHeaders: _
|
|
959
981
|
}).then(async () => e.startPresentation(
|
|
960
982
|
c,
|
|
961
983
|
o,
|
|
962
|
-
|
|
984
|
+
s
|
|
963
985
|
)).then(async () => {
|
|
964
986
|
const { connection: h } = this;
|
|
965
|
-
if (!h ||
|
|
987
|
+
if (!h || n === void 0)
|
|
966
988
|
return;
|
|
967
|
-
const
|
|
968
|
-
await
|
|
989
|
+
const d = h.getSenders();
|
|
990
|
+
await wn(d, t, n);
|
|
969
991
|
}).then(() => t).catch((h) => {
|
|
970
|
-
throw this._sessionEvents.trigger(
|
|
992
|
+
throw this._removeStreamPresentationCurrent(), this._sessionEvents.trigger(U, h), h;
|
|
971
993
|
});
|
|
972
994
|
return this.promisePendingStartPresentation = E, E.finally(() => {
|
|
973
995
|
this.promisePendingStartPresentation = void 0;
|
|
@@ -975,45 +997,51 @@ class an {
|
|
|
975
997
|
}
|
|
976
998
|
async startPresentation(e, {
|
|
977
999
|
isNeedReinvite: t = !0,
|
|
978
|
-
isP2P:
|
|
979
|
-
maxBitrate:
|
|
1000
|
+
isP2P: n = !1,
|
|
1001
|
+
maxBitrate: s,
|
|
980
1002
|
degradationPreference: o
|
|
981
|
-
} = {}) {
|
|
982
|
-
const
|
|
983
|
-
if (!
|
|
1003
|
+
} = {}, a) {
|
|
1004
|
+
const c = this.establishedSession;
|
|
1005
|
+
if (!c)
|
|
984
1006
|
throw new Error("No session established");
|
|
985
1007
|
if (this._streamPresentationCurrent)
|
|
986
1008
|
throw new Error("Presentation is already started");
|
|
987
|
-
return
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1009
|
+
return n && await this.sendMustStopPresentation(c), this._sendPresentationWithDuplicatedCalls({
|
|
1010
|
+
session: c,
|
|
1011
|
+
stream: e,
|
|
1012
|
+
presentationOptions: {
|
|
1013
|
+
isNeedReinvite: t,
|
|
1014
|
+
isP2P: n,
|
|
1015
|
+
maxBitrate: s,
|
|
1016
|
+
degradationPreference: o
|
|
1017
|
+
},
|
|
1018
|
+
options: a
|
|
992
1019
|
});
|
|
993
1020
|
}
|
|
994
1021
|
async sendMustStopPresentation(e) {
|
|
995
|
-
await e.sendInfo(
|
|
996
|
-
extraHeaders: [
|
|
1022
|
+
await e.sendInfo(O, void 0, {
|
|
1023
|
+
extraHeaders: [dn]
|
|
997
1024
|
});
|
|
998
1025
|
}
|
|
999
1026
|
async stopPresentation({
|
|
1000
1027
|
isP2P: e = !1
|
|
1001
1028
|
} = {}) {
|
|
1029
|
+
this._cancelSendPresentationWithRepeatedCalls();
|
|
1002
1030
|
const t = this._streamPresentationCurrent;
|
|
1003
|
-
let
|
|
1004
|
-
const
|
|
1005
|
-
return o && t && (
|
|
1006
|
-
extraHeaders:
|
|
1031
|
+
let n = this.promisePendingStartPresentation ?? Promise.resolve();
|
|
1032
|
+
const s = e ? [Sn] : [ln], o = this.establishedSession;
|
|
1033
|
+
return o && t && (n = n.then(async () => o.sendInfo(O, void 0, {
|
|
1034
|
+
extraHeaders: s
|
|
1007
1035
|
})).then(async () => o.stopPresentation(t)).catch((a) => {
|
|
1008
|
-
throw this._sessionEvents.trigger(
|
|
1009
|
-
})), !o && t && this._sessionEvents.trigger(Re, t), this.promisePendingStopPresentation =
|
|
1036
|
+
throw this._sessionEvents.trigger(U, a), a;
|
|
1037
|
+
})), !o && t && this._sessionEvents.trigger(Re, t), this.promisePendingStopPresentation = n, n.finally(() => {
|
|
1010
1038
|
this._resetPresentation();
|
|
1011
1039
|
});
|
|
1012
1040
|
}
|
|
1013
1041
|
async updatePresentation(e, {
|
|
1014
1042
|
isP2P: t = !1,
|
|
1015
|
-
maxBitrate:
|
|
1016
|
-
degradationPreference:
|
|
1043
|
+
maxBitrate: n,
|
|
1044
|
+
degradationPreference: s
|
|
1017
1045
|
} = {}) {
|
|
1018
1046
|
const o = this.establishedSession;
|
|
1019
1047
|
if (!o)
|
|
@@ -1022,13 +1050,19 @@ class an {
|
|
|
1022
1050
|
throw new Error("Presentation has not started yet");
|
|
1023
1051
|
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this._sendPresentation(o, e, {
|
|
1024
1052
|
isP2P: t,
|
|
1025
|
-
maxBitrate:
|
|
1026
|
-
degradationPreference:
|
|
1053
|
+
maxBitrate: n,
|
|
1054
|
+
degradationPreference: s,
|
|
1027
1055
|
isNeedReinvite: !1
|
|
1028
1056
|
});
|
|
1029
1057
|
}
|
|
1058
|
+
_removeStreamPresentationCurrent() {
|
|
1059
|
+
delete this._streamPresentationCurrent;
|
|
1060
|
+
}
|
|
1030
1061
|
_resetPresentation() {
|
|
1031
|
-
|
|
1062
|
+
this._removeStreamPresentationCurrent(), this.promisePendingStartPresentation = void 0, this.promisePendingStopPresentation = void 0;
|
|
1063
|
+
}
|
|
1064
|
+
_cancelRequestsAndResetPresentation() {
|
|
1065
|
+
this._cancelSendPresentationWithRepeatedCalls(), this._resetPresentation();
|
|
1032
1066
|
}
|
|
1033
1067
|
on(e, t) {
|
|
1034
1068
|
return this._uaEvents.on(e, t);
|
|
@@ -1069,18 +1103,18 @@ class an {
|
|
|
1069
1103
|
getRemoteStreams() {
|
|
1070
1104
|
if (!this.connection)
|
|
1071
1105
|
return;
|
|
1072
|
-
const t = this.connection.getReceivers().map(({ track:
|
|
1073
|
-
return
|
|
1106
|
+
const t = this.connection.getReceivers().map(({ track: n }) => n);
|
|
1107
|
+
return In(t) ? this._generateStreams(t) : this._generateAudioStreams(t);
|
|
1074
1108
|
}
|
|
1075
1109
|
get connection() {
|
|
1076
1110
|
var t;
|
|
1077
1111
|
return (t = this.session) == null ? void 0 : t.connection;
|
|
1078
1112
|
}
|
|
1079
1113
|
get remoteCallerData() {
|
|
1080
|
-
var e, t,
|
|
1114
|
+
var e, t, n, s, o, a;
|
|
1081
1115
|
return {
|
|
1082
1116
|
displayName: (t = (e = this.incomingSession) == null ? void 0 : e.remote_identity) == null ? void 0 : t.display_name,
|
|
1083
|
-
host: (
|
|
1117
|
+
host: (s = (n = this.incomingSession) == null ? void 0 : n.remote_identity) == null ? void 0 : s.uri.host,
|
|
1084
1118
|
incomingNumber: (a = (o = this.incomingSession) == null ? void 0 : o.remote_identity) == null ? void 0 : a.uri.user,
|
|
1085
1119
|
session: this.incomingSession
|
|
1086
1120
|
};
|
|
@@ -1105,19 +1139,19 @@ class an {
|
|
|
1105
1139
|
return !!this.incomingSession;
|
|
1106
1140
|
}
|
|
1107
1141
|
_generateStream(e, t) {
|
|
1108
|
-
const { id:
|
|
1109
|
-
return t &&
|
|
1142
|
+
const { id: n } = e, s = this._remoteStreams[n] || new MediaStream();
|
|
1143
|
+
return t && s.addTrack(t), s.addTrack(e), this._remoteStreams[n] = s, s;
|
|
1110
1144
|
}
|
|
1111
1145
|
_generateAudioStream(e) {
|
|
1112
|
-
const { id: t } = e,
|
|
1113
|
-
return
|
|
1146
|
+
const { id: t } = e, n = this._remoteStreams[t] || new MediaStream();
|
|
1147
|
+
return n.addTrack(e), this._remoteStreams[t] = n, n;
|
|
1114
1148
|
}
|
|
1115
1149
|
_generateStreams(e) {
|
|
1116
1150
|
const t = [];
|
|
1117
|
-
return e.forEach((
|
|
1118
|
-
if (
|
|
1151
|
+
return e.forEach((n, s) => {
|
|
1152
|
+
if (n.kind === "audio")
|
|
1119
1153
|
return;
|
|
1120
|
-
const o =
|
|
1154
|
+
const o = n, a = e[s - 1];
|
|
1121
1155
|
let c;
|
|
1122
1156
|
a && a.kind === "audio" && (c = a);
|
|
1123
1157
|
const _ = this._generateStream(o, c);
|
|
@@ -1125,7 +1159,7 @@ class an {
|
|
|
1125
1159
|
}), t;
|
|
1126
1160
|
}
|
|
1127
1161
|
_generateAudioStreams(e) {
|
|
1128
|
-
return e.map((
|
|
1162
|
+
return e.map((n) => this._generateAudioStream(n));
|
|
1129
1163
|
}
|
|
1130
1164
|
_cancelRequests() {
|
|
1131
1165
|
this._cancelActionsRequests(), this._cancelCallRequests(), this._cancelConnectWithRepeatedCalls();
|
|
@@ -1134,6 +1168,10 @@ class an {
|
|
|
1134
1168
|
var e;
|
|
1135
1169
|
(e = this._cancelableConnectWithRepeatedCalls) == null || e.cancel();
|
|
1136
1170
|
}
|
|
1171
|
+
_cancelSendPresentationWithRepeatedCalls() {
|
|
1172
|
+
var e;
|
|
1173
|
+
(e = this._cancelableSendPresentationWithRepeatedCalls) == null || e.cancel();
|
|
1174
|
+
}
|
|
1137
1175
|
_cancelCallRequests() {
|
|
1138
1176
|
this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest();
|
|
1139
1177
|
}
|
|
@@ -1141,39 +1179,39 @@ class an {
|
|
|
1141
1179
|
this._cancelableAnswer.cancelRequest(), this._cancelableSendDTMF.cancelRequest();
|
|
1142
1180
|
}
|
|
1143
1181
|
async waitChannels() {
|
|
1144
|
-
return this.waitSession(
|
|
1182
|
+
return this.waitSession(v);
|
|
1145
1183
|
}
|
|
1146
1184
|
async waitSyncMediaState() {
|
|
1147
|
-
return this.waitSession(
|
|
1185
|
+
return this.waitSession(y);
|
|
1148
1186
|
}
|
|
1149
1187
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
1150
1188
|
if (!this.session)
|
|
1151
1189
|
throw new Error("No session established");
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
|
|
1190
|
+
const n = `${Me}: ${e}`, s = `${ve}: ${t}`, o = [
|
|
1191
|
+
n,
|
|
1192
|
+
s
|
|
1155
1193
|
];
|
|
1156
|
-
return this.session.sendInfo(
|
|
1194
|
+
return this.session.sendInfo($t, void 0, { extraHeaders: o });
|
|
1157
1195
|
}
|
|
1158
|
-
async sendMediaState({ cam: e, mic: t },
|
|
1196
|
+
async sendMediaState({ cam: e, mic: t }, n = {}) {
|
|
1159
1197
|
if (!this.session)
|
|
1160
1198
|
throw new Error("No session established");
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1199
|
+
const s = `${nn}: currentstate`, o = `${rn}: ${Number(e)}`, a = `${on}: ${Number(t)}`, c = [
|
|
1200
|
+
s,
|
|
1163
1201
|
o,
|
|
1164
1202
|
a
|
|
1165
1203
|
];
|
|
1166
|
-
return this.session.sendInfo(
|
|
1204
|
+
return this.session.sendInfo(Xt, void 0, {
|
|
1167
1205
|
noTerminateWhenError: !0,
|
|
1168
|
-
...
|
|
1206
|
+
...n,
|
|
1169
1207
|
extraHeaders: c
|
|
1170
1208
|
});
|
|
1171
1209
|
}
|
|
1172
1210
|
async _sendRefusalToTurnOn(e, t = {}) {
|
|
1173
1211
|
if (!this.session)
|
|
1174
1212
|
throw new Error("No session established");
|
|
1175
|
-
const c = [`${
|
|
1176
|
-
return this.session.sendInfo(
|
|
1213
|
+
const c = [`${sn}: ${e === "mic" ? 0 : 1}`];
|
|
1214
|
+
return this.session.sendInfo(Jt, void 0, {
|
|
1177
1215
|
noTerminateWhenError: !0,
|
|
1178
1216
|
...t,
|
|
1179
1217
|
extraHeaders: c
|
|
@@ -1191,22 +1229,22 @@ class an {
|
|
|
1191
1229
|
}
|
|
1192
1230
|
}
|
|
1193
1231
|
export {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1232
|
+
Ft as B,
|
|
1233
|
+
I as E,
|
|
1234
|
+
Mt as N,
|
|
1197
1235
|
Le as R,
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1236
|
+
as as S,
|
|
1237
|
+
_t as U,
|
|
1238
|
+
ns as a,
|
|
1239
|
+
is as b,
|
|
1240
|
+
ts as c,
|
|
1241
|
+
rs as d,
|
|
1242
|
+
ss as e,
|
|
1205
1243
|
k as f,
|
|
1206
1244
|
q as g,
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1245
|
+
os as h,
|
|
1246
|
+
Nn as i,
|
|
1247
|
+
Et as j,
|
|
1248
|
+
H as l,
|
|
1249
|
+
bn as s
|
|
1212
1250
|
};
|