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