sip-connector 6.24.1 → 6.24.3
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-BWd7Anni.cjs +1 -0
- package/dist/{SipConnector-1HoiCnsj.js → SipConnector-BfKQCTIn.js} +300 -289
- package/dist/SipConnector.d.ts +9 -8
- package/dist/__fixtures__/RTCRtpSenderMock.d.ts +1 -0
- package/dist/__fixtures__/index.d.ts +4 -4
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/headers.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +54 -52
- package/dist/tools/__fixtures__/call.d.ts +1 -1
- package/dist/tools/__fixtures__/connectToServer.d.ts +2 -2
- package/dist/tools/hasPurgatory.d.ts +1 -1
- package/package.json +10 -10
- package/dist/SipConnector-eRr2JbY9.cjs +0 -1
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (
|
|
4
|
-
import { CancelableRequest as
|
|
1
|
+
var gt = Object.defineProperty;
|
|
2
|
+
var Ct = (o, e, t) => e in o ? gt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var i = (o, e, t) => (Ct(o, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { CancelableRequest as N, isCanceledError as At } from "@krivega/cancelable-promise";
|
|
5
5
|
import fe from "events-constructor";
|
|
6
6
|
import F from "debug";
|
|
7
|
-
const
|
|
7
|
+
const Rt = "Connection Error", be = "Request Timeout", It = "SIP Failure Code", mt = "Internal Error", ft = "Busy", Ue = "Rejected", Ot = "Redirected", Dt = "Unavailable", Mt = "Not Found", Pt = "Address Incomplete", pt = "Incompatible SDP", vt = "Missing SDP", wt = "Authentication Error", Le = "Terminated", yt = "WebRTC Error", He = "Canceled", bt = "No Answer", Ut = "Expires", Lt = "No ACK", Ht = "Dialog Error", kt = "User Denied Media Access", qt = "Bad Media Description", Wt = "RTP Timeout", Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
8
8
|
__proto__: null,
|
|
9
|
-
ADDRESS_INCOMPLETE:
|
|
10
|
-
AUTHENTICATION_ERROR:
|
|
11
|
-
BAD_MEDIA_DESCRIPTION:
|
|
12
|
-
BUSY:
|
|
9
|
+
ADDRESS_INCOMPLETE: Pt,
|
|
10
|
+
AUTHENTICATION_ERROR: wt,
|
|
11
|
+
BAD_MEDIA_DESCRIPTION: qt,
|
|
12
|
+
BUSY: ft,
|
|
13
13
|
BYE: Le,
|
|
14
14
|
CANCELED: He,
|
|
15
|
-
CONNECTION_ERROR:
|
|
16
|
-
DIALOG_ERROR:
|
|
17
|
-
EXPIRES:
|
|
18
|
-
INCOMPATIBLE_SDP:
|
|
19
|
-
INTERNAL_ERROR:
|
|
20
|
-
MISSING_SDP:
|
|
21
|
-
NOT_FOUND:
|
|
22
|
-
NO_ACK:
|
|
23
|
-
NO_ANSWER:
|
|
24
|
-
REDIRECTED:
|
|
15
|
+
CONNECTION_ERROR: Rt,
|
|
16
|
+
DIALOG_ERROR: Ht,
|
|
17
|
+
EXPIRES: Ut,
|
|
18
|
+
INCOMPATIBLE_SDP: pt,
|
|
19
|
+
INTERNAL_ERROR: mt,
|
|
20
|
+
MISSING_SDP: vt,
|
|
21
|
+
NOT_FOUND: Mt,
|
|
22
|
+
NO_ACK: Lt,
|
|
23
|
+
NO_ANSWER: bt,
|
|
24
|
+
REDIRECTED: Ot,
|
|
25
25
|
REJECTED: Ue,
|
|
26
26
|
REQUEST_TIMEOUT: be,
|
|
27
|
-
RTP_TIMEOUT:
|
|
28
|
-
SIP_FAILURE_CODE:
|
|
29
|
-
UNAVAILABLE:
|
|
30
|
-
USER_DENIED_MEDIA_ACCESS:
|
|
31
|
-
WEBRTC_ERROR:
|
|
32
|
-
}, Symbol.toStringTag, { value: "Module" })), B = "incomingCall", V = "declinedIncomingCall", Y = "failedIncomingCall", x = "terminatedIncomingCall",
|
|
27
|
+
RTP_TIMEOUT: Wt,
|
|
28
|
+
SIP_FAILURE_CODE: It,
|
|
29
|
+
UNAVAILABLE: Dt,
|
|
30
|
+
USER_DENIED_MEDIA_ACCESS: kt,
|
|
31
|
+
WEBRTC_ERROR: yt
|
|
32
|
+
}, Symbol.toStringTag, { value: "Module" })), B = "incomingCall", V = "declinedIncomingCall", Y = "failedIncomingCall", x = "terminatedIncomingCall", L = "connecting", m = "connected", T = "disconnected", P = "newRTCSession", f = "registered", $ = "unregistered", O = "registrationFailed", ke = "newMessage", G = "sipEvent", X = "availableSecondRemoteStream", J = "notAvailableSecondRemoteStream", z = "mustStopPresentation", p = "shareState", Q = "enterRoom", K = "useLicense", j = "peerconnection:confirmed", Z = "peerconnection:ontrack", v = "channels", ee = "channels:notify", te = "ended:fromserver", se = "main-cam-control", ne = "admin-stop-main-cam", ie = "admin-start-main-cam", oe = "admin-stop-mic", re = "admin-start-mic", w = "admin-force-sync-media-state", ae = "participant:added-to-list-moderators", ce = "participant:removed-from-list-moderators", Ee = "participant:move-request-to-stream", _e = "participation:accepting-word-request", he = "participation:cancelling-word-request", de = "webcast:started", le = "webcast:stopped", ue = "account:changed", Te = "account:deleted", Se = "conference:participant-token-issued", D = "ended", qe = "sending", We = "reinvite", Fe = "replaces", Be = "refer", Ve = "progress", Ye = "accepted", y = "confirmed", b = "peerconnection", C = "failed", xe = "muted", $e = "unmuted", Ne = "newDTMF", ge = "newInfo", Ge = "hold", Xe = "unhold", Je = "update", ze = "sdp", Qe = "icecandidate", Ke = "getusermediafailed", je = "peerconnection:createofferfailed", Ze = "peerconnection:createanswerfailed", et = "peerconnection:setlocaldescriptionfailed", tt = "peerconnection:setremotedescriptionfailed", st = "presentation:start", nt = "presentation:started", it = "presentation:end", Ce = "presentation:ended", U = "presentation:failed", xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
33
33
|
__proto__: null,
|
|
34
34
|
ACCEPTED: Ye,
|
|
35
35
|
ACCOUNT_CHANGED: ue,
|
|
36
36
|
ACCOUNT_DELETED: Te,
|
|
37
|
-
ADMIN_FORCE_SYNC_MEDIA_STATE:
|
|
37
|
+
ADMIN_FORCE_SYNC_MEDIA_STATE: w,
|
|
38
38
|
ADMIN_START_MAIN_CAM: ie,
|
|
39
|
-
ADMIN_START_MIC:
|
|
39
|
+
ADMIN_START_MIC: re,
|
|
40
40
|
ADMIN_STOP_MAIN_CAM: ne,
|
|
41
|
-
ADMIN_STOP_MIC:
|
|
41
|
+
ADMIN_STOP_MIC: oe,
|
|
42
42
|
AVAILABLE_SECOND_REMOTE_STREAM_EVENT: X,
|
|
43
|
-
CHANNELS:
|
|
43
|
+
CHANNELS: v,
|
|
44
44
|
CHANNELS_NOTIFY: ee,
|
|
45
45
|
CONFERENCE_PARTICIPANT_TOKEN_ISSUED: Se,
|
|
46
|
-
CONFIRMED:
|
|
47
|
-
CONNECTED:
|
|
48
|
-
CONNECTING:
|
|
46
|
+
CONFIRMED: y,
|
|
47
|
+
CONNECTED: m,
|
|
48
|
+
CONNECTING: L,
|
|
49
49
|
DECLINED_INCOMING_CALL: V,
|
|
50
50
|
DISCONNECTED: T,
|
|
51
|
-
ENDED:
|
|
51
|
+
ENDED: D,
|
|
52
52
|
ENDED_FROM_SERVER: te,
|
|
53
53
|
ENTER_ROOM: Q,
|
|
54
54
|
FAILED: C,
|
|
55
55
|
FAILED_INCOMING_CALL: Y,
|
|
56
56
|
GET_USER_MEDIA_FAILED: Ke,
|
|
57
|
-
HOLD:
|
|
57
|
+
HOLD: Ge,
|
|
58
58
|
ICE_CANDIDATE: Qe,
|
|
59
59
|
INCOMING_CALL: B,
|
|
60
60
|
MAIN_CAM_CONTROL: se,
|
|
@@ -63,14 +63,14 @@ const At = "Connection Error", be = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
63
63
|
NEW_DTMF: Ne,
|
|
64
64
|
NEW_INFO: ge,
|
|
65
65
|
NEW_MESSAGE: ke,
|
|
66
|
-
NEW_RTC_SESSION:
|
|
66
|
+
NEW_RTC_SESSION: P,
|
|
67
67
|
NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: J,
|
|
68
68
|
PARTICIPANT_ADDED_TO_LIST_MODERATORS: ae,
|
|
69
69
|
PARTICIPANT_MOVE_REQUEST_TO_STREAM: Ee,
|
|
70
70
|
PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: ce,
|
|
71
71
|
PARTICIPATION_ACCEPTING_WORD_REQUEST: _e,
|
|
72
72
|
PARTICIPATION_CANCELLING_WORD_REQUEST: he,
|
|
73
|
-
PEER_CONNECTION:
|
|
73
|
+
PEER_CONNECTION: b,
|
|
74
74
|
PEER_CONNECTION_CONFIRMED: j,
|
|
75
75
|
PEER_CONNECTION_CREATE_ANSWER_FAILED: Ze,
|
|
76
76
|
PEER_CONNECTION_CREATE_OFFER_FAILED: je,
|
|
@@ -79,28 +79,28 @@ const At = "Connection Error", be = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
79
79
|
PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED: tt,
|
|
80
80
|
PRESENTATION_END: it,
|
|
81
81
|
PRESENTATION_ENDED: Ce,
|
|
82
|
-
PRESENTATION_FAILED:
|
|
82
|
+
PRESENTATION_FAILED: U,
|
|
83
83
|
PRESENTATION_START: st,
|
|
84
84
|
PRESENTATION_STARTED: nt,
|
|
85
85
|
PROGRESS: Ve,
|
|
86
86
|
REFER: Be,
|
|
87
|
-
REGISTERED:
|
|
88
|
-
REGISTRATION_FAILED:
|
|
87
|
+
REGISTERED: f,
|
|
88
|
+
REGISTRATION_FAILED: O,
|
|
89
89
|
REINVITE: We,
|
|
90
90
|
REPLACES: Fe,
|
|
91
91
|
SDP: ze,
|
|
92
92
|
SENDING: qe,
|
|
93
|
-
SHARE_STATE:
|
|
94
|
-
SIP_EVENT:
|
|
93
|
+
SHARE_STATE: p,
|
|
94
|
+
SIP_EVENT: G,
|
|
95
95
|
TERMINATED_INCOMING_CALL: x,
|
|
96
96
|
UNHOLD: Xe,
|
|
97
|
-
UNMUTED:
|
|
98
|
-
UNREGISTERED:
|
|
97
|
+
UNMUTED: $e,
|
|
98
|
+
UNREGISTERED: $,
|
|
99
99
|
UPDATE: Je,
|
|
100
100
|
USE_LICENSE: K,
|
|
101
101
|
WEBCAST_STARTED: de,
|
|
102
102
|
WEBCAST_STOPPED: le
|
|
103
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
103
|
+
}, Symbol.toStringTag, { value: "Module" })), ot = [
|
|
104
104
|
B,
|
|
105
105
|
V,
|
|
106
106
|
x,
|
|
@@ -117,49 +117,49 @@ const At = "Connection Error", be = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
117
117
|
ae,
|
|
118
118
|
ce
|
|
119
119
|
], Ae = [
|
|
120
|
-
|
|
121
|
-
I,
|
|
122
|
-
T,
|
|
123
|
-
M,
|
|
120
|
+
L,
|
|
124
121
|
m,
|
|
125
|
-
|
|
122
|
+
T,
|
|
123
|
+
P,
|
|
126
124
|
f,
|
|
125
|
+
$,
|
|
126
|
+
O,
|
|
127
127
|
ke,
|
|
128
|
-
|
|
129
|
-
],
|
|
128
|
+
G
|
|
129
|
+
], rt = [
|
|
130
130
|
X,
|
|
131
131
|
J,
|
|
132
132
|
z,
|
|
133
|
-
|
|
133
|
+
p,
|
|
134
134
|
Q,
|
|
135
135
|
K,
|
|
136
136
|
j,
|
|
137
137
|
Z,
|
|
138
|
-
|
|
138
|
+
v,
|
|
139
139
|
te,
|
|
140
140
|
se,
|
|
141
141
|
ie,
|
|
142
142
|
ne,
|
|
143
|
-
re,
|
|
144
143
|
oe,
|
|
145
|
-
|
|
144
|
+
re,
|
|
145
|
+
w
|
|
146
146
|
], Re = [
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
D,
|
|
148
|
+
L,
|
|
149
149
|
qe,
|
|
150
150
|
We,
|
|
151
151
|
Fe,
|
|
152
152
|
Be,
|
|
153
153
|
Ve,
|
|
154
154
|
Ye,
|
|
155
|
-
w,
|
|
156
155
|
y,
|
|
156
|
+
b,
|
|
157
157
|
C,
|
|
158
158
|
xe,
|
|
159
|
-
|
|
159
|
+
$e,
|
|
160
160
|
Ne,
|
|
161
161
|
ge,
|
|
162
|
-
|
|
162
|
+
Ge,
|
|
163
163
|
Xe,
|
|
164
164
|
Je,
|
|
165
165
|
ze,
|
|
@@ -173,73 +173,73 @@ const At = "Connection Error", be = "Request Timeout", Rt = "SIP Failure Code",
|
|
|
173
173
|
nt,
|
|
174
174
|
it,
|
|
175
175
|
Ce,
|
|
176
|
-
|
|
177
|
-
], at = [...Ae, ...
|
|
176
|
+
U
|
|
177
|
+
], at = [...Ae, ...ot], ct = [
|
|
178
178
|
...Re,
|
|
179
|
-
...
|
|
180
|
-
],
|
|
179
|
+
...rt
|
|
180
|
+
], $s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
181
181
|
__proto__: null,
|
|
182
182
|
SESSION_EVENT_NAMES: ct,
|
|
183
183
|
SESSION_JSSIP_EVENT_NAMES: Re,
|
|
184
|
-
SESSION_SYNTHETICS_EVENT_NAMES:
|
|
184
|
+
SESSION_SYNTHETICS_EVENT_NAMES: rt,
|
|
185
185
|
UA_EVENT_NAMES: at,
|
|
186
186
|
UA_JSSIP_EVENT_NAMES: Ae,
|
|
187
|
-
UA_SYNTHETICS_EVENT_NAMES:
|
|
188
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
187
|
+
UA_SYNTHETICS_EVENT_NAMES: ot
|
|
188
|
+
}, Symbol.toStringTag, { value: "Module" })), Ft = (o) => {
|
|
189
189
|
const e = [];
|
|
190
|
-
return
|
|
191
|
-
},
|
|
190
|
+
return o && e.push(`X-Vinteo-Remote: ${o}`), e;
|
|
191
|
+
}, Bt = "content-type", Vt = "x-webrtc-enter-room", M = "application/vinteo.webrtc.sharedesktop", Yt = "application/vinteo.webrtc.roomname", xt = "application/vinteo.webrtc.channels", $t = "application/vinteo.webrtc.mediastate", Gt = "application/vinteo.webrtc.refusal", Oe = "application/vinteo.webrtc.maincam", Xt = "application/vinteo.webrtc.mic", Jt = "application/vinteo.webrtc.uselic", zt = "X-WEBRTC-USE-LICENSE", De = "X-WEBRTC-INPUT-CHANNELS", Me = "X-WEBRTC-OUTPUT-CHANNELS", Qt = "X-WEBRTC-MAINCAM", Kt = "X-WEBRTC-MIC", Pe = "X-WEBRTC-SYNC", jt = "X-WEBRTC-MAINCAM-RESOLUTION", Zt = "X-WEBRTC-MEDIA-STATE", es = "X-Vinteo-Media-Type", ts = "X-Vinteo-MainCam-State", ss = "X-Vinteo-Mic-State", ns = "application/vinteo.webrtc.notify", is = "X-VINTEO-NOTIFY", A = "x-webrtc-share-state", os = `${A}: LETMESTARTPRESENTATION`, rs = `${A}: STOPPRESENTATION`, Et = "YOUCANRECEIVECONTENT", _t = "CONTENTEND", ht = "YOUMUSTSTOPSENDCONTENT", as = `${A}: ${ht}`, cs = `${A}: ${Et}`, Es = `${A}: ${_t}`, _s = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", hs = `${_s}: LETMESTARTMAINCAM`, Ie = "sip-connector", pe = F(Ie), Gs = () => {
|
|
192
192
|
F.enable(Ie);
|
|
193
|
-
},
|
|
193
|
+
}, Xs = () => {
|
|
194
194
|
F.enable(`-${Ie}`);
|
|
195
195
|
};
|
|
196
|
-
var
|
|
197
|
-
function ve(
|
|
198
|
-
return (e) => `sip:${e}@${
|
|
196
|
+
var I = /* @__PURE__ */ ((o) => (o.PAUSE_MAIN_CAM = "PAUSEMAINCAM", o.RESUME_MAIN_CAM = "RESUMEMAINCAM", o.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", o.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", o.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", o))(I || {}), k = /* @__PURE__ */ ((o) => (o.ADMIN_STOP_MIC = "ADMINSTOPMIC", o.ADMIN_START_MIC = "ADMINSTARTMIC", o))(k || {}), q = /* @__PURE__ */ ((o) => (o.ADMIN_SYNC_FORCED = "1", o.ADMIN_SYNC_NOT_FORCED = "0", o))(q || {}), ds = /* @__PURE__ */ ((o) => (o.AUDIO = "AUDIO", o.VIDEO = "VIDEO", o.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", o))(ds || {});
|
|
197
|
+
function ve(o) {
|
|
198
|
+
return (e) => `sip:${e}@${o}`;
|
|
199
199
|
}
|
|
200
|
-
const
|
|
200
|
+
const ls = (o, e) => () => Math.floor(Math.random() * (e - o)) + o, we = (o) => o.trim().replaceAll(" ", "_"), us = ls(1e5, 99999999), H = (o, {
|
|
201
201
|
videoMode: e,
|
|
202
202
|
audioMode: t
|
|
203
203
|
} = {}) => {
|
|
204
|
-
if (!
|
|
204
|
+
if (!o || e === "recvonly" && t === "recvonly")
|
|
205
205
|
return;
|
|
206
|
-
const s = t === "recvonly" ? [] :
|
|
206
|
+
const s = t === "recvonly" ? [] : o.getAudioTracks(), n = e === "recvonly" ? [] : o.getVideoTracks(), r = [...s, ...n], a = new MediaStream(r);
|
|
207
207
|
return a.getTracks = () => [...a.getAudioTracks(), ...a.getVideoTracks()], a;
|
|
208
|
-
},
|
|
208
|
+
}, Ts = (o) => o.some((t) => {
|
|
209
209
|
const { kind: s } = t;
|
|
210
210
|
return s === "video";
|
|
211
|
-
}),
|
|
212
|
-
|
|
213
|
-
),
|
|
214
|
-
const t =
|
|
215
|
-
if (t !== void 0 &&
|
|
211
|
+
}), Ss = "Error decline with 603", Ns = (o) => o.message === Ss, gs = (o, e) => o.find((t) => t.track && e.getTracks().includes(t.track)), dt = 1, lt = (o) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== o, Cs = lt(
|
|
212
|
+
dt
|
|
213
|
+
), As = (o, e) => {
|
|
214
|
+
const t = o === void 0 ? void 0 : Math.max(o, dt);
|
|
215
|
+
if (t !== void 0 && Cs(
|
|
216
216
|
t,
|
|
217
217
|
e
|
|
218
218
|
))
|
|
219
219
|
return t;
|
|
220
|
-
},
|
|
221
|
-
if (
|
|
222
|
-
return
|
|
223
|
-
},
|
|
224
|
-
const s =
|
|
220
|
+
}, Rs = lt(), Is = (o, e) => {
|
|
221
|
+
if (Rs(o, e))
|
|
222
|
+
return o;
|
|
223
|
+
}, ms = async (o, e, t) => {
|
|
224
|
+
const s = o.getParameters();
|
|
225
225
|
(s.encodings === void 0 || s.encodings.length === 0) && (s.encodings = [{}]);
|
|
226
|
-
const [n] = s.encodings,
|
|
226
|
+
const [n] = s.encodings, r = n.scaleResolutionDownBy, a = As(
|
|
227
227
|
e.scaleResolutionDownBy,
|
|
228
|
-
|
|
228
|
+
r
|
|
229
229
|
);
|
|
230
230
|
let c = !1;
|
|
231
231
|
a !== void 0 && (s.encodings[0].scaleResolutionDownBy = a, c = !0);
|
|
232
|
-
const E = n.maxBitrate,
|
|
233
|
-
return
|
|
234
|
-
},
|
|
235
|
-
const s =
|
|
232
|
+
const E = n.maxBitrate, _ = Is(e.maxBitrate, E);
|
|
233
|
+
return _ !== void 0 && (s.encodings[0].maxBitrate = _, c = !0), c ? (t && t(s), o.setParameters(s).then(() => ({ parameters: s, isChanged: c }))) : { parameters: s, isChanged: c };
|
|
234
|
+
}, fs = async (o, e, t) => {
|
|
235
|
+
const s = gs(o, e);
|
|
236
236
|
if (s)
|
|
237
|
-
return
|
|
238
|
-
},
|
|
239
|
-
const { originator: e, cause: t } =
|
|
240
|
-
return
|
|
241
|
-
},
|
|
242
|
-
class
|
|
237
|
+
return ms(s, { maxBitrate: t });
|
|
238
|
+
}, Os = 486, Ds = 487, W = "local", ye = "remote", Js = (o = new Error()) => {
|
|
239
|
+
const { originator: e, cause: t } = o;
|
|
240
|
+
return At(o) ? !0 : typeof t == "string" ? t === be || t === Ue || e === W && (t === He || t === Le) : !1;
|
|
241
|
+
}, g = "SipConnector", Ms = "channels", Ps = "WebcastStarted", ps = "WebcastStopped", vs = "accountChanged", ws = "accountDeleted", ys = "addedToListModerators", bs = "removedFromListModerators", Us = "ParticipationRequestAccepted", Ls = "ParticipationRequestRejected", Hs = "ParticipantMovedToWebcast", ks = "ConferenceParticipantTokenIssued";
|
|
242
|
+
class zs {
|
|
243
243
|
constructor({ JsSIP: e }) {
|
|
244
244
|
i(this, "_isRegisterConfig", !1);
|
|
245
245
|
i(this, "_connectionConfiguration", {});
|
|
@@ -273,7 +273,7 @@ class Js {
|
|
|
273
273
|
i(this, "tryRegister", async () => {
|
|
274
274
|
if (!this.isRegisterConfig)
|
|
275
275
|
throw new Error("Config is not registered");
|
|
276
|
-
this._uaEvents.trigger(
|
|
276
|
+
this._uaEvents.trigger(L, void 0);
|
|
277
277
|
try {
|
|
278
278
|
await this.unregister();
|
|
279
279
|
} catch (e) {
|
|
@@ -281,15 +281,15 @@ class Js {
|
|
|
281
281
|
}
|
|
282
282
|
return this.register();
|
|
283
283
|
});
|
|
284
|
-
i(this, "declineToIncomingCall", async ({ statusCode: e =
|
|
284
|
+
i(this, "declineToIncomingCall", async ({ statusCode: e = Ds } = {}) => new Promise((t, s) => {
|
|
285
285
|
if (!this.isAvailableIncomingCall) {
|
|
286
286
|
s(new Error("no incomingSession"));
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
|
-
const n = this.incomingSession,
|
|
290
|
-
this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(V,
|
|
289
|
+
const n = this.incomingSession, r = this.remoteCallerData;
|
|
290
|
+
this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(V, r), t(n.terminate({ status_code: e }));
|
|
291
291
|
}));
|
|
292
|
-
i(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode:
|
|
292
|
+
i(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode: Os }));
|
|
293
293
|
i(this, "removeIncomingSession", () => {
|
|
294
294
|
delete this.incomingSession;
|
|
295
295
|
});
|
|
@@ -308,84 +308,84 @@ class Js {
|
|
|
308
308
|
password: t,
|
|
309
309
|
sipServerUrl: s,
|
|
310
310
|
sipWebSocketServerURL: n,
|
|
311
|
-
remoteAddress:
|
|
311
|
+
remoteAddress: r,
|
|
312
312
|
sdpSemantics: a,
|
|
313
313
|
sessionTimers: c,
|
|
314
314
|
registerExpires: E,
|
|
315
|
-
connectionRecoveryMinInterval:
|
|
316
|
-
connectionRecoveryMaxInterval:
|
|
315
|
+
connectionRecoveryMinInterval: _,
|
|
316
|
+
connectionRecoveryMaxInterval: h,
|
|
317
317
|
userAgent: u,
|
|
318
|
-
displayName:
|
|
319
|
-
register:
|
|
320
|
-
extraHeaders:
|
|
318
|
+
displayName: d = "",
|
|
319
|
+
register: l = !1,
|
|
320
|
+
extraHeaders: S = []
|
|
321
321
|
}) => {
|
|
322
322
|
if (!s)
|
|
323
323
|
throw new Error("sipServerUrl is required");
|
|
324
324
|
if (!n)
|
|
325
325
|
throw new Error("sipWebSocketServerURL is required");
|
|
326
|
-
if (
|
|
326
|
+
if (l && !e)
|
|
327
327
|
throw new Error("user is required for authorized connection");
|
|
328
|
-
if (
|
|
328
|
+
if (l && !t)
|
|
329
329
|
throw new Error("password is required for authorized connection");
|
|
330
330
|
this._connectionConfiguration = {
|
|
331
331
|
sipServerUrl: s,
|
|
332
|
-
displayName:
|
|
333
|
-
register:
|
|
332
|
+
displayName: d,
|
|
333
|
+
register: l,
|
|
334
334
|
user: e,
|
|
335
335
|
password: t
|
|
336
|
-
}, this.getSipServerUrl = ve(s), this.socket = new this.JsSIP.WebSocketInterface(n), this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!
|
|
337
|
-
const { socket:
|
|
336
|
+
}, this.getSipServerUrl = ve(s), this.socket = new this.JsSIP.WebSocketInterface(n), this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!l;
|
|
337
|
+
const { socket: R } = this;
|
|
338
338
|
this.ua = this._createUa({
|
|
339
339
|
user: e,
|
|
340
340
|
password: t,
|
|
341
|
-
socket:
|
|
342
|
-
displayName:
|
|
343
|
-
register:
|
|
341
|
+
socket: R,
|
|
342
|
+
displayName: d,
|
|
343
|
+
register: l,
|
|
344
344
|
sdpSemantics: a,
|
|
345
345
|
sessionTimers: c,
|
|
346
346
|
registerExpires: E,
|
|
347
|
-
connectionRecoveryMinInterval:
|
|
348
|
-
connectionRecoveryMaxInterval:
|
|
347
|
+
connectionRecoveryMinInterval: _,
|
|
348
|
+
connectionRecoveryMaxInterval: h,
|
|
349
349
|
userAgent: u,
|
|
350
350
|
getSipServerUrl: this.getSipServerUrl
|
|
351
|
-
}), this._uaEvents.eachTriggers((
|
|
352
|
-
const me = Ae.find((
|
|
353
|
-
me && this.ua && this.ua.on(me,
|
|
351
|
+
}), this._uaEvents.eachTriggers((Tt, St) => {
|
|
352
|
+
const me = Ae.find((Nt) => Nt === St);
|
|
353
|
+
me && this.ua && this.ua.on(me, Tt);
|
|
354
354
|
});
|
|
355
|
-
const
|
|
356
|
-
return this.ua.registrator().setExtraHeaders(
|
|
355
|
+
const ut = [...Ft(r), ...S];
|
|
356
|
+
return this.ua.registrator().setExtraHeaders(ut), this.ua;
|
|
357
357
|
});
|
|
358
358
|
i(this, "_createUa", ({
|
|
359
359
|
user: e,
|
|
360
360
|
password: t,
|
|
361
361
|
socket: s,
|
|
362
362
|
displayName: n,
|
|
363
|
-
getSipServerUrl:
|
|
363
|
+
getSipServerUrl: r,
|
|
364
364
|
register: a = !1,
|
|
365
365
|
sdpSemantics: c = "plan-b",
|
|
366
366
|
sessionTimers: E = !1,
|
|
367
|
-
registerExpires:
|
|
367
|
+
registerExpires: _ = 60 * 5,
|
|
368
368
|
// 5 minutes in sec
|
|
369
|
-
connectionRecoveryMinInterval:
|
|
369
|
+
connectionRecoveryMinInterval: h = 2,
|
|
370
370
|
connectionRecoveryMaxInterval: u = 6,
|
|
371
|
-
userAgent:
|
|
371
|
+
userAgent: d
|
|
372
372
|
}) => {
|
|
373
373
|
if (a && !t)
|
|
374
374
|
throw new Error("password is required for authorized connection");
|
|
375
|
-
const
|
|
375
|
+
const l = a && e ? e.trim() : `${us()}`, S = r(l), R = {
|
|
376
376
|
password: t,
|
|
377
377
|
register: a,
|
|
378
|
-
uri:
|
|
378
|
+
uri: S,
|
|
379
379
|
display_name: we(n),
|
|
380
|
-
user_agent:
|
|
380
|
+
user_agent: d,
|
|
381
381
|
sdp_semantics: c,
|
|
382
382
|
sockets: [s],
|
|
383
383
|
session_timers: E,
|
|
384
|
-
register_expires:
|
|
385
|
-
connection_recovery_min_interval:
|
|
384
|
+
register_expires: _,
|
|
385
|
+
connection_recovery_min_interval: h,
|
|
386
386
|
connection_recovery_max_interval: u
|
|
387
387
|
};
|
|
388
|
-
return new this.JsSIP.UA(
|
|
388
|
+
return new this.JsSIP.UA(R);
|
|
389
389
|
});
|
|
390
390
|
i(this, "_start", async () => new Promise((e, t) => {
|
|
391
391
|
const { ua: s } = this;
|
|
@@ -395,31 +395,33 @@ class Js {
|
|
|
395
395
|
}
|
|
396
396
|
const n = () => {
|
|
397
397
|
c(), e(s);
|
|
398
|
-
},
|
|
398
|
+
}, r = (E) => {
|
|
399
399
|
c(), t(E);
|
|
400
400
|
}, a = () => {
|
|
401
|
-
this.isRegisterConfig ? (this.on(
|
|
401
|
+
this.isRegisterConfig ? (this.on(f, n), this.on(O, r)) : this.on(m, n), this.on(T, r);
|
|
402
402
|
}, c = () => {
|
|
403
|
-
this.off(
|
|
403
|
+
this.off(f, n), this.off(O, r), this.off(m, n), this.off(T, r);
|
|
404
404
|
};
|
|
405
|
-
a(), this.on(
|
|
405
|
+
a(), this.on(P, this.handleNewRTCSession), s.start();
|
|
406
406
|
}));
|
|
407
407
|
i(this, "_set", async ({ displayName: e, password: t }) => new Promise((s, n) => {
|
|
408
|
-
const { ua:
|
|
409
|
-
if (!
|
|
408
|
+
const { ua: r } = this;
|
|
409
|
+
if (!r) {
|
|
410
410
|
n(new Error("this.ua is not initialized"));
|
|
411
411
|
return;
|
|
412
412
|
}
|
|
413
413
|
let a = !1, c = !1;
|
|
414
|
-
e !== void 0 && e !== this._connectionConfiguration.displayName && (a =
|
|
414
|
+
e !== void 0 && e !== this._connectionConfiguration.displayName && (a = r.set("display_name", we(e)), this._connectionConfiguration.displayName = e), t !== void 0 && t !== this._connectionConfiguration.password && (c = r.set("password", t), this._connectionConfiguration.password = t);
|
|
415
415
|
const E = a || c;
|
|
416
416
|
c && this.isRegisterConfig ? this.register().then(() => {
|
|
417
417
|
s(E);
|
|
418
|
-
}).catch(
|
|
418
|
+
}).catch((_) => {
|
|
419
|
+
n(_);
|
|
420
|
+
}) : E ? s(E) : n(new Error("nothing changed"));
|
|
419
421
|
}));
|
|
420
422
|
i(this, "_disconnectWithoutCancelRequests", async () => this._cancelableDisconnect.request());
|
|
421
423
|
i(this, "_disconnect", async () => {
|
|
422
|
-
this.off(
|
|
424
|
+
this.off(P, this.handleNewRTCSession);
|
|
423
425
|
const e = new Promise((t) => {
|
|
424
426
|
this.once(T, () => {
|
|
425
427
|
delete this.ua, t();
|
|
@@ -432,19 +434,21 @@ class Js {
|
|
|
432
434
|
mediaStream: t,
|
|
433
435
|
extraHeaders: s = [],
|
|
434
436
|
ontrack: n,
|
|
435
|
-
iceServers:
|
|
437
|
+
iceServers: r,
|
|
436
438
|
videoMode: a,
|
|
437
439
|
audioMode: c,
|
|
438
440
|
degradationPreference: E,
|
|
439
|
-
offerToReceiveAudio:
|
|
440
|
-
offerToReceiveVideo:
|
|
441
|
-
}) => new Promise((u,
|
|
442
|
-
const { ua:
|
|
443
|
-
if (!
|
|
444
|
-
|
|
441
|
+
offerToReceiveAudio: _ = !0,
|
|
442
|
+
offerToReceiveVideo: h = !0
|
|
443
|
+
}) => new Promise((u, d) => {
|
|
444
|
+
const { ua: l } = this;
|
|
445
|
+
if (!l) {
|
|
446
|
+
d(new Error("this.ua is not initialized"));
|
|
445
447
|
return;
|
|
446
448
|
}
|
|
447
|
-
this._connectionConfiguration.number = e, this._connectionConfiguration.answer = !1, this._handleCall({ ontrack: n }).then(u).catch(
|
|
449
|
+
this._connectionConfiguration.number = e, this._connectionConfiguration.answer = !1, this._handleCall({ ontrack: n }).then(u).catch((S) => {
|
|
450
|
+
d(S);
|
|
451
|
+
}), this.session = l.call(this.getSipServerUrl(e), {
|
|
448
452
|
extraHeaders: s,
|
|
449
453
|
mediaStream: H(t, {
|
|
450
454
|
videoMode: a,
|
|
@@ -455,11 +459,11 @@ class Js {
|
|
|
455
459
|
audioMode: c,
|
|
456
460
|
degradationPreference: E,
|
|
457
461
|
pcConfig: {
|
|
458
|
-
iceServers:
|
|
462
|
+
iceServers: r
|
|
459
463
|
},
|
|
460
464
|
rtcOfferConstraints: {
|
|
461
|
-
offerToReceiveAudio:
|
|
462
|
-
offerToReceiveVideo:
|
|
465
|
+
offerToReceiveAudio: _,
|
|
466
|
+
offerToReceiveVideo: h
|
|
463
467
|
}
|
|
464
468
|
});
|
|
465
469
|
}));
|
|
@@ -468,31 +472,33 @@ class Js {
|
|
|
468
472
|
ontrack: t,
|
|
469
473
|
extraHeaders: s = [],
|
|
470
474
|
iceServers: n,
|
|
471
|
-
videoMode:
|
|
475
|
+
videoMode: r,
|
|
472
476
|
audioMode: a,
|
|
473
477
|
degradationPreference: c
|
|
474
|
-
}) => new Promise((E,
|
|
478
|
+
}) => new Promise((E, _) => {
|
|
475
479
|
if (!this.isAvailableIncomingCall) {
|
|
476
|
-
|
|
480
|
+
_(new Error("no incomingSession"));
|
|
477
481
|
return;
|
|
478
482
|
}
|
|
479
483
|
this.session = this.incomingSession, this.removeIncomingSession();
|
|
480
|
-
const { session:
|
|
481
|
-
if (!
|
|
482
|
-
|
|
484
|
+
const { session: h } = this;
|
|
485
|
+
if (!h) {
|
|
486
|
+
_(new Error("No session established"));
|
|
483
487
|
return;
|
|
484
488
|
}
|
|
485
|
-
this._sessionEvents.eachTriggers((
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
}), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number =
|
|
489
|
+
this._sessionEvents.eachTriggers((d, l) => {
|
|
490
|
+
const S = Re.find((R) => R === l);
|
|
491
|
+
S && h.on(S, d);
|
|
492
|
+
}), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = h.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(E).catch((d) => {
|
|
493
|
+
_(d);
|
|
494
|
+
});
|
|
489
495
|
const u = H(e, {
|
|
490
|
-
videoMode:
|
|
496
|
+
videoMode: r,
|
|
491
497
|
audioMode: a
|
|
492
498
|
});
|
|
493
|
-
|
|
499
|
+
h.answer({
|
|
494
500
|
extraHeaders: s,
|
|
495
|
-
videoMode:
|
|
501
|
+
videoMode: r,
|
|
496
502
|
audioMode: a,
|
|
497
503
|
degradationPreference: c,
|
|
498
504
|
mediaStream: u,
|
|
@@ -503,23 +509,23 @@ class Js {
|
|
|
503
509
|
}));
|
|
504
510
|
i(this, "_handleCall", async ({ ontrack: e }) => new Promise((t, s) => {
|
|
505
511
|
const n = () => {
|
|
506
|
-
this.onSession(
|
|
507
|
-
},
|
|
508
|
-
this.offSession(
|
|
512
|
+
this.onSession(b, h), this.onSession(y, u);
|
|
513
|
+
}, r = () => {
|
|
514
|
+
this.offSession(b, h), this.offSession(y, u);
|
|
509
515
|
}, a = () => {
|
|
510
|
-
this.onSession(C, E), this.onSession(
|
|
516
|
+
this.onSession(C, E), this.onSession(D, E);
|
|
511
517
|
}, c = () => {
|
|
512
|
-
this.offSession(C, E), this.offSession(
|
|
513
|
-
}, E = (
|
|
514
|
-
|
|
518
|
+
this.offSession(C, E), this.offSession(D, E);
|
|
519
|
+
}, E = (d) => {
|
|
520
|
+
r(), c(), s(d);
|
|
515
521
|
};
|
|
516
|
-
let
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
this._sessionEvents.trigger(Z,
|
|
522
|
+
let _;
|
|
523
|
+
const h = ({ peerconnection: d }) => {
|
|
524
|
+
_ = d, _.ontrack = (l) => {
|
|
525
|
+
this._sessionEvents.trigger(Z, _), e && e(l);
|
|
520
526
|
};
|
|
521
527
|
}, u = () => {
|
|
522
|
-
|
|
528
|
+
_ && this._sessionEvents.trigger(j, _), r(), c(), t(_);
|
|
523
529
|
};
|
|
524
530
|
n(), a();
|
|
525
531
|
}));
|
|
@@ -532,8 +538,8 @@ class Js {
|
|
|
532
538
|
s(new Error("No session established"));
|
|
533
539
|
return;
|
|
534
540
|
}
|
|
535
|
-
this.onceSession(Ne, ({ originator:
|
|
536
|
-
|
|
541
|
+
this.onceSession(Ne, ({ originator: r }) => {
|
|
542
|
+
r === W && t();
|
|
537
543
|
}), n.sendDTMF(e, {
|
|
538
544
|
duration: 120,
|
|
539
545
|
interToneGap: 600
|
|
@@ -555,7 +561,7 @@ class Js {
|
|
|
555
561
|
this._sessionEvents.trigger(J, void 0);
|
|
556
562
|
break;
|
|
557
563
|
}
|
|
558
|
-
case
|
|
564
|
+
case ht: {
|
|
559
565
|
this._sessionEvents.trigger(z, void 0);
|
|
560
566
|
break;
|
|
561
567
|
}
|
|
@@ -568,60 +574,60 @@ class Js {
|
|
|
568
574
|
inputChannels: t,
|
|
569
575
|
outputChannels: s
|
|
570
576
|
};
|
|
571
|
-
this._sessionEvents.trigger(
|
|
577
|
+
this._sessionEvents.trigger(v, n);
|
|
572
578
|
}
|
|
573
579
|
});
|
|
574
580
|
i(this, "_handleNotify", (e) => {
|
|
575
581
|
switch (e.cmd) {
|
|
576
|
-
case
|
|
582
|
+
case Ms: {
|
|
577
583
|
const t = e;
|
|
578
584
|
this._triggerChannelsNotify(t);
|
|
579
585
|
break;
|
|
580
586
|
}
|
|
581
|
-
case
|
|
587
|
+
case Ps: {
|
|
582
588
|
const t = e;
|
|
583
589
|
this._triggerWebcastStartedNotify(t);
|
|
584
590
|
break;
|
|
585
591
|
}
|
|
586
|
-
case
|
|
592
|
+
case ps: {
|
|
587
593
|
const t = e;
|
|
588
594
|
this._triggerWebcastStoppedNotify(t);
|
|
589
595
|
break;
|
|
590
596
|
}
|
|
591
|
-
case
|
|
597
|
+
case ys: {
|
|
592
598
|
const t = e;
|
|
593
599
|
this._triggerAddedToListModeratorsNotify(t);
|
|
594
600
|
break;
|
|
595
601
|
}
|
|
596
|
-
case
|
|
602
|
+
case bs: {
|
|
597
603
|
const t = e;
|
|
598
604
|
this._triggerRemovedFromListModeratorsNotify(t);
|
|
599
605
|
break;
|
|
600
606
|
}
|
|
601
|
-
case
|
|
607
|
+
case Us: {
|
|
602
608
|
const t = e;
|
|
603
609
|
this._triggerParticipationAcceptingWordRequest(t);
|
|
604
610
|
break;
|
|
605
611
|
}
|
|
606
|
-
case
|
|
612
|
+
case Ls: {
|
|
607
613
|
const t = e;
|
|
608
614
|
this._triggerParticipationCancellingWordRequest(t);
|
|
609
615
|
break;
|
|
610
616
|
}
|
|
611
|
-
case
|
|
617
|
+
case Hs: {
|
|
612
618
|
const t = e;
|
|
613
619
|
this._triggerParticipantMoveRequestToStream(t);
|
|
614
620
|
break;
|
|
615
621
|
}
|
|
616
|
-
case
|
|
622
|
+
case vs: {
|
|
617
623
|
this._triggerAccountChangedNotify();
|
|
618
624
|
break;
|
|
619
625
|
}
|
|
620
|
-
case
|
|
626
|
+
case ws: {
|
|
621
627
|
this._triggerAccountDeletedNotify();
|
|
622
628
|
break;
|
|
623
629
|
}
|
|
624
|
-
case
|
|
630
|
+
case ks: {
|
|
625
631
|
const t = e;
|
|
626
632
|
this._triggerConferenceParticipantTokenIssued(t);
|
|
627
633
|
break;
|
|
@@ -712,53 +718,53 @@ class Js {
|
|
|
712
718
|
this._uaEvents.trigger(Ee, t);
|
|
713
719
|
});
|
|
714
720
|
i(this, "_triggerEnterRoom", (e) => {
|
|
715
|
-
const t = e.getHeader(
|
|
721
|
+
const t = e.getHeader(Vt);
|
|
716
722
|
this._sessionEvents.trigger(Q, t);
|
|
717
723
|
});
|
|
718
724
|
i(this, "_triggerShareState", (e) => {
|
|
719
|
-
const t = e.getHeader(
|
|
720
|
-
this._sessionEvents.trigger(
|
|
725
|
+
const t = e.getHeader(A);
|
|
726
|
+
this._sessionEvents.trigger(p, t);
|
|
721
727
|
});
|
|
722
728
|
i(this, "_triggerMainCamControl", (e) => {
|
|
723
|
-
const t = e.getHeader(
|
|
724
|
-
if (t ===
|
|
729
|
+
const t = e.getHeader(Qt), s = e.getHeader(Pe), n = s === q.ADMIN_SYNC_FORCED;
|
|
730
|
+
if (t === I.ADMIN_START_MAIN_CAM)
|
|
725
731
|
this._sessionEvents.trigger(ie, { isSyncForced: n });
|
|
726
|
-
else if (t ===
|
|
732
|
+
else if (t === I.ADMIN_STOP_MAIN_CAM)
|
|
727
733
|
this._sessionEvents.trigger(ne, { isSyncForced: n });
|
|
728
|
-
else if ((t ===
|
|
729
|
-
this._sessionEvents.trigger(
|
|
734
|
+
else if ((t === I.RESUME_MAIN_CAM || t === I.PAUSE_MAIN_CAM) && s)
|
|
735
|
+
this._sessionEvents.trigger(w, { isSyncForced: n });
|
|
730
736
|
else {
|
|
731
|
-
const
|
|
737
|
+
const r = e.getHeader(jt);
|
|
732
738
|
this._sessionEvents.trigger(se, {
|
|
733
739
|
mainCam: t,
|
|
734
|
-
resolutionMainCam:
|
|
740
|
+
resolutionMainCam: r
|
|
735
741
|
});
|
|
736
742
|
}
|
|
737
743
|
});
|
|
738
744
|
i(this, "_triggerMicControl", (e) => {
|
|
739
|
-
const t = e.getHeader(
|
|
740
|
-
t === k.ADMIN_START_MIC ? this._sessionEvents.trigger(
|
|
745
|
+
const t = e.getHeader(Kt), n = e.getHeader(Pe) === q.ADMIN_SYNC_FORCED;
|
|
746
|
+
t === k.ADMIN_START_MIC ? this._sessionEvents.trigger(re, { isSyncForced: n }) : t === k.ADMIN_STOP_MIC && this._sessionEvents.trigger(oe, { isSyncForced: n });
|
|
741
747
|
});
|
|
742
748
|
i(this, "_triggerUseLicense", (e) => {
|
|
743
|
-
const t = e.getHeader(
|
|
749
|
+
const t = e.getHeader(zt);
|
|
744
750
|
this._sessionEvents.trigger(K, t);
|
|
745
751
|
});
|
|
746
752
|
i(this, "_handleNewInfo", (e) => {
|
|
747
753
|
const { originator: t } = e;
|
|
748
754
|
if (t !== "remote")
|
|
749
755
|
return;
|
|
750
|
-
const { request: s } = e, n = s.getHeader(
|
|
756
|
+
const { request: s } = e, n = s.getHeader(Bt);
|
|
751
757
|
if (n)
|
|
752
758
|
switch (n) {
|
|
753
|
-
case
|
|
759
|
+
case Yt: {
|
|
754
760
|
this._triggerEnterRoom(s), this._maybeTriggerChannels(s);
|
|
755
761
|
break;
|
|
756
762
|
}
|
|
757
|
-
case
|
|
763
|
+
case ns: {
|
|
758
764
|
this._maybeHandleNotify(s);
|
|
759
765
|
break;
|
|
760
766
|
}
|
|
761
|
-
case
|
|
767
|
+
case M: {
|
|
762
768
|
this._triggerShareState(s);
|
|
763
769
|
break;
|
|
764
770
|
}
|
|
@@ -766,11 +772,11 @@ class Js {
|
|
|
766
772
|
this._triggerMainCamControl(s);
|
|
767
773
|
break;
|
|
768
774
|
}
|
|
769
|
-
case
|
|
775
|
+
case Xt: {
|
|
770
776
|
this._triggerMicControl(s);
|
|
771
777
|
break;
|
|
772
778
|
}
|
|
773
|
-
case
|
|
779
|
+
case Jt: {
|
|
774
780
|
this._triggerUseLicense(s);
|
|
775
781
|
break;
|
|
776
782
|
}
|
|
@@ -780,7 +786,7 @@ class Js {
|
|
|
780
786
|
this._maybeHandleNotify(e);
|
|
781
787
|
});
|
|
782
788
|
i(this, "_maybeHandleNotify", (e) => {
|
|
783
|
-
const t = e.getHeader(
|
|
789
|
+
const t = e.getHeader(is);
|
|
784
790
|
if (t) {
|
|
785
791
|
const s = JSON.parse(t);
|
|
786
792
|
this._handleNotify(s);
|
|
@@ -790,41 +796,41 @@ class Js {
|
|
|
790
796
|
const { originator: t } = e;
|
|
791
797
|
t === ye && this._sessionEvents.trigger(te, e), this._restoreSession();
|
|
792
798
|
});
|
|
793
|
-
this.JsSIP = e, this._sessionEvents = new fe(ct), this._uaEvents = new fe(at), this._cancelableConnect = new
|
|
799
|
+
this.JsSIP = e, this._sessionEvents = new fe(ct), this._uaEvents = new fe(at), this._cancelableConnect = new N(
|
|
794
800
|
this._connect,
|
|
795
801
|
{
|
|
796
|
-
moduleName:
|
|
802
|
+
moduleName: g,
|
|
797
803
|
afterCancelRequest: () => {
|
|
798
804
|
this._cancelableInitUa.cancelRequest(), this._cancelableDisconnect.cancelRequest();
|
|
799
805
|
}
|
|
800
806
|
}
|
|
801
|
-
), this._cancelableInitUa = new
|
|
807
|
+
), this._cancelableInitUa = new N(
|
|
802
808
|
this._initUa,
|
|
803
|
-
{ moduleName:
|
|
804
|
-
), this._cancelableDisconnect = new
|
|
809
|
+
{ moduleName: g }
|
|
810
|
+
), this._cancelableDisconnect = new N(
|
|
805
811
|
this._disconnect,
|
|
806
|
-
{ moduleName:
|
|
807
|
-
), this._cancelableSet = new
|
|
808
|
-
moduleName:
|
|
809
|
-
}), this._cancelableCall = new
|
|
812
|
+
{ moduleName: g }
|
|
813
|
+
), this._cancelableSet = new N(this._set, {
|
|
814
|
+
moduleName: g
|
|
815
|
+
}), this._cancelableCall = new N(
|
|
810
816
|
this._call,
|
|
811
|
-
{ moduleName:
|
|
812
|
-
), this._cancelableAnswer = new
|
|
817
|
+
{ moduleName: g }
|
|
818
|
+
), this._cancelableAnswer = new N(this._answer, { moduleName: g }), this._cancelableSendDTMF = new N(this._sendDTMF, { moduleName: g }), this.onSession(p, this._handleShareState), this.onSession(ge, this._handleNewInfo), this.on(G, this._handleSipEvent), this.onSession(C, this._handleEnded), this.onSession(D, this._handleEnded);
|
|
813
819
|
}
|
|
814
820
|
async register() {
|
|
815
821
|
return new Promise((e, t) => {
|
|
816
|
-
this.isRegisterConfig && this.ua ? (this.ua.on(
|
|
822
|
+
this.isRegisterConfig && this.ua ? (this.ua.on(f, e), this.ua.on(O, t), this.ua.register()) : t(new Error("Config is not registered"));
|
|
817
823
|
});
|
|
818
824
|
}
|
|
819
825
|
async unregister() {
|
|
820
826
|
return new Promise((e, t) => {
|
|
821
|
-
this.isRegistered && this.ua ? (this.ua.on(
|
|
827
|
+
this.isRegistered && this.ua ? (this.ua.on($, e), this.ua.unregister()) : t(new Error("ua is not registered"));
|
|
822
828
|
});
|
|
823
829
|
}
|
|
824
830
|
async sendOptions(e, t, s) {
|
|
825
831
|
if (!this.ua)
|
|
826
832
|
throw new Error("is not connected");
|
|
827
|
-
return new Promise((n,
|
|
833
|
+
return new Promise((n, r) => {
|
|
828
834
|
try {
|
|
829
835
|
this.ua.sendOptions(e, t, {
|
|
830
836
|
extraHeaders: s,
|
|
@@ -832,11 +838,11 @@ class Js {
|
|
|
832
838
|
succeeded: () => {
|
|
833
839
|
n();
|
|
834
840
|
},
|
|
835
|
-
failed:
|
|
841
|
+
failed: r
|
|
836
842
|
}
|
|
837
843
|
});
|
|
838
844
|
} catch (a) {
|
|
839
|
-
|
|
845
|
+
r(a);
|
|
840
846
|
}
|
|
841
847
|
});
|
|
842
848
|
}
|
|
@@ -852,24 +858,24 @@ class Js {
|
|
|
852
858
|
displayName: t,
|
|
853
859
|
sipServerUrl: s,
|
|
854
860
|
sipWebSocketServerURL: n,
|
|
855
|
-
sdpSemantics:
|
|
861
|
+
sdpSemantics: r
|
|
856
862
|
}) {
|
|
857
863
|
return new Promise((a, c) => {
|
|
858
|
-
const E = ve(s),
|
|
859
|
-
socket:
|
|
864
|
+
const E = ve(s), _ = new this.JsSIP.WebSocketInterface(n), h = this._createUa({
|
|
865
|
+
socket: _,
|
|
860
866
|
displayName: t,
|
|
861
|
-
sdpSemantics:
|
|
867
|
+
sdpSemantics: r,
|
|
862
868
|
userAgent: e,
|
|
863
869
|
getSipServerUrl: E
|
|
864
870
|
}), u = () => {
|
|
865
|
-
const
|
|
866
|
-
c(
|
|
871
|
+
const l = new Error("Telephony is not available");
|
|
872
|
+
c(l);
|
|
867
873
|
};
|
|
868
|
-
|
|
869
|
-
const
|
|
870
|
-
|
|
874
|
+
h.once(T, u);
|
|
875
|
+
const d = () => {
|
|
876
|
+
h.removeAllListeners(), h.once(T, a), h.stop();
|
|
871
877
|
};
|
|
872
|
-
|
|
878
|
+
h.once(m, d), h.start();
|
|
873
879
|
});
|
|
874
880
|
}
|
|
875
881
|
async replaceMediaStream(e, t) {
|
|
@@ -880,13 +886,13 @@ class Js {
|
|
|
880
886
|
async askPermissionToEnableCam(e = {}) {
|
|
881
887
|
if (!this.session)
|
|
882
888
|
throw new Error("No session established");
|
|
883
|
-
const t = [
|
|
889
|
+
const t = [hs];
|
|
884
890
|
return this.session.sendInfo(Oe, void 0, {
|
|
885
891
|
noTerminateWhenError: !0,
|
|
886
892
|
...e,
|
|
887
893
|
extraHeaders: t
|
|
888
894
|
}).catch((s) => {
|
|
889
|
-
if (
|
|
895
|
+
if (Ns(s))
|
|
890
896
|
throw s;
|
|
891
897
|
});
|
|
892
898
|
}
|
|
@@ -896,27 +902,27 @@ class Js {
|
|
|
896
902
|
async _sendPresentation(e, t, {
|
|
897
903
|
maxBitrate: s,
|
|
898
904
|
degradationPreference: n,
|
|
899
|
-
isNeedReinvite:
|
|
905
|
+
isNeedReinvite: r = !0,
|
|
900
906
|
isP2P: a = !1
|
|
901
907
|
}) {
|
|
902
908
|
const c = H(t);
|
|
903
909
|
this._streamPresentationCurrent = c;
|
|
904
|
-
const E = a ? [
|
|
910
|
+
const E = a ? [cs] : [os], _ = e.sendInfo(M, void 0, {
|
|
905
911
|
extraHeaders: E
|
|
906
912
|
}).then(async () => e.startPresentation(
|
|
907
913
|
c,
|
|
908
|
-
|
|
914
|
+
r,
|
|
909
915
|
n
|
|
910
916
|
)).then(async () => {
|
|
911
|
-
const { connection:
|
|
912
|
-
if (!
|
|
917
|
+
const { connection: h } = this;
|
|
918
|
+
if (!h || s === void 0)
|
|
913
919
|
return;
|
|
914
|
-
const u =
|
|
915
|
-
await
|
|
916
|
-
}).then(() => t).catch((
|
|
917
|
-
throw this._sessionEvents.trigger(
|
|
920
|
+
const u = h.getSenders();
|
|
921
|
+
await fs(u, t, s);
|
|
922
|
+
}).then(() => t).catch((h) => {
|
|
923
|
+
throw this._sessionEvents.trigger(U, h), h;
|
|
918
924
|
});
|
|
919
|
-
return this.promisePendingStartPresentation =
|
|
925
|
+
return this.promisePendingStartPresentation = _, _.finally(() => {
|
|
920
926
|
this.promisePendingStartPresentation = void 0;
|
|
921
927
|
});
|
|
922
928
|
}
|
|
@@ -924,18 +930,23 @@ class Js {
|
|
|
924
930
|
isNeedReinvite: t = !0,
|
|
925
931
|
isP2P: s = !1,
|
|
926
932
|
maxBitrate: n,
|
|
927
|
-
degradationPreference:
|
|
933
|
+
degradationPreference: r
|
|
928
934
|
} = {}) {
|
|
929
935
|
const a = this.establishedSession;
|
|
930
936
|
if (!a)
|
|
931
937
|
throw new Error("No session established");
|
|
932
938
|
if (this._streamPresentationCurrent)
|
|
933
939
|
throw new Error("Presentation is already started");
|
|
934
|
-
return this._sendPresentation(a, e, {
|
|
940
|
+
return s && await this.sendMustStopPresentation(a), this._sendPresentation(a, e, {
|
|
935
941
|
isNeedReinvite: t,
|
|
936
942
|
isP2P: s,
|
|
937
943
|
maxBitrate: n,
|
|
938
|
-
degradationPreference:
|
|
944
|
+
degradationPreference: r
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
async sendMustStopPresentation(e) {
|
|
948
|
+
await e.sendInfo(M, void 0, {
|
|
949
|
+
extraHeaders: [as]
|
|
939
950
|
});
|
|
940
951
|
}
|
|
941
952
|
async stopPresentation({
|
|
@@ -943,12 +954,12 @@ class Js {
|
|
|
943
954
|
} = {}) {
|
|
944
955
|
const t = this._streamPresentationCurrent;
|
|
945
956
|
let s = this.promisePendingStartPresentation ?? Promise.resolve();
|
|
946
|
-
const n = e ? [
|
|
947
|
-
return
|
|
957
|
+
const n = e ? [Es] : [rs], r = this.establishedSession;
|
|
958
|
+
return r && t && (s = s.then(async () => r.sendInfo(M, void 0, {
|
|
948
959
|
extraHeaders: n
|
|
949
|
-
})).then(async () =>
|
|
950
|
-
throw this._sessionEvents.trigger(
|
|
951
|
-
})), !
|
|
960
|
+
})).then(async () => r.stopPresentation(t)).catch((a) => {
|
|
961
|
+
throw this._sessionEvents.trigger(U, a), a;
|
|
962
|
+
})), !r && t && this._sessionEvents.trigger(Ce, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
952
963
|
this._resetPresentation();
|
|
953
964
|
});
|
|
954
965
|
}
|
|
@@ -957,12 +968,12 @@ class Js {
|
|
|
957
968
|
maxBitrate: s,
|
|
958
969
|
degradationPreference: n
|
|
959
970
|
} = {}) {
|
|
960
|
-
const
|
|
961
|
-
if (!
|
|
971
|
+
const r = this.establishedSession;
|
|
972
|
+
if (!r)
|
|
962
973
|
throw new Error("No session established");
|
|
963
974
|
if (!this._streamPresentationCurrent)
|
|
964
975
|
throw new Error("Presentation has not started yet");
|
|
965
|
-
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this._sendPresentation(
|
|
976
|
+
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this._sendPresentation(r, e, {
|
|
966
977
|
isP2P: t,
|
|
967
978
|
maxBitrate: s,
|
|
968
979
|
degradationPreference: n,
|
|
@@ -1012,18 +1023,18 @@ class Js {
|
|
|
1012
1023
|
if (!this.connection)
|
|
1013
1024
|
return;
|
|
1014
1025
|
const t = this.connection.getReceivers().map(({ track: s }) => s);
|
|
1015
|
-
return
|
|
1026
|
+
return Ts(t) ? this._generateStreams(t) : this._generateAudioStreams(t);
|
|
1016
1027
|
}
|
|
1017
1028
|
get connection() {
|
|
1018
1029
|
var t;
|
|
1019
1030
|
return (t = this.session) == null ? void 0 : t.connection;
|
|
1020
1031
|
}
|
|
1021
1032
|
get remoteCallerData() {
|
|
1022
|
-
var e, t, s, n,
|
|
1033
|
+
var e, t, s, n, r, a;
|
|
1023
1034
|
return {
|
|
1024
1035
|
displayName: (t = (e = this.incomingSession) == null ? void 0 : e.remote_identity) == null ? void 0 : t.display_name,
|
|
1025
1036
|
host: (n = (s = this.incomingSession) == null ? void 0 : s.remote_identity) == null ? void 0 : n.uri.host,
|
|
1026
|
-
incomingNumber: (a = (
|
|
1037
|
+
incomingNumber: (a = (r = this.incomingSession) == null ? void 0 : r.remote_identity) == null ? void 0 : a.uri.user,
|
|
1027
1038
|
session: this.incomingSession
|
|
1028
1039
|
};
|
|
1029
1040
|
}
|
|
@@ -1058,10 +1069,10 @@ class Js {
|
|
|
1058
1069
|
return e.forEach((s, n) => {
|
|
1059
1070
|
if (s.kind === "audio")
|
|
1060
1071
|
return;
|
|
1061
|
-
const
|
|
1072
|
+
const r = s, a = e[n - 1];
|
|
1062
1073
|
let c;
|
|
1063
1074
|
a && a.kind === "audio" && (c = a);
|
|
1064
|
-
const E = this._generateStream(
|
|
1075
|
+
const E = this._generateStream(r, c);
|
|
1065
1076
|
t.push(E);
|
|
1066
1077
|
}), t;
|
|
1067
1078
|
}
|
|
@@ -1081,29 +1092,29 @@ class Js {
|
|
|
1081
1092
|
this._cancelableAnswer.cancelRequest(), this._cancelableSendDTMF.cancelRequest();
|
|
1082
1093
|
}
|
|
1083
1094
|
async waitChannels() {
|
|
1084
|
-
return this.waitSession(
|
|
1095
|
+
return this.waitSession(v);
|
|
1085
1096
|
}
|
|
1086
1097
|
async waitSyncMediaState() {
|
|
1087
|
-
return this.waitSession(
|
|
1098
|
+
return this.waitSession(w);
|
|
1088
1099
|
}
|
|
1089
1100
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
1090
1101
|
if (!this.session)
|
|
1091
1102
|
throw new Error("No session established");
|
|
1092
|
-
const s = `${De}: ${e}`, n = `${Me}: ${t}`,
|
|
1103
|
+
const s = `${De}: ${e}`, n = `${Me}: ${t}`, r = [
|
|
1093
1104
|
s,
|
|
1094
1105
|
n
|
|
1095
1106
|
];
|
|
1096
|
-
return this.session.sendInfo(
|
|
1107
|
+
return this.session.sendInfo(xt, void 0, { extraHeaders: r });
|
|
1097
1108
|
}
|
|
1098
1109
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
1099
1110
|
if (!this.session)
|
|
1100
1111
|
throw new Error("No session established");
|
|
1101
|
-
const n = `${
|
|
1112
|
+
const n = `${Zt}: currentstate`, r = `${ts}: ${Number(e)}`, a = `${ss}: ${Number(t)}`, c = [
|
|
1102
1113
|
n,
|
|
1103
|
-
|
|
1114
|
+
r,
|
|
1104
1115
|
a
|
|
1105
1116
|
];
|
|
1106
|
-
return this.session.sendInfo(
|
|
1117
|
+
return this.session.sendInfo($t, void 0, {
|
|
1107
1118
|
noTerminateWhenError: !0,
|
|
1108
1119
|
...s,
|
|
1109
1120
|
extraHeaders: c
|
|
@@ -1112,7 +1123,7 @@ class Js {
|
|
|
1112
1123
|
async _sendRefusalToTurnOn(e, t = {}) {
|
|
1113
1124
|
if (!this.session)
|
|
1114
1125
|
throw new Error("No session established");
|
|
1115
|
-
const c = [`${
|
|
1126
|
+
const c = [`${es}: ${e === "mic" ? 0 : 1}`];
|
|
1116
1127
|
return this.session.sendInfo(Gt, void 0, {
|
|
1117
1128
|
noTerminateWhenError: !0,
|
|
1118
1129
|
...t,
|
|
@@ -1131,22 +1142,22 @@ class Js {
|
|
|
1131
1142
|
}
|
|
1132
1143
|
}
|
|
1133
1144
|
export {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1145
|
+
qt as B,
|
|
1146
|
+
I as E,
|
|
1147
|
+
Mt as N,
|
|
1137
1148
|
Ue as R,
|
|
1138
|
-
|
|
1149
|
+
zs as S,
|
|
1139
1150
|
at as U,
|
|
1140
|
-
|
|
1151
|
+
xs as a,
|
|
1141
1152
|
Gs as b,
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1153
|
+
Ys as c,
|
|
1154
|
+
Xs as d,
|
|
1155
|
+
$s as e,
|
|
1145
1156
|
k as f,
|
|
1146
1157
|
q as g,
|
|
1147
|
-
|
|
1148
|
-
|
|
1158
|
+
Js as h,
|
|
1159
|
+
ds as i,
|
|
1149
1160
|
ct as j,
|
|
1150
1161
|
pe as l,
|
|
1151
|
-
|
|
1162
|
+
ms as s
|
|
1152
1163
|
};
|