sip-connector 14.1.0 → 14.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SipConnector-DRjfFGAZ.js +1339 -0
- package/dist/SipConnector-EXAO9Z-2.cjs +1 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +399 -402
- package/dist/index.cjs +1 -1
- package/dist/index.js +499 -500
- package/dist/src/SipConnector.d.ts +235 -0
- package/dist/{SipConnectorFacade → src/SipConnectorFacade}/SipConnectorFacade.d.ts +7 -7
- package/dist/{__fixtures__ → src/__fixtures__}/BaseSession.mock.d.ts +22 -34
- package/dist/{__fixtures__ → src/__fixtures__}/RTCPeerConnectionMock.d.ts +15 -15
- package/dist/{__fixtures__ → src/__fixtures__}/RTCRtpSenderMock.d.ts +2 -2
- package/dist/{__fixtures__ → src/__fixtures__}/RTCSessionMock.d.ts +34 -38
- package/dist/{__fixtures__ → src/__fixtures__}/UA.mock.d.ts +25 -44
- package/dist/{__fixtures__ → src/__fixtures__}/channelsNotify.d.ts +2 -2
- package/dist/{__fixtures__ → src/__fixtures__}/jssip.mock.d.ts +1 -1
- package/dist/{__fixtures__ → src/__fixtures__}/participantNotify.d.ts +2 -2
- package/dist/{tools → src/tools}/index.d.ts +2 -2
- package/dist/{tools → src/tools}/sendDTMFAccumulated.d.ts +2 -2
- package/dist/{types.d.ts → src/types.d.ts} +2 -1
- package/dist/src/videoSendingBalancer/scaleBitrate.d.ts +2 -0
- package/package.json +30 -30
- package/dist/SipConnector-BPIL3yLc.js +0 -1343
- package/dist/SipConnector-BUbfMgHs.cjs +0 -1
- package/dist/SipConnector.d.ts +0 -315
- package/dist/utils.d.ts +0 -4
- package/dist/videoSendingBalancer/scaleBitrate.d.ts +0 -2
- /package/dist/{SipConnectorFacade → src/SipConnectorFacade}/index.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/Registrator.mock.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/Request.mock.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/WebSocketInterface.mock.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/accountNotify.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/channels.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/conferenceParticipantTokenIssuedNotify.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/delayPromise.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/enterRoom.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/index.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/mediaState.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/participantMoveRequests.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/remoteCallerData.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/utils.d.ts +0 -0
- /package/dist/{__fixtures__ → src/__fixtures__}/webcastNotify.d.ts +0 -0
- /package/dist/{causes.d.ts → src/causes.d.ts} +0 -0
- /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/dist/{doMock.d.ts → src/doMock.d.ts} +0 -0
- /package/dist/{eventNames.d.ts → src/eventNames.d.ts} +0 -0
- /package/dist/{getExtraHeadersRemoteAddress.d.ts → src/getExtraHeadersRemoteAddress.d.ts} +0 -0
- /package/dist/{headers.d.ts → src/headers.d.ts} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{logger.d.ts → src/logger.d.ts} +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureDegradationPreference.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureEncodings.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureMaxBitrate.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/index.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +0 -0
- /package/dist/{setParametersToSender → src/setParametersToSender}/setParametersToSender.d.ts +0 -0
- /package/dist/{tools → src/tools}/__fixtures__/call.d.ts +0 -0
- /package/dist/{tools → src/tools}/__fixtures__/connectToServer.d.ts +0 -0
- /package/dist/{tools → src/tools}/__fixtures__/hasValidUri.d.ts +0 -0
- /package/dist/{tools → src/tools}/__fixtures__/permissions.d.ts +0 -0
- /package/dist/{tools → src/tools}/__fixtures__/processRequest.d.ts +0 -0
- /package/dist/{tools → src/tools}/__tests-utils__/parseObject.d.ts +0 -0
- /package/dist/{tools → src/tools}/__tests-utils__/resolveParseArray.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/getLinkError.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/getTypeFromError.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/getValuesFromError.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/index.d.ts +0 -0
- /package/dist/{tools → src/tools}/error/stringifyMessage.d.ts +0 -0
- /package/dist/{tools → src/tools}/generateSimulcastEncodings.d.ts +0 -0
- /package/dist/{tools → src/tools}/getExtraHeaders.d.ts +0 -0
- /package/dist/{tools → src/tools}/getUserAgent.d.ts +0 -0
- /package/dist/{tools → src/tools}/hasPurgatory.d.ts +0 -0
- /package/dist/{tools → src/tools}/prepareMediaStream.d.ts +0 -0
- /package/dist/{tools → src/tools}/resolveUpdateTransceiver.d.ts +0 -0
- /package/dist/{tools → src/tools}/setVideoTrackContentHints.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/index.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMainCam.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/resolveOnStartMic.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMainCam.d.ts +0 -0
- /package/dist/{tools → src/tools}/syncMediaState/resolveOnStopMic.d.ts +0 -0
- /package/dist/{utils → src/utils}/errors.d.ts +0 -0
- /package/dist/{utils → src/utils}/findSenderByStream.d.ts +0 -0
- /package/dist/{utils → src/utils}/findVideoSender.d.ts +0 -0
- /package/dist/{utils → src/utils}/findVideoTrack.d.ts +0 -0
- /package/dist/{utils → src/utils}/getCodecFromSender.d.ts +0 -0
- /package/dist/{utils → src/utils}/replaceForbiddenSymbolsWithUnderscore.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/balance.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidth.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/getMaxBitrateByWidthAndCodec.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasAv1Codec.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/hasIncludesString.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/index.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/processSender.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleBitrateByCodec.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/scaleResolutionAndBitrate.d.ts +0 -0
- /package/dist/{videoSendingBalancer → src/videoSendingBalancer}/setEncodingsToSender.d.ts +0 -0
|
@@ -0,0 +1,1339 @@
|
|
|
1
|
+
import { isCanceledError as Nt } from "@krivega/cancelable-promise";
|
|
2
|
+
import Me from "events-constructor";
|
|
3
|
+
import { repeatedCallsAsync as De, hasCanceledError as _t } from "repeated-calls";
|
|
4
|
+
import V from "debug";
|
|
5
|
+
const At = "Connection Error", Ue = "Request Timeout", Rt = "SIP Failure Code", ft = "Internal Error", It = "Busy", He = "Rejected", Pt = "Redirected", mt = "Unavailable", Ot = "Not Found", pt = "Address Incomplete", Mt = "Incompatible SDP", Dt = "Missing SDP", vt = "Authentication Error", We = "Terminated", yt = "WebRTC Error", Y = "Canceled", wt = "No Answer", bt = "Expires", Lt = "No ACK", Ut = "Dialog Error", Ht = "User Denied Media Access", Wt = "Bad Media Description", kt = "RTP Timeout", os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
6
|
+
__proto__: null,
|
|
7
|
+
ADDRESS_INCOMPLETE: pt,
|
|
8
|
+
AUTHENTICATION_ERROR: vt,
|
|
9
|
+
BAD_MEDIA_DESCRIPTION: Wt,
|
|
10
|
+
BUSY: It,
|
|
11
|
+
BYE: We,
|
|
12
|
+
CANCELED: Y,
|
|
13
|
+
CONNECTION_ERROR: At,
|
|
14
|
+
DIALOG_ERROR: Ut,
|
|
15
|
+
EXPIRES: bt,
|
|
16
|
+
INCOMPATIBLE_SDP: Mt,
|
|
17
|
+
INTERNAL_ERROR: ft,
|
|
18
|
+
MISSING_SDP: Dt,
|
|
19
|
+
NOT_FOUND: Ot,
|
|
20
|
+
NO_ACK: Lt,
|
|
21
|
+
NO_ANSWER: wt,
|
|
22
|
+
REDIRECTED: Pt,
|
|
23
|
+
REJECTED: He,
|
|
24
|
+
REQUEST_TIMEOUT: Ue,
|
|
25
|
+
RTP_TIMEOUT: kt,
|
|
26
|
+
SIP_FAILURE_CODE: Rt,
|
|
27
|
+
UNAVAILABLE: mt,
|
|
28
|
+
USER_DENIED_MEDIA_ACCESS: Ht,
|
|
29
|
+
WEBRTC_ERROR: yt
|
|
30
|
+
}, Symbol.toStringTag, { value: "Module" })), q = "incomingCall", $ = "declinedIncomingCall", G = "failedIncomingCall", J = "terminatedIncomingCall", H = "connecting", I = "connected", g = "disconnected", D = "newRTCSession", P = "registered", X = "unregistered", m = "registrationFailed", ke = "newMessage", z = "sipEvent", Q = "availableSecondRemoteStream", j = "notAvailableSecondRemoteStream", K = "mustStopPresentation", v = "shareState", Z = "enterRoom", ee = "useLicense", te = "peerconnection:confirmed", ne = "peerconnection:ontrack", y = "channels", se = "channels:notify", ie = "ended:fromserver", re = "main-cam-control", oe = "admin-stop-main-cam", ae = "admin-start-main-cam", ce = "admin-stop-mic", Ee = "admin-start-mic", w = "admin-force-sync-media-state", de = "participant:added-to-list-moderators", he = "participant:removed-from-list-moderators", Se = "participant:move-request-to-stream", Te = "participant:move-request-to-spectators", le = "participant:move-request-to-participants", ue = "participation:accepting-word-request", ge = "participation:cancelling-word-request", Ce = "webcast:started", Ne = "webcast:stopped", _e = "account:changed", Ae = "account:deleted", Re = "conference:participant-token-issued", O = "ended", Be = "sending", xe = "reinvite", Fe = "replaces", Ve = "refer", Ye = "progress", qe = "accepted", b = "confirmed", L = "peerconnection", _ = "failed", $e = "muted", Ge = "unmuted", fe = "newDTMF", Ie = "newInfo", Je = "hold", Xe = "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", Pe = "presentation:ended", U = "presentation:failed", ot = "SPECTATOR", at = "PARTICIPANT", ct = 1e6;
|
|
31
|
+
var C = /* @__PURE__ */ ((s) => (s.LOCAL = "local", s.REMOTE = "remote", s.SYSTEM = "system", s))(C || {});
|
|
32
|
+
const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
33
|
+
__proto__: null,
|
|
34
|
+
ACCEPTED: qe,
|
|
35
|
+
ACCOUNT_CHANGED: _e,
|
|
36
|
+
ACCOUNT_DELETED: Ae,
|
|
37
|
+
ADMIN_FORCE_SYNC_MEDIA_STATE: w,
|
|
38
|
+
ADMIN_START_MAIN_CAM: ae,
|
|
39
|
+
ADMIN_START_MIC: Ee,
|
|
40
|
+
ADMIN_STOP_MAIN_CAM: oe,
|
|
41
|
+
ADMIN_STOP_MIC: ce,
|
|
42
|
+
AVAILABLE_SECOND_REMOTE_STREAM_EVENT: Q,
|
|
43
|
+
CHANNELS: y,
|
|
44
|
+
CHANNELS_NOTIFY: se,
|
|
45
|
+
CONFERENCE_PARTICIPANT_TOKEN_ISSUED: Re,
|
|
46
|
+
CONFIRMED: b,
|
|
47
|
+
CONNECTED: I,
|
|
48
|
+
CONNECTING: H,
|
|
49
|
+
DECLINED_INCOMING_CALL: $,
|
|
50
|
+
DISCONNECTED: g,
|
|
51
|
+
ENDED: O,
|
|
52
|
+
ENDED_FROM_SERVER: ie,
|
|
53
|
+
ENTER_ROOM: Z,
|
|
54
|
+
FAILED: _,
|
|
55
|
+
FAILED_INCOMING_CALL: G,
|
|
56
|
+
GET_USER_MEDIA_FAILED: Ke,
|
|
57
|
+
HOLD: Je,
|
|
58
|
+
ICE_CANDIDATE: je,
|
|
59
|
+
INCOMING_CALL: q,
|
|
60
|
+
MAIN_CAM_CONTROL: re,
|
|
61
|
+
MUST_STOP_PRESENTATION_EVENT: K,
|
|
62
|
+
MUTED: $e,
|
|
63
|
+
NEW_DTMF: fe,
|
|
64
|
+
NEW_INFO: Ie,
|
|
65
|
+
NEW_MESSAGE: ke,
|
|
66
|
+
NEW_RTC_SESSION: D,
|
|
67
|
+
NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: j,
|
|
68
|
+
ONE_MEGABIT_IN_BITS: ct,
|
|
69
|
+
Originator: C,
|
|
70
|
+
PARTICIPANT: at,
|
|
71
|
+
PARTICIPANT_ADDED_TO_LIST_MODERATORS: de,
|
|
72
|
+
PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS: le,
|
|
73
|
+
PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS: Te,
|
|
74
|
+
PARTICIPANT_MOVE_REQUEST_TO_STREAM: Se,
|
|
75
|
+
PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: he,
|
|
76
|
+
PARTICIPATION_ACCEPTING_WORD_REQUEST: ue,
|
|
77
|
+
PARTICIPATION_CANCELLING_WORD_REQUEST: ge,
|
|
78
|
+
PEER_CONNECTION: L,
|
|
79
|
+
PEER_CONNECTION_CONFIRMED: te,
|
|
80
|
+
PEER_CONNECTION_CREATE_ANSWER_FAILED: et,
|
|
81
|
+
PEER_CONNECTION_CREATE_OFFER_FAILED: Ze,
|
|
82
|
+
PEER_CONNECTION_ONTRACK: ne,
|
|
83
|
+
PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED: tt,
|
|
84
|
+
PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED: nt,
|
|
85
|
+
PRESENTATION_END: rt,
|
|
86
|
+
PRESENTATION_ENDED: Pe,
|
|
87
|
+
PRESENTATION_FAILED: U,
|
|
88
|
+
PRESENTATION_START: st,
|
|
89
|
+
PRESENTATION_STARTED: it,
|
|
90
|
+
PROGRESS: Ye,
|
|
91
|
+
REFER: Ve,
|
|
92
|
+
REGISTERED: P,
|
|
93
|
+
REGISTRATION_FAILED: m,
|
|
94
|
+
REINVITE: xe,
|
|
95
|
+
REPLACES: Fe,
|
|
96
|
+
SDP: Qe,
|
|
97
|
+
SENDING: Be,
|
|
98
|
+
SHARE_STATE: v,
|
|
99
|
+
SIP_EVENT: z,
|
|
100
|
+
SPECTATOR: ot,
|
|
101
|
+
TERMINATED_INCOMING_CALL: J,
|
|
102
|
+
UNHOLD: Xe,
|
|
103
|
+
UNMUTED: Ge,
|
|
104
|
+
UNREGISTERED: X,
|
|
105
|
+
UPDATE: ze,
|
|
106
|
+
USE_LICENSE: ee,
|
|
107
|
+
WEBCAST_STARTED: Ce,
|
|
108
|
+
WEBCAST_STOPPED: Ne
|
|
109
|
+
}, Symbol.toStringTag, { value: "Module" })), Et = [
|
|
110
|
+
q,
|
|
111
|
+
$,
|
|
112
|
+
J,
|
|
113
|
+
G,
|
|
114
|
+
ue,
|
|
115
|
+
ge,
|
|
116
|
+
Se,
|
|
117
|
+
se,
|
|
118
|
+
Re,
|
|
119
|
+
_e,
|
|
120
|
+
Ae,
|
|
121
|
+
Ce,
|
|
122
|
+
Ne,
|
|
123
|
+
de,
|
|
124
|
+
he
|
|
125
|
+
], me = [
|
|
126
|
+
H,
|
|
127
|
+
I,
|
|
128
|
+
g,
|
|
129
|
+
D,
|
|
130
|
+
P,
|
|
131
|
+
X,
|
|
132
|
+
m,
|
|
133
|
+
ke,
|
|
134
|
+
z
|
|
135
|
+
], dt = [
|
|
136
|
+
Q,
|
|
137
|
+
j,
|
|
138
|
+
K,
|
|
139
|
+
v,
|
|
140
|
+
Z,
|
|
141
|
+
ee,
|
|
142
|
+
te,
|
|
143
|
+
ne,
|
|
144
|
+
y,
|
|
145
|
+
ie,
|
|
146
|
+
re,
|
|
147
|
+
ae,
|
|
148
|
+
oe,
|
|
149
|
+
ce,
|
|
150
|
+
Ee,
|
|
151
|
+
w,
|
|
152
|
+
Te,
|
|
153
|
+
le
|
|
154
|
+
], Oe = [
|
|
155
|
+
O,
|
|
156
|
+
H,
|
|
157
|
+
Be,
|
|
158
|
+
xe,
|
|
159
|
+
Fe,
|
|
160
|
+
Ve,
|
|
161
|
+
Ye,
|
|
162
|
+
qe,
|
|
163
|
+
b,
|
|
164
|
+
L,
|
|
165
|
+
_,
|
|
166
|
+
$e,
|
|
167
|
+
Ge,
|
|
168
|
+
fe,
|
|
169
|
+
Ie,
|
|
170
|
+
Je,
|
|
171
|
+
Xe,
|
|
172
|
+
ze,
|
|
173
|
+
Qe,
|
|
174
|
+
je,
|
|
175
|
+
Ke,
|
|
176
|
+
Ze,
|
|
177
|
+
et,
|
|
178
|
+
tt,
|
|
179
|
+
nt,
|
|
180
|
+
st,
|
|
181
|
+
it,
|
|
182
|
+
rt,
|
|
183
|
+
Pe,
|
|
184
|
+
U
|
|
185
|
+
], ht = [...me, ...Et], St = [
|
|
186
|
+
...Oe,
|
|
187
|
+
...dt
|
|
188
|
+
], cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
189
|
+
__proto__: null,
|
|
190
|
+
SESSION_EVENT_NAMES: St,
|
|
191
|
+
SESSION_JSSIP_EVENT_NAMES: Oe,
|
|
192
|
+
SESSION_SYNTHETICS_EVENT_NAMES: dt,
|
|
193
|
+
UA_EVENT_NAMES: ht,
|
|
194
|
+
UA_JSSIP_EVENT_NAMES: me,
|
|
195
|
+
UA_SYNTHETICS_EVENT_NAMES: Et
|
|
196
|
+
}, Symbol.toStringTag, { value: "Module" })), pe = "sip-connector", B = V(pe), Es = () => {
|
|
197
|
+
V.enable(pe);
|
|
198
|
+
}, ds = () => {
|
|
199
|
+
V.enable(`-${pe}`);
|
|
200
|
+
}, Bt = (s, e) => (s.degradationPreference = e.degradationPreference, s), xt = (s, e) => {
|
|
201
|
+
s.encodings ??= [];
|
|
202
|
+
for (let t = s.encodings.length; t < e; t += 1)
|
|
203
|
+
s.encodings.push({});
|
|
204
|
+
return s;
|
|
205
|
+
}, Tt = (s) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== s, Ft = Tt(), Vt = (s, e) => {
|
|
206
|
+
if (Ft(s, e))
|
|
207
|
+
return s;
|
|
208
|
+
}, Yt = (s, e) => {
|
|
209
|
+
const t = s.maxBitrate, n = Vt(e, t);
|
|
210
|
+
return n !== void 0 && (s.maxBitrate = n), s;
|
|
211
|
+
}, lt = 1, qt = Tt(
|
|
212
|
+
lt
|
|
213
|
+
), $t = (s, e) => {
|
|
214
|
+
const t = s === void 0 ? void 0 : Math.max(s, lt);
|
|
215
|
+
if (t !== void 0 && qt(
|
|
216
|
+
t,
|
|
217
|
+
e
|
|
218
|
+
))
|
|
219
|
+
return t;
|
|
220
|
+
}, Gt = (s, e) => {
|
|
221
|
+
const t = s.scaleResolutionDownBy, n = $t(
|
|
222
|
+
e,
|
|
223
|
+
t
|
|
224
|
+
);
|
|
225
|
+
return n !== void 0 && (s.scaleResolutionDownBy = n), s;
|
|
226
|
+
}, Jt = (s, e) => {
|
|
227
|
+
const t = e.encodings?.length ?? 0;
|
|
228
|
+
return xt(s, t), s.encodings.forEach((n, i) => {
|
|
229
|
+
const r = (e?.encodings ?? [])[i], o = r?.maxBitrate, a = r?.scaleResolutionDownBy;
|
|
230
|
+
Yt(n, o), Gt(n, a);
|
|
231
|
+
}), s;
|
|
232
|
+
}, Xt = (s, e) => {
|
|
233
|
+
if (s.codecs?.length !== e.codecs?.length)
|
|
234
|
+
return !0;
|
|
235
|
+
for (let t = 0; t < (s.codecs?.length ?? 0); t++)
|
|
236
|
+
if (JSON.stringify(s.codecs[t]) !== JSON.stringify(e.codecs[t]))
|
|
237
|
+
return !0;
|
|
238
|
+
if (s.headerExtensions?.length !== e.headerExtensions?.length)
|
|
239
|
+
return !0;
|
|
240
|
+
for (let t = 0; t < (s.headerExtensions?.length ?? 0); t++)
|
|
241
|
+
if (JSON.stringify(s.headerExtensions[t]) !== JSON.stringify(e.headerExtensions[t]))
|
|
242
|
+
return !0;
|
|
243
|
+
if (s.encodings?.length !== e.encodings?.length)
|
|
244
|
+
return !0;
|
|
245
|
+
for (let t = 0; t < (s.encodings.length ?? 0); t++)
|
|
246
|
+
if (JSON.stringify(s.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
247
|
+
return !0;
|
|
248
|
+
return s.rtcp?.cname !== e.rtcp?.cname || s.rtcp?.reducedSize !== e.rtcp?.reducedSize || s.degradationPreference !== e.degradationPreference;
|
|
249
|
+
}, zt = async (s, e) => {
|
|
250
|
+
const t = s.getParameters(), n = JSON.parse(
|
|
251
|
+
JSON.stringify(t)
|
|
252
|
+
);
|
|
253
|
+
Jt(t, e), Bt(t, e);
|
|
254
|
+
const i = Xt(n, t);
|
|
255
|
+
return i && await s.setParameters(t), { parameters: t, isChanged: i };
|
|
256
|
+
};
|
|
257
|
+
var f = /* @__PURE__ */ ((s) => (s.PAUSE_MAIN_CAM = "PAUSEMAINCAM", s.RESUME_MAIN_CAM = "RESUMEMAINCAM", s.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", s.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", s.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", s))(f || {}), x = /* @__PURE__ */ ((s) => (s.ADMIN_STOP_MIC = "ADMINSTOPMIC", s.ADMIN_START_MIC = "ADMINSTARTMIC", s))(x || {}), F = /* @__PURE__ */ ((s) => (s.ADMIN_SYNC_FORCED = "1", s.ADMIN_SYNC_NOT_FORCED = "0", s))(F || {}), Qt = /* @__PURE__ */ ((s) => (s.AUDIO = "AUDIO", s.VIDEO = "VIDEO", s.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", s))(Qt || {}), jt = /* @__PURE__ */ ((s) => (s.VP8 = "video/VP8", s.VP9 = "video/VP9", s.H264 = "video/H264", s.AV1 = "video/AV1", s.rtx = "video/rtx", s.red = "video/red", s.flexfec03 = "video/flexfec-03", s))(jt || {});
|
|
258
|
+
const Kt = async (s, e, t) => {
|
|
259
|
+
const { isChanged: n, parameters: i } = await zt(s, {
|
|
260
|
+
encodings: [
|
|
261
|
+
{
|
|
262
|
+
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
263
|
+
maxBitrate: e.maxBitrate
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
});
|
|
267
|
+
return n && t && t(i), { isChanged: n, parameters: i };
|
|
268
|
+
};
|
|
269
|
+
function Zt(s) {
|
|
270
|
+
return (e) => `sip:${e}@${s}`;
|
|
271
|
+
}
|
|
272
|
+
const en = (s, e) => () => Math.floor(Math.random() * (e - s)) + s, ve = (s) => s.trim().replaceAll(" ", "_"), tn = en(1e5, 99999999), nn = (s) => s.some((t) => {
|
|
273
|
+
const { kind: n } = t;
|
|
274
|
+
return n === "video";
|
|
275
|
+
}), sn = (s) => {
|
|
276
|
+
const e = [];
|
|
277
|
+
return s !== void 0 && s !== "" && e.push(`X-Vinteo-Remote: ${s}`), e;
|
|
278
|
+
}, rn = "content-type", on = "x-webrtc-enter-room", p = "application/vinteo.webrtc.sharedesktop", an = "application/vinteo.webrtc.roomname", cn = "application/vinteo.webrtc.channels", En = "application/vinteo.webrtc.mediastate", dn = "application/vinteo.webrtc.refusal", ye = "application/vinteo.webrtc.maincam", hn = "application/vinteo.webrtc.mic", Sn = "application/vinteo.webrtc.uselic", Tn = "X-WEBRTC-USE-LICENSE", ln = "X-WEBRTC-PARTICIPANT-NAME", we = "X-WEBRTC-INPUT-CHANNELS", be = "X-WEBRTC-OUTPUT-CHANNELS", un = "X-WEBRTC-MAINCAM", gn = "X-WEBRTC-MIC", Le = "X-WEBRTC-SYNC", Cn = "X-WEBRTC-MAINCAM-RESOLUTION", Nn = "X-WEBRTC-MEDIA-STATE", _n = "X-Vinteo-Media-Type", An = "X-Vinteo-MainCam-State", Rn = "X-Vinteo-Mic-State", fn = "application/vinteo.webrtc.partstate", In = "X-WEBRTC-PARTSTATE", Pn = "application/vinteo.webrtc.notify", mn = "X-VINTEO-NOTIFY", A = "x-webrtc-share-state", On = `${A}: LETMESTARTPRESENTATION`, pn = `${A}: STOPPRESENTATION`, ut = "YOUCANRECEIVECONTENT", gt = "CONTENTEND", Ct = "YOUMUSTSTOPSENDCONTENT", Mn = `${A}: ${Ct}`, Dn = `${A}: ${ut}`, vn = `${A}: ${gt}`, yn = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", wn = `${yn}: LETMESTARTMAINCAM`, bn = (s, e) => {
|
|
279
|
+
s.getVideoTracks().forEach((n) => {
|
|
280
|
+
"contentHint" in n && n.contentHint !== e && (n.contentHint = e);
|
|
281
|
+
});
|
|
282
|
+
}, M = (s, {
|
|
283
|
+
directionVideo: e,
|
|
284
|
+
directionAudio: t,
|
|
285
|
+
contentHint: n
|
|
286
|
+
} = {}) => {
|
|
287
|
+
if (!s || e === "recvonly" && t === "recvonly")
|
|
288
|
+
return;
|
|
289
|
+
const i = t === "recvonly" ? [] : s.getAudioTracks(), r = e === "recvonly" ? [] : s.getVideoTracks(), o = [...i, ...r], a = new MediaStream(o);
|
|
290
|
+
return a.getTracks = () => [...a.getAudioTracks(), ...a.getVideoTracks()], n && n !== "none" && bn(a, n), a;
|
|
291
|
+
}, Ln = "Error decline with 603", Un = 1006, Hn = (s) => typeof s == "object" && s !== null && "code" in s && s.code === Un, Wn = (s) => s.message === Ln, kn = (s, e) => s.find((t) => t.track !== null && e.getTracks().includes(t.track)), Bn = async (s, e, t) => {
|
|
292
|
+
const n = kn(s, e);
|
|
293
|
+
if (n)
|
|
294
|
+
return Kt(n, { maxBitrate: t });
|
|
295
|
+
}, xn = 486, Fn = 487, Vn = 3, Yn = 1, qn = (s) => s instanceof Object && ("originator" in s || "cause" in s), hs = (s) => {
|
|
296
|
+
if (Nt(s))
|
|
297
|
+
return !0;
|
|
298
|
+
if (!qn(s))
|
|
299
|
+
return !1;
|
|
300
|
+
const { originator: e, cause: t } = s;
|
|
301
|
+
return typeof t == "string" ? t === Ue || t === He || e === C.LOCAL && (t === Y || t === We) : !1;
|
|
302
|
+
}, Ss = (s) => _t(s), $n = "channels", Gn = "WebcastStarted", Jn = "WebcastStopped", Xn = "accountChanged", zn = "accountDeleted", Qn = "addedToListModerators", jn = "removedFromListModerators", Kn = "ParticipationRequestAccepted", Zn = "ParticipationRequestRejected", es = "ParticipantMovedToWebcast", ts = "ConferenceParticipantTokenIssued";
|
|
303
|
+
class Ts {
|
|
304
|
+
promisePendingStartPresentation;
|
|
305
|
+
promisePendingStopPresentation;
|
|
306
|
+
ua;
|
|
307
|
+
rtcSession;
|
|
308
|
+
incomingRTCSession;
|
|
309
|
+
streamPresentationCurrent;
|
|
310
|
+
socket;
|
|
311
|
+
isRegisterConfigInner = !1;
|
|
312
|
+
connectionConfiguration = {};
|
|
313
|
+
remoteStreams = {};
|
|
314
|
+
JsSIP;
|
|
315
|
+
sessionEvents;
|
|
316
|
+
uaEvents;
|
|
317
|
+
cancelableConnectWithRepeatedCalls;
|
|
318
|
+
cancelableSendPresentationWithRepeatedCalls;
|
|
319
|
+
isPendingConnect = !1;
|
|
320
|
+
isPendingInitUa = !1;
|
|
321
|
+
isPendingCall = !1;
|
|
322
|
+
isPendingAnswer = !1;
|
|
323
|
+
constructor({ JsSIP: e }) {
|
|
324
|
+
this.JsSIP = e, this.sessionEvents = new Me(St), this.uaEvents = new Me(ht), this.onSession(v, this.handleShareState), this.onSession(Ie, this.handleNewInfo), this.on(z, this.handleSipEvent), this.onSession(_, this.handleEnded), this.onSession(O, this.handleEnded);
|
|
325
|
+
}
|
|
326
|
+
get connection() {
|
|
327
|
+
return this.rtcSession?.connection;
|
|
328
|
+
}
|
|
329
|
+
get remoteCallerData() {
|
|
330
|
+
return {
|
|
331
|
+
displayName: this.incomingRTCSession?.remote_identity.display_name,
|
|
332
|
+
host: this.incomingRTCSession?.remote_identity.uri.host,
|
|
333
|
+
incomingNumber: this.incomingRTCSession?.remote_identity.uri.user,
|
|
334
|
+
rtcSession: this.incomingRTCSession
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
get requested() {
|
|
338
|
+
return this.isPendingInitUa || this.isPendingConnect || this.isPendingCall || this.isPendingAnswer;
|
|
339
|
+
}
|
|
340
|
+
get establishedRTCSession() {
|
|
341
|
+
return this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
|
|
342
|
+
}
|
|
343
|
+
get isRegistered() {
|
|
344
|
+
return !!this.ua && this.ua.isRegistered();
|
|
345
|
+
}
|
|
346
|
+
get isRegisterConfig() {
|
|
347
|
+
return !!this.ua && this.isRegisterConfigInner;
|
|
348
|
+
}
|
|
349
|
+
get isCallActive() {
|
|
350
|
+
return !!(this.ua && this.rtcSession);
|
|
351
|
+
}
|
|
352
|
+
get isAvailableIncomingCall() {
|
|
353
|
+
return !!this.incomingRTCSession;
|
|
354
|
+
}
|
|
355
|
+
get isPendingPresentation() {
|
|
356
|
+
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
357
|
+
}
|
|
358
|
+
connect = async (e, t) => (this.cancelRequests(), this.connectWithDuplicatedCalls(e, t));
|
|
359
|
+
hangUp = async () => (this.cancelRequests(), this.hangUpWithoutCancelRequests());
|
|
360
|
+
async register() {
|
|
361
|
+
return new Promise((e, t) => {
|
|
362
|
+
this.isRegisterConfig && this.ua ? (this.ua.on(P, e), this.ua.on(m, t), this.ua.register()) : t(new Error("Config is not registered"));
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
async unregister() {
|
|
366
|
+
return new Promise((e, t) => {
|
|
367
|
+
this.isRegistered && this.ua ? (this.ua.on(X, e), this.ua.unregister()) : t(new Error("ua is not registered"));
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
tryRegister = async () => {
|
|
371
|
+
if (!this.isRegisterConfig)
|
|
372
|
+
throw new Error("Config is not registered");
|
|
373
|
+
this.uaEvents.trigger(H, void 0);
|
|
374
|
+
try {
|
|
375
|
+
await this.unregister();
|
|
376
|
+
} catch (e) {
|
|
377
|
+
B("tryRegister", e);
|
|
378
|
+
}
|
|
379
|
+
return this.register();
|
|
380
|
+
};
|
|
381
|
+
async sendOptions(e, t, n) {
|
|
382
|
+
if (!this.ua)
|
|
383
|
+
throw new Error("is not connected");
|
|
384
|
+
return new Promise((i, r) => {
|
|
385
|
+
try {
|
|
386
|
+
this.ua.sendOptions(e, t, {
|
|
387
|
+
extraHeaders: n,
|
|
388
|
+
eventHandlers: {
|
|
389
|
+
succeeded: () => {
|
|
390
|
+
i();
|
|
391
|
+
},
|
|
392
|
+
failed: r
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
} catch (o) {
|
|
396
|
+
r(o);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
async ping(e, t) {
|
|
401
|
+
if (!this.ua?.configuration.uri)
|
|
402
|
+
throw new Error("is not connected");
|
|
403
|
+
const n = this.ua.configuration.uri;
|
|
404
|
+
return this.sendOptions(n, e, t);
|
|
405
|
+
}
|
|
406
|
+
async checkTelephony({
|
|
407
|
+
userAgent: e,
|
|
408
|
+
displayName: t,
|
|
409
|
+
sipServerUrl: n,
|
|
410
|
+
sipWebSocketServerURL: i,
|
|
411
|
+
remoteAddress: r,
|
|
412
|
+
extraHeaders: o
|
|
413
|
+
}) {
|
|
414
|
+
return new Promise((a, c) => {
|
|
415
|
+
const { configuration: E } = this.createUaConfiguration({
|
|
416
|
+
sipWebSocketServerURL: i,
|
|
417
|
+
displayName: t,
|
|
418
|
+
userAgent: e,
|
|
419
|
+
sipServerUrl: n
|
|
420
|
+
}), h = this.createUa({ ...E, remoteAddress: r, extraHeaders: o }), S = () => {
|
|
421
|
+
const T = new Error("Telephony is not available");
|
|
422
|
+
c(T);
|
|
423
|
+
};
|
|
424
|
+
h.once(g, S);
|
|
425
|
+
const d = () => {
|
|
426
|
+
h.removeAllListeners(), h.once(g, a), h.stop();
|
|
427
|
+
};
|
|
428
|
+
h.once(I, d), h.start();
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
async replaceMediaStream(e, t) {
|
|
432
|
+
if (!this.rtcSession)
|
|
433
|
+
throw new Error("No rtcSession established");
|
|
434
|
+
const { contentHint: n } = t ?? {}, i = M(e, { contentHint: n });
|
|
435
|
+
if (i === void 0)
|
|
436
|
+
throw new Error("No preparedMediaStream");
|
|
437
|
+
return this.rtcSession.replaceMediaStream(i, t);
|
|
438
|
+
}
|
|
439
|
+
declineToIncomingCall = async ({
|
|
440
|
+
statusCode: e = Fn
|
|
441
|
+
} = {}) => new Promise((t, n) => {
|
|
442
|
+
try {
|
|
443
|
+
const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
|
|
444
|
+
this.removeIncomingSession(), this.uaEvents.trigger($, r), i.terminate({ status_code: e }), t();
|
|
445
|
+
} catch (i) {
|
|
446
|
+
n(i);
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
busyIncomingCall = async () => this.declineToIncomingCall({ statusCode: xn });
|
|
450
|
+
async askPermissionToEnableCam(e = {}) {
|
|
451
|
+
if (!this.rtcSession)
|
|
452
|
+
throw new Error("No rtcSession established");
|
|
453
|
+
const t = [wn];
|
|
454
|
+
return this.rtcSession.sendInfo(ye, void 0, {
|
|
455
|
+
noTerminateWhenError: !0,
|
|
456
|
+
...e,
|
|
457
|
+
extraHeaders: t
|
|
458
|
+
}).catch((n) => {
|
|
459
|
+
if (Wn(n))
|
|
460
|
+
throw n;
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
async startPresentation(e, {
|
|
464
|
+
isNeedReinvite: t,
|
|
465
|
+
isP2P: n,
|
|
466
|
+
maxBitrate: i,
|
|
467
|
+
contentHint: r,
|
|
468
|
+
sendEncodings: o,
|
|
469
|
+
onAddedTransceiver: a
|
|
470
|
+
} = {}, c) {
|
|
471
|
+
const E = this.establishedRTCSession;
|
|
472
|
+
if (!E)
|
|
473
|
+
throw new Error("No rtcSession established");
|
|
474
|
+
if (this.streamPresentationCurrent)
|
|
475
|
+
throw new Error("Presentation is already started");
|
|
476
|
+
return n === !0 && await this.sendMustStopPresentation(), this.sendPresentationWithDuplicatedCalls({
|
|
477
|
+
rtcSession: E,
|
|
478
|
+
stream: e,
|
|
479
|
+
presentationOptions: {
|
|
480
|
+
isNeedReinvite: t,
|
|
481
|
+
isP2P: n,
|
|
482
|
+
maxBitrate: i,
|
|
483
|
+
contentHint: r,
|
|
484
|
+
sendEncodings: o,
|
|
485
|
+
onAddedTransceiver: a
|
|
486
|
+
},
|
|
487
|
+
options: c
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
async stopPresentation({
|
|
491
|
+
isP2P: e = !1
|
|
492
|
+
} = {}) {
|
|
493
|
+
this.cancelSendPresentationWithRepeatedCalls();
|
|
494
|
+
const t = this.streamPresentationCurrent;
|
|
495
|
+
let n = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
|
|
496
|
+
const i = e ? [vn] : [pn], r = this.establishedRTCSession;
|
|
497
|
+
return r && t && (n = n.then(async () => r.sendInfo(p, void 0, {
|
|
498
|
+
extraHeaders: i
|
|
499
|
+
})).then(async () => r.stopPresentation(t)).catch((o) => {
|
|
500
|
+
throw this.sessionEvents.trigger(U, o), o;
|
|
501
|
+
})), !r && t && this.sessionEvents.trigger(Pe, t), this.promisePendingStopPresentation = n, n.finally(() => {
|
|
502
|
+
this.resetPresentation();
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
async updatePresentation(e, {
|
|
506
|
+
isP2P: t,
|
|
507
|
+
maxBitrate: n,
|
|
508
|
+
contentHint: i,
|
|
509
|
+
sendEncodings: r,
|
|
510
|
+
onAddedTransceiver: o
|
|
511
|
+
} = {}) {
|
|
512
|
+
const a = this.establishedRTCSession;
|
|
513
|
+
if (!a)
|
|
514
|
+
throw new Error("No rtcSession established");
|
|
515
|
+
if (!this.streamPresentationCurrent)
|
|
516
|
+
throw new Error("Presentation has not started yet");
|
|
517
|
+
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(a, e, {
|
|
518
|
+
isP2P: t,
|
|
519
|
+
maxBitrate: n,
|
|
520
|
+
contentHint: i,
|
|
521
|
+
isNeedReinvite: !1,
|
|
522
|
+
sendEncodings: r,
|
|
523
|
+
onAddedTransceiver: o
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
527
|
+
on(e, t) {
|
|
528
|
+
return this.uaEvents.on(e, t);
|
|
529
|
+
}
|
|
530
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
531
|
+
once(e, t) {
|
|
532
|
+
return this.uaEvents.once(e, t);
|
|
533
|
+
}
|
|
534
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
535
|
+
onceRace(e, t) {
|
|
536
|
+
return this.uaEvents.onceRace(e, t);
|
|
537
|
+
}
|
|
538
|
+
async wait(e) {
|
|
539
|
+
return this.uaEvents.wait(e);
|
|
540
|
+
}
|
|
541
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
542
|
+
off(e, t) {
|
|
543
|
+
this.uaEvents.off(e, t);
|
|
544
|
+
}
|
|
545
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
546
|
+
onSession(e, t) {
|
|
547
|
+
return this.sessionEvents.on(e, t);
|
|
548
|
+
}
|
|
549
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
550
|
+
onceSession(e, t) {
|
|
551
|
+
return this.sessionEvents.once(e, t);
|
|
552
|
+
}
|
|
553
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
554
|
+
onceRaceSession(e, t) {
|
|
555
|
+
return this.sessionEvents.onceRace(e, t);
|
|
556
|
+
}
|
|
557
|
+
async waitSession(e) {
|
|
558
|
+
return this.sessionEvents.wait(e);
|
|
559
|
+
}
|
|
560
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
561
|
+
offSession(e, t) {
|
|
562
|
+
this.sessionEvents.off(e, t);
|
|
563
|
+
}
|
|
564
|
+
isConfigured() {
|
|
565
|
+
return !!this.ua;
|
|
566
|
+
}
|
|
567
|
+
getConnectionConfiguration() {
|
|
568
|
+
return { ...this.connectionConfiguration };
|
|
569
|
+
}
|
|
570
|
+
getRemoteStreams() {
|
|
571
|
+
if (!this.connection)
|
|
572
|
+
return;
|
|
573
|
+
const t = this.connection.getReceivers().map(({ track: n }) => n);
|
|
574
|
+
return nn(t) ? this.generateStreams(t) : this.generateAudioStreams(t);
|
|
575
|
+
}
|
|
576
|
+
getIncomingRTCSession() {
|
|
577
|
+
const { incomingRTCSession: e } = this;
|
|
578
|
+
if (!e)
|
|
579
|
+
throw new Error("No incomingRTCSession");
|
|
580
|
+
return e;
|
|
581
|
+
}
|
|
582
|
+
set = async ({ displayName: e, password: t }) => new Promise((n, i) => {
|
|
583
|
+
const { ua: r } = this;
|
|
584
|
+
if (!r) {
|
|
585
|
+
i(new Error("this.ua is not initialized"));
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
let o = !1, a = !1;
|
|
589
|
+
e !== void 0 && e !== this.connectionConfiguration.displayName && (o = r.set("display_name", ve(e)), this.connectionConfiguration.displayName = e), t !== void 0 && t !== this.connectionConfiguration.password && (a = r.set("password", t), this.connectionConfiguration.password = t);
|
|
590
|
+
const c = o || a;
|
|
591
|
+
a && this.isRegisterConfig ? this.register().then(() => {
|
|
592
|
+
n(c);
|
|
593
|
+
}).catch((E) => {
|
|
594
|
+
i(E);
|
|
595
|
+
}) : c ? n(c) : i(new Error("nothing changed"));
|
|
596
|
+
});
|
|
597
|
+
disconnect = async () => {
|
|
598
|
+
this.off(D, this.handleNewRTCSession);
|
|
599
|
+
const e = new Promise((n) => {
|
|
600
|
+
this.once(g, () => {
|
|
601
|
+
n();
|
|
602
|
+
});
|
|
603
|
+
}), { ua: t } = this;
|
|
604
|
+
return t ? (await this.hangUpWithoutCancelRequests(), t.stop()) : this.uaEvents.trigger(g, void 0), e.finally(() => {
|
|
605
|
+
delete this.ua;
|
|
606
|
+
});
|
|
607
|
+
};
|
|
608
|
+
call = async ({
|
|
609
|
+
number: e,
|
|
610
|
+
mediaStream: t,
|
|
611
|
+
extraHeaders: n = [],
|
|
612
|
+
ontrack: i,
|
|
613
|
+
iceServers: r,
|
|
614
|
+
directionVideo: o,
|
|
615
|
+
directionAudio: a,
|
|
616
|
+
contentHint: c,
|
|
617
|
+
offerToReceiveAudio: E = !0,
|
|
618
|
+
offerToReceiveVideo: h = !0,
|
|
619
|
+
sendEncodings: S,
|
|
620
|
+
onAddedTransceiver: d
|
|
621
|
+
}) => (this.isPendingCall = !0, new Promise((T, l) => {
|
|
622
|
+
const { ua: u } = this;
|
|
623
|
+
if (!u) {
|
|
624
|
+
l(new Error("this.ua is not initialized"));
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
this.connectionConfiguration.number = e, this.connectionConfiguration.answer = !1, this.handleCall({ ontrack: i }).then(T).catch((N) => {
|
|
628
|
+
l(N);
|
|
629
|
+
}), this.rtcSession = u.call(this.getSipServerUrl(e), {
|
|
630
|
+
extraHeaders: n,
|
|
631
|
+
mediaStream: M(t, {
|
|
632
|
+
directionVideo: o,
|
|
633
|
+
directionAudio: a,
|
|
634
|
+
contentHint: c
|
|
635
|
+
}),
|
|
636
|
+
eventHandlers: this.sessionEvents.triggers,
|
|
637
|
+
directionVideo: o,
|
|
638
|
+
directionAudio: a,
|
|
639
|
+
pcConfig: {
|
|
640
|
+
iceServers: r
|
|
641
|
+
},
|
|
642
|
+
rtcOfferConstraints: {
|
|
643
|
+
offerToReceiveAudio: E,
|
|
644
|
+
offerToReceiveVideo: h
|
|
645
|
+
},
|
|
646
|
+
sendEncodings: S,
|
|
647
|
+
onAddedTransceiver: d
|
|
648
|
+
});
|
|
649
|
+
}).finally(() => {
|
|
650
|
+
this.isPendingCall = !1;
|
|
651
|
+
}));
|
|
652
|
+
answerToIncomingCall = async ({
|
|
653
|
+
mediaStream: e,
|
|
654
|
+
ontrack: t,
|
|
655
|
+
extraHeaders: n = [],
|
|
656
|
+
iceServers: i,
|
|
657
|
+
directionVideo: r,
|
|
658
|
+
directionAudio: o,
|
|
659
|
+
offerToReceiveAudio: a,
|
|
660
|
+
offerToReceiveVideo: c,
|
|
661
|
+
contentHint: E,
|
|
662
|
+
sendEncodings: h,
|
|
663
|
+
onAddedTransceiver: S
|
|
664
|
+
}) => (this.isPendingAnswer = !0, new Promise((d, T) => {
|
|
665
|
+
try {
|
|
666
|
+
const l = this.getIncomingRTCSession();
|
|
667
|
+
this.rtcSession = l, this.removeIncomingSession(), this.sessionEvents.eachTriggers((N, W) => {
|
|
668
|
+
const R = Oe.find((k) => k === W);
|
|
669
|
+
R && l.on(R, N);
|
|
670
|
+
}), this.connectionConfiguration.answer = !0, this.connectionConfiguration.number = l.remote_identity.uri.user, this.handleCall({ ontrack: t }).then(d).catch((N) => {
|
|
671
|
+
T(N);
|
|
672
|
+
});
|
|
673
|
+
const u = M(e, {
|
|
674
|
+
directionVideo: r,
|
|
675
|
+
directionAudio: o,
|
|
676
|
+
contentHint: E
|
|
677
|
+
});
|
|
678
|
+
l.answer({
|
|
679
|
+
extraHeaders: n,
|
|
680
|
+
directionVideo: r,
|
|
681
|
+
directionAudio: o,
|
|
682
|
+
mediaStream: u,
|
|
683
|
+
pcConfig: {
|
|
684
|
+
iceServers: i
|
|
685
|
+
},
|
|
686
|
+
rtcOfferConstraints: {
|
|
687
|
+
offerToReceiveAudio: a,
|
|
688
|
+
offerToReceiveVideo: c
|
|
689
|
+
},
|
|
690
|
+
sendEncodings: h,
|
|
691
|
+
onAddedTransceiver: S
|
|
692
|
+
});
|
|
693
|
+
} catch (l) {
|
|
694
|
+
T(l);
|
|
695
|
+
}
|
|
696
|
+
}).finally(() => {
|
|
697
|
+
this.isPendingAnswer = !1;
|
|
698
|
+
}));
|
|
699
|
+
sendDTMF = async (e) => new Promise((t, n) => {
|
|
700
|
+
const { rtcSession: i } = this;
|
|
701
|
+
if (!i) {
|
|
702
|
+
n(new Error("No rtcSession established"));
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
this.onceSession(fe, ({ originator: r }) => {
|
|
706
|
+
r === C.LOCAL && t();
|
|
707
|
+
}), i.sendDTMF(e, {
|
|
708
|
+
duration: 120,
|
|
709
|
+
interToneGap: 600
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
|
+
cancelSendPresentationWithRepeatedCalls() {
|
|
713
|
+
this.cancelableSendPresentationWithRepeatedCalls?.cancel();
|
|
714
|
+
}
|
|
715
|
+
async waitChannels() {
|
|
716
|
+
return this.waitSession(y);
|
|
717
|
+
}
|
|
718
|
+
async waitSyncMediaState() {
|
|
719
|
+
return this.waitSession(w);
|
|
720
|
+
}
|
|
721
|
+
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
722
|
+
if (!this.rtcSession)
|
|
723
|
+
throw new Error("No rtcSession established");
|
|
724
|
+
const n = `${we}: ${e}`, i = `${be}: ${t}`, r = [
|
|
725
|
+
n,
|
|
726
|
+
i
|
|
727
|
+
];
|
|
728
|
+
return this.rtcSession.sendInfo(cn, void 0, { extraHeaders: r });
|
|
729
|
+
}
|
|
730
|
+
async sendMediaState({ cam: e, mic: t }, n = {}) {
|
|
731
|
+
if (!this.rtcSession)
|
|
732
|
+
throw new Error("No rtcSession established");
|
|
733
|
+
const i = `${Nn}: currentstate`, r = `${An}: ${Number(e)}`, o = `${Rn}: ${Number(t)}`, a = [
|
|
734
|
+
i,
|
|
735
|
+
r,
|
|
736
|
+
o
|
|
737
|
+
];
|
|
738
|
+
return this.rtcSession.sendInfo(En, void 0, {
|
|
739
|
+
noTerminateWhenError: !0,
|
|
740
|
+
...n,
|
|
741
|
+
extraHeaders: a
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
async sendRefusalToTurnOn(e, t = {}) {
|
|
745
|
+
if (!this.rtcSession)
|
|
746
|
+
throw new Error("No rtcSession established");
|
|
747
|
+
const a = [`${_n}: ${e === "mic" ? 0 : 1}`];
|
|
748
|
+
return this.rtcSession.sendInfo(dn, void 0, {
|
|
749
|
+
noTerminateWhenError: !0,
|
|
750
|
+
...t,
|
|
751
|
+
extraHeaders: a
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
async sendRefusalToTurnOnMic(e = {}) {
|
|
755
|
+
if (!this.rtcSession)
|
|
756
|
+
throw new Error("No rtcSession established");
|
|
757
|
+
return this.sendRefusalToTurnOn("mic", { noTerminateWhenError: !0, ...e });
|
|
758
|
+
}
|
|
759
|
+
async sendRefusalToTurnOnCam(e = {}) {
|
|
760
|
+
if (!this.rtcSession)
|
|
761
|
+
throw new Error("No rtcSession established");
|
|
762
|
+
return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
|
|
763
|
+
}
|
|
764
|
+
removeIncomingSession = () => {
|
|
765
|
+
delete this.incomingRTCSession;
|
|
766
|
+
};
|
|
767
|
+
// eslint-disable-next-line class-methods-use-this
|
|
768
|
+
getSipServerUrl = (e) => e;
|
|
769
|
+
async sendMustStopPresentation() {
|
|
770
|
+
const e = this.establishedRTCSession;
|
|
771
|
+
if (!e)
|
|
772
|
+
throw new Error("No rtcSession established");
|
|
773
|
+
await e.sendInfo(p, void 0, {
|
|
774
|
+
extraHeaders: [Mn]
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = Vn } = {}) => {
|
|
778
|
+
const n = async () => this.connectInner(e), i = (r) => {
|
|
779
|
+
const a = this.ua?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), c = r != null && !Hn(r);
|
|
780
|
+
return a || c;
|
|
781
|
+
};
|
|
782
|
+
return this.isPendingConnect = !0, this.cancelableConnectWithRepeatedCalls = De({
|
|
783
|
+
targetFunction: n,
|
|
784
|
+
isComplete: i,
|
|
785
|
+
callLimit: t,
|
|
786
|
+
isRejectAsValid: !0,
|
|
787
|
+
isCheckBeforeCall: !1
|
|
788
|
+
}), this.cancelableConnectWithRepeatedCalls.then((r) => {
|
|
789
|
+
if (r instanceof this.JsSIP.UA)
|
|
790
|
+
return r;
|
|
791
|
+
throw r;
|
|
792
|
+
}).finally(() => {
|
|
793
|
+
this.isPendingConnect = !1;
|
|
794
|
+
});
|
|
795
|
+
};
|
|
796
|
+
async sendPresentationWithDuplicatedCalls({
|
|
797
|
+
rtcSession: e,
|
|
798
|
+
stream: t,
|
|
799
|
+
presentationOptions: n,
|
|
800
|
+
options: i = {
|
|
801
|
+
callLimit: Yn
|
|
802
|
+
}
|
|
803
|
+
}) {
|
|
804
|
+
const r = async () => this.sendPresentation(e, t, n), o = () => !!this.streamPresentationCurrent;
|
|
805
|
+
return this.cancelableSendPresentationWithRepeatedCalls = De({
|
|
806
|
+
targetFunction: r,
|
|
807
|
+
isComplete: o,
|
|
808
|
+
isRejectAsValid: !0,
|
|
809
|
+
...i
|
|
810
|
+
}), this.cancelableSendPresentationWithRepeatedCalls.then((a) => a);
|
|
811
|
+
}
|
|
812
|
+
hasEqualConnectionConfiguration(e) {
|
|
813
|
+
const { configuration: t } = this.createUaConfiguration(e), n = this.ua?.configuration;
|
|
814
|
+
return n?.password === t.password && n?.register === t.register && n.uri.toString() === t.uri && n.display_name === t.display_name && n.user_agent === t.user_agent && n.sockets === t.sockets && n.session_timers === t.session_timers && n.register_expires === t.register_expires && n.connection_recovery_min_interval === t.connection_recovery_min_interval && n.connection_recovery_max_interval === t.connection_recovery_max_interval;
|
|
815
|
+
}
|
|
816
|
+
createUaConfiguration({
|
|
817
|
+
user: e,
|
|
818
|
+
password: t,
|
|
819
|
+
sipWebSocketServerURL: n,
|
|
820
|
+
displayName: i = "",
|
|
821
|
+
sipServerUrl: r,
|
|
822
|
+
register: o = !1,
|
|
823
|
+
sessionTimers: a = !1,
|
|
824
|
+
registerExpires: c = 60 * 5,
|
|
825
|
+
// 5 minutes in sec
|
|
826
|
+
connectionRecoveryMinInterval: E = 2,
|
|
827
|
+
connectionRecoveryMaxInterval: h = 6,
|
|
828
|
+
userAgent: S
|
|
829
|
+
}) {
|
|
830
|
+
if (o && (t === void 0 || t === ""))
|
|
831
|
+
throw new Error("password is required for authorized connection");
|
|
832
|
+
const d = o && e !== void 0 && e.trim() !== "" ? e.trim() : `${tn()}`, T = Zt(r), l = T(d), u = new this.JsSIP.WebSocketInterface(n);
|
|
833
|
+
return {
|
|
834
|
+
configuration: {
|
|
835
|
+
password: t,
|
|
836
|
+
register: o,
|
|
837
|
+
uri: l,
|
|
838
|
+
display_name: ve(i),
|
|
839
|
+
user_agent: S,
|
|
840
|
+
sdp_semantics: "unified-plan",
|
|
841
|
+
sockets: [u],
|
|
842
|
+
session_timers: a,
|
|
843
|
+
register_expires: c,
|
|
844
|
+
connection_recovery_min_interval: E,
|
|
845
|
+
connection_recovery_max_interval: h
|
|
846
|
+
},
|
|
847
|
+
helpers: {
|
|
848
|
+
socket: u,
|
|
849
|
+
getSipServerUrl: T
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
async sendPresentation(e, t, {
|
|
854
|
+
maxBitrate: n = ct,
|
|
855
|
+
isNeedReinvite: i = !0,
|
|
856
|
+
isP2P: r = !1,
|
|
857
|
+
contentHint: o = "detail",
|
|
858
|
+
sendEncodings: a,
|
|
859
|
+
onAddedTransceiver: c
|
|
860
|
+
}) {
|
|
861
|
+
const E = M(t, { contentHint: o });
|
|
862
|
+
if (E === void 0)
|
|
863
|
+
throw new Error("No streamPresentationCurrent");
|
|
864
|
+
this.streamPresentationCurrent = E;
|
|
865
|
+
const h = r ? [Dn] : [On], S = e.sendInfo(p, void 0, {
|
|
866
|
+
extraHeaders: h
|
|
867
|
+
}).then(async () => e.startPresentation(E, i, {
|
|
868
|
+
sendEncodings: a,
|
|
869
|
+
onAddedTransceiver: c
|
|
870
|
+
})).then(async () => {
|
|
871
|
+
const { connection: d } = this;
|
|
872
|
+
if (!d)
|
|
873
|
+
return;
|
|
874
|
+
const T = d.getSenders();
|
|
875
|
+
await Bn(T, t, n);
|
|
876
|
+
}).then(() => t).catch((d) => {
|
|
877
|
+
throw this.removeStreamPresentationCurrent(), this.sessionEvents.trigger(U, d), d;
|
|
878
|
+
});
|
|
879
|
+
return this.promisePendingStartPresentation = S, S.finally(() => {
|
|
880
|
+
this.promisePendingStartPresentation = void 0;
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
removeStreamPresentationCurrent() {
|
|
884
|
+
delete this.streamPresentationCurrent;
|
|
885
|
+
}
|
|
886
|
+
resetPresentation() {
|
|
887
|
+
this.removeStreamPresentationCurrent(), this.promisePendingStartPresentation = void 0, this.promisePendingStopPresentation = void 0;
|
|
888
|
+
}
|
|
889
|
+
cancelRequestsAndResetPresentation() {
|
|
890
|
+
this.cancelSendPresentationWithRepeatedCalls(), this.resetPresentation();
|
|
891
|
+
}
|
|
892
|
+
handleNewRTCSession = ({
|
|
893
|
+
originator: e,
|
|
894
|
+
session: t
|
|
895
|
+
}) => {
|
|
896
|
+
if (e === C.REMOTE) {
|
|
897
|
+
this.incomingRTCSession = t;
|
|
898
|
+
const n = this.remoteCallerData;
|
|
899
|
+
t.on(_, (i) => {
|
|
900
|
+
this.removeIncomingSession(), i.originator === C.LOCAL ? this.uaEvents.trigger(J, n) : this.uaEvents.trigger(G, n);
|
|
901
|
+
}), this.uaEvents.trigger(q, n);
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
connectInner = async (e) => this.initUa(e).then(async () => this.start());
|
|
905
|
+
initUa = async ({
|
|
906
|
+
user: e,
|
|
907
|
+
password: t,
|
|
908
|
+
sipServerUrl: n,
|
|
909
|
+
sipWebSocketServerURL: i,
|
|
910
|
+
remoteAddress: r,
|
|
911
|
+
sessionTimers: o,
|
|
912
|
+
registerExpires: a,
|
|
913
|
+
connectionRecoveryMinInterval: c,
|
|
914
|
+
connectionRecoveryMaxInterval: E,
|
|
915
|
+
userAgent: h,
|
|
916
|
+
displayName: S = "",
|
|
917
|
+
register: d = !1,
|
|
918
|
+
extraHeaders: T = []
|
|
919
|
+
}) => {
|
|
920
|
+
if (!n)
|
|
921
|
+
throw new Error("sipServerUrl is required");
|
|
922
|
+
if (!i)
|
|
923
|
+
throw new Error("sipWebSocketServerURL is required");
|
|
924
|
+
if (d && (e === void 0 || e === ""))
|
|
925
|
+
throw new Error("user is required for authorized connection");
|
|
926
|
+
if (d && (t === void 0 || t === ""))
|
|
927
|
+
throw new Error("password is required for authorized connection");
|
|
928
|
+
this.isPendingInitUa = !0;
|
|
929
|
+
try {
|
|
930
|
+
this.connectionConfiguration = {
|
|
931
|
+
sipServerUrl: n,
|
|
932
|
+
displayName: S,
|
|
933
|
+
register: d,
|
|
934
|
+
user: e,
|
|
935
|
+
password: t
|
|
936
|
+
};
|
|
937
|
+
const { configuration: l, helpers: u } = this.createUaConfiguration({
|
|
938
|
+
user: e,
|
|
939
|
+
sipServerUrl: n,
|
|
940
|
+
sipWebSocketServerURL: i,
|
|
941
|
+
password: t,
|
|
942
|
+
displayName: S,
|
|
943
|
+
register: d,
|
|
944
|
+
sessionTimers: o,
|
|
945
|
+
registerExpires: a,
|
|
946
|
+
connectionRecoveryMinInterval: c,
|
|
947
|
+
connectionRecoveryMaxInterval: E,
|
|
948
|
+
userAgent: h
|
|
949
|
+
});
|
|
950
|
+
return this.getSipServerUrl = u.getSipServerUrl, this.socket = u.socket, this.ua && await this.disconnect(), this.isRegisterConfigInner = !!d, this.ua = this.createUa({ ...l, remoteAddress: r, extraHeaders: T }), this.uaEvents.eachTriggers((N, W) => {
|
|
951
|
+
const R = me.find((k) => k === W);
|
|
952
|
+
R && this.ua && this.ua.on(R, N);
|
|
953
|
+
}), this.ua;
|
|
954
|
+
} finally {
|
|
955
|
+
this.isPendingInitUa = !1;
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
createUa = ({
|
|
959
|
+
remoteAddress: e,
|
|
960
|
+
extraHeaders: t = [],
|
|
961
|
+
...n
|
|
962
|
+
}) => {
|
|
963
|
+
const i = new this.JsSIP.UA(n), o = [...e !== void 0 && e !== "" ? sn(e) : [], ...t];
|
|
964
|
+
return o.length > 0 && i.registrator().setExtraHeaders(o), i;
|
|
965
|
+
};
|
|
966
|
+
start = async () => new Promise((e, t) => {
|
|
967
|
+
const { ua: n } = this;
|
|
968
|
+
if (!n) {
|
|
969
|
+
t(new Error("this.ua is not initialized"));
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
const i = () => {
|
|
973
|
+
a(), e(n);
|
|
974
|
+
}, r = (c) => {
|
|
975
|
+
a(), t(c);
|
|
976
|
+
}, o = () => {
|
|
977
|
+
this.isRegisterConfig ? (this.on(P, i), this.on(m, r)) : this.on(I, i), this.on(g, r);
|
|
978
|
+
}, a = () => {
|
|
979
|
+
this.off(P, i), this.off(m, r), this.off(I, i), this.off(g, r);
|
|
980
|
+
};
|
|
981
|
+
o(), this.on(D, this.handleNewRTCSession), n.start();
|
|
982
|
+
});
|
|
983
|
+
handleCall = async ({
|
|
984
|
+
ontrack: e
|
|
985
|
+
}) => new Promise((t, n) => {
|
|
986
|
+
const i = () => {
|
|
987
|
+
this.onSession(L, h), this.onSession(b, S);
|
|
988
|
+
}, r = () => {
|
|
989
|
+
this.offSession(L, h), this.offSession(b, S);
|
|
990
|
+
}, o = () => {
|
|
991
|
+
this.onSession(_, c), this.onSession(O, c);
|
|
992
|
+
}, a = () => {
|
|
993
|
+
this.offSession(_, c), this.offSession(O, c);
|
|
994
|
+
}, c = (d) => {
|
|
995
|
+
r(), a(), n(d);
|
|
996
|
+
};
|
|
997
|
+
let E;
|
|
998
|
+
const h = ({ peerconnection: d }) => {
|
|
999
|
+
E = d, E.ontrack = (T) => {
|
|
1000
|
+
this.sessionEvents.trigger(ne, E), e && e(T);
|
|
1001
|
+
};
|
|
1002
|
+
}, S = () => {
|
|
1003
|
+
E !== void 0 && this.sessionEvents.trigger(te, E), r(), a(), t(E);
|
|
1004
|
+
};
|
|
1005
|
+
i(), o();
|
|
1006
|
+
});
|
|
1007
|
+
restoreSession = () => {
|
|
1008
|
+
this.cancelRequestsAndResetPresentation(), delete this.connectionConfiguration.number, delete this.rtcSession, this.remoteStreams = {};
|
|
1009
|
+
};
|
|
1010
|
+
generateStream(e, t) {
|
|
1011
|
+
const { id: n } = e, i = this.remoteStreams[n] ?? new MediaStream();
|
|
1012
|
+
return t && i.addTrack(t), i.addTrack(e), this.remoteStreams[n] = i, i;
|
|
1013
|
+
}
|
|
1014
|
+
generateAudioStream(e) {
|
|
1015
|
+
const { id: t } = e, n = this.remoteStreams[t] ?? new MediaStream();
|
|
1016
|
+
return n.addTrack(e), this.remoteStreams[t] = n, n;
|
|
1017
|
+
}
|
|
1018
|
+
generateStreams(e) {
|
|
1019
|
+
const t = [];
|
|
1020
|
+
return e.forEach((n, i) => {
|
|
1021
|
+
if (n.kind === "audio")
|
|
1022
|
+
return;
|
|
1023
|
+
const r = n, o = e[i - 1];
|
|
1024
|
+
let a;
|
|
1025
|
+
o?.kind === "audio" && (a = o);
|
|
1026
|
+
const c = this.generateStream(r, a);
|
|
1027
|
+
t.push(c);
|
|
1028
|
+
}), t;
|
|
1029
|
+
}
|
|
1030
|
+
generateAudioStreams(e) {
|
|
1031
|
+
return e.map((n) => this.generateAudioStream(n));
|
|
1032
|
+
}
|
|
1033
|
+
hangUpWithoutCancelRequests = async () => {
|
|
1034
|
+
if (this.ua && this.rtcSession) {
|
|
1035
|
+
const { rtcSession: e } = this;
|
|
1036
|
+
if (this.streamPresentationCurrent)
|
|
1037
|
+
try {
|
|
1038
|
+
await this.stopPresentation();
|
|
1039
|
+
} catch (t) {
|
|
1040
|
+
B("error stop presentation: ", t);
|
|
1041
|
+
}
|
|
1042
|
+
if (this.restoreSession(), !e.isEnded())
|
|
1043
|
+
return e.terminateAsync({
|
|
1044
|
+
cause: Y
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
cancelRequests() {
|
|
1049
|
+
this.cancelConnectWithRepeatedCalls();
|
|
1050
|
+
}
|
|
1051
|
+
cancelConnectWithRepeatedCalls() {
|
|
1052
|
+
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
1053
|
+
}
|
|
1054
|
+
handleShareState = (e) => {
|
|
1055
|
+
switch (e) {
|
|
1056
|
+
case ut: {
|
|
1057
|
+
this.sessionEvents.trigger(Q, void 0);
|
|
1058
|
+
break;
|
|
1059
|
+
}
|
|
1060
|
+
case gt: {
|
|
1061
|
+
this.sessionEvents.trigger(j, void 0);
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
case Ct: {
|
|
1065
|
+
this.sessionEvents.trigger(K, void 0);
|
|
1066
|
+
break;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
maybeTriggerChannels = (e) => {
|
|
1071
|
+
const t = e.getHeader(we), n = e.getHeader(be);
|
|
1072
|
+
if (t && n) {
|
|
1073
|
+
const i = {
|
|
1074
|
+
inputChannels: t,
|
|
1075
|
+
outputChannels: n
|
|
1076
|
+
};
|
|
1077
|
+
this.sessionEvents.trigger(y, i);
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
handleNotify = (e) => {
|
|
1081
|
+
switch (e.cmd) {
|
|
1082
|
+
case $n: {
|
|
1083
|
+
const t = e;
|
|
1084
|
+
this.triggerChannelsNotify(t);
|
|
1085
|
+
break;
|
|
1086
|
+
}
|
|
1087
|
+
case Gn: {
|
|
1088
|
+
const t = e;
|
|
1089
|
+
this.triggerWebcastStartedNotify(t);
|
|
1090
|
+
break;
|
|
1091
|
+
}
|
|
1092
|
+
case Jn: {
|
|
1093
|
+
const t = e;
|
|
1094
|
+
this.triggerWebcastStoppedNotify(t);
|
|
1095
|
+
break;
|
|
1096
|
+
}
|
|
1097
|
+
case Qn: {
|
|
1098
|
+
const t = e;
|
|
1099
|
+
this.triggerAddedToListModeratorsNotify(t);
|
|
1100
|
+
break;
|
|
1101
|
+
}
|
|
1102
|
+
case jn: {
|
|
1103
|
+
const t = e;
|
|
1104
|
+
this.triggerRemovedFromListModeratorsNotify(t);
|
|
1105
|
+
break;
|
|
1106
|
+
}
|
|
1107
|
+
case Kn: {
|
|
1108
|
+
const t = e;
|
|
1109
|
+
this.triggerParticipationAcceptingWordRequest(t);
|
|
1110
|
+
break;
|
|
1111
|
+
}
|
|
1112
|
+
case Zn: {
|
|
1113
|
+
const t = e;
|
|
1114
|
+
this.triggerParticipationCancellingWordRequest(t);
|
|
1115
|
+
break;
|
|
1116
|
+
}
|
|
1117
|
+
case es: {
|
|
1118
|
+
const t = e;
|
|
1119
|
+
this.triggerParticipantMoveRequestToStream(t);
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
case Xn: {
|
|
1123
|
+
this.triggerAccountChangedNotify();
|
|
1124
|
+
break;
|
|
1125
|
+
}
|
|
1126
|
+
case zn: {
|
|
1127
|
+
this.triggerAccountDeletedNotify();
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
case ts: {
|
|
1131
|
+
const t = e;
|
|
1132
|
+
this.triggerConferenceParticipantTokenIssued(t);
|
|
1133
|
+
break;
|
|
1134
|
+
}
|
|
1135
|
+
default:
|
|
1136
|
+
B("unknown cmd", e.cmd);
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
triggerRemovedFromListModeratorsNotify = ({
|
|
1140
|
+
conference: e
|
|
1141
|
+
}) => {
|
|
1142
|
+
const t = {
|
|
1143
|
+
conference: e
|
|
1144
|
+
};
|
|
1145
|
+
this.uaEvents.trigger(
|
|
1146
|
+
he,
|
|
1147
|
+
t
|
|
1148
|
+
);
|
|
1149
|
+
};
|
|
1150
|
+
triggerAddedToListModeratorsNotify = ({
|
|
1151
|
+
conference: e
|
|
1152
|
+
}) => {
|
|
1153
|
+
const t = {
|
|
1154
|
+
conference: e
|
|
1155
|
+
};
|
|
1156
|
+
this.uaEvents.trigger(de, t);
|
|
1157
|
+
};
|
|
1158
|
+
triggerWebcastStartedNotify = ({
|
|
1159
|
+
body: { conference: e, type: t }
|
|
1160
|
+
}) => {
|
|
1161
|
+
const n = {
|
|
1162
|
+
conference: e,
|
|
1163
|
+
type: t
|
|
1164
|
+
};
|
|
1165
|
+
this.uaEvents.trigger(Ce, n);
|
|
1166
|
+
};
|
|
1167
|
+
triggerWebcastStoppedNotify = ({
|
|
1168
|
+
body: { conference: e, type: t }
|
|
1169
|
+
}) => {
|
|
1170
|
+
const n = {
|
|
1171
|
+
conference: e,
|
|
1172
|
+
type: t
|
|
1173
|
+
};
|
|
1174
|
+
this.uaEvents.trigger(Ne, n);
|
|
1175
|
+
};
|
|
1176
|
+
triggerAccountChangedNotify = () => {
|
|
1177
|
+
this.uaEvents.trigger(_e, void 0);
|
|
1178
|
+
};
|
|
1179
|
+
triggerAccountDeletedNotify = () => {
|
|
1180
|
+
this.uaEvents.trigger(Ae, void 0);
|
|
1181
|
+
};
|
|
1182
|
+
triggerConferenceParticipantTokenIssued = ({
|
|
1183
|
+
body: { conference: e, participant: t, jwt: n }
|
|
1184
|
+
}) => {
|
|
1185
|
+
const i = {
|
|
1186
|
+
conference: e,
|
|
1187
|
+
participant: t,
|
|
1188
|
+
jwt: n
|
|
1189
|
+
};
|
|
1190
|
+
this.uaEvents.trigger(
|
|
1191
|
+
Re,
|
|
1192
|
+
i
|
|
1193
|
+
);
|
|
1194
|
+
};
|
|
1195
|
+
triggerChannelsNotify = (e) => {
|
|
1196
|
+
const t = e.input, n = e.output, i = {
|
|
1197
|
+
inputChannels: t,
|
|
1198
|
+
outputChannels: n
|
|
1199
|
+
};
|
|
1200
|
+
this.uaEvents.trigger(se, i);
|
|
1201
|
+
};
|
|
1202
|
+
triggerParticipationAcceptingWordRequest = ({
|
|
1203
|
+
body: { conference: e }
|
|
1204
|
+
}) => {
|
|
1205
|
+
const t = {
|
|
1206
|
+
conference: e
|
|
1207
|
+
};
|
|
1208
|
+
this.uaEvents.trigger(ue, t);
|
|
1209
|
+
};
|
|
1210
|
+
triggerParticipationCancellingWordRequest = ({
|
|
1211
|
+
body: { conference: e }
|
|
1212
|
+
}) => {
|
|
1213
|
+
const t = {
|
|
1214
|
+
conference: e
|
|
1215
|
+
};
|
|
1216
|
+
this.uaEvents.trigger(ge, t);
|
|
1217
|
+
};
|
|
1218
|
+
triggerParticipantMoveRequestToStream = ({
|
|
1219
|
+
body: { conference: e }
|
|
1220
|
+
}) => {
|
|
1221
|
+
const t = {
|
|
1222
|
+
conference: e
|
|
1223
|
+
};
|
|
1224
|
+
this.uaEvents.trigger(Se, t);
|
|
1225
|
+
};
|
|
1226
|
+
triggerEnterRoom = (e) => {
|
|
1227
|
+
const t = e.getHeader(on), n = e.getHeader(ln);
|
|
1228
|
+
this.sessionEvents.trigger(Z, { room: t, participantName: n });
|
|
1229
|
+
};
|
|
1230
|
+
triggerShareState = (e) => {
|
|
1231
|
+
const t = e.getHeader(A);
|
|
1232
|
+
this.sessionEvents.trigger(v, t);
|
|
1233
|
+
};
|
|
1234
|
+
maybeTriggerParticipantMoveRequest = (e) => {
|
|
1235
|
+
const t = e.getHeader(In);
|
|
1236
|
+
t === ot && this.sessionEvents.trigger(Te, void 0), t === at && this.sessionEvents.trigger(le, void 0);
|
|
1237
|
+
};
|
|
1238
|
+
triggerMainCamControl = (e) => {
|
|
1239
|
+
const t = e.getHeader(un), n = e.getHeader(Le), i = n === F.ADMIN_SYNC_FORCED;
|
|
1240
|
+
if (t === f.ADMIN_START_MAIN_CAM) {
|
|
1241
|
+
this.sessionEvents.trigger(ae, { isSyncForced: i });
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
if (t === f.ADMIN_STOP_MAIN_CAM) {
|
|
1245
|
+
this.sessionEvents.trigger(oe, { isSyncForced: i });
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
(t === f.RESUME_MAIN_CAM || t === f.PAUSE_MAIN_CAM) && n !== void 0 && this.sessionEvents.trigger(w, { isSyncForced: i });
|
|
1249
|
+
const r = e.getHeader(Cn);
|
|
1250
|
+
this.sessionEvents.trigger(re, {
|
|
1251
|
+
mainCam: t,
|
|
1252
|
+
resolutionMainCam: r
|
|
1253
|
+
});
|
|
1254
|
+
};
|
|
1255
|
+
triggerMicControl = (e) => {
|
|
1256
|
+
const t = e.getHeader(gn), i = e.getHeader(Le) === F.ADMIN_SYNC_FORCED;
|
|
1257
|
+
t === x.ADMIN_START_MIC ? this.sessionEvents.trigger(Ee, { isSyncForced: i }) : t === x.ADMIN_STOP_MIC && this.sessionEvents.trigger(ce, { isSyncForced: i });
|
|
1258
|
+
};
|
|
1259
|
+
triggerUseLicense = (e) => {
|
|
1260
|
+
const t = e.getHeader(Tn);
|
|
1261
|
+
this.sessionEvents.trigger(ee, t);
|
|
1262
|
+
};
|
|
1263
|
+
handleNewInfo = (e) => {
|
|
1264
|
+
const { originator: t } = e;
|
|
1265
|
+
if (t !== C.REMOTE)
|
|
1266
|
+
return;
|
|
1267
|
+
const { request: n } = e, i = n.getHeader(rn);
|
|
1268
|
+
if (i)
|
|
1269
|
+
switch (i) {
|
|
1270
|
+
case an: {
|
|
1271
|
+
this.triggerEnterRoom(n), this.maybeTriggerChannels(n);
|
|
1272
|
+
break;
|
|
1273
|
+
}
|
|
1274
|
+
case Pn: {
|
|
1275
|
+
this.maybeHandleNotify(n);
|
|
1276
|
+
break;
|
|
1277
|
+
}
|
|
1278
|
+
case p: {
|
|
1279
|
+
this.triggerShareState(n);
|
|
1280
|
+
break;
|
|
1281
|
+
}
|
|
1282
|
+
case ye: {
|
|
1283
|
+
this.triggerMainCamControl(n);
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
case hn: {
|
|
1287
|
+
this.triggerMicControl(n);
|
|
1288
|
+
break;
|
|
1289
|
+
}
|
|
1290
|
+
case Sn: {
|
|
1291
|
+
this.triggerUseLicense(n);
|
|
1292
|
+
break;
|
|
1293
|
+
}
|
|
1294
|
+
case fn: {
|
|
1295
|
+
this.maybeTriggerParticipantMoveRequest(n);
|
|
1296
|
+
break;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
handleSipEvent = ({ request: e }) => {
|
|
1301
|
+
this.maybeHandleNotify(e);
|
|
1302
|
+
};
|
|
1303
|
+
maybeHandleNotify = (e) => {
|
|
1304
|
+
const t = e.getHeader(mn);
|
|
1305
|
+
if (t) {
|
|
1306
|
+
const n = JSON.parse(t);
|
|
1307
|
+
this.handleNotify(n);
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
handleEnded = (e) => {
|
|
1311
|
+
const { originator: t } = e;
|
|
1312
|
+
t === C.REMOTE && this.sessionEvents.trigger(ie, e), this.restoreSession();
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
export {
|
|
1316
|
+
Wt as B,
|
|
1317
|
+
f as E,
|
|
1318
|
+
Ot as N,
|
|
1319
|
+
Te as P,
|
|
1320
|
+
He as R,
|
|
1321
|
+
Ts as S,
|
|
1322
|
+
me as U,
|
|
1323
|
+
zt as a,
|
|
1324
|
+
le as b,
|
|
1325
|
+
os as c,
|
|
1326
|
+
as as d,
|
|
1327
|
+
cs as e,
|
|
1328
|
+
ds as f,
|
|
1329
|
+
Es as g,
|
|
1330
|
+
hs as h,
|
|
1331
|
+
Ss as i,
|
|
1332
|
+
x as j,
|
|
1333
|
+
F as k,
|
|
1334
|
+
B as l,
|
|
1335
|
+
Qt as m,
|
|
1336
|
+
jt as n,
|
|
1337
|
+
St as o,
|
|
1338
|
+
Kt as s
|
|
1339
|
+
};
|