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