sip-connector 20.2.1 → 20.4.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/README.md +116 -1
- package/dist/@SipConnector-DB4bLDI5.cjs +1 -0
- package/dist/{@SipConnector-OO78fz6E.js → @SipConnector-FYEV5h4G.js} +1948 -713
- package/dist/ApiManager/index.d.ts +1 -0
- package/dist/CallManager/CallStateMachine.d.ts +83 -0
- package/dist/ConferenceStateManager/@ConferenceStateManager.d.ts +22 -0
- package/dist/ConferenceStateManager/events.d.ts +18 -0
- package/dist/ConferenceStateManager/index.d.ts +4 -0
- package/dist/ConferenceStateManager/types.d.ts +12 -0
- package/dist/ConnectionManager/ConnectionStateMachine.d.ts +53 -4
- package/dist/IncomingCallManager/IncomingCallStateMachine.d.ts +114 -0
- package/dist/PresentationManager/PresentationStateMachine.d.ts +101 -0
- package/dist/SipConnector/@SipConnector.d.ts +11 -3
- package/dist/SipConnector/events.d.ts +2 -2
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +206 -188
- package/dist/session/createSession.d.ts +26 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/selectors.d.ts +10 -0
- package/dist/session/types.d.ts +20 -0
- package/dist/tools/BaseStateMachine.d.ts +18 -0
- package/dist/tools/sendOffer.d.ts +8 -1
- package/package.json +1 -1
- package/dist/@SipConnector-BTqBRDjY.cjs +0 -1
- package/dist/CallManager/@CallManager.d.ts +0 -60
- package/dist/ConnectionManager/@ConnectionManager.d.ts +0 -57
- package/dist/IncomingCallManager/@IncomingCallManager.d.ts +0 -29
- package/dist/PresentationManager/@PresentationManager.d.ts +0 -49
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import X from "debug";
|
|
2
2
|
import { TypedEvents as M } from "events-constructor";
|
|
3
|
-
import { CancelableRequest as
|
|
4
|
-
import { resolveRequesterByTimeout as
|
|
5
|
-
import { hasCanceledError as
|
|
6
|
-
import {
|
|
7
|
-
import { createStackPromises as
|
|
3
|
+
import { CancelableRequest as G, isCanceledError as Ue } from "@krivega/cancelable-promise";
|
|
4
|
+
import { resolveRequesterByTimeout as Fe, requesterByTimeoutsWithFailCalls as Be, DelayRequester as ke, hasCanceledError as Ge, SetTimeoutRequest as ce } from "@krivega/timeout-requester";
|
|
5
|
+
import { hasCanceledError as $e, repeatedCallsAsync as de } from "repeated-calls";
|
|
6
|
+
import { createActor as qe, setup as $, assign as b } from "xstate";
|
|
7
|
+
import { createStackPromises as le, isPromiseIsNotActualError as Ve } from "stack-promises";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
import
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
var
|
|
17
|
-
const
|
|
10
|
+
import He from "lodash";
|
|
11
|
+
const J = "sip-connector", d = X(J), Us = () => {
|
|
12
|
+
X.enable(J);
|
|
13
|
+
}, Fs = () => {
|
|
14
|
+
X.enable(`-${J}`);
|
|
15
|
+
}, We = "Error decline with 603", xe = 1006, Qe = (n) => typeof n == "object" && n !== null && "code" in n && n.code === xe, Ye = (n) => n.message === We;
|
|
16
|
+
var E = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(E || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), x = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(x || {}), y = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n))(y || {}), I = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(I || {}), _ = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(_ || {}), Q = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(Q || {}), Y = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(Y || {}), ze = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(ze || {}), g = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n))(g || {});
|
|
17
|
+
const he = [
|
|
18
18
|
"participation:accepting-word-request",
|
|
19
19
|
"participation:cancelling-word-request",
|
|
20
20
|
"participant:move-request-to-stream",
|
|
@@ -44,9 +44,9 @@ const ae = [
|
|
|
44
44
|
"notAvailableSecondRemoteStream",
|
|
45
45
|
"mustStopPresentation",
|
|
46
46
|
"newDTMF"
|
|
47
|
-
],
|
|
48
|
-
var
|
|
49
|
-
class
|
|
47
|
+
], Xe = () => new M(he);
|
|
48
|
+
var R = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(R || {});
|
|
49
|
+
class Je {
|
|
50
50
|
events;
|
|
51
51
|
connectionManager;
|
|
52
52
|
callManager;
|
|
@@ -54,13 +54,13 @@ class Qe {
|
|
|
54
54
|
connectionManager: e,
|
|
55
55
|
callManager: t
|
|
56
56
|
}) {
|
|
57
|
-
this.connectionManager = e, this.callManager = t, this.events =
|
|
57
|
+
this.connectionManager = e, this.callManager = t, this.events = Xe(), this.subscribe();
|
|
58
58
|
}
|
|
59
59
|
async waitChannels() {
|
|
60
|
-
return this.wait(
|
|
60
|
+
return this.wait(g.CHANNELS);
|
|
61
61
|
}
|
|
62
62
|
async waitSyncMediaState() {
|
|
63
|
-
return this.wait(
|
|
63
|
+
return this.wait(g.ADMIN_FORCE_SYNC_MEDIA_STATE);
|
|
64
64
|
}
|
|
65
65
|
async sendDTMF(e) {
|
|
66
66
|
return new Promise((t, s) => {
|
|
@@ -79,19 +79,19 @@ class Qe {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
82
|
-
const s = this.getEstablishedRTCSessionProtected(), i = `${
|
|
82
|
+
const s = this.getEstablishedRTCSessionProtected(), i = `${E.INPUT_CHANNELS}: ${e}`, r = `${E.OUTPUT_CHANNELS}: ${t}`, a = [
|
|
83
83
|
i,
|
|
84
84
|
r
|
|
85
85
|
];
|
|
86
|
-
return s.sendInfo(
|
|
86
|
+
return s.sendInfo(I.CHANNELS, void 0, { extraHeaders: a });
|
|
87
87
|
}
|
|
88
88
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
89
|
-
const i = this.getEstablishedRTCSessionProtected(), r = `${
|
|
89
|
+
const i = this.getEstablishedRTCSessionProtected(), r = `${E.MEDIA_STATE}: currentstate`, a = `${E.MAIN_CAM_STATE}: ${Number(e)}`, o = `${E.MIC_STATE}: ${Number(t)}`, c = [
|
|
90
90
|
r,
|
|
91
91
|
a,
|
|
92
92
|
o
|
|
93
93
|
];
|
|
94
|
-
return i.sendInfo(
|
|
94
|
+
return i.sendInfo(I.MEDIA_STATE, void 0, {
|
|
95
95
|
noTerminateWhenError: !0,
|
|
96
96
|
...s,
|
|
97
97
|
extraHeaders: c
|
|
@@ -100,15 +100,15 @@ class Qe {
|
|
|
100
100
|
async sendStats({
|
|
101
101
|
availableIncomingBitrate: e
|
|
102
102
|
}) {
|
|
103
|
-
const t = this.getEstablishedRTCSessionProtected(), i = [`${
|
|
104
|
-
return t.sendInfo(
|
|
103
|
+
const t = this.getEstablishedRTCSessionProtected(), i = [`${E.AVAILABLE_INCOMING_BITRATE}: ${e}`];
|
|
104
|
+
return t.sendInfo(I.STATS, void 0, {
|
|
105
105
|
noTerminateWhenError: !0,
|
|
106
106
|
extraHeaders: i
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
async sendRefusalToTurnOn(e, t = {}) {
|
|
110
|
-
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${
|
|
111
|
-
return s.sendInfo(
|
|
110
|
+
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${E.MEDIA_TYPE}: ${a}`];
|
|
111
|
+
return s.sendInfo(I.REFUSAL, void 0, {
|
|
112
112
|
noTerminateWhenError: !0,
|
|
113
113
|
...t,
|
|
114
114
|
extraHeaders: c
|
|
@@ -121,38 +121,38 @@ class Qe {
|
|
|
121
121
|
return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
|
|
122
122
|
}
|
|
123
123
|
async sendMustStopPresentationP2P() {
|
|
124
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
125
|
-
extraHeaders: [
|
|
124
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
125
|
+
extraHeaders: [E.MUST_STOP_PRESENTATION_P2P]
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
async sendStoppedPresentationP2P() {
|
|
129
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
130
|
-
extraHeaders: [
|
|
129
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
130
|
+
extraHeaders: [E.STOP_PRESENTATION_P2P]
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
async sendStoppedPresentation() {
|
|
134
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
135
|
-
extraHeaders: [
|
|
134
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
135
|
+
extraHeaders: [E.STOP_PRESENTATION]
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
async askPermissionToStartPresentationP2P() {
|
|
139
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
140
|
-
extraHeaders: [
|
|
139
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
140
|
+
extraHeaders: [E.START_PRESENTATION_P2P]
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
async askPermissionToStartPresentation() {
|
|
144
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
145
|
-
extraHeaders: [
|
|
144
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
145
|
+
extraHeaders: [E.START_PRESENTATION]
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
async askPermissionToEnableCam(e = {}) {
|
|
149
|
-
const t = this.getEstablishedRTCSessionProtected(), s = [
|
|
150
|
-
return t.sendInfo(
|
|
149
|
+
const t = this.getEstablishedRTCSessionProtected(), s = [E.ENABLE_MAIN_CAM];
|
|
150
|
+
return t.sendInfo(I.MAIN_CAM, void 0, {
|
|
151
151
|
noTerminateWhenError: !0,
|
|
152
152
|
...e,
|
|
153
153
|
extraHeaders: s
|
|
154
154
|
}).catch((i) => {
|
|
155
|
-
if (
|
|
155
|
+
if (Ye(i))
|
|
156
156
|
throw i;
|
|
157
157
|
});
|
|
158
158
|
}
|
|
@@ -187,106 +187,106 @@ class Qe {
|
|
|
187
187
|
};
|
|
188
188
|
maybeHandleNotify = (e) => {
|
|
189
189
|
try {
|
|
190
|
-
const t = e.getHeader(
|
|
190
|
+
const t = e.getHeader(E.NOTIFY);
|
|
191
191
|
if (t) {
|
|
192
192
|
const s = JSON.parse(t);
|
|
193
193
|
this.handleNotify(s);
|
|
194
194
|
}
|
|
195
195
|
} catch (t) {
|
|
196
|
-
|
|
196
|
+
d("error parse notify", t);
|
|
197
197
|
}
|
|
198
198
|
};
|
|
199
199
|
handleNotify = (e) => {
|
|
200
200
|
switch (e.cmd) {
|
|
201
|
-
case
|
|
201
|
+
case R.CHANNELS: {
|
|
202
202
|
const t = e;
|
|
203
203
|
this.triggerChannelsNotify(t);
|
|
204
204
|
break;
|
|
205
205
|
}
|
|
206
|
-
case
|
|
206
|
+
case R.WEBCAST_STARTED: {
|
|
207
207
|
const t = e;
|
|
208
208
|
this.triggerWebcastStartedNotify(t);
|
|
209
209
|
break;
|
|
210
210
|
}
|
|
211
|
-
case
|
|
211
|
+
case R.WEBCAST_STOPPED: {
|
|
212
212
|
const t = e;
|
|
213
213
|
this.triggerWebcastStoppedNotify(t);
|
|
214
214
|
break;
|
|
215
215
|
}
|
|
216
|
-
case
|
|
216
|
+
case R.ADDED_TO_LIST_MODERATORS: {
|
|
217
217
|
const t = e;
|
|
218
218
|
this.triggerAddedToListModeratorsNotify(t);
|
|
219
219
|
break;
|
|
220
220
|
}
|
|
221
|
-
case
|
|
221
|
+
case R.REMOVED_FROM_LIST_MODERATORS: {
|
|
222
222
|
const t = e;
|
|
223
223
|
this.triggerRemovedFromListModeratorsNotify(t);
|
|
224
224
|
break;
|
|
225
225
|
}
|
|
226
|
-
case
|
|
226
|
+
case R.ACCEPTING_WORD_REQUEST: {
|
|
227
227
|
const t = e;
|
|
228
228
|
this.triggerParticipationAcceptingWordRequest(t);
|
|
229
229
|
break;
|
|
230
230
|
}
|
|
231
|
-
case
|
|
231
|
+
case R.CANCELLING_WORD_REQUEST: {
|
|
232
232
|
const t = e;
|
|
233
233
|
this.triggerParticipationCancellingWordRequest(t);
|
|
234
234
|
break;
|
|
235
235
|
}
|
|
236
|
-
case
|
|
236
|
+
case R.MOVE_REQUEST_TO_STREAM: {
|
|
237
237
|
const t = e;
|
|
238
238
|
this.triggerParticipantMoveRequestToStream(t);
|
|
239
239
|
break;
|
|
240
240
|
}
|
|
241
|
-
case
|
|
241
|
+
case R.ACCOUNT_CHANGED: {
|
|
242
242
|
this.triggerAccountChangedNotify();
|
|
243
243
|
break;
|
|
244
244
|
}
|
|
245
|
-
case
|
|
245
|
+
case R.ACCOUNT_DELETED: {
|
|
246
246
|
this.triggerAccountDeletedNotify();
|
|
247
247
|
break;
|
|
248
248
|
}
|
|
249
|
-
case
|
|
249
|
+
case R.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
|
|
250
250
|
const t = e;
|
|
251
251
|
this.triggerConferenceParticipantTokenIssued(t);
|
|
252
252
|
break;
|
|
253
253
|
}
|
|
254
254
|
default:
|
|
255
|
-
|
|
255
|
+
d("unknown cmd", e);
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
258
|
handleNewInfo = (e) => {
|
|
259
259
|
const { originator: t } = e;
|
|
260
260
|
if (t !== "remote")
|
|
261
261
|
return;
|
|
262
|
-
const { request: s } = e, i = s, r = i.getHeader(
|
|
262
|
+
const { request: s } = e, i = s, r = i.getHeader(E.CONTENT_TYPE);
|
|
263
263
|
if (r !== void 0)
|
|
264
264
|
switch (r) {
|
|
265
|
-
case
|
|
265
|
+
case y.ENTER_ROOM: {
|
|
266
266
|
this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
|
|
267
267
|
break;
|
|
268
268
|
}
|
|
269
|
-
case
|
|
269
|
+
case y.NOTIFY: {
|
|
270
270
|
this.maybeHandleNotify(i);
|
|
271
271
|
break;
|
|
272
272
|
}
|
|
273
|
-
case
|
|
273
|
+
case y.SHARE_STATE: {
|
|
274
274
|
this.triggerShareState(i);
|
|
275
275
|
break;
|
|
276
276
|
}
|
|
277
|
-
case
|
|
277
|
+
case y.MAIN_CAM: {
|
|
278
278
|
this.triggerMainCamControl(i);
|
|
279
279
|
break;
|
|
280
280
|
}
|
|
281
|
-
case
|
|
281
|
+
case y.MIC: {
|
|
282
282
|
this.triggerMicControl(i);
|
|
283
283
|
break;
|
|
284
284
|
}
|
|
285
|
-
case
|
|
285
|
+
case y.USE_LICENSE: {
|
|
286
286
|
this.triggerUseLicense(i);
|
|
287
287
|
break;
|
|
288
288
|
}
|
|
289
|
-
case
|
|
289
|
+
case y.PARTICIPANT_STATE: {
|
|
290
290
|
this.maybeTriggerParticipantMoveRequest(i);
|
|
291
291
|
break;
|
|
292
292
|
}
|
|
@@ -297,7 +297,7 @@ class Qe {
|
|
|
297
297
|
inputChannels: t,
|
|
298
298
|
outputChannels: s
|
|
299
299
|
};
|
|
300
|
-
this.events.trigger(
|
|
300
|
+
this.events.trigger(g.CHANNELS_NOTIFY, i);
|
|
301
301
|
};
|
|
302
302
|
triggerWebcastStartedNotify = ({
|
|
303
303
|
body: { conference: e, type: t }
|
|
@@ -306,7 +306,7 @@ class Qe {
|
|
|
306
306
|
conference: e,
|
|
307
307
|
type: t
|
|
308
308
|
};
|
|
309
|
-
this.events.trigger(
|
|
309
|
+
this.events.trigger(g.WEBCAST_STARTED, s);
|
|
310
310
|
};
|
|
311
311
|
triggerWebcastStoppedNotify = ({
|
|
312
312
|
body: { conference: e, type: t }
|
|
@@ -315,7 +315,7 @@ class Qe {
|
|
|
315
315
|
conference: e,
|
|
316
316
|
type: t
|
|
317
317
|
};
|
|
318
|
-
this.events.trigger(
|
|
318
|
+
this.events.trigger(g.WEBCAST_STOPPED, s);
|
|
319
319
|
};
|
|
320
320
|
triggerAddedToListModeratorsNotify = ({
|
|
321
321
|
conference: e
|
|
@@ -324,7 +324,7 @@ class Qe {
|
|
|
324
324
|
conference: e
|
|
325
325
|
};
|
|
326
326
|
this.events.trigger(
|
|
327
|
-
|
|
327
|
+
g.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
|
|
328
328
|
t
|
|
329
329
|
);
|
|
330
330
|
};
|
|
@@ -335,7 +335,7 @@ class Qe {
|
|
|
335
335
|
conference: e
|
|
336
336
|
};
|
|
337
337
|
this.events.trigger(
|
|
338
|
-
|
|
338
|
+
g.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
|
|
339
339
|
t
|
|
340
340
|
);
|
|
341
341
|
};
|
|
@@ -345,7 +345,7 @@ class Qe {
|
|
|
345
345
|
const t = {
|
|
346
346
|
conference: e
|
|
347
347
|
};
|
|
348
|
-
this.events.trigger(
|
|
348
|
+
this.events.trigger(g.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
|
|
349
349
|
};
|
|
350
350
|
triggerParticipationCancellingWordRequest = ({
|
|
351
351
|
body: { conference: e }
|
|
@@ -353,7 +353,7 @@ class Qe {
|
|
|
353
353
|
const t = {
|
|
354
354
|
conference: e
|
|
355
355
|
};
|
|
356
|
-
this.events.trigger(
|
|
356
|
+
this.events.trigger(g.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
|
|
357
357
|
};
|
|
358
358
|
triggerParticipantMoveRequestToStream = ({
|
|
359
359
|
body: { conference: e }
|
|
@@ -361,13 +361,13 @@ class Qe {
|
|
|
361
361
|
const t = {
|
|
362
362
|
conference: e
|
|
363
363
|
};
|
|
364
|
-
this.events.trigger(
|
|
364
|
+
this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
|
|
365
365
|
};
|
|
366
366
|
triggerAccountChangedNotify = () => {
|
|
367
|
-
this.events.trigger(
|
|
367
|
+
this.events.trigger(g.ACCOUNT_CHANGED, {});
|
|
368
368
|
};
|
|
369
369
|
triggerAccountDeletedNotify = () => {
|
|
370
|
-
this.events.trigger(
|
|
370
|
+
this.events.trigger(g.ACCOUNT_DELETED, {});
|
|
371
371
|
};
|
|
372
372
|
triggerConferenceParticipantTokenIssued = ({
|
|
373
373
|
body: { conference: e, participant: t, jwt: s }
|
|
@@ -378,79 +378,288 @@ class Qe {
|
|
|
378
378
|
jwt: s
|
|
379
379
|
};
|
|
380
380
|
this.events.trigger(
|
|
381
|
-
|
|
381
|
+
g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
|
|
382
382
|
i
|
|
383
383
|
);
|
|
384
384
|
};
|
|
385
385
|
maybeTriggerChannels = (e) => {
|
|
386
|
-
const t = e.getHeader(
|
|
386
|
+
const t = e.getHeader(E.INPUT_CHANNELS), s = e.getHeader(E.OUTPUT_CHANNELS);
|
|
387
387
|
if (t && s) {
|
|
388
388
|
const i = {
|
|
389
389
|
inputChannels: t,
|
|
390
390
|
outputChannels: s
|
|
391
391
|
};
|
|
392
|
-
this.events.trigger(
|
|
392
|
+
this.events.trigger(g.CHANNELS, i);
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
395
|
triggerEnterRoom = (e) => {
|
|
396
|
-
const t = e.getHeader(
|
|
397
|
-
this.events.trigger(
|
|
396
|
+
const t = e.getHeader(E.CONTENT_ENTER_ROOM), s = e.getHeader(E.PARTICIPANT_NAME);
|
|
397
|
+
this.events.trigger(g.ENTER_ROOM, { room: t, participantName: s });
|
|
398
398
|
};
|
|
399
399
|
triggerShareState = (e) => {
|
|
400
|
-
const t = e.getHeader(
|
|
400
|
+
const t = e.getHeader(E.CONTENT_SHARE_STATE);
|
|
401
401
|
if (t !== void 0)
|
|
402
402
|
switch (t) {
|
|
403
|
-
case
|
|
404
|
-
this.events.trigger(
|
|
403
|
+
case B.AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
404
|
+
this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, {});
|
|
405
405
|
break;
|
|
406
406
|
}
|
|
407
|
-
case
|
|
408
|
-
this.events.trigger(
|
|
407
|
+
case B.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
408
|
+
this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, {});
|
|
409
409
|
break;
|
|
410
410
|
}
|
|
411
|
-
case
|
|
412
|
-
this.events.trigger(
|
|
411
|
+
case B.MUST_STOP_PRESENTATION: {
|
|
412
|
+
this.events.trigger(g.MUST_STOP_PRESENTATION, {});
|
|
413
413
|
break;
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
};
|
|
417
417
|
maybeTriggerParticipantMoveRequest = (e) => {
|
|
418
|
-
const t = e.getHeader(
|
|
419
|
-
t ===
|
|
418
|
+
const t = e.getHeader(E.CONTENT_PARTICIPANT_STATE), s = e.getHeader(E.AUDIO_ID);
|
|
419
|
+
t === x.SPECTATOR && (s ? (this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID, {
|
|
420
420
|
audioId: s
|
|
421
|
-
}), this.events.trigger(
|
|
421
|
+
}), this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, {
|
|
422
422
|
isSynthetic: !1,
|
|
423
423
|
audioId: s
|
|
424
|
-
})) : (this.events.trigger(
|
|
424
|
+
})) : (this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC, {}), this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, { isSynthetic: !0 }))), t === x.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
|
|
425
425
|
};
|
|
426
426
|
triggerMainCamControl = (e) => {
|
|
427
|
-
const t = e.getHeader(
|
|
427
|
+
const t = e.getHeader(E.MAIN_CAM), s = e.getHeader(E.MEDIA_SYNC), i = s === Y.ADMIN_SYNC_FORCED;
|
|
428
428
|
if (t === _.ADMIN_START_MAIN_CAM) {
|
|
429
|
-
this.events.trigger(
|
|
429
|
+
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
|
|
430
430
|
return;
|
|
431
431
|
}
|
|
432
432
|
if (t === _.ADMIN_STOP_MAIN_CAM) {
|
|
433
|
-
this.events.trigger(
|
|
433
|
+
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
|
|
434
434
|
return;
|
|
435
435
|
}
|
|
436
|
-
(t === _.RESUME_MAIN_CAM || t === _.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(
|
|
437
|
-
const r = e.getHeader(
|
|
438
|
-
this.events.trigger(
|
|
436
|
+
(t === _.RESUME_MAIN_CAM || t === _.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
|
|
437
|
+
const r = e.getHeader(E.MAIN_CAM_RESOLUTION);
|
|
438
|
+
this.events.trigger(g.MAIN_CAM_CONTROL, {
|
|
439
439
|
mainCam: t,
|
|
440
440
|
resolutionMainCam: r
|
|
441
441
|
});
|
|
442
442
|
};
|
|
443
443
|
triggerMicControl = (e) => {
|
|
444
|
-
const t = e.getHeader(
|
|
445
|
-
t ===
|
|
444
|
+
const t = e.getHeader(E.MIC), i = e.getHeader(E.MEDIA_SYNC) === Y.ADMIN_SYNC_FORCED;
|
|
445
|
+
t === Q.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === Q.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
|
|
446
446
|
};
|
|
447
447
|
triggerUseLicense = (e) => {
|
|
448
|
-
const t = e.getHeader(
|
|
449
|
-
this.events.trigger(
|
|
448
|
+
const t = e.getHeader(E.CONTENT_USE_LICENSE);
|
|
449
|
+
this.events.trigger(g.USE_LICENSE, t);
|
|
450
450
|
};
|
|
451
451
|
}
|
|
452
|
-
|
|
453
|
-
|
|
452
|
+
class q {
|
|
453
|
+
actor;
|
|
454
|
+
subscriptions = [];
|
|
455
|
+
constructor(e) {
|
|
456
|
+
this.actor = qe(e), this.actor.start();
|
|
457
|
+
}
|
|
458
|
+
get actorRef() {
|
|
459
|
+
return this.actor;
|
|
460
|
+
}
|
|
461
|
+
get state() {
|
|
462
|
+
return this.getSnapshot().value;
|
|
463
|
+
}
|
|
464
|
+
send(e) {
|
|
465
|
+
this.actor.send(e);
|
|
466
|
+
}
|
|
467
|
+
getSnapshot() {
|
|
468
|
+
return this.actor.getSnapshot();
|
|
469
|
+
}
|
|
470
|
+
subscribe(e) {
|
|
471
|
+
const t = this.actor.subscribe(e);
|
|
472
|
+
return this.addSubscription(t), t;
|
|
473
|
+
}
|
|
474
|
+
stop() {
|
|
475
|
+
this.subscriptions.forEach((e) => {
|
|
476
|
+
e();
|
|
477
|
+
}), this.subscriptions.length = 0, this.actor.stop();
|
|
478
|
+
}
|
|
479
|
+
addSubscription(e) {
|
|
480
|
+
const t = typeof e == "function" ? e : () => {
|
|
481
|
+
e.unsubscribe();
|
|
482
|
+
};
|
|
483
|
+
return this.subscriptions.push(t), t;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
var Ke = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.RINGING = "call:ringing", n.ACCEPTED = "call:accepted", n.IN_CALL = "call:inCall", n.ENDED = "call:ended", n.FAILED = "call:failed", n))(Ke || {});
|
|
487
|
+
const je = $({
|
|
488
|
+
types: {
|
|
489
|
+
context: {},
|
|
490
|
+
events: {}
|
|
491
|
+
},
|
|
492
|
+
actions: {
|
|
493
|
+
rememberError: b(({ event: n }) => "error" in n && n.error !== void 0 ? {
|
|
494
|
+
lastError: n.error instanceof Error ? n.error : new Error(JSON.stringify(n.error))
|
|
495
|
+
} : { lastError: void 0 }),
|
|
496
|
+
resetError: b({ lastError: void 0 })
|
|
497
|
+
}
|
|
498
|
+
}).createMachine({
|
|
499
|
+
id: "call",
|
|
500
|
+
initial: "call:idle",
|
|
501
|
+
context: {},
|
|
502
|
+
states: {
|
|
503
|
+
"call:idle": {
|
|
504
|
+
on: {
|
|
505
|
+
"CALL.CONNECTING": {
|
|
506
|
+
target: "call:connecting",
|
|
507
|
+
actions: "resetError"
|
|
508
|
+
},
|
|
509
|
+
"CALL.RINGING": {
|
|
510
|
+
target: "call:ringing",
|
|
511
|
+
actions: "resetError"
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
"call:connecting": {
|
|
516
|
+
on: {
|
|
517
|
+
"CALL.RINGING": "call:ringing",
|
|
518
|
+
"CALL.ACCEPTED": "call:accepted",
|
|
519
|
+
"CALL.CONFIRMED": "call:inCall",
|
|
520
|
+
"CALL.ENDED": "call:ended",
|
|
521
|
+
"CALL.FAILED": {
|
|
522
|
+
target: "call:failed",
|
|
523
|
+
actions: "rememberError"
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
"call:ringing": {
|
|
528
|
+
on: {
|
|
529
|
+
"CALL.ACCEPTED": "call:accepted",
|
|
530
|
+
"CALL.CONFIRMED": "call:inCall",
|
|
531
|
+
"CALL.ENDED": "call:ended",
|
|
532
|
+
"CALL.FAILED": {
|
|
533
|
+
target: "call:failed",
|
|
534
|
+
actions: "rememberError"
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
"call:accepted": {
|
|
539
|
+
on: {
|
|
540
|
+
"CALL.CONFIRMED": "call:inCall",
|
|
541
|
+
"CALL.ENDED": "call:ended",
|
|
542
|
+
"CALL.FAILED": {
|
|
543
|
+
target: "call:failed",
|
|
544
|
+
actions: "rememberError"
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
"call:inCall": {
|
|
549
|
+
on: {
|
|
550
|
+
"CALL.ENDED": "call:ended",
|
|
551
|
+
"CALL.FAILED": {
|
|
552
|
+
target: "call:failed",
|
|
553
|
+
actions: "rememberError"
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
"call:ended": {
|
|
558
|
+
on: {
|
|
559
|
+
"CALL.RESET": {
|
|
560
|
+
target: "call:idle",
|
|
561
|
+
actions: "resetError"
|
|
562
|
+
},
|
|
563
|
+
"CALL.CONNECTING": {
|
|
564
|
+
target: "call:connecting",
|
|
565
|
+
actions: "resetError"
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
"call:failed": {
|
|
570
|
+
on: {
|
|
571
|
+
"CALL.RESET": {
|
|
572
|
+
target: "call:idle",
|
|
573
|
+
actions: "resetError"
|
|
574
|
+
},
|
|
575
|
+
"CALL.CONNECTING": {
|
|
576
|
+
target: "call:connecting",
|
|
577
|
+
actions: "resetError"
|
|
578
|
+
},
|
|
579
|
+
"CALL.ENDED": {
|
|
580
|
+
target: "call:ended",
|
|
581
|
+
actions: "resetError"
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
class Ze extends q {
|
|
588
|
+
constructor(e) {
|
|
589
|
+
super(je), this.subscribeToEvents(e);
|
|
590
|
+
}
|
|
591
|
+
get isIdle() {
|
|
592
|
+
return this.state === "call:idle";
|
|
593
|
+
}
|
|
594
|
+
get isConnecting() {
|
|
595
|
+
return this.state === "call:connecting";
|
|
596
|
+
}
|
|
597
|
+
get isRinging() {
|
|
598
|
+
return this.state === "call:ringing";
|
|
599
|
+
}
|
|
600
|
+
get isAccepted() {
|
|
601
|
+
return this.state === "call:accepted";
|
|
602
|
+
}
|
|
603
|
+
get isInCall() {
|
|
604
|
+
return this.state === "call:inCall";
|
|
605
|
+
}
|
|
606
|
+
get isEnded() {
|
|
607
|
+
return this.state === "call:ended";
|
|
608
|
+
}
|
|
609
|
+
get isFailed() {
|
|
610
|
+
return this.state === "call:failed";
|
|
611
|
+
}
|
|
612
|
+
get isActive() {
|
|
613
|
+
return this.isAccepted || this.isInCall;
|
|
614
|
+
}
|
|
615
|
+
get isPending() {
|
|
616
|
+
return this.isConnecting || this.isRinging;
|
|
617
|
+
}
|
|
618
|
+
get lastError() {
|
|
619
|
+
return this.getSnapshot().context.lastError;
|
|
620
|
+
}
|
|
621
|
+
reset() {
|
|
622
|
+
this.send({ type: "CALL.RESET" });
|
|
623
|
+
}
|
|
624
|
+
send(e) {
|
|
625
|
+
if (!this.getSnapshot().can(e)) {
|
|
626
|
+
console.warn(
|
|
627
|
+
`[CallStateMachine] Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
|
|
628
|
+
);
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
super.send(e);
|
|
632
|
+
}
|
|
633
|
+
subscribeToEvents(e) {
|
|
634
|
+
this.addSubscription(
|
|
635
|
+
e.on("connecting", () => {
|
|
636
|
+
this.send({ type: "CALL.CONNECTING" });
|
|
637
|
+
})
|
|
638
|
+
), this.addSubscription(
|
|
639
|
+
e.on("progress", () => {
|
|
640
|
+
this.send({ type: "CALL.RINGING" });
|
|
641
|
+
})
|
|
642
|
+
), this.addSubscription(
|
|
643
|
+
e.on("accepted", () => {
|
|
644
|
+
this.send({ type: "CALL.ACCEPTED" });
|
|
645
|
+
})
|
|
646
|
+
), this.addSubscription(
|
|
647
|
+
e.on("confirmed", () => {
|
|
648
|
+
this.send({ type: "CALL.CONFIRMED" });
|
|
649
|
+
})
|
|
650
|
+
), this.addSubscription(
|
|
651
|
+
e.on("ended", () => {
|
|
652
|
+
this.send({ type: "CALL.ENDED" });
|
|
653
|
+
})
|
|
654
|
+
), this.addSubscription(
|
|
655
|
+
e.on("failed", (t) => {
|
|
656
|
+
this.send({ type: "CALL.FAILED", error: t });
|
|
657
|
+
})
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
var C = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n))(C || {}), et = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(et || {});
|
|
662
|
+
const ge = [
|
|
454
663
|
"peerconnection",
|
|
455
664
|
"connecting",
|
|
456
665
|
"sending",
|
|
@@ -477,20 +686,20 @@ const oe = [
|
|
|
477
686
|
"peerconnection:createanswerfailed",
|
|
478
687
|
"peerconnection:setlocaldescriptionfailed",
|
|
479
688
|
"peerconnection:setremotedescriptionfailed"
|
|
480
|
-
],
|
|
689
|
+
], tt = [
|
|
481
690
|
"peerconnection:confirmed",
|
|
482
691
|
"peerconnection:ontrack",
|
|
483
692
|
"ended:fromserver",
|
|
484
693
|
"call-status-changed",
|
|
485
694
|
"remote-streams-changed"
|
|
486
|
-
],
|
|
487
|
-
...
|
|
488
|
-
...
|
|
489
|
-
],
|
|
695
|
+
], ue = [
|
|
696
|
+
...ge,
|
|
697
|
+
...tt
|
|
698
|
+
], nt = () => new M(ue), st = (n, e) => {
|
|
490
699
|
n.getVideoTracks().forEach((s) => {
|
|
491
700
|
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
492
701
|
});
|
|
493
|
-
},
|
|
702
|
+
}, k = (n, {
|
|
494
703
|
directionVideo: e,
|
|
495
704
|
directionAudio: t,
|
|
496
705
|
contentHint: s
|
|
@@ -498,16 +707,16 @@ const oe = [
|
|
|
498
707
|
if (!n || e === "recvonly" && t === "recvonly")
|
|
499
708
|
return;
|
|
500
709
|
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
|
|
501
|
-
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" &&
|
|
710
|
+
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && st(o, s), o;
|
|
502
711
|
};
|
|
503
|
-
var
|
|
504
|
-
class
|
|
712
|
+
var Te = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(Te || {});
|
|
713
|
+
class it {
|
|
505
714
|
events;
|
|
506
715
|
rtcSession;
|
|
507
716
|
disposers = /* @__PURE__ */ new Set();
|
|
508
717
|
onReset;
|
|
509
718
|
constructor(e, { onReset: t }) {
|
|
510
|
-
this.events = e, this.onReset = t, e.on(
|
|
719
|
+
this.events = e, this.onReset = t, e.on(C.FAILED, this.handleEnded), e.on(C.ENDED, this.handleEnded);
|
|
511
720
|
}
|
|
512
721
|
get connection() {
|
|
513
722
|
return this.rtcSession?.connection;
|
|
@@ -528,27 +737,27 @@ class Ke {
|
|
|
528
737
|
iceServers: a,
|
|
529
738
|
directionVideo: o,
|
|
530
739
|
directionAudio: c,
|
|
531
|
-
contentHint:
|
|
532
|
-
offerToReceiveAudio:
|
|
533
|
-
offerToReceiveVideo:
|
|
534
|
-
degradationPreference:
|
|
740
|
+
contentHint: l,
|
|
741
|
+
offerToReceiveAudio: T = !0,
|
|
742
|
+
offerToReceiveVideo: h = !0,
|
|
743
|
+
degradationPreference: u,
|
|
535
744
|
sendEncodings: p,
|
|
536
|
-
onAddedTransceiver:
|
|
537
|
-
}) => new Promise((
|
|
538
|
-
this.handleCall().then(
|
|
539
|
-
|
|
745
|
+
onAddedTransceiver: A
|
|
746
|
+
}) => new Promise((N, D) => {
|
|
747
|
+
this.handleCall().then(N).catch((V) => {
|
|
748
|
+
D(V);
|
|
540
749
|
}), this.rtcSession = e.call(t(s), {
|
|
541
|
-
mediaStream:
|
|
750
|
+
mediaStream: k(i, {
|
|
542
751
|
directionVideo: o,
|
|
543
752
|
directionAudio: c,
|
|
544
|
-
contentHint:
|
|
753
|
+
contentHint: l
|
|
545
754
|
}),
|
|
546
755
|
pcConfig: {
|
|
547
756
|
iceServers: a
|
|
548
757
|
},
|
|
549
758
|
rtcOfferConstraints: {
|
|
550
|
-
offerToReceiveAudio:
|
|
551
|
-
offerToReceiveVideo:
|
|
759
|
+
offerToReceiveAudio: T,
|
|
760
|
+
offerToReceiveVideo: h
|
|
552
761
|
},
|
|
553
762
|
// необходимо передавать в методе call, чтобы подписаться на события peerconnection,
|
|
554
763
|
// так как в методе call создается RTCSession
|
|
@@ -557,16 +766,16 @@ class Ke {
|
|
|
557
766
|
extraHeaders: r,
|
|
558
767
|
directionVideo: o,
|
|
559
768
|
directionAudio: c,
|
|
560
|
-
degradationPreference:
|
|
769
|
+
degradationPreference: u,
|
|
561
770
|
sendEncodings: p,
|
|
562
|
-
onAddedTransceiver:
|
|
771
|
+
onAddedTransceiver: A
|
|
563
772
|
});
|
|
564
773
|
});
|
|
565
774
|
async endCall() {
|
|
566
775
|
const { rtcSession: e } = this;
|
|
567
776
|
if (e && !e.isEnded())
|
|
568
777
|
return e.terminateAsync({
|
|
569
|
-
cause:
|
|
778
|
+
cause: Te.CANCELED
|
|
570
779
|
}).finally(() => {
|
|
571
780
|
this.reset();
|
|
572
781
|
});
|
|
@@ -580,14 +789,14 @@ class Ke {
|
|
|
580
789
|
directionAudio: a,
|
|
581
790
|
offerToReceiveAudio: o,
|
|
582
791
|
offerToReceiveVideo: c,
|
|
583
|
-
contentHint:
|
|
584
|
-
degradationPreference:
|
|
585
|
-
sendEncodings:
|
|
586
|
-
onAddedTransceiver:
|
|
587
|
-
}) => new Promise((p,
|
|
792
|
+
contentHint: l,
|
|
793
|
+
degradationPreference: T,
|
|
794
|
+
sendEncodings: h,
|
|
795
|
+
onAddedTransceiver: u
|
|
796
|
+
}) => new Promise((p, A) => {
|
|
588
797
|
try {
|
|
589
|
-
this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(p).catch((
|
|
590
|
-
|
|
798
|
+
this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(p).catch((N) => {
|
|
799
|
+
A(N);
|
|
591
800
|
}), e.answer({
|
|
592
801
|
pcConfig: {
|
|
593
802
|
iceServers: i
|
|
@@ -596,26 +805,26 @@ class Ke {
|
|
|
596
805
|
offerToReceiveAudio: o,
|
|
597
806
|
offerToReceiveVideo: c
|
|
598
807
|
},
|
|
599
|
-
mediaStream:
|
|
808
|
+
mediaStream: k(t, {
|
|
600
809
|
directionVideo: r,
|
|
601
810
|
directionAudio: a,
|
|
602
|
-
contentHint:
|
|
811
|
+
contentHint: l
|
|
603
812
|
}),
|
|
604
813
|
extraHeaders: s,
|
|
605
814
|
directionVideo: r,
|
|
606
815
|
directionAudio: a,
|
|
607
|
-
degradationPreference:
|
|
608
|
-
sendEncodings:
|
|
609
|
-
onAddedTransceiver:
|
|
816
|
+
degradationPreference: T,
|
|
817
|
+
sendEncodings: h,
|
|
818
|
+
onAddedTransceiver: u
|
|
610
819
|
});
|
|
611
|
-
} catch (
|
|
612
|
-
|
|
820
|
+
} catch (N) {
|
|
821
|
+
A(N);
|
|
613
822
|
}
|
|
614
823
|
});
|
|
615
824
|
async replaceMediaStream(e, t) {
|
|
616
825
|
if (!this.rtcSession)
|
|
617
826
|
throw new Error("No rtcSession established");
|
|
618
|
-
const { contentHint: s } = t ?? {}, i =
|
|
827
|
+
const { contentHint: s } = t ?? {}, i = k(e, { contentHint: s });
|
|
619
828
|
if (i === void 0)
|
|
620
829
|
throw new Error("No preparedMediaStream");
|
|
621
830
|
return this.rtcSession.replaceMediaStream(i, t);
|
|
@@ -627,33 +836,33 @@ class Ke {
|
|
|
627
836
|
}
|
|
628
837
|
handleCall = async () => new Promise((e, t) => {
|
|
629
838
|
const s = () => {
|
|
630
|
-
this.events.on(
|
|
839
|
+
this.events.on(C.PEER_CONNECTION, l), this.events.on(C.CONFIRMED, T);
|
|
631
840
|
}, i = () => {
|
|
632
|
-
this.events.off(
|
|
841
|
+
this.events.off(C.PEER_CONNECTION, l), this.events.off(C.CONFIRMED, T);
|
|
633
842
|
}, r = () => {
|
|
634
|
-
this.events.on(
|
|
843
|
+
this.events.on(C.FAILED, o), this.events.on(C.ENDED, o);
|
|
635
844
|
}, a = () => {
|
|
636
|
-
this.events.off(
|
|
637
|
-
}, o = (
|
|
638
|
-
i(), a(), t(
|
|
845
|
+
this.events.off(C.FAILED, o), this.events.off(C.ENDED, o);
|
|
846
|
+
}, o = (h) => {
|
|
847
|
+
i(), a(), t(h);
|
|
639
848
|
};
|
|
640
849
|
let c;
|
|
641
|
-
const
|
|
642
|
-
c =
|
|
643
|
-
const
|
|
644
|
-
this.events.trigger(
|
|
850
|
+
const l = ({ peerconnection: h }) => {
|
|
851
|
+
c = h;
|
|
852
|
+
const u = (p) => {
|
|
853
|
+
this.events.trigger(C.PEER_CONNECTION_ONTRACK, p);
|
|
645
854
|
};
|
|
646
|
-
|
|
647
|
-
|
|
855
|
+
h.addEventListener("track", u), this.disposers.add(() => {
|
|
856
|
+
h.removeEventListener("track", u);
|
|
648
857
|
});
|
|
649
|
-
},
|
|
650
|
-
c !== void 0 && this.events.trigger(
|
|
858
|
+
}, T = () => {
|
|
859
|
+
c !== void 0 && this.events.trigger(C.PEER_CONNECTION_CONFIRMED, c), i(), a(), e(c);
|
|
651
860
|
};
|
|
652
861
|
s(), r();
|
|
653
862
|
});
|
|
654
863
|
subscribeToSessionEvents(e) {
|
|
655
864
|
this.events.eachTriggers((t, s) => {
|
|
656
|
-
const i =
|
|
865
|
+
const i = ge.find((r) => r === s);
|
|
657
866
|
i && (e.on(i, t), this.disposers.add(() => {
|
|
658
867
|
e.off(i, t);
|
|
659
868
|
}));
|
|
@@ -666,13 +875,13 @@ class Ke {
|
|
|
666
875
|
}
|
|
667
876
|
handleEnded = (e) => {
|
|
668
877
|
const { originator: t } = e;
|
|
669
|
-
t === "remote" && this.events.trigger(
|
|
878
|
+
t === "remote" && this.events.trigger(C.ENDED_FROM_SERVER, e), this.reset();
|
|
670
879
|
};
|
|
671
880
|
reset = () => {
|
|
672
881
|
delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
|
|
673
882
|
};
|
|
674
883
|
}
|
|
675
|
-
class
|
|
884
|
+
class rt {
|
|
676
885
|
config;
|
|
677
886
|
tools;
|
|
678
887
|
connection;
|
|
@@ -721,18 +930,18 @@ class je {
|
|
|
721
930
|
return this.connection.addTransceiver(e, t);
|
|
722
931
|
}
|
|
723
932
|
}
|
|
724
|
-
const
|
|
725
|
-
const t =
|
|
933
|
+
const Ee = (n) => n.getSettings(), at = (n, e) => {
|
|
934
|
+
const t = Ee(n);
|
|
726
935
|
let s = e;
|
|
727
936
|
s ??= n.label;
|
|
728
937
|
let i = t?.msid;
|
|
729
938
|
return i ??= s, i ??= n.id, i;
|
|
730
|
-
},
|
|
731
|
-
const t =
|
|
939
|
+
}, ot = (n, e) => {
|
|
940
|
+
const t = Ee(n);
|
|
732
941
|
let s = e;
|
|
733
942
|
return s ??= t?.msid, s ??= n.label, (s && s.length > 0 ? s : void 0) ?? n.id;
|
|
734
943
|
};
|
|
735
|
-
class
|
|
944
|
+
class Z {
|
|
736
945
|
participantGroups = /* @__PURE__ */ new Map();
|
|
737
946
|
trackToGroup = /* @__PURE__ */ new Map();
|
|
738
947
|
trackDisposers = /* @__PURE__ */ new Map();
|
|
@@ -749,7 +958,7 @@ class X {
|
|
|
749
958
|
onRemoved: t,
|
|
750
959
|
streamHint: s
|
|
751
960
|
} = {}) {
|
|
752
|
-
const i =
|
|
961
|
+
const i = ot(e, s), r = at(e, s);
|
|
753
962
|
if (this.trackToGroup.has(e.id))
|
|
754
963
|
return { isAdded: !1 };
|
|
755
964
|
const a = this.getParticipantGroups(i);
|
|
@@ -785,8 +994,8 @@ class X {
|
|
|
785
994
|
let i = !1;
|
|
786
995
|
return [...s.values()].forEach((a) => {
|
|
787
996
|
[...a.trackIds].filter((c) => !t.includes(c)).forEach((c) => {
|
|
788
|
-
const
|
|
789
|
-
i ||=
|
|
997
|
+
const l = this.removeTrack(c);
|
|
998
|
+
i ||= l;
|
|
790
999
|
});
|
|
791
1000
|
}), i;
|
|
792
1001
|
}
|
|
@@ -809,16 +1018,16 @@ class X {
|
|
|
809
1018
|
return this.participantGroups.set(e, s), s;
|
|
810
1019
|
}
|
|
811
1020
|
}
|
|
812
|
-
const
|
|
1021
|
+
const H = {
|
|
813
1022
|
type: "participant"
|
|
814
|
-
},
|
|
1023
|
+
}, ct = {
|
|
815
1024
|
type: "spectator_synthetic"
|
|
816
|
-
},
|
|
1025
|
+
}, dt = (n) => ({
|
|
817
1026
|
type: "spectator",
|
|
818
1027
|
recvParams: n
|
|
819
1028
|
});
|
|
820
|
-
class
|
|
821
|
-
role =
|
|
1029
|
+
class O {
|
|
1030
|
+
role = H;
|
|
822
1031
|
mainManager;
|
|
823
1032
|
recvManager;
|
|
824
1033
|
onRoleChanged;
|
|
@@ -841,13 +1050,13 @@ class f {
|
|
|
841
1050
|
return this.role;
|
|
842
1051
|
}
|
|
843
1052
|
setCallRoleParticipant() {
|
|
844
|
-
this.changeRole(
|
|
1053
|
+
this.changeRole(H);
|
|
845
1054
|
}
|
|
846
1055
|
setCallRoleSpectatorSynthetic() {
|
|
847
|
-
this.changeRole(
|
|
1056
|
+
this.changeRole(ct);
|
|
848
1057
|
}
|
|
849
1058
|
setCallRoleSpectator(e) {
|
|
850
|
-
this.changeRole(
|
|
1059
|
+
this.changeRole(dt(e));
|
|
851
1060
|
}
|
|
852
1061
|
changeRole(e) {
|
|
853
1062
|
const t = this.role;
|
|
@@ -855,38 +1064,39 @@ class f {
|
|
|
855
1064
|
this.setRole(e);
|
|
856
1065
|
return;
|
|
857
1066
|
}
|
|
858
|
-
|
|
1067
|
+
O.hasSpectator(e) && O.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
|
|
859
1068
|
}
|
|
860
1069
|
reset() {
|
|
861
|
-
this.role =
|
|
1070
|
+
this.role = H, this.recvManager.reset();
|
|
862
1071
|
}
|
|
863
1072
|
getActiveManager() {
|
|
864
1073
|
return this.hasSpectator() ? this.recvManager : this.mainManager;
|
|
865
1074
|
}
|
|
866
1075
|
hasParticipant() {
|
|
867
|
-
return
|
|
1076
|
+
return O.hasParticipant(this.role);
|
|
868
1077
|
}
|
|
869
1078
|
hasSpectatorSynthetic() {
|
|
870
|
-
return
|
|
1079
|
+
return O.hasSpectatorSynthetic(this.role);
|
|
871
1080
|
}
|
|
872
1081
|
hasSpectator() {
|
|
873
|
-
return
|
|
1082
|
+
return O.hasSpectator(this.role);
|
|
874
1083
|
}
|
|
875
1084
|
setRole(e) {
|
|
876
1085
|
const t = this.role;
|
|
877
1086
|
this.role = e, this.onRoleChanged?.({ previous: t, next: e });
|
|
878
1087
|
}
|
|
879
1088
|
}
|
|
880
|
-
const
|
|
881
|
-
class
|
|
1089
|
+
const ee = (n) => n.streams[0]?.id;
|
|
1090
|
+
class lt {
|
|
882
1091
|
events;
|
|
1092
|
+
callStateMachine;
|
|
883
1093
|
isPendingCall = !1;
|
|
884
1094
|
isPendingAnswer = !1;
|
|
885
1095
|
rtcSession;
|
|
886
|
-
|
|
887
|
-
mainRemoteStreamsManager = new
|
|
888
|
-
recvRemoteStreamsManager = new
|
|
889
|
-
roleManager = new
|
|
1096
|
+
conferenceStateManager;
|
|
1097
|
+
mainRemoteStreamsManager = new Z();
|
|
1098
|
+
recvRemoteStreamsManager = new Z();
|
|
1099
|
+
roleManager = new O(
|
|
890
1100
|
{ mainManager: this.mainRemoteStreamsManager, recvManager: this.recvRemoteStreamsManager },
|
|
891
1101
|
(e) => {
|
|
892
1102
|
this.onRoleChanged(e);
|
|
@@ -895,8 +1105,11 @@ class st {
|
|
|
895
1105
|
mcuSession;
|
|
896
1106
|
recvSession;
|
|
897
1107
|
disposeRecvSessionTrackListener;
|
|
898
|
-
constructor() {
|
|
899
|
-
this.events =
|
|
1108
|
+
constructor(e) {
|
|
1109
|
+
this.conferenceStateManager = e, this.events = nt(), this.mcuSession = new it(this.events, { onReset: this.reset }), this.callStateMachine = new Ze(this.events), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents();
|
|
1110
|
+
}
|
|
1111
|
+
get callActor() {
|
|
1112
|
+
return this.callStateMachine.actorRef;
|
|
900
1113
|
}
|
|
901
1114
|
get requested() {
|
|
902
1115
|
return this.isPendingCall || this.isPendingAnswer;
|
|
@@ -926,7 +1139,7 @@ class st {
|
|
|
926
1139
|
off(e, t) {
|
|
927
1140
|
this.events.off(e, t);
|
|
928
1141
|
}
|
|
929
|
-
startCall = async (e, t, s) => (this.isPendingCall = !0, this.
|
|
1142
|
+
startCall = async (e, t, s) => (this.isPendingCall = !0, this.conferenceStateManager.updateState({ number: s.number, answer: !1 }), this.mcuSession.startCall(e, t, s).finally(() => {
|
|
930
1143
|
this.isPendingCall = !1;
|
|
931
1144
|
}));
|
|
932
1145
|
async endCall() {
|
|
@@ -938,13 +1151,13 @@ class st {
|
|
|
938
1151
|
answerToIncomingCall = async (e, t) => {
|
|
939
1152
|
this.isPendingAnswer = !0;
|
|
940
1153
|
const s = e();
|
|
941
|
-
return this.
|
|
1154
|
+
return this.conferenceStateManager.updateState({
|
|
1155
|
+
answer: !0,
|
|
1156
|
+
number: s.remote_identity.uri.user
|
|
1157
|
+
}), this.mcuSession.answerToIncomingCall(s, t).finally(() => {
|
|
942
1158
|
this.isPendingAnswer = !1;
|
|
943
1159
|
});
|
|
944
1160
|
};
|
|
945
|
-
getCallConfiguration() {
|
|
946
|
-
return { ...this.callConfiguration };
|
|
947
|
-
}
|
|
948
1161
|
getMainStream() {
|
|
949
1162
|
return this.getActiveStreamsManager().mainStream;
|
|
950
1163
|
}
|
|
@@ -967,22 +1180,22 @@ class st {
|
|
|
967
1180
|
return this.mcuSession.restartIce(e);
|
|
968
1181
|
}
|
|
969
1182
|
reset = () => {
|
|
970
|
-
this.mainRemoteStreamsManager.reset(), this.
|
|
1183
|
+
this.mainRemoteStreamsManager.reset(), this.conferenceStateManager.updateState({ number: void 0, answer: !1 }), this.roleManager.reset(), this.stopRecvSession();
|
|
971
1184
|
};
|
|
972
1185
|
subscribeCallStatusChange() {
|
|
973
1186
|
let { isCallActive: e } = this;
|
|
974
|
-
const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } =
|
|
1187
|
+
const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = C;
|
|
975
1188
|
this.onRace([t, s, i, r], () => {
|
|
976
1189
|
e = this.maybeTriggerCallStatus(e);
|
|
977
1190
|
});
|
|
978
1191
|
}
|
|
979
1192
|
maybeTriggerCallStatus(e) {
|
|
980
1193
|
const t = this.isCallActive;
|
|
981
|
-
return t !== e && this.events.trigger(
|
|
1194
|
+
return t !== e && this.events.trigger(C.CALL_STATUS_CHANGED, { isCallActive: t }), t;
|
|
982
1195
|
}
|
|
983
1196
|
subscribeMcuRemoteTrackEvents() {
|
|
984
|
-
this.on(
|
|
985
|
-
this.addRemoteTrack(this.mainRemoteStreamsManager, e.track,
|
|
1197
|
+
this.on(C.PEER_CONNECTION_ONTRACK, (e) => {
|
|
1198
|
+
this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, ee(e));
|
|
986
1199
|
});
|
|
987
1200
|
}
|
|
988
1201
|
addRemoteTrack(e, t, s) {
|
|
@@ -1005,7 +1218,7 @@ class st {
|
|
|
1005
1218
|
if (e !== r)
|
|
1006
1219
|
return;
|
|
1007
1220
|
const a = [...r.getStreams()];
|
|
1008
|
-
this.events.trigger(
|
|
1221
|
+
this.events.trigger(C.REMOTE_STREAMS_CHANGED, {
|
|
1009
1222
|
participantId: i,
|
|
1010
1223
|
changeType: t,
|
|
1011
1224
|
trackId: s,
|
|
@@ -1017,21 +1230,21 @@ class st {
|
|
|
1017
1230
|
}
|
|
1018
1231
|
attachRecvSessionTracks(e) {
|
|
1019
1232
|
const { peerConnection: t } = e, s = (i) => {
|
|
1020
|
-
this.addRemoteTrack(this.recvRemoteStreamsManager, i.track,
|
|
1233
|
+
this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, ee(i));
|
|
1021
1234
|
};
|
|
1022
1235
|
t.addEventListener("track", s), this.disposeRecvSessionTrackListener = () => {
|
|
1023
1236
|
t.removeEventListener("track", s);
|
|
1024
1237
|
};
|
|
1025
1238
|
}
|
|
1026
1239
|
startRecvSession(e, t) {
|
|
1027
|
-
const
|
|
1240
|
+
const s = this.conferenceStateManager.getNumber();
|
|
1028
1241
|
if (s === void 0)
|
|
1029
1242
|
return;
|
|
1030
1243
|
this.stopRecvSession();
|
|
1031
1244
|
const i = {
|
|
1032
1245
|
quality: "high",
|
|
1033
1246
|
audioChannel: e
|
|
1034
|
-
}, r = new
|
|
1247
|
+
}, r = new rt(i, { sendOffer: t });
|
|
1035
1248
|
this.recvSession = r, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(r), r.call(s).catch(() => {
|
|
1036
1249
|
this.stopRecvSession();
|
|
1037
1250
|
});
|
|
@@ -1043,45 +1256,45 @@ class st {
|
|
|
1043
1256
|
previous: e,
|
|
1044
1257
|
next: t
|
|
1045
1258
|
}) => {
|
|
1046
|
-
if (
|
|
1259
|
+
if (O.hasSpectator(e) && !O.hasSpectator(t) && this.stopRecvSession(), O.hasSpectator(t)) {
|
|
1047
1260
|
const s = t.recvParams;
|
|
1048
1261
|
this.startRecvSession(s.audioId, s.sendOffer);
|
|
1049
1262
|
}
|
|
1050
1263
|
};
|
|
1051
1264
|
}
|
|
1052
|
-
const
|
|
1265
|
+
const ht = (n, e) => (n.degradationPreference = e.degradationPreference, n), gt = (n, e) => {
|
|
1053
1266
|
n.encodings ??= [];
|
|
1054
1267
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
1055
1268
|
n.encodings.push({});
|
|
1056
1269
|
return n;
|
|
1057
|
-
},
|
|
1058
|
-
if (
|
|
1270
|
+
}, Ce = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, ut = Ce(), Tt = (n, e) => {
|
|
1271
|
+
if (ut(n, e))
|
|
1059
1272
|
return n;
|
|
1060
|
-
},
|
|
1061
|
-
const t = n.maxBitrate, s =
|
|
1273
|
+
}, Et = (n, e) => {
|
|
1274
|
+
const t = n.maxBitrate, s = Tt(e, t);
|
|
1062
1275
|
return s !== void 0 && (n.maxBitrate = s), n;
|
|
1063
|
-
},
|
|
1064
|
-
|
|
1065
|
-
),
|
|
1066
|
-
const t = n === void 0 ? void 0 : Math.max(n,
|
|
1067
|
-
if (t !== void 0 &&
|
|
1276
|
+
}, Se = 1, Ct = Ce(
|
|
1277
|
+
Se
|
|
1278
|
+
), St = (n, e) => {
|
|
1279
|
+
const t = n === void 0 ? void 0 : Math.max(n, Se);
|
|
1280
|
+
if (t !== void 0 && Ct(
|
|
1068
1281
|
t,
|
|
1069
1282
|
e
|
|
1070
1283
|
))
|
|
1071
1284
|
return t;
|
|
1072
|
-
},
|
|
1073
|
-
const t = n.scaleResolutionDownBy, s =
|
|
1285
|
+
}, pt = (n, e) => {
|
|
1286
|
+
const t = n.scaleResolutionDownBy, s = St(
|
|
1074
1287
|
e,
|
|
1075
1288
|
t
|
|
1076
1289
|
);
|
|
1077
1290
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
1078
|
-
},
|
|
1291
|
+
}, mt = (n, e) => {
|
|
1079
1292
|
const t = e.encodings?.length ?? 0;
|
|
1080
|
-
return
|
|
1293
|
+
return gt(n, t), n.encodings.forEach((s, i) => {
|
|
1081
1294
|
const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
|
|
1082
|
-
|
|
1295
|
+
Et(s, a), pt(s, o);
|
|
1083
1296
|
}), n;
|
|
1084
|
-
},
|
|
1297
|
+
}, Nt = (n, e) => {
|
|
1085
1298
|
if (n.codecs?.length !== e.codecs?.length)
|
|
1086
1299
|
return !0;
|
|
1087
1300
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -1098,15 +1311,15 @@ const it = (n, e) => (n.degradationPreference = e.degradationPreference, n), rt
|
|
|
1098
1311
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
1099
1312
|
return !0;
|
|
1100
1313
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
1101
|
-
},
|
|
1314
|
+
}, Rt = async (n, e) => {
|
|
1102
1315
|
const t = n.getParameters(), s = JSON.parse(
|
|
1103
1316
|
JSON.stringify(t)
|
|
1104
1317
|
);
|
|
1105
|
-
|
|
1106
|
-
const i =
|
|
1318
|
+
mt(t, e), ht(t, e);
|
|
1319
|
+
const i = Nt(s, t);
|
|
1107
1320
|
return i && await n.setParameters(t), { parameters: t, isChanged: i };
|
|
1108
|
-
},
|
|
1109
|
-
const { isChanged: s, parameters: i } = await
|
|
1321
|
+
}, pe = async (n, e, t) => {
|
|
1322
|
+
const { isChanged: s, parameters: i } = await Rt(n, {
|
|
1110
1323
|
encodings: [
|
|
1111
1324
|
{
|
|
1112
1325
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -1115,21 +1328,421 @@ const it = (n, e) => (n.degradationPreference = e.degradationPreference, n), rt
|
|
|
1115
1328
|
]
|
|
1116
1329
|
});
|
|
1117
1330
|
return s && t && t(i), { isChanged: s, parameters: i };
|
|
1118
|
-
},
|
|
1119
|
-
const s =
|
|
1331
|
+
}, At = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), It = async (n, e, t) => {
|
|
1332
|
+
const s = At(n, e);
|
|
1120
1333
|
if (s)
|
|
1121
|
-
return
|
|
1334
|
+
return pe(s, { maxBitrate: t });
|
|
1122
1335
|
};
|
|
1123
|
-
var
|
|
1124
|
-
const
|
|
1336
|
+
var P = /* @__PURE__ */ ((n) => (n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n))(P || {});
|
|
1337
|
+
const me = [
|
|
1125
1338
|
"presentation:start",
|
|
1126
1339
|
"presentation:started",
|
|
1127
1340
|
"presentation:end",
|
|
1128
1341
|
"presentation:ended",
|
|
1129
1342
|
"presentation:failed"
|
|
1130
|
-
],
|
|
1131
|
-
|
|
1343
|
+
], ft = () => new M(me);
|
|
1344
|
+
var Mt = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(Mt || {});
|
|
1345
|
+
const vt = $({
|
|
1346
|
+
types: {
|
|
1347
|
+
context: {},
|
|
1348
|
+
events: {}
|
|
1349
|
+
},
|
|
1350
|
+
actions: {
|
|
1351
|
+
logTransition: (n, e) => {
|
|
1352
|
+
d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1353
|
+
},
|
|
1354
|
+
logStateChange: (n, e) => {
|
|
1355
|
+
d("PresentationStateMachine state changed", e.state);
|
|
1356
|
+
},
|
|
1357
|
+
setError: b(({ event: n }) => "error" in n && n.error !== void 0 ? {
|
|
1358
|
+
lastError: n.error instanceof Error ? n.error : new Error(JSON.stringify(n.error))
|
|
1359
|
+
} : { lastError: void 0 }),
|
|
1360
|
+
clearError: b({ lastError: void 0 })
|
|
1361
|
+
}
|
|
1362
|
+
}).createMachine({
|
|
1363
|
+
id: "presentation",
|
|
1364
|
+
initial: "presentation:idle",
|
|
1365
|
+
context: {},
|
|
1366
|
+
states: {
|
|
1367
|
+
"presentation:idle": {
|
|
1368
|
+
entry: {
|
|
1369
|
+
type: "logStateChange",
|
|
1370
|
+
params: {
|
|
1371
|
+
state: "presentation:idle"
|
|
1372
|
+
/* IDLE */
|
|
1373
|
+
}
|
|
1374
|
+
},
|
|
1375
|
+
on: {
|
|
1376
|
+
"SCREEN.STARTING": {
|
|
1377
|
+
target: "presentation:starting",
|
|
1378
|
+
actions: [
|
|
1379
|
+
"clearError",
|
|
1380
|
+
{
|
|
1381
|
+
type: "logTransition",
|
|
1382
|
+
params: {
|
|
1383
|
+
from: "presentation:idle",
|
|
1384
|
+
to: "presentation:starting",
|
|
1385
|
+
event: "SCREEN.STARTING"
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
]
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
},
|
|
1392
|
+
"presentation:starting": {
|
|
1393
|
+
entry: {
|
|
1394
|
+
type: "logStateChange",
|
|
1395
|
+
params: {
|
|
1396
|
+
state: "presentation:starting"
|
|
1397
|
+
/* STARTING */
|
|
1398
|
+
}
|
|
1399
|
+
},
|
|
1400
|
+
on: {
|
|
1401
|
+
"SCREEN.STARTED": {
|
|
1402
|
+
target: "presentation:active",
|
|
1403
|
+
actions: {
|
|
1404
|
+
type: "logTransition",
|
|
1405
|
+
params: {
|
|
1406
|
+
from: "presentation:starting",
|
|
1407
|
+
to: "presentation:active",
|
|
1408
|
+
event: "SCREEN.STARTED"
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
},
|
|
1412
|
+
"SCREEN.FAILED": {
|
|
1413
|
+
target: "presentation:failed",
|
|
1414
|
+
actions: [
|
|
1415
|
+
"setError",
|
|
1416
|
+
{
|
|
1417
|
+
type: "logTransition",
|
|
1418
|
+
params: {
|
|
1419
|
+
from: "presentation:starting",
|
|
1420
|
+
to: "presentation:failed",
|
|
1421
|
+
event: "SCREEN.FAILED"
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
]
|
|
1425
|
+
},
|
|
1426
|
+
"SCREEN.ENDED": {
|
|
1427
|
+
target: "presentation:idle",
|
|
1428
|
+
actions: [
|
|
1429
|
+
"clearError",
|
|
1430
|
+
{
|
|
1431
|
+
type: "logTransition",
|
|
1432
|
+
params: {
|
|
1433
|
+
from: "presentation:starting",
|
|
1434
|
+
to: "presentation:idle",
|
|
1435
|
+
event: "SCREEN.ENDED"
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
]
|
|
1439
|
+
},
|
|
1440
|
+
"CALL.ENDED": {
|
|
1441
|
+
target: "presentation:idle",
|
|
1442
|
+
actions: [
|
|
1443
|
+
"clearError",
|
|
1444
|
+
{
|
|
1445
|
+
type: "logTransition",
|
|
1446
|
+
params: {
|
|
1447
|
+
from: "presentation:starting",
|
|
1448
|
+
to: "presentation:idle",
|
|
1449
|
+
event: "CALL.ENDED"
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
]
|
|
1453
|
+
},
|
|
1454
|
+
"CALL.FAILED": {
|
|
1455
|
+
target: "presentation:failed",
|
|
1456
|
+
actions: [
|
|
1457
|
+
"setError",
|
|
1458
|
+
{
|
|
1459
|
+
type: "logTransition",
|
|
1460
|
+
params: {
|
|
1461
|
+
from: "presentation:starting",
|
|
1462
|
+
to: "presentation:failed",
|
|
1463
|
+
event: "CALL.FAILED"
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
]
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
},
|
|
1470
|
+
"presentation:active": {
|
|
1471
|
+
entry: {
|
|
1472
|
+
type: "logStateChange",
|
|
1473
|
+
params: {
|
|
1474
|
+
state: "presentation:active"
|
|
1475
|
+
/* ACTIVE */
|
|
1476
|
+
}
|
|
1477
|
+
},
|
|
1478
|
+
on: {
|
|
1479
|
+
"SCREEN.ENDING": {
|
|
1480
|
+
target: "presentation:stopping",
|
|
1481
|
+
actions: {
|
|
1482
|
+
type: "logTransition",
|
|
1483
|
+
params: {
|
|
1484
|
+
from: "presentation:active",
|
|
1485
|
+
to: "presentation:stopping",
|
|
1486
|
+
event: "SCREEN.ENDING"
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
},
|
|
1490
|
+
"SCREEN.ENDED": {
|
|
1491
|
+
target: "presentation:idle",
|
|
1492
|
+
actions: [
|
|
1493
|
+
"clearError",
|
|
1494
|
+
{
|
|
1495
|
+
type: "logTransition",
|
|
1496
|
+
params: {
|
|
1497
|
+
from: "presentation:active",
|
|
1498
|
+
to: "presentation:idle",
|
|
1499
|
+
event: "SCREEN.ENDED"
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
]
|
|
1503
|
+
},
|
|
1504
|
+
"SCREEN.FAILED": {
|
|
1505
|
+
target: "presentation:failed",
|
|
1506
|
+
actions: [
|
|
1507
|
+
"setError",
|
|
1508
|
+
{
|
|
1509
|
+
type: "logTransition",
|
|
1510
|
+
params: {
|
|
1511
|
+
from: "presentation:active",
|
|
1512
|
+
to: "presentation:failed",
|
|
1513
|
+
event: "SCREEN.FAILED"
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
]
|
|
1517
|
+
},
|
|
1518
|
+
"CALL.ENDED": {
|
|
1519
|
+
target: "presentation:idle",
|
|
1520
|
+
actions: [
|
|
1521
|
+
"clearError",
|
|
1522
|
+
{
|
|
1523
|
+
type: "logTransition",
|
|
1524
|
+
params: {
|
|
1525
|
+
from: "presentation:active",
|
|
1526
|
+
to: "presentation:idle",
|
|
1527
|
+
event: "CALL.ENDED"
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
]
|
|
1531
|
+
},
|
|
1532
|
+
"CALL.FAILED": {
|
|
1533
|
+
target: "presentation:failed",
|
|
1534
|
+
actions: [
|
|
1535
|
+
"setError",
|
|
1536
|
+
{
|
|
1537
|
+
type: "logTransition",
|
|
1538
|
+
params: {
|
|
1539
|
+
from: "presentation:active",
|
|
1540
|
+
to: "presentation:failed",
|
|
1541
|
+
event: "CALL.FAILED"
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
]
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
},
|
|
1548
|
+
"presentation:stopping": {
|
|
1549
|
+
entry: {
|
|
1550
|
+
type: "logStateChange",
|
|
1551
|
+
params: {
|
|
1552
|
+
state: "presentation:stopping"
|
|
1553
|
+
/* STOPPING */
|
|
1554
|
+
}
|
|
1555
|
+
},
|
|
1556
|
+
on: {
|
|
1557
|
+
"SCREEN.ENDED": {
|
|
1558
|
+
target: "presentation:idle",
|
|
1559
|
+
actions: [
|
|
1560
|
+
"clearError",
|
|
1561
|
+
{
|
|
1562
|
+
type: "logTransition",
|
|
1563
|
+
params: {
|
|
1564
|
+
from: "presentation:stopping",
|
|
1565
|
+
to: "presentation:idle",
|
|
1566
|
+
event: "SCREEN.ENDED"
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
]
|
|
1570
|
+
},
|
|
1571
|
+
"SCREEN.FAILED": {
|
|
1572
|
+
target: "presentation:failed",
|
|
1573
|
+
actions: [
|
|
1574
|
+
"setError",
|
|
1575
|
+
{
|
|
1576
|
+
type: "logTransition",
|
|
1577
|
+
params: {
|
|
1578
|
+
from: "presentation:stopping",
|
|
1579
|
+
to: "presentation:failed",
|
|
1580
|
+
event: "SCREEN.FAILED"
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
]
|
|
1584
|
+
},
|
|
1585
|
+
"CALL.ENDED": {
|
|
1586
|
+
target: "presentation:idle",
|
|
1587
|
+
actions: [
|
|
1588
|
+
"clearError",
|
|
1589
|
+
{
|
|
1590
|
+
type: "logTransition",
|
|
1591
|
+
params: {
|
|
1592
|
+
from: "presentation:stopping",
|
|
1593
|
+
to: "presentation:idle",
|
|
1594
|
+
event: "CALL.ENDED"
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
]
|
|
1598
|
+
},
|
|
1599
|
+
"CALL.FAILED": {
|
|
1600
|
+
target: "presentation:failed",
|
|
1601
|
+
actions: [
|
|
1602
|
+
"setError",
|
|
1603
|
+
{
|
|
1604
|
+
type: "logTransition",
|
|
1605
|
+
params: {
|
|
1606
|
+
from: "presentation:stopping",
|
|
1607
|
+
to: "presentation:failed",
|
|
1608
|
+
event: "CALL.FAILED"
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
]
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
},
|
|
1615
|
+
"presentation:failed": {
|
|
1616
|
+
entry: {
|
|
1617
|
+
type: "logStateChange",
|
|
1618
|
+
params: {
|
|
1619
|
+
state: "presentation:failed"
|
|
1620
|
+
/* FAILED */
|
|
1621
|
+
}
|
|
1622
|
+
},
|
|
1623
|
+
on: {
|
|
1624
|
+
"SCREEN.STARTING": {
|
|
1625
|
+
target: "presentation:starting",
|
|
1626
|
+
actions: [
|
|
1627
|
+
"clearError",
|
|
1628
|
+
{
|
|
1629
|
+
type: "logTransition",
|
|
1630
|
+
params: {
|
|
1631
|
+
from: "presentation:failed",
|
|
1632
|
+
to: "presentation:starting",
|
|
1633
|
+
event: "SCREEN.STARTING"
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
]
|
|
1637
|
+
},
|
|
1638
|
+
"SCREEN.ENDED": {
|
|
1639
|
+
target: "presentation:idle",
|
|
1640
|
+
actions: [
|
|
1641
|
+
"clearError",
|
|
1642
|
+
{
|
|
1643
|
+
type: "logTransition",
|
|
1644
|
+
params: {
|
|
1645
|
+
from: "presentation:failed",
|
|
1646
|
+
to: "presentation:idle",
|
|
1647
|
+
event: "SCREEN.ENDED"
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
]
|
|
1651
|
+
},
|
|
1652
|
+
"PRESENTATION.RESET": {
|
|
1653
|
+
target: "presentation:idle",
|
|
1654
|
+
actions: [
|
|
1655
|
+
"clearError",
|
|
1656
|
+
{
|
|
1657
|
+
type: "logTransition",
|
|
1658
|
+
params: {
|
|
1659
|
+
from: "presentation:failed",
|
|
1660
|
+
to: "presentation:idle",
|
|
1661
|
+
event: "PRESENTATION.RESET"
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
]
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
});
|
|
1670
|
+
class _t extends q {
|
|
1671
|
+
constructor(e) {
|
|
1672
|
+
super(vt), this.subscribeCallEvents(e);
|
|
1673
|
+
}
|
|
1674
|
+
get isIdle() {
|
|
1675
|
+
return this.state === "presentation:idle";
|
|
1676
|
+
}
|
|
1677
|
+
get isStarting() {
|
|
1678
|
+
return this.state === "presentation:starting";
|
|
1679
|
+
}
|
|
1680
|
+
get isActive() {
|
|
1681
|
+
return this.state === "presentation:active";
|
|
1682
|
+
}
|
|
1683
|
+
get isStopping() {
|
|
1684
|
+
return this.state === "presentation:stopping";
|
|
1685
|
+
}
|
|
1686
|
+
get isFailed() {
|
|
1687
|
+
return this.state === "presentation:failed";
|
|
1688
|
+
}
|
|
1689
|
+
get isPending() {
|
|
1690
|
+
return this.isStarting || this.isStopping;
|
|
1691
|
+
}
|
|
1692
|
+
get isActiveOrPending() {
|
|
1693
|
+
return this.isActive || this.isPending;
|
|
1694
|
+
}
|
|
1695
|
+
get lastError() {
|
|
1696
|
+
return this.getSnapshot().context.lastError;
|
|
1697
|
+
}
|
|
1698
|
+
reset() {
|
|
1699
|
+
this.send({ type: "PRESENTATION.RESET" });
|
|
1700
|
+
}
|
|
1701
|
+
send(e) {
|
|
1702
|
+
if (!this.getSnapshot().can(e)) {
|
|
1703
|
+
console.warn(
|
|
1704
|
+
`[PresentationStateMachine] Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1705
|
+
);
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
super.send(e);
|
|
1709
|
+
}
|
|
1710
|
+
subscribeCallEvents(e) {
|
|
1711
|
+
this.addSubscription(
|
|
1712
|
+
e.on(C.START_PRESENTATION, () => {
|
|
1713
|
+
this.send({ type: "SCREEN.STARTING" });
|
|
1714
|
+
})
|
|
1715
|
+
), this.addSubscription(
|
|
1716
|
+
e.on(C.STARTED_PRESENTATION, () => {
|
|
1717
|
+
this.send({ type: "SCREEN.STARTED" });
|
|
1718
|
+
})
|
|
1719
|
+
), this.addSubscription(
|
|
1720
|
+
e.on(C.END_PRESENTATION, () => {
|
|
1721
|
+
this.send({ type: "SCREEN.ENDING" });
|
|
1722
|
+
})
|
|
1723
|
+
), this.addSubscription(
|
|
1724
|
+
e.on(C.ENDED_PRESENTATION, () => {
|
|
1725
|
+
this.send({ type: "SCREEN.ENDED" });
|
|
1726
|
+
})
|
|
1727
|
+
), this.addSubscription(
|
|
1728
|
+
e.on(C.FAILED_PRESENTATION, (t) => {
|
|
1729
|
+
this.send({ type: "SCREEN.FAILED", error: t });
|
|
1730
|
+
})
|
|
1731
|
+
), this.addSubscription(
|
|
1732
|
+
e.on(C.ENDED, () => {
|
|
1733
|
+
this.send({ type: "CALL.ENDED" });
|
|
1734
|
+
})
|
|
1735
|
+
), this.addSubscription(
|
|
1736
|
+
e.on(C.FAILED, (t) => {
|
|
1737
|
+
this.send({ type: "CALL.FAILED", error: t });
|
|
1738
|
+
})
|
|
1739
|
+
);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
const Ot = 1, Bs = (n) => $e(n);
|
|
1743
|
+
class Pt {
|
|
1132
1744
|
events;
|
|
1745
|
+
presentationStateMachine;
|
|
1133
1746
|
promisePendingStartPresentation;
|
|
1134
1747
|
promisePendingStopPresentation;
|
|
1135
1748
|
streamPresentationCurrent;
|
|
@@ -1140,11 +1753,17 @@ class Rt {
|
|
|
1140
1753
|
callManager: e,
|
|
1141
1754
|
maxBitrate: t
|
|
1142
1755
|
}) {
|
|
1143
|
-
this.callManager = e, this.maxBitrate = t, this.events =
|
|
1756
|
+
this.callManager = e, this.maxBitrate = t, this.events = ft(), this.presentationStateMachine = new _t(this.callManager.events), this.subscribe();
|
|
1757
|
+
}
|
|
1758
|
+
get presentationActor() {
|
|
1759
|
+
return this.presentationStateMachine.actorRef;
|
|
1144
1760
|
}
|
|
1145
1761
|
get isPendingPresentation() {
|
|
1146
1762
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
1147
1763
|
}
|
|
1764
|
+
get isPresentationInProcess() {
|
|
1765
|
+
return !!this.streamPresentationCurrent || this.isPendingPresentation;
|
|
1766
|
+
}
|
|
1148
1767
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
1149
1768
|
async startPresentation(e, t, {
|
|
1150
1769
|
isNeedReinvite: s,
|
|
@@ -1176,8 +1795,8 @@ class Rt {
|
|
|
1176
1795
|
const i = this.callManager.getEstablishedRTCSession();
|
|
1177
1796
|
return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
|
|
1178
1797
|
const a = r instanceof Error ? r : new Error(String(r));
|
|
1179
|
-
throw this.events.trigger(
|
|
1180
|
-
}) : t && this.events.trigger(
|
|
1798
|
+
throw this.events.trigger(P.FAILED_PRESENTATION, a), r;
|
|
1799
|
+
}) : t && this.events.trigger(P.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
1181
1800
|
this.resetPresentation();
|
|
1182
1801
|
});
|
|
1183
1802
|
}
|
|
@@ -1216,15 +1835,15 @@ class Rt {
|
|
|
1216
1835
|
}
|
|
1217
1836
|
subscribe() {
|
|
1218
1837
|
this.callManager.on("presentation:start", (e) => {
|
|
1219
|
-
this.events.trigger(
|
|
1838
|
+
this.events.trigger(P.START_PRESENTATION, e);
|
|
1220
1839
|
}), this.callManager.on("presentation:started", (e) => {
|
|
1221
|
-
this.events.trigger(
|
|
1840
|
+
this.events.trigger(P.STARTED_PRESENTATION, e);
|
|
1222
1841
|
}), this.callManager.on("presentation:end", (e) => {
|
|
1223
|
-
this.events.trigger(
|
|
1842
|
+
this.events.trigger(P.END_PRESENTATION, e);
|
|
1224
1843
|
}), this.callManager.on("presentation:ended", (e) => {
|
|
1225
|
-
this.events.trigger(
|
|
1844
|
+
this.events.trigger(P.ENDED_PRESENTATION, e);
|
|
1226
1845
|
}), this.callManager.on("presentation:failed", (e) => {
|
|
1227
|
-
this.events.trigger(
|
|
1846
|
+
this.events.trigger(P.FAILED_PRESENTATION, e);
|
|
1228
1847
|
}), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
|
|
1229
1848
|
}
|
|
1230
1849
|
async sendPresentationWithDuplicatedCalls(e, {
|
|
@@ -1232,7 +1851,7 @@ class Rt {
|
|
|
1232
1851
|
stream: s,
|
|
1233
1852
|
presentationOptions: i,
|
|
1234
1853
|
options: r = {
|
|
1235
|
-
callLimit:
|
|
1854
|
+
callLimit: Ot
|
|
1236
1855
|
}
|
|
1237
1856
|
}) {
|
|
1238
1857
|
const a = async () => this.sendPresentation(
|
|
@@ -1241,7 +1860,7 @@ class Rt {
|
|
|
1241
1860
|
s,
|
|
1242
1861
|
i
|
|
1243
1862
|
), o = () => !!this.streamPresentationCurrent;
|
|
1244
|
-
return this.cancelableSendPresentationWithRepeatedCalls =
|
|
1863
|
+
return this.cancelableSendPresentationWithRepeatedCalls = de({
|
|
1245
1864
|
targetFunction: a,
|
|
1246
1865
|
isComplete: o,
|
|
1247
1866
|
isRejectAsValid: !0,
|
|
@@ -1256,20 +1875,20 @@ class Rt {
|
|
|
1256
1875
|
sendEncodings: o,
|
|
1257
1876
|
onAddedTransceiver: c
|
|
1258
1877
|
}) {
|
|
1259
|
-
const
|
|
1260
|
-
if (
|
|
1878
|
+
const l = k(s, { contentHint: r });
|
|
1879
|
+
if (l === void 0)
|
|
1261
1880
|
throw new Error("No streamPresentationTarget");
|
|
1262
|
-
this.streamPresentationCurrent =
|
|
1263
|
-
const
|
|
1881
|
+
this.streamPresentationCurrent = l;
|
|
1882
|
+
const T = e().then(async () => t.startPresentation(l, i, {
|
|
1264
1883
|
degradationPreference: a,
|
|
1265
1884
|
sendEncodings: o,
|
|
1266
1885
|
onAddedTransceiver: c
|
|
1267
|
-
})).then(this.setMaxBitrate).then(() => s).catch((
|
|
1886
|
+
})).then(this.setMaxBitrate).then(() => s).catch((h) => {
|
|
1268
1887
|
this.removeStreamPresentationCurrent();
|
|
1269
|
-
const
|
|
1270
|
-
throw this.events.trigger(
|
|
1888
|
+
const u = h instanceof Error ? h : new Error(String(h));
|
|
1889
|
+
throw this.events.trigger(P.FAILED_PRESENTATION, u), h;
|
|
1271
1890
|
});
|
|
1272
|
-
return this.promisePendingStartPresentation =
|
|
1891
|
+
return this.promisePendingStartPresentation = T, T.finally(() => {
|
|
1273
1892
|
this.promisePendingStartPresentation = void 0;
|
|
1274
1893
|
});
|
|
1275
1894
|
}
|
|
@@ -1278,7 +1897,7 @@ class Rt {
|
|
|
1278
1897
|
if (!e || !t || s === void 0)
|
|
1279
1898
|
return;
|
|
1280
1899
|
const i = e.getSenders();
|
|
1281
|
-
await
|
|
1900
|
+
await It(i, t, s);
|
|
1282
1901
|
};
|
|
1283
1902
|
getRtcSessionProtected = () => {
|
|
1284
1903
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1299,7 +1918,7 @@ class Rt {
|
|
|
1299
1918
|
delete this.streamPresentationCurrent;
|
|
1300
1919
|
}
|
|
1301
1920
|
}
|
|
1302
|
-
class
|
|
1921
|
+
class bt {
|
|
1303
1922
|
data;
|
|
1304
1923
|
getUa;
|
|
1305
1924
|
constructor(e) {
|
|
@@ -1385,8 +2004,8 @@ class At {
|
|
|
1385
2004
|
return this.data?.register === !0;
|
|
1386
2005
|
}
|
|
1387
2006
|
}
|
|
1388
|
-
var
|
|
1389
|
-
const
|
|
2007
|
+
var S = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(S || {});
|
|
2008
|
+
const Ne = [
|
|
1390
2009
|
"connecting",
|
|
1391
2010
|
"connected",
|
|
1392
2011
|
"disconnected",
|
|
@@ -1396,7 +2015,7 @@ const Se = [
|
|
|
1396
2015
|
"registrationFailed",
|
|
1397
2016
|
"newMessage",
|
|
1398
2017
|
"sipEvent"
|
|
1399
|
-
],
|
|
2018
|
+
], Dt = [
|
|
1400
2019
|
"disconnecting",
|
|
1401
2020
|
"connect-started",
|
|
1402
2021
|
"connect-succeeded",
|
|
@@ -1404,12 +2023,12 @@ const Se = [
|
|
|
1404
2023
|
"connect-parameters-resolve-success",
|
|
1405
2024
|
"connect-parameters-resolve-failed",
|
|
1406
2025
|
"connected-with-configuration"
|
|
1407
|
-
],
|
|
1408
|
-
function
|
|
2026
|
+
], Re = [...Ne, ...Dt], yt = () => new M(Re);
|
|
2027
|
+
function Lt(n) {
|
|
1409
2028
|
return (e) => `sip:${e}@${n}`;
|
|
1410
2029
|
}
|
|
1411
|
-
const
|
|
1412
|
-
class
|
|
2030
|
+
const wt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Ae = (n) => n.trim().replaceAll(" ", "_"), Ut = wt(1e5, 99999999), Ft = 3;
|
|
2031
|
+
class Bt {
|
|
1413
2032
|
cancelableConnectWithRepeatedCalls;
|
|
1414
2033
|
JsSIP;
|
|
1415
2034
|
events;
|
|
@@ -1435,30 +2054,30 @@ class Mt {
|
|
|
1435
2054
|
}
|
|
1436
2055
|
let r = !1;
|
|
1437
2056
|
const a = this.getConnectionConfiguration();
|
|
1438
|
-
e !== void 0 && e !== a?.displayName && (r = i.set("display_name",
|
|
2057
|
+
e !== void 0 && e !== a?.displayName && (r = i.set("display_name", Ae(e)), this.updateConnectionConfiguration("displayName", e));
|
|
1439
2058
|
const o = r;
|
|
1440
2059
|
o ? t(o) : s(new Error("nothing changed"));
|
|
1441
2060
|
});
|
|
1442
2061
|
disconnect = async () => {
|
|
1443
|
-
this.events.trigger(
|
|
2062
|
+
this.events.trigger(S.DISCONNECTING, {});
|
|
1444
2063
|
const e = new Promise((s) => {
|
|
1445
|
-
this.events.once(
|
|
2064
|
+
this.events.once(S.DISCONNECTED, () => {
|
|
1446
2065
|
s();
|
|
1447
2066
|
});
|
|
1448
2067
|
}), t = this.getUa();
|
|
1449
|
-
return t ? t.stop() : this.events.trigger(
|
|
2068
|
+
return t ? t.stop() : this.events.trigger(S.DISCONNECTED, { socket: {}, error: !1 }), e.finally(() => {
|
|
1450
2069
|
t?.removeAllListeners(), this.setUa(void 0), this.stateMachine.reset();
|
|
1451
2070
|
});
|
|
1452
2071
|
};
|
|
1453
2072
|
cancelRequests() {
|
|
1454
2073
|
this.cancelConnectWithRepeatedCalls();
|
|
1455
2074
|
}
|
|
1456
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
2075
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = Ft } = {}) => {
|
|
1457
2076
|
const s = async () => this.connectInner(e), i = (r) => {
|
|
1458
|
-
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e),
|
|
1459
|
-
return c ||
|
|
2077
|
+
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), l = r != null && !Qe(r);
|
|
2078
|
+
return c || l;
|
|
1460
2079
|
};
|
|
1461
|
-
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls =
|
|
2080
|
+
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = de({
|
|
1462
2081
|
targetFunction: s,
|
|
1463
2082
|
isComplete: i,
|
|
1464
2083
|
callLimit: t,
|
|
@@ -1492,39 +2111,39 @@ class Mt {
|
|
|
1492
2111
|
sessionTimers: a,
|
|
1493
2112
|
registerExpires: o,
|
|
1494
2113
|
connectionRecoveryMinInterval: c,
|
|
1495
|
-
connectionRecoveryMaxInterval:
|
|
1496
|
-
userAgent:
|
|
1497
|
-
displayName:
|
|
1498
|
-
register:
|
|
2114
|
+
connectionRecoveryMaxInterval: l,
|
|
2115
|
+
userAgent: T,
|
|
2116
|
+
displayName: h = "",
|
|
2117
|
+
register: u = !1,
|
|
1499
2118
|
extraHeaders: p = []
|
|
1500
2119
|
}) => {
|
|
1501
2120
|
this.stateMachine.startInitUa(), this.setConnectionConfiguration({
|
|
1502
2121
|
sipServerIp: s,
|
|
1503
2122
|
sipServerUrl: i,
|
|
1504
|
-
displayName:
|
|
1505
|
-
register:
|
|
2123
|
+
displayName: h,
|
|
2124
|
+
register: u,
|
|
1506
2125
|
user: e,
|
|
1507
2126
|
password: t
|
|
1508
2127
|
}), this.getUa() && await this.disconnect();
|
|
1509
|
-
const { ua:
|
|
2128
|
+
const { ua: N, helpers: D } = this.uaFactory.createUAWithConfiguration(
|
|
1510
2129
|
{
|
|
1511
2130
|
user: e,
|
|
1512
2131
|
password: t,
|
|
1513
2132
|
sipServerIp: s,
|
|
1514
2133
|
sipServerUrl: i,
|
|
1515
|
-
displayName:
|
|
1516
|
-
register:
|
|
2134
|
+
displayName: h,
|
|
2135
|
+
register: u,
|
|
1517
2136
|
sessionTimers: a,
|
|
1518
2137
|
registerExpires: o,
|
|
1519
2138
|
connectionRecoveryMinInterval: c,
|
|
1520
|
-
connectionRecoveryMaxInterval:
|
|
1521
|
-
userAgent:
|
|
2139
|
+
connectionRecoveryMaxInterval: l,
|
|
2140
|
+
userAgent: T,
|
|
1522
2141
|
remoteAddress: r,
|
|
1523
2142
|
extraHeaders: p
|
|
1524
2143
|
},
|
|
1525
2144
|
this.events
|
|
1526
2145
|
);
|
|
1527
|
-
return this.setUa(
|
|
2146
|
+
return this.setUa(N), this.setGetUri(D.getUri), this.setSocket(D.socket), N;
|
|
1528
2147
|
};
|
|
1529
2148
|
start = async () => new Promise((e, t) => {
|
|
1530
2149
|
const s = this.getUa();
|
|
@@ -1533,15 +2152,15 @@ class Mt {
|
|
|
1533
2152
|
return;
|
|
1534
2153
|
}
|
|
1535
2154
|
let i;
|
|
1536
|
-
i = ((c,
|
|
2155
|
+
i = ((c, l) => {
|
|
1537
2156
|
if (this.getConnectionConfiguration()?.register === !0)
|
|
1538
|
-
return this.registrationManager.subscribeToStartEvents(c,
|
|
1539
|
-
const
|
|
1540
|
-
return this.events.on(
|
|
1541
|
-
this.events.on(p,
|
|
2157
|
+
return this.registrationManager.subscribeToStartEvents(c, l);
|
|
2158
|
+
const h = S.CONNECTED, u = [S.DISCONNECTED];
|
|
2159
|
+
return this.events.on(h, c), u.forEach((p) => {
|
|
2160
|
+
this.events.on(p, l);
|
|
1542
2161
|
}), () => {
|
|
1543
|
-
this.events.off(
|
|
1544
|
-
this.events.off(p,
|
|
2162
|
+
this.events.off(h, c), u.forEach((p) => {
|
|
2163
|
+
this.events.off(p, l);
|
|
1545
2164
|
});
|
|
1546
2165
|
};
|
|
1547
2166
|
})(() => {
|
|
@@ -1554,28 +2173,40 @@ class Mt {
|
|
|
1554
2173
|
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
1555
2174
|
}
|
|
1556
2175
|
proxyEvents() {
|
|
1557
|
-
this.events.on(
|
|
2176
|
+
this.events.on(S.CONNECTED, () => {
|
|
1558
2177
|
const e = this.getConnectionConfiguration(), t = this.getUa();
|
|
1559
|
-
e !== void 0 && t !== void 0 && this.events.trigger(
|
|
2178
|
+
e !== void 0 && t !== void 0 && this.events.trigger(S.CONNECTED_WITH_CONFIGURATION, {
|
|
1560
2179
|
...e,
|
|
1561
2180
|
ua: t
|
|
1562
2181
|
});
|
|
1563
2182
|
});
|
|
1564
2183
|
}
|
|
1565
2184
|
}
|
|
1566
|
-
var
|
|
1567
|
-
const
|
|
2185
|
+
var Ie = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(Ie || {});
|
|
2186
|
+
const kt = Object.values(Ie);
|
|
2187
|
+
var Gt = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.CONNECTING = "connection:connecting", n.INITIALIZING = "connection:initializing", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))(Gt || {});
|
|
2188
|
+
const $t = $({
|
|
1568
2189
|
types: {
|
|
1569
2190
|
context: {},
|
|
1570
2191
|
events: {}
|
|
1571
2192
|
},
|
|
1572
2193
|
actions: {
|
|
1573
2194
|
logTransition: (n, e) => {
|
|
1574
|
-
|
|
2195
|
+
d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1575
2196
|
},
|
|
1576
2197
|
logStateChange: (n, e) => {
|
|
1577
|
-
|
|
1578
|
-
}
|
|
2198
|
+
d("ConnectionStateMachine state changed", e.state);
|
|
2199
|
+
},
|
|
2200
|
+
setError: b({
|
|
2201
|
+
error: ({ event: n }) => {
|
|
2202
|
+
if (n.type === "CONNECTION_FAILED" && "error" in n)
|
|
2203
|
+
return n.error;
|
|
2204
|
+
}
|
|
2205
|
+
}),
|
|
2206
|
+
clearError: b({
|
|
2207
|
+
error: () => {
|
|
2208
|
+
}
|
|
2209
|
+
})
|
|
1579
2210
|
}
|
|
1580
2211
|
}).createMachine({
|
|
1581
2212
|
id: "connection",
|
|
@@ -1623,7 +2254,6 @@ const Pt = Object.values(pe), Ot = Fe({
|
|
|
1623
2254
|
to: "connection:initializing",
|
|
1624
2255
|
event: "START_INIT_UA"
|
|
1625
2256
|
/* START_INIT_UA */
|
|
1626
|
-
// TODO: remove
|
|
1627
2257
|
}
|
|
1628
2258
|
}
|
|
1629
2259
|
},
|
|
@@ -1641,15 +2271,21 @@ const Pt = Object.values(pe), Ot = Fe({
|
|
|
1641
2271
|
},
|
|
1642
2272
|
CONNECTION_FAILED: {
|
|
1643
2273
|
target: "connection:failed",
|
|
1644
|
-
actions:
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
2274
|
+
actions: [
|
|
2275
|
+
{
|
|
2276
|
+
type: "logTransition",
|
|
2277
|
+
params: {
|
|
2278
|
+
from: "connection:connecting",
|
|
2279
|
+
to: "connection:failed",
|
|
2280
|
+
event: "CONNECTION_FAILED"
|
|
2281
|
+
/* CONNECTION_FAILED */
|
|
2282
|
+
}
|
|
2283
|
+
},
|
|
2284
|
+
{
|
|
2285
|
+
type: "setError"
|
|
2286
|
+
/* SET_ERROR */
|
|
1651
2287
|
}
|
|
1652
|
-
|
|
2288
|
+
]
|
|
1653
2289
|
}
|
|
1654
2290
|
}
|
|
1655
2291
|
},
|
|
@@ -1700,15 +2336,21 @@ const Pt = Object.values(pe), Ot = Fe({
|
|
|
1700
2336
|
},
|
|
1701
2337
|
CONNECTION_FAILED: {
|
|
1702
2338
|
target: "connection:failed",
|
|
1703
|
-
actions:
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
2339
|
+
actions: [
|
|
2340
|
+
{
|
|
2341
|
+
type: "logTransition",
|
|
2342
|
+
params: {
|
|
2343
|
+
from: "connection:initializing",
|
|
2344
|
+
to: "connection:failed",
|
|
2345
|
+
event: "CONNECTION_FAILED"
|
|
2346
|
+
/* CONNECTION_FAILED */
|
|
2347
|
+
}
|
|
2348
|
+
},
|
|
2349
|
+
{
|
|
2350
|
+
type: "setError"
|
|
2351
|
+
/* SET_ERROR */
|
|
1710
2352
|
}
|
|
1711
|
-
|
|
2353
|
+
]
|
|
1712
2354
|
}
|
|
1713
2355
|
}
|
|
1714
2356
|
},
|
|
@@ -1747,15 +2389,21 @@ const Pt = Object.values(pe), Ot = Fe({
|
|
|
1747
2389
|
},
|
|
1748
2390
|
CONNECTION_FAILED: {
|
|
1749
2391
|
target: "connection:failed",
|
|
1750
|
-
actions:
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
2392
|
+
actions: [
|
|
2393
|
+
{
|
|
2394
|
+
type: "logTransition",
|
|
2395
|
+
params: {
|
|
2396
|
+
from: "connection:connected",
|
|
2397
|
+
to: "connection:failed",
|
|
2398
|
+
event: "CONNECTION_FAILED"
|
|
2399
|
+
/* CONNECTION_FAILED */
|
|
2400
|
+
}
|
|
2401
|
+
},
|
|
2402
|
+
{
|
|
2403
|
+
type: "setError"
|
|
2404
|
+
/* SET_ERROR */
|
|
1757
2405
|
}
|
|
1758
|
-
|
|
2406
|
+
]
|
|
1759
2407
|
}
|
|
1760
2408
|
}
|
|
1761
2409
|
},
|
|
@@ -1794,15 +2442,21 @@ const Pt = Object.values(pe), Ot = Fe({
|
|
|
1794
2442
|
},
|
|
1795
2443
|
CONNECTION_FAILED: {
|
|
1796
2444
|
target: "connection:failed",
|
|
1797
|
-
actions:
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
2445
|
+
actions: [
|
|
2446
|
+
{
|
|
2447
|
+
type: "logTransition",
|
|
2448
|
+
params: {
|
|
2449
|
+
from: "connection:registered",
|
|
2450
|
+
to: "connection:failed",
|
|
2451
|
+
event: "CONNECTION_FAILED"
|
|
2452
|
+
/* CONNECTION_FAILED */
|
|
2453
|
+
}
|
|
2454
|
+
},
|
|
2455
|
+
{
|
|
2456
|
+
type: "setError"
|
|
2457
|
+
/* SET_ERROR */
|
|
1804
2458
|
}
|
|
1805
|
-
|
|
2459
|
+
]
|
|
1806
2460
|
}
|
|
1807
2461
|
}
|
|
1808
2462
|
},
|
|
@@ -1852,48 +2506,57 @@ const Pt = Object.values(pe), Ot = Fe({
|
|
|
1852
2506
|
on: {
|
|
1853
2507
|
RESET: {
|
|
1854
2508
|
target: "connection:idle",
|
|
1855
|
-
actions:
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
2509
|
+
actions: [
|
|
2510
|
+
{
|
|
2511
|
+
type: "logTransition",
|
|
2512
|
+
params: {
|
|
2513
|
+
from: "connection:failed",
|
|
2514
|
+
to: "connection:idle",
|
|
2515
|
+
event: "RESET"
|
|
2516
|
+
/* RESET */
|
|
2517
|
+
}
|
|
2518
|
+
},
|
|
2519
|
+
{
|
|
2520
|
+
type: "clearError"
|
|
2521
|
+
/* CLEAR_ERROR */
|
|
1862
2522
|
}
|
|
1863
|
-
|
|
2523
|
+
]
|
|
1864
2524
|
},
|
|
1865
2525
|
START_CONNECT: {
|
|
1866
2526
|
target: "connection:connecting",
|
|
1867
|
-
actions:
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
2527
|
+
actions: [
|
|
2528
|
+
{
|
|
2529
|
+
type: "logTransition",
|
|
2530
|
+
params: {
|
|
2531
|
+
from: "connection:failed",
|
|
2532
|
+
to: "connection:connecting",
|
|
2533
|
+
event: "START_CONNECT"
|
|
2534
|
+
/* START_CONNECT */
|
|
2535
|
+
}
|
|
2536
|
+
},
|
|
2537
|
+
{
|
|
2538
|
+
type: "clearError"
|
|
2539
|
+
/* CLEAR_ERROR */
|
|
1874
2540
|
}
|
|
1875
|
-
|
|
2541
|
+
]
|
|
1876
2542
|
}
|
|
1877
2543
|
}
|
|
1878
2544
|
}
|
|
1879
2545
|
}
|
|
1880
2546
|
});
|
|
1881
|
-
class
|
|
1882
|
-
actor;
|
|
2547
|
+
class qt extends q {
|
|
1883
2548
|
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
1884
2549
|
events;
|
|
1885
2550
|
unsubscribeFromEvents;
|
|
1886
|
-
actorSubscription;
|
|
1887
2551
|
constructor(e) {
|
|
1888
|
-
this.events = e, this.
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
i
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
return this.actor.getSnapshot().value;
|
|
2552
|
+
super($t), this.events = e, this.addSubscription(
|
|
2553
|
+
this.subscribe((t) => {
|
|
2554
|
+
const s = t.value;
|
|
2555
|
+
this.stateChangeListeners.forEach((i) => {
|
|
2556
|
+
i(s);
|
|
2557
|
+
});
|
|
2558
|
+
})
|
|
2559
|
+
), this.subscribeToEvents();
|
|
1897
2560
|
}
|
|
1898
2561
|
get isIdle() {
|
|
1899
2562
|
return this.hasState(
|
|
@@ -1937,6 +2600,9 @@ class bt {
|
|
|
1937
2600
|
/* FAILED */
|
|
1938
2601
|
);
|
|
1939
2602
|
}
|
|
2603
|
+
get error() {
|
|
2604
|
+
return this.getSnapshot().context.error;
|
|
2605
|
+
}
|
|
1940
2606
|
get isPending() {
|
|
1941
2607
|
return this.isConnecting || this.isInitializing;
|
|
1942
2608
|
}
|
|
@@ -1960,7 +2626,7 @@ class bt {
|
|
|
1960
2626
|
this.toIdle();
|
|
1961
2627
|
}
|
|
1962
2628
|
destroy() {
|
|
1963
|
-
this.
|
|
2629
|
+
this.stateChangeListeners.clear(), this.unsubscribeFromEvents?.(), this.stop();
|
|
1964
2630
|
}
|
|
1965
2631
|
onStateChange(e) {
|
|
1966
2632
|
return this.stateChangeListeners.add(e), () => {
|
|
@@ -1968,79 +2634,82 @@ class bt {
|
|
|
1968
2634
|
};
|
|
1969
2635
|
}
|
|
1970
2636
|
canTransition(e) {
|
|
1971
|
-
return this.
|
|
2637
|
+
return this.getSnapshot().can({ type: e });
|
|
1972
2638
|
}
|
|
1973
2639
|
getValidEvents() {
|
|
1974
|
-
return
|
|
2640
|
+
return kt.filter((e) => this.canTransition(e));
|
|
1975
2641
|
}
|
|
1976
2642
|
hasState(e) {
|
|
1977
|
-
return this.
|
|
2643
|
+
return this.getSnapshot().matches(e);
|
|
1978
2644
|
}
|
|
1979
2645
|
sendEvent(e) {
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
2646
|
+
if (!this.getSnapshot().can(e)) {
|
|
2647
|
+
d(
|
|
2648
|
+
`Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1984
2649
|
);
|
|
1985
2650
|
return;
|
|
1986
2651
|
}
|
|
1987
|
-
this.
|
|
2652
|
+
this.send(e);
|
|
1988
2653
|
}
|
|
1989
2654
|
toStartConnect = () => {
|
|
1990
|
-
this.sendEvent(
|
|
1991
|
-
"START_CONNECT"
|
|
2655
|
+
this.sendEvent({
|
|
2656
|
+
type: "START_CONNECT"
|
|
1992
2657
|
/* START_CONNECT */
|
|
1993
|
-
);
|
|
2658
|
+
});
|
|
1994
2659
|
};
|
|
1995
2660
|
toStartInitUa = () => {
|
|
1996
|
-
this.sendEvent(
|
|
1997
|
-
"START_INIT_UA"
|
|
2661
|
+
this.sendEvent({
|
|
2662
|
+
type: "START_INIT_UA"
|
|
1998
2663
|
/* START_INIT_UA */
|
|
1999
|
-
);
|
|
2664
|
+
});
|
|
2000
2665
|
};
|
|
2001
2666
|
toConnected = () => {
|
|
2002
|
-
this.sendEvent(
|
|
2003
|
-
"UA_CONNECTED"
|
|
2667
|
+
this.sendEvent({
|
|
2668
|
+
type: "UA_CONNECTED"
|
|
2004
2669
|
/* UA_CONNECTED */
|
|
2005
|
-
);
|
|
2670
|
+
});
|
|
2006
2671
|
};
|
|
2007
2672
|
toRegistered = () => {
|
|
2008
|
-
this.sendEvent(
|
|
2009
|
-
"UA_REGISTERED"
|
|
2673
|
+
this.sendEvent({
|
|
2674
|
+
type: "UA_REGISTERED"
|
|
2010
2675
|
/* UA_REGISTERED */
|
|
2011
|
-
);
|
|
2676
|
+
});
|
|
2012
2677
|
};
|
|
2013
2678
|
toUnregistered = () => {
|
|
2014
|
-
this.sendEvent(
|
|
2015
|
-
"UA_UNREGISTERED"
|
|
2679
|
+
this.sendEvent({
|
|
2680
|
+
type: "UA_UNREGISTERED"
|
|
2016
2681
|
/* UA_UNREGISTERED */
|
|
2017
|
-
);
|
|
2682
|
+
});
|
|
2018
2683
|
};
|
|
2019
2684
|
toDisconnected = () => {
|
|
2020
|
-
this.sendEvent(
|
|
2021
|
-
"UA_DISCONNECTED"
|
|
2685
|
+
this.sendEvent({
|
|
2686
|
+
type: "UA_DISCONNECTED"
|
|
2022
2687
|
/* UA_DISCONNECTED */
|
|
2023
|
-
);
|
|
2688
|
+
});
|
|
2024
2689
|
};
|
|
2025
|
-
toFailed = () => {
|
|
2026
|
-
this.sendEvent(
|
|
2027
|
-
"CONNECTION_FAILED"
|
|
2028
|
-
/* CONNECTION_FAILED */
|
|
2029
|
-
);
|
|
2690
|
+
toFailed = (e) => {
|
|
2691
|
+
this.sendEvent({ type: "CONNECTION_FAILED", error: e });
|
|
2030
2692
|
};
|
|
2031
2693
|
toIdle = () => {
|
|
2032
|
-
this.sendEvent(
|
|
2033
|
-
"RESET"
|
|
2694
|
+
this.sendEvent({
|
|
2695
|
+
type: "RESET"
|
|
2034
2696
|
/* RESET */
|
|
2035
|
-
);
|
|
2697
|
+
});
|
|
2036
2698
|
};
|
|
2037
2699
|
subscribeToEvents() {
|
|
2038
|
-
this.events.on("connected", this.toConnected), this.events.on("registered", this.toRegistered), this.events.on("unregistered", this.toUnregistered), this.events.on("disconnected", this.toDisconnected), this.events.on("registrationFailed", this.
|
|
2039
|
-
this.events.off("connected", this.toConnected), this.events.off("registered", this.toRegistered), this.events.off("unregistered", this.toUnregistered), this.events.off("disconnected", this.toDisconnected), this.events.off("registrationFailed", this.
|
|
2700
|
+
this.events.on("connected", this.toConnected), this.events.on("registered", this.toRegistered), this.events.on("unregistered", this.toUnregistered), this.events.on("disconnected", this.toDisconnected), this.events.on("registrationFailed", this.handleRegistrationFailed), this.events.on("connect-failed", this.handleConnectFailed), this.unsubscribeFromEvents = () => {
|
|
2701
|
+
this.events.off("connected", this.toConnected), this.events.off("registered", this.toRegistered), this.events.off("unregistered", this.toUnregistered), this.events.off("disconnected", this.toDisconnected), this.events.off("registrationFailed", this.handleRegistrationFailed), this.events.off("connect-failed", this.handleConnectFailed);
|
|
2040
2702
|
};
|
|
2041
2703
|
}
|
|
2704
|
+
handleRegistrationFailed = (e) => {
|
|
2705
|
+
const { response: t } = e, s = t.status_code || "Unknown", i = t.reason_phrase || "Registration failed", r = new Error(`Registration failed: ${s} ${i}`);
|
|
2706
|
+
this.toFailed(r);
|
|
2707
|
+
};
|
|
2708
|
+
handleConnectFailed = (e) => {
|
|
2709
|
+
this.toFailed(e instanceof Error ? e : void 0);
|
|
2710
|
+
};
|
|
2042
2711
|
}
|
|
2043
|
-
class
|
|
2712
|
+
class Vt {
|
|
2044
2713
|
events;
|
|
2045
2714
|
getUaProtected;
|
|
2046
2715
|
constructor(e) {
|
|
@@ -2049,25 +2718,25 @@ class yt {
|
|
|
2049
2718
|
async register() {
|
|
2050
2719
|
const e = this.getUaProtected();
|
|
2051
2720
|
return new Promise((t, s) => {
|
|
2052
|
-
e.on(
|
|
2721
|
+
e.on(S.REGISTERED, t), e.on(S.REGISTRATION_FAILED, s), e.register();
|
|
2053
2722
|
});
|
|
2054
2723
|
}
|
|
2055
2724
|
async unregister() {
|
|
2056
2725
|
const e = this.getUaProtected();
|
|
2057
2726
|
return new Promise((t) => {
|
|
2058
|
-
e.on(
|
|
2727
|
+
e.on(S.UNREGISTERED, t), e.unregister();
|
|
2059
2728
|
});
|
|
2060
2729
|
}
|
|
2061
2730
|
async tryRegister() {
|
|
2062
2731
|
try {
|
|
2063
2732
|
await this.unregister();
|
|
2064
2733
|
} catch (e) {
|
|
2065
|
-
|
|
2734
|
+
d("tryRegister", e);
|
|
2066
2735
|
}
|
|
2067
2736
|
return this.register();
|
|
2068
2737
|
}
|
|
2069
2738
|
subscribeToStartEvents(e, t) {
|
|
2070
|
-
const s =
|
|
2739
|
+
const s = S.REGISTERED, i = [S.REGISTRATION_FAILED, S.DISCONNECTED];
|
|
2071
2740
|
return this.events.on(s, e), i.forEach((r) => {
|
|
2072
2741
|
this.events.on(r, t);
|
|
2073
2742
|
}), () => {
|
|
@@ -2077,7 +2746,7 @@ class yt {
|
|
|
2077
2746
|
};
|
|
2078
2747
|
}
|
|
2079
2748
|
}
|
|
2080
|
-
class
|
|
2749
|
+
class Ht {
|
|
2081
2750
|
uaFactory;
|
|
2082
2751
|
getUaProtected;
|
|
2083
2752
|
constructor(e) {
|
|
@@ -2123,30 +2792,30 @@ class Dt {
|
|
|
2123
2792
|
extraHeaders: a
|
|
2124
2793
|
}) {
|
|
2125
2794
|
return new Promise((o, c) => {
|
|
2126
|
-
const { configuration:
|
|
2795
|
+
const { configuration: l } = this.uaFactory.createConfiguration({
|
|
2127
2796
|
sipServerUrl: i,
|
|
2128
2797
|
displayName: t,
|
|
2129
2798
|
userAgent: e,
|
|
2130
2799
|
sipServerIp: s
|
|
2131
|
-
}),
|
|
2800
|
+
}), T = this.uaFactory.createUA({ ...l, remoteAddress: r, extraHeaders: a }), h = () => {
|
|
2132
2801
|
const p = new Error("Telephony is not available");
|
|
2133
2802
|
c(p);
|
|
2134
2803
|
};
|
|
2135
|
-
|
|
2136
|
-
const
|
|
2137
|
-
|
|
2804
|
+
T.once(S.DISCONNECTED, h);
|
|
2805
|
+
const u = () => {
|
|
2806
|
+
T.removeAllListeners(), T.once(S.DISCONNECTED, () => {
|
|
2138
2807
|
o();
|
|
2139
|
-
}),
|
|
2808
|
+
}), T.stop();
|
|
2140
2809
|
};
|
|
2141
|
-
|
|
2810
|
+
T.once(S.CONNECTED, u), T.start();
|
|
2142
2811
|
});
|
|
2143
2812
|
}
|
|
2144
2813
|
}
|
|
2145
|
-
const
|
|
2814
|
+
const Wt = (n) => {
|
|
2146
2815
|
const e = [];
|
|
2147
2816
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
2148
2817
|
};
|
|
2149
|
-
class
|
|
2818
|
+
class L {
|
|
2150
2819
|
JsSIP;
|
|
2151
2820
|
constructor(e) {
|
|
2152
2821
|
this.JsSIP = e;
|
|
@@ -2171,10 +2840,10 @@ class D {
|
|
|
2171
2840
|
throw new Error("user is required for authorized connection");
|
|
2172
2841
|
}
|
|
2173
2842
|
static resolveAuthorizationUser(e, t) {
|
|
2174
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
2843
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Ut()}`;
|
|
2175
2844
|
}
|
|
2176
2845
|
static buildExtraHeaders(e, t) {
|
|
2177
|
-
const s = e !== void 0 && e !== "" ?
|
|
2846
|
+
const s = e !== void 0 && e !== "" ? Wt(e) : [];
|
|
2178
2847
|
return t === void 0 ? s : [...s, ...t];
|
|
2179
2848
|
}
|
|
2180
2849
|
createConfiguration({
|
|
@@ -2187,40 +2856,40 @@ class D {
|
|
|
2187
2856
|
sessionTimers: o = !1,
|
|
2188
2857
|
registerExpires: c = 300,
|
|
2189
2858
|
// 5 minutes in sec
|
|
2190
|
-
connectionRecoveryMinInterval:
|
|
2191
|
-
connectionRecoveryMaxInterval:
|
|
2192
|
-
userAgent:
|
|
2859
|
+
connectionRecoveryMinInterval: l = 2,
|
|
2860
|
+
connectionRecoveryMaxInterval: T = 6,
|
|
2861
|
+
userAgent: h
|
|
2193
2862
|
}) {
|
|
2194
|
-
|
|
2863
|
+
L.validateParametersConnection({
|
|
2195
2864
|
register: a,
|
|
2196
2865
|
password: t,
|
|
2197
2866
|
user: e,
|
|
2198
2867
|
sipServerIp: r,
|
|
2199
2868
|
sipServerUrl: s
|
|
2200
2869
|
});
|
|
2201
|
-
const
|
|
2870
|
+
const u = L.resolveAuthorizationUser(a, e), p = Lt(r), A = p(u), N = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
|
|
2202
2871
|
return {
|
|
2203
2872
|
configuration: {
|
|
2204
2873
|
password: t,
|
|
2205
2874
|
register: a,
|
|
2206
|
-
uri:
|
|
2207
|
-
display_name:
|
|
2208
|
-
user_agent:
|
|
2875
|
+
uri: A,
|
|
2876
|
+
display_name: Ae(i),
|
|
2877
|
+
user_agent: h,
|
|
2209
2878
|
sdpSemantics: "unified-plan",
|
|
2210
|
-
sockets: [
|
|
2879
|
+
sockets: [N],
|
|
2211
2880
|
session_timers: o,
|
|
2212
2881
|
register_expires: c,
|
|
2213
|
-
connection_recovery_min_interval:
|
|
2214
|
-
connection_recovery_max_interval:
|
|
2882
|
+
connection_recovery_min_interval: l,
|
|
2883
|
+
connection_recovery_max_interval: T
|
|
2215
2884
|
},
|
|
2216
2885
|
helpers: {
|
|
2217
|
-
socket:
|
|
2886
|
+
socket: N,
|
|
2218
2887
|
getUri: p
|
|
2219
2888
|
}
|
|
2220
2889
|
};
|
|
2221
2890
|
}
|
|
2222
2891
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
2223
|
-
const i = new this.JsSIP.UA(s), r =
|
|
2892
|
+
const i = new this.JsSIP.UA(s), r = L.buildExtraHeaders(e, t);
|
|
2224
2893
|
return r.length > 0 && i.registrator().setExtraHeaders(r), i;
|
|
2225
2894
|
}
|
|
2226
2895
|
/**
|
|
@@ -2233,13 +2902,13 @@ class D {
|
|
|
2233
2902
|
extraHeaders: e.extraHeaders
|
|
2234
2903
|
});
|
|
2235
2904
|
return t.eachTriggers((a, o) => {
|
|
2236
|
-
const c =
|
|
2905
|
+
const c = Ne.find((l) => l === o);
|
|
2237
2906
|
c && r.on(c, a);
|
|
2238
2907
|
}), { ua: r, helpers: i };
|
|
2239
2908
|
}
|
|
2240
2909
|
}
|
|
2241
|
-
const
|
|
2242
|
-
class
|
|
2910
|
+
const fe = "Not ready for connection", xt = (n) => n instanceof Error && n.message === fe, Qt = () => new Error(fe), Yt = async (n) => typeof n == "function" ? n() : n;
|
|
2911
|
+
class zt {
|
|
2243
2912
|
events;
|
|
2244
2913
|
ua;
|
|
2245
2914
|
socket;
|
|
@@ -2251,15 +2920,15 @@ class Bt {
|
|
|
2251
2920
|
configurationManager;
|
|
2252
2921
|
JsSIP;
|
|
2253
2922
|
constructor({ JsSIP: e }) {
|
|
2254
|
-
this.JsSIP = e, this.events =
|
|
2923
|
+
this.JsSIP = e, this.events = yt(), this.uaFactory = new L(e), this.registrationManager = new Vt({
|
|
2255
2924
|
events: this.events,
|
|
2256
2925
|
getUaProtected: this.getUaProtected
|
|
2257
|
-
}), this.stateMachine = new
|
|
2926
|
+
}), this.stateMachine = new qt(this.events), this.configurationManager = new bt({
|
|
2258
2927
|
getUa: this.getUa
|
|
2259
|
-
}), this.sipOperations = new
|
|
2928
|
+
}), this.sipOperations = new Ht({
|
|
2260
2929
|
uaFactory: this.uaFactory,
|
|
2261
2930
|
getUaProtected: this.getUaProtected
|
|
2262
|
-
}), this.connectionFlow = new
|
|
2931
|
+
}), this.connectionFlow = new Bt({
|
|
2263
2932
|
JsSIP: this.JsSIP,
|
|
2264
2933
|
events: this.events,
|
|
2265
2934
|
uaFactory: this.uaFactory,
|
|
@@ -2302,17 +2971,20 @@ class Bt {
|
|
|
2302
2971
|
get isFailed() {
|
|
2303
2972
|
return this.stateMachine.isFailed;
|
|
2304
2973
|
}
|
|
2974
|
+
get connectionActor() {
|
|
2975
|
+
return this.stateMachine.actorRef;
|
|
2976
|
+
}
|
|
2305
2977
|
get connectionState() {
|
|
2306
2978
|
return this.stateMachine.state;
|
|
2307
2979
|
}
|
|
2308
2980
|
get isRegistered() {
|
|
2309
|
-
return
|
|
2981
|
+
return L.isRegisteredUA(this.ua);
|
|
2310
2982
|
}
|
|
2311
2983
|
get isRegisterConfig() {
|
|
2312
2984
|
return this.configurationManager.isRegister();
|
|
2313
2985
|
}
|
|
2314
2986
|
connect = async (e, t) => this.disconnect().catch((s) => {
|
|
2315
|
-
|
|
2987
|
+
d("connect: disconnect error", s);
|
|
2316
2988
|
}).then(async () => this.connectWithProcessError(e, t));
|
|
2317
2989
|
set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
|
|
2318
2990
|
disconnect = async () => {
|
|
@@ -2361,7 +3033,7 @@ class Bt {
|
|
|
2361
3033
|
getUa = () => this.ua;
|
|
2362
3034
|
connectWithProcessError = async (e, t) => {
|
|
2363
3035
|
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
2364
|
-
throw
|
|
3036
|
+
throw Qt();
|
|
2365
3037
|
return this.processConnect(e, t).catch(async (i) => {
|
|
2366
3038
|
const r = i;
|
|
2367
3039
|
return this.disconnect().then(() => {
|
|
@@ -2371,18 +3043,18 @@ class Bt {
|
|
|
2371
3043
|
});
|
|
2372
3044
|
});
|
|
2373
3045
|
};
|
|
2374
|
-
processConnect = async (e, t) => (this.events.trigger(
|
|
2375
|
-
throw this.events.trigger(
|
|
2376
|
-
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(
|
|
3046
|
+
processConnect = async (e, t) => (this.events.trigger(S.CONNECT_STARTED, {}), Yt(e).then((s) => (this.events.trigger(S.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
|
|
3047
|
+
throw this.events.trigger(S.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
|
|
3048
|
+
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(S.CONNECT_SUCCEEDED, {
|
|
2377
3049
|
...s
|
|
2378
3050
|
}), s)).catch((s) => {
|
|
2379
3051
|
const i = s ?? new Error("Failed to connect to server");
|
|
2380
|
-
throw this.events.trigger(
|
|
3052
|
+
throw this.events.trigger(S.CONNECT_FAILED, i), i;
|
|
2381
3053
|
}));
|
|
2382
3054
|
}
|
|
2383
|
-
class
|
|
3055
|
+
class Xt {
|
|
2384
3056
|
connectionManager;
|
|
2385
|
-
stackPromises =
|
|
3057
|
+
stackPromises = le({
|
|
2386
3058
|
noRunIsNotActual: !0
|
|
2387
3059
|
});
|
|
2388
3060
|
constructor({ connectionManager: e }) {
|
|
@@ -2394,11 +3066,11 @@ class kt {
|
|
|
2394
3066
|
this.stackPromises.stop();
|
|
2395
3067
|
}
|
|
2396
3068
|
}
|
|
2397
|
-
const
|
|
2398
|
-
class
|
|
2399
|
-
countInner =
|
|
2400
|
-
initialCount =
|
|
2401
|
-
limitInner =
|
|
3069
|
+
const te = 0, Jt = 30;
|
|
3070
|
+
class Kt {
|
|
3071
|
+
countInner = te;
|
|
3072
|
+
initialCount = te;
|
|
3073
|
+
limitInner = Jt;
|
|
2402
3074
|
isInProgress = !1;
|
|
2403
3075
|
onStatusChange;
|
|
2404
3076
|
constructor({
|
|
@@ -2431,7 +3103,7 @@ class qt {
|
|
|
2431
3103
|
this.countInner = this.initialCount, this.finishAttempt();
|
|
2432
3104
|
}
|
|
2433
3105
|
}
|
|
2434
|
-
class
|
|
3106
|
+
class jt {
|
|
2435
3107
|
connectionManager;
|
|
2436
3108
|
interval;
|
|
2437
3109
|
checkTelephonyByTimeout = void 0;
|
|
@@ -2447,7 +3119,7 @@ class Vt {
|
|
|
2447
3119
|
onSuccessRequest: t,
|
|
2448
3120
|
onFailRequest: s
|
|
2449
3121
|
}) {
|
|
2450
|
-
this.stop(), this.cancelableBeforeRequest = new
|
|
3122
|
+
this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Fe({
|
|
2451
3123
|
isDontStopOnFail: !0,
|
|
2452
3124
|
requestInterval: this.interval,
|
|
2453
3125
|
request: async () => {
|
|
@@ -2467,8 +3139,8 @@ class Vt {
|
|
|
2467
3139
|
this.checkTelephonyByTimeout?.stop(), this.checkTelephonyByTimeout = void 0, this.cancelableBeforeRequest?.cancelRequest(), this.cancelableBeforeRequest = void 0;
|
|
2468
3140
|
}
|
|
2469
3141
|
}
|
|
2470
|
-
var
|
|
2471
|
-
const
|
|
3142
|
+
var f = /* @__PURE__ */ ((n) => (n.BEFORE_ATTEMPT = "before-attempt", n.SUCCESS = "success", n.FAILED_ALL_ATTEMPTS = "failed-all-attempts", n.CANCELLED_ATTEMPTS = "cancelled-attempts", n.CHANGED_ATTEMPT_STATUS = "changed-attempt-status", n.STOP_ATTEMPTS_BY_ERROR = "stop-attempts-by-error", n.LIMIT_REACHED_ATTEMPTS = "limit-reached-attempts", n))(f || {});
|
|
3143
|
+
const Me = [
|
|
2472
3144
|
"before-attempt",
|
|
2473
3145
|
"success",
|
|
2474
3146
|
"failed-all-attempts",
|
|
@@ -2476,8 +3148,8 @@ const Ae = [
|
|
|
2476
3148
|
"changed-attempt-status",
|
|
2477
3149
|
"stop-attempts-by-error",
|
|
2478
3150
|
"limit-reached-attempts"
|
|
2479
|
-
],
|
|
2480
|
-
class
|
|
3151
|
+
], Zt = () => new M(Me);
|
|
3152
|
+
class K {
|
|
2481
3153
|
callManager;
|
|
2482
3154
|
disposers = [];
|
|
2483
3155
|
constructor({ callManager: e }) {
|
|
@@ -2502,40 +3174,40 @@ class Y {
|
|
|
2502
3174
|
this.callManager.isCallActive ? e?.() : t();
|
|
2503
3175
|
}
|
|
2504
3176
|
}
|
|
2505
|
-
const
|
|
2506
|
-
class
|
|
3177
|
+
const en = 15e3, tn = 2;
|
|
3178
|
+
class nn {
|
|
2507
3179
|
connectionManager;
|
|
2508
3180
|
pingServerByTimeoutWithFailCalls;
|
|
2509
3181
|
constructor({ connectionManager: e }) {
|
|
2510
|
-
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls =
|
|
3182
|
+
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Be(tn, {
|
|
2511
3183
|
whenPossibleRequest: async () => {
|
|
2512
3184
|
},
|
|
2513
|
-
requestInterval:
|
|
2514
|
-
request: async () => (
|
|
2515
|
-
|
|
3185
|
+
requestInterval: en,
|
|
3186
|
+
request: async () => (d("ping"), this.connectionManager.ping().then(() => {
|
|
3187
|
+
d("ping success");
|
|
2516
3188
|
}))
|
|
2517
3189
|
});
|
|
2518
3190
|
}
|
|
2519
3191
|
start({ onFailRequest: e }) {
|
|
2520
|
-
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(
|
|
3192
|
+
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(d);
|
|
2521
3193
|
}
|
|
2522
3194
|
stop() {
|
|
2523
3195
|
this.pingServerByTimeoutWithFailCalls.stop();
|
|
2524
3196
|
}
|
|
2525
3197
|
}
|
|
2526
|
-
class
|
|
3198
|
+
class sn {
|
|
2527
3199
|
pingServerRequester;
|
|
2528
3200
|
notActiveCallSubscriber;
|
|
2529
3201
|
constructor({
|
|
2530
3202
|
connectionManager: e,
|
|
2531
3203
|
callManager: t
|
|
2532
3204
|
}) {
|
|
2533
|
-
this.pingServerRequester = new
|
|
3205
|
+
this.pingServerRequester = new nn({
|
|
2534
3206
|
connectionManager: e
|
|
2535
|
-
}), this.notActiveCallSubscriber = new
|
|
3207
|
+
}), this.notActiveCallSubscriber = new K({ callManager: t });
|
|
2536
3208
|
}
|
|
2537
3209
|
start({ onFailRequest: e }) {
|
|
2538
|
-
|
|
3210
|
+
d("start"), this.notActiveCallSubscriber.subscribe({
|
|
2539
3211
|
onActive: () => {
|
|
2540
3212
|
this.pingServerRequester.stop();
|
|
2541
3213
|
},
|
|
@@ -2545,13 +3217,13 @@ class Qt {
|
|
|
2545
3217
|
});
|
|
2546
3218
|
}
|
|
2547
3219
|
stop() {
|
|
2548
|
-
|
|
3220
|
+
d("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
|
|
2549
3221
|
}
|
|
2550
3222
|
unsubscribeCallStatusChange() {
|
|
2551
3223
|
this.notActiveCallSubscriber.unsubscribe();
|
|
2552
3224
|
}
|
|
2553
3225
|
}
|
|
2554
|
-
class
|
|
3226
|
+
class rn {
|
|
2555
3227
|
connectionManager;
|
|
2556
3228
|
isRegistrationFailed = !1;
|
|
2557
3229
|
disposers = [];
|
|
@@ -2560,7 +3232,7 @@ class Yt {
|
|
|
2560
3232
|
connectionManager: e,
|
|
2561
3233
|
callManager: t
|
|
2562
3234
|
}) {
|
|
2563
|
-
this.connectionManager = e, this.notActiveCallSubscriber = new
|
|
3235
|
+
this.connectionManager = e, this.notActiveCallSubscriber = new K({ callManager: t });
|
|
2564
3236
|
}
|
|
2565
3237
|
subscribe(e) {
|
|
2566
3238
|
this.unsubscribe(), this.disposers.push(
|
|
@@ -2587,12 +3259,12 @@ class Yt {
|
|
|
2587
3259
|
this.isRegistrationFailed = !1;
|
|
2588
3260
|
}
|
|
2589
3261
|
}
|
|
2590
|
-
const
|
|
3262
|
+
const an = 3e3, on = 15e3, ne = {
|
|
2591
3263
|
LIMIT_REACHED: "Limit reached",
|
|
2592
3264
|
FAILED_TO_RECONNECT: "Failed to reconnect"
|
|
2593
|
-
},
|
|
2594
|
-
},
|
|
2595
|
-
class
|
|
3265
|
+
}, cn = async () => {
|
|
3266
|
+
}, dn = (n) => !0;
|
|
3267
|
+
class ln {
|
|
2596
3268
|
events;
|
|
2597
3269
|
connectionManager;
|
|
2598
3270
|
connectionQueueManager;
|
|
@@ -2612,28 +3284,28 @@ class jt {
|
|
|
2612
3284
|
connectionManager: t,
|
|
2613
3285
|
callManager: s
|
|
2614
3286
|
}, i) {
|
|
2615
|
-
const r = i?.onBeforeRetry ??
|
|
2616
|
-
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events =
|
|
3287
|
+
const r = i?.onBeforeRetry ?? cn, a = i?.canRetryOnError ?? dn;
|
|
3288
|
+
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = Zt(), this.checkTelephonyRequester = new jt({
|
|
2617
3289
|
connectionManager: t,
|
|
2618
|
-
interval: i?.checkTelephonyRequestInterval ??
|
|
2619
|
-
}), this.pingServerIfNotActiveCallRequester = new
|
|
3290
|
+
interval: i?.checkTelephonyRequestInterval ?? on
|
|
3291
|
+
}), this.pingServerIfNotActiveCallRequester = new sn({
|
|
2620
3292
|
connectionManager: t,
|
|
2621
3293
|
callManager: s
|
|
2622
|
-
}), this.registrationFailedOutOfCallSubscriber = new
|
|
3294
|
+
}), this.registrationFailedOutOfCallSubscriber = new rn({
|
|
2623
3295
|
connectionManager: t,
|
|
2624
3296
|
callManager: s
|
|
2625
|
-
}), this.attemptsState = new
|
|
3297
|
+
}), this.attemptsState = new Kt({
|
|
2626
3298
|
onStatusChange: this.emitStatusChange
|
|
2627
|
-
}), this.cancelableRequestBeforeRetry = new
|
|
2628
|
-
i?.timeoutBetweenAttempts ??
|
|
2629
|
-
), this.notActiveCallSubscriber = new
|
|
3299
|
+
}), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new ke(
|
|
3300
|
+
i?.timeoutBetweenAttempts ?? an
|
|
3301
|
+
), this.notActiveCallSubscriber = new K({ callManager: s });
|
|
2630
3302
|
}
|
|
2631
3303
|
start(e) {
|
|
2632
|
-
|
|
3304
|
+
d("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
|
|
2633
3305
|
}
|
|
2634
3306
|
stop() {
|
|
2635
|
-
|
|
2636
|
-
|
|
3307
|
+
d("auto connector stop"), this.unsubscribeFromNotActiveCall(), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow().catch((e) => {
|
|
3308
|
+
d("auto connector stop from stop method: error", e);
|
|
2637
3309
|
});
|
|
2638
3310
|
}
|
|
2639
3311
|
on(e, t) {
|
|
@@ -2652,77 +3324,77 @@ class jt {
|
|
|
2652
3324
|
this.events.off(e, t);
|
|
2653
3325
|
}
|
|
2654
3326
|
restartConnectionAttempts(e) {
|
|
2655
|
-
|
|
2656
|
-
|
|
3327
|
+
d("auto connector restart connection attempts"), this.stopConnectionFlow().then(async () => this.attemptConnection(e)).catch((t) => {
|
|
3328
|
+
d("auto connector failed to restart connection attempts:", t);
|
|
2657
3329
|
});
|
|
2658
3330
|
}
|
|
2659
3331
|
async stopConnectionFlow() {
|
|
2660
|
-
|
|
3332
|
+
d("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), await this.connectionQueueManager.disconnect();
|
|
2661
3333
|
}
|
|
2662
3334
|
stopAttempts() {
|
|
2663
3335
|
this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
|
|
2664
3336
|
}
|
|
2665
3337
|
stopConnectTriggers() {
|
|
2666
|
-
|
|
3338
|
+
d("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
|
|
2667
3339
|
}
|
|
2668
3340
|
startCheckTelephony(e) {
|
|
2669
|
-
|
|
3341
|
+
d("startCheckTelephony"), this.checkTelephonyRequester.start({
|
|
2670
3342
|
onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
|
|
2671
3343
|
onSuccessRequest: () => {
|
|
2672
|
-
|
|
3344
|
+
d("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
|
|
2673
3345
|
},
|
|
2674
3346
|
onFailRequest: (t) => {
|
|
2675
|
-
|
|
3347
|
+
d("startCheckTelephony: onFailRequest", t.message);
|
|
2676
3348
|
}
|
|
2677
3349
|
});
|
|
2678
3350
|
}
|
|
2679
3351
|
async attemptConnection(e) {
|
|
2680
|
-
if (
|
|
2681
|
-
|
|
3352
|
+
if (d("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(f.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
|
|
3353
|
+
d("attemptConnection: limit reached"), this.handleLimitReached(e);
|
|
2682
3354
|
return;
|
|
2683
3355
|
}
|
|
2684
3356
|
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.executeConnectionAttempt(e);
|
|
2685
3357
|
}
|
|
2686
3358
|
async executeConnectionAttempt(e) {
|
|
2687
3359
|
try {
|
|
2688
|
-
await this.connectionQueueManager.connect(e.getParameters, e.options),
|
|
3360
|
+
await this.connectionQueueManager.connect(e.getParameters, e.options), d("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
|
|
2689
3361
|
} catch (t) {
|
|
2690
3362
|
this.handleConnectionError(t, e);
|
|
2691
3363
|
}
|
|
2692
3364
|
}
|
|
2693
3365
|
handleConnectionError(e, t) {
|
|
2694
|
-
if (
|
|
2695
|
-
this.attemptsState.finishAttempt(), this.events.trigger(
|
|
3366
|
+
if (xt(e)) {
|
|
3367
|
+
this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
|
|
2696
3368
|
return;
|
|
2697
3369
|
}
|
|
2698
3370
|
if (!this.canRetryOnError(e)) {
|
|
2699
|
-
|
|
3371
|
+
d("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
|
|
2700
3372
|
return;
|
|
2701
3373
|
}
|
|
2702
|
-
if (
|
|
2703
|
-
|
|
3374
|
+
if (Ve(e)) {
|
|
3375
|
+
d("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(f.CANCELLED_ATTEMPTS, e);
|
|
2704
3376
|
return;
|
|
2705
3377
|
}
|
|
2706
|
-
|
|
3378
|
+
d("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
|
|
2707
3379
|
}
|
|
2708
3380
|
handleLimitReached(e) {
|
|
2709
|
-
this.attemptsState.finishAttempt(), this.events.trigger(
|
|
3381
|
+
this.attemptsState.finishAttempt(), this.events.trigger(f.LIMIT_REACHED_ATTEMPTS, new Error(ne.LIMIT_REACHED)), this.startCheckTelephony(e);
|
|
2710
3382
|
}
|
|
2711
3383
|
handleSucceededAttempt(e) {
|
|
2712
|
-
|
|
3384
|
+
d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(f.SUCCESS);
|
|
2713
3385
|
}
|
|
2714
3386
|
subscribeToConnectTriggers(e) {
|
|
2715
3387
|
this.startPingRequester(e), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2716
|
-
|
|
3388
|
+
d("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
|
|
2717
3389
|
});
|
|
2718
3390
|
}
|
|
2719
3391
|
subscribeToNotActiveCall(e) {
|
|
2720
3392
|
this.notActiveCallSubscriber.subscribe({
|
|
2721
3393
|
onActive: () => {
|
|
2722
|
-
|
|
3394
|
+
d("subscribeToNotActiveCall onActive"), this.unsubscribeFromHardwareTriggers();
|
|
2723
3395
|
},
|
|
2724
3396
|
onInactive: () => {
|
|
2725
|
-
|
|
3397
|
+
d("subscribeToNotActiveCall onInactive"), this.subscribeToHardwareTriggers(e);
|
|
2726
3398
|
}
|
|
2727
3399
|
});
|
|
2728
3400
|
}
|
|
@@ -2730,13 +3402,13 @@ class jt {
|
|
|
2730
3402
|
this.notActiveCallSubscriber.unsubscribe();
|
|
2731
3403
|
}
|
|
2732
3404
|
subscribeToHardwareTriggers(e) {
|
|
2733
|
-
this.unsubscribeFromHardwareTriggers(),
|
|
3405
|
+
this.unsubscribeFromHardwareTriggers(), d("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
|
|
2734
3406
|
onChange: () => {
|
|
2735
|
-
|
|
3407
|
+
d("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
|
|
2736
3408
|
},
|
|
2737
3409
|
onUnavailable: () => {
|
|
2738
|
-
|
|
2739
|
-
|
|
3410
|
+
d("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow().catch((t) => {
|
|
3411
|
+
d(
|
|
2740
3412
|
"auto connector stop from networkInterfacesSubscriber onUnavailable: error",
|
|
2741
3413
|
t
|
|
2742
3414
|
);
|
|
@@ -2744,12 +3416,12 @@ class jt {
|
|
|
2744
3416
|
}
|
|
2745
3417
|
}), this.resumeFromSleepModeSubscriber?.subscribe({
|
|
2746
3418
|
onResume: () => {
|
|
2747
|
-
|
|
3419
|
+
d("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
|
|
2748
3420
|
}
|
|
2749
3421
|
});
|
|
2750
3422
|
}
|
|
2751
3423
|
unsubscribeFromHardwareTriggers() {
|
|
2752
|
-
|
|
3424
|
+
d("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
|
|
2753
3425
|
}
|
|
2754
3426
|
stopPingRequester() {
|
|
2755
3427
|
this.pingServerIfNotActiveCallRequester.stop();
|
|
@@ -2757,18 +3429,18 @@ class jt {
|
|
|
2757
3429
|
startPingRequester(e) {
|
|
2758
3430
|
this.pingServerIfNotActiveCallRequester.start({
|
|
2759
3431
|
onFailRequest: () => {
|
|
2760
|
-
|
|
3432
|
+
d("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
|
|
2761
3433
|
}
|
|
2762
3434
|
});
|
|
2763
3435
|
}
|
|
2764
3436
|
connectIfDisconnected(e) {
|
|
2765
3437
|
const t = this.isConnectionUnavailable();
|
|
2766
|
-
|
|
3438
|
+
d("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(f.SUCCESS));
|
|
2767
3439
|
}
|
|
2768
3440
|
scheduleReconnect(e) {
|
|
2769
|
-
|
|
2770
|
-
const s = t instanceof Error ? t : new Error(
|
|
2771
|
-
this.attemptsState.finishAttempt(),
|
|
3441
|
+
d("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (d("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (d("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
|
|
3442
|
+
const s = t instanceof Error ? t : new Error(ne.FAILED_TO_RECONNECT);
|
|
3443
|
+
this.attemptsState.finishAttempt(), Ue(t) || Ge(t) ? this.events.trigger(f.CANCELLED_ATTEMPTS, s) : this.events.trigger(f.FAILED_ALL_ATTEMPTS, s), d("scheduleReconnect: error", t);
|
|
2772
3444
|
});
|
|
2773
3445
|
}
|
|
2774
3446
|
isConnectionUnavailable() {
|
|
@@ -2776,22 +3448,506 @@ class jt {
|
|
|
2776
3448
|
return e || t || s;
|
|
2777
3449
|
}
|
|
2778
3450
|
emitStatusChange = ({ isInProgress: e }) => {
|
|
2779
|
-
this.events.trigger(
|
|
3451
|
+
this.events.trigger(f.CHANGED_ATTEMPT_STATUS, { isInProgress: e });
|
|
2780
3452
|
};
|
|
2781
3453
|
}
|
|
3454
|
+
var z = /* @__PURE__ */ ((n) => (n.STATE_CHANGED = "state-changed", n.STATE_RESET = "state-reset", n))(z || {});
|
|
3455
|
+
const hn = ["state-changed", "state-reset"], gn = () => new M(hn);
|
|
3456
|
+
class un {
|
|
3457
|
+
events;
|
|
3458
|
+
state = {};
|
|
3459
|
+
constructor() {
|
|
3460
|
+
this.events = gn();
|
|
3461
|
+
}
|
|
3462
|
+
getState() {
|
|
3463
|
+
return { ...this.state };
|
|
3464
|
+
}
|
|
3465
|
+
updateState(e) {
|
|
3466
|
+
const t = { ...this.state };
|
|
3467
|
+
this.state = { ...this.state, ...e }, this.events.trigger(z.STATE_CHANGED, {
|
|
3468
|
+
previous: t,
|
|
3469
|
+
current: this.state,
|
|
3470
|
+
updates: e
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3473
|
+
reset() {
|
|
3474
|
+
this.state = {}, this.events.trigger(z.STATE_RESET, {});
|
|
3475
|
+
}
|
|
3476
|
+
getToken() {
|
|
3477
|
+
return this.state.token;
|
|
3478
|
+
}
|
|
3479
|
+
getRoom() {
|
|
3480
|
+
return this.state.room;
|
|
3481
|
+
}
|
|
3482
|
+
getParticipantName() {
|
|
3483
|
+
return this.state.participantName;
|
|
3484
|
+
}
|
|
3485
|
+
getChannels() {
|
|
3486
|
+
return this.state.channels;
|
|
3487
|
+
}
|
|
3488
|
+
getConference() {
|
|
3489
|
+
return this.state.conference;
|
|
3490
|
+
}
|
|
3491
|
+
getParticipant() {
|
|
3492
|
+
return this.state.participant;
|
|
3493
|
+
}
|
|
3494
|
+
getNumber() {
|
|
3495
|
+
return this.state.number;
|
|
3496
|
+
}
|
|
3497
|
+
getAnswer() {
|
|
3498
|
+
return this.state.answer;
|
|
3499
|
+
}
|
|
3500
|
+
on(e, t) {
|
|
3501
|
+
return this.events.on(e, t);
|
|
3502
|
+
}
|
|
3503
|
+
once(e, t) {
|
|
3504
|
+
return this.events.once(e, t);
|
|
3505
|
+
}
|
|
3506
|
+
off(e, t) {
|
|
3507
|
+
this.events.off(e, t);
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
2782
3510
|
var U = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(U || {});
|
|
2783
|
-
const
|
|
3511
|
+
const ve = [
|
|
2784
3512
|
"incomingCall",
|
|
2785
3513
|
"declinedIncomingCall",
|
|
2786
3514
|
"terminatedIncomingCall",
|
|
2787
3515
|
"failedIncomingCall"
|
|
2788
|
-
],
|
|
2789
|
-
|
|
3516
|
+
], Tn = () => new M(ve);
|
|
3517
|
+
var En = /* @__PURE__ */ ((n) => (n.IDLE = "incoming:idle", n.RINGING = "incoming:ringing", n.CONSUMED = "incoming:consumed", n.DECLINED = "incoming:declined", n.TERMINATED = "incoming:terminated", n.FAILED = "incoming:failed", n))(En || {});
|
|
3518
|
+
const Cn = $({
|
|
3519
|
+
types: {
|
|
3520
|
+
context: {},
|
|
3521
|
+
events: {}
|
|
3522
|
+
},
|
|
3523
|
+
actions: {
|
|
3524
|
+
logTransition: (n, e) => {
|
|
3525
|
+
d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
3526
|
+
},
|
|
3527
|
+
logStateChange: (n, e) => {
|
|
3528
|
+
d("IncomingCallStateMachine state changed", e.state);
|
|
3529
|
+
},
|
|
3530
|
+
rememberIncoming: b(({ event: n }) => {
|
|
3531
|
+
const { data: e } = n;
|
|
3532
|
+
return { remoteCallerData: e, lastReason: void 0 };
|
|
3533
|
+
}),
|
|
3534
|
+
rememberReason: b(({ event: n, context: e }) => n.type === "INCOMING.CONSUMED" ? {
|
|
3535
|
+
remoteCallerData: e.remoteCallerData,
|
|
3536
|
+
lastReason: "incoming:consumed"
|
|
3537
|
+
/* CONSUMED */
|
|
3538
|
+
} : n.type === "INCOMING.DECLINED" ? {
|
|
3539
|
+
remoteCallerData: n.data,
|
|
3540
|
+
lastReason: "incoming:declined"
|
|
3541
|
+
/* DECLINED */
|
|
3542
|
+
} : n.type === "INCOMING.TERMINATED" ? {
|
|
3543
|
+
remoteCallerData: n.data,
|
|
3544
|
+
lastReason: "incoming:terminated"
|
|
3545
|
+
/* TERMINATED */
|
|
3546
|
+
} : {
|
|
3547
|
+
remoteCallerData: n.data,
|
|
3548
|
+
lastReason: "incoming:failed"
|
|
3549
|
+
/* FAILED */
|
|
3550
|
+
}),
|
|
3551
|
+
clearIncoming: b(() => ({ remoteCallerData: void 0, lastReason: void 0 }))
|
|
3552
|
+
}
|
|
3553
|
+
}).createMachine({
|
|
3554
|
+
id: "incoming",
|
|
3555
|
+
initial: "incoming:idle",
|
|
3556
|
+
context: {},
|
|
3557
|
+
states: {
|
|
3558
|
+
"incoming:idle": {
|
|
3559
|
+
entry: {
|
|
3560
|
+
type: "logStateChange",
|
|
3561
|
+
params: {
|
|
3562
|
+
state: "incoming:idle"
|
|
3563
|
+
/* IDLE */
|
|
3564
|
+
}
|
|
3565
|
+
},
|
|
3566
|
+
on: {
|
|
3567
|
+
"INCOMING.RINGING": {
|
|
3568
|
+
target: "incoming:ringing",
|
|
3569
|
+
actions: [
|
|
3570
|
+
"rememberIncoming",
|
|
3571
|
+
{
|
|
3572
|
+
type: "logTransition",
|
|
3573
|
+
params: {
|
|
3574
|
+
from: "incoming:idle",
|
|
3575
|
+
to: "incoming:ringing",
|
|
3576
|
+
event: "INCOMING.RINGING"
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
]
|
|
3580
|
+
},
|
|
3581
|
+
"INCOMING.CLEAR": {
|
|
3582
|
+
target: "incoming:idle",
|
|
3583
|
+
actions: [
|
|
3584
|
+
"clearIncoming",
|
|
3585
|
+
{
|
|
3586
|
+
type: "logTransition",
|
|
3587
|
+
params: {
|
|
3588
|
+
from: "incoming:idle",
|
|
3589
|
+
to: "incoming:idle",
|
|
3590
|
+
event: "INCOMING.CLEAR"
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
]
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
},
|
|
3597
|
+
"incoming:ringing": {
|
|
3598
|
+
entry: {
|
|
3599
|
+
type: "logStateChange",
|
|
3600
|
+
params: {
|
|
3601
|
+
state: "incoming:ringing"
|
|
3602
|
+
/* RINGING */
|
|
3603
|
+
}
|
|
3604
|
+
},
|
|
3605
|
+
on: {
|
|
3606
|
+
"INCOMING.RINGING": {
|
|
3607
|
+
target: "incoming:ringing",
|
|
3608
|
+
actions: [
|
|
3609
|
+
"rememberIncoming",
|
|
3610
|
+
{
|
|
3611
|
+
type: "logTransition",
|
|
3612
|
+
params: {
|
|
3613
|
+
from: "incoming:ringing",
|
|
3614
|
+
to: "incoming:ringing",
|
|
3615
|
+
event: "INCOMING.RINGING"
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
]
|
|
3619
|
+
},
|
|
3620
|
+
"INCOMING.CONSUMED": {
|
|
3621
|
+
target: "incoming:consumed",
|
|
3622
|
+
actions: [
|
|
3623
|
+
"rememberReason",
|
|
3624
|
+
{
|
|
3625
|
+
type: "logTransition",
|
|
3626
|
+
params: {
|
|
3627
|
+
from: "incoming:ringing",
|
|
3628
|
+
to: "incoming:consumed",
|
|
3629
|
+
event: "INCOMING.CONSUMED"
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
]
|
|
3633
|
+
},
|
|
3634
|
+
"INCOMING.DECLINED": {
|
|
3635
|
+
target: "incoming:declined",
|
|
3636
|
+
actions: [
|
|
3637
|
+
"rememberReason",
|
|
3638
|
+
{
|
|
3639
|
+
type: "logTransition",
|
|
3640
|
+
params: {
|
|
3641
|
+
from: "incoming:ringing",
|
|
3642
|
+
to: "incoming:declined",
|
|
3643
|
+
event: "INCOMING.DECLINED"
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
]
|
|
3647
|
+
},
|
|
3648
|
+
"INCOMING.TERMINATED": {
|
|
3649
|
+
target: "incoming:terminated",
|
|
3650
|
+
actions: [
|
|
3651
|
+
"rememberReason",
|
|
3652
|
+
{
|
|
3653
|
+
type: "logTransition",
|
|
3654
|
+
params: {
|
|
3655
|
+
from: "incoming:ringing",
|
|
3656
|
+
to: "incoming:terminated",
|
|
3657
|
+
event: "INCOMING.TERMINATED"
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
]
|
|
3661
|
+
},
|
|
3662
|
+
"INCOMING.FAILED": {
|
|
3663
|
+
target: "incoming:failed",
|
|
3664
|
+
actions: [
|
|
3665
|
+
"rememberReason",
|
|
3666
|
+
{
|
|
3667
|
+
type: "logTransition",
|
|
3668
|
+
params: {
|
|
3669
|
+
from: "incoming:ringing",
|
|
3670
|
+
to: "incoming:failed",
|
|
3671
|
+
event: "INCOMING.FAILED"
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
]
|
|
3675
|
+
},
|
|
3676
|
+
"INCOMING.CLEAR": {
|
|
3677
|
+
target: "incoming:idle",
|
|
3678
|
+
actions: [
|
|
3679
|
+
"clearIncoming",
|
|
3680
|
+
{
|
|
3681
|
+
type: "logTransition",
|
|
3682
|
+
params: {
|
|
3683
|
+
from: "incoming:ringing",
|
|
3684
|
+
to: "incoming:idle",
|
|
3685
|
+
event: "INCOMING.CLEAR"
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
]
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3691
|
+
},
|
|
3692
|
+
"incoming:consumed": {
|
|
3693
|
+
entry: {
|
|
3694
|
+
type: "logStateChange",
|
|
3695
|
+
params: {
|
|
3696
|
+
state: "incoming:consumed"
|
|
3697
|
+
/* CONSUMED */
|
|
3698
|
+
}
|
|
3699
|
+
},
|
|
3700
|
+
on: {
|
|
3701
|
+
"INCOMING.CLEAR": {
|
|
3702
|
+
target: "incoming:idle",
|
|
3703
|
+
actions: [
|
|
3704
|
+
"clearIncoming",
|
|
3705
|
+
{
|
|
3706
|
+
type: "logTransition",
|
|
3707
|
+
params: {
|
|
3708
|
+
from: "incoming:consumed",
|
|
3709
|
+
to: "incoming:idle",
|
|
3710
|
+
event: "INCOMING.CLEAR"
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
]
|
|
3714
|
+
},
|
|
3715
|
+
"INCOMING.RINGING": {
|
|
3716
|
+
target: "incoming:ringing",
|
|
3717
|
+
actions: [
|
|
3718
|
+
"rememberIncoming",
|
|
3719
|
+
{
|
|
3720
|
+
type: "logTransition",
|
|
3721
|
+
params: {
|
|
3722
|
+
from: "incoming:consumed",
|
|
3723
|
+
to: "incoming:ringing",
|
|
3724
|
+
event: "INCOMING.RINGING"
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
]
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
},
|
|
3731
|
+
"incoming:declined": {
|
|
3732
|
+
entry: {
|
|
3733
|
+
type: "logStateChange",
|
|
3734
|
+
params: {
|
|
3735
|
+
state: "incoming:declined"
|
|
3736
|
+
/* DECLINED */
|
|
3737
|
+
}
|
|
3738
|
+
},
|
|
3739
|
+
on: {
|
|
3740
|
+
"INCOMING.CLEAR": {
|
|
3741
|
+
target: "incoming:idle",
|
|
3742
|
+
actions: [
|
|
3743
|
+
"clearIncoming",
|
|
3744
|
+
{
|
|
3745
|
+
type: "logTransition",
|
|
3746
|
+
params: {
|
|
3747
|
+
from: "incoming:declined",
|
|
3748
|
+
to: "incoming:idle",
|
|
3749
|
+
event: "INCOMING.CLEAR"
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
]
|
|
3753
|
+
},
|
|
3754
|
+
"INCOMING.RINGING": {
|
|
3755
|
+
target: "incoming:ringing",
|
|
3756
|
+
actions: [
|
|
3757
|
+
"rememberIncoming",
|
|
3758
|
+
{
|
|
3759
|
+
type: "logTransition",
|
|
3760
|
+
params: {
|
|
3761
|
+
from: "incoming:declined",
|
|
3762
|
+
to: "incoming:ringing",
|
|
3763
|
+
event: "INCOMING.RINGING"
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
]
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
},
|
|
3770
|
+
"incoming:terminated": {
|
|
3771
|
+
entry: {
|
|
3772
|
+
type: "logStateChange",
|
|
3773
|
+
params: {
|
|
3774
|
+
state: "incoming:terminated"
|
|
3775
|
+
/* TERMINATED */
|
|
3776
|
+
}
|
|
3777
|
+
},
|
|
3778
|
+
on: {
|
|
3779
|
+
"INCOMING.CLEAR": {
|
|
3780
|
+
target: "incoming:idle",
|
|
3781
|
+
actions: [
|
|
3782
|
+
"clearIncoming",
|
|
3783
|
+
{
|
|
3784
|
+
type: "logTransition",
|
|
3785
|
+
params: {
|
|
3786
|
+
from: "incoming:terminated",
|
|
3787
|
+
to: "incoming:idle",
|
|
3788
|
+
event: "INCOMING.CLEAR"
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
]
|
|
3792
|
+
},
|
|
3793
|
+
"INCOMING.RINGING": {
|
|
3794
|
+
target: "incoming:ringing",
|
|
3795
|
+
actions: [
|
|
3796
|
+
"rememberIncoming",
|
|
3797
|
+
{
|
|
3798
|
+
type: "logTransition",
|
|
3799
|
+
params: {
|
|
3800
|
+
from: "incoming:terminated",
|
|
3801
|
+
to: "incoming:ringing",
|
|
3802
|
+
event: "INCOMING.RINGING"
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
]
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
},
|
|
3809
|
+
"incoming:failed": {
|
|
3810
|
+
entry: {
|
|
3811
|
+
type: "logStateChange",
|
|
3812
|
+
params: {
|
|
3813
|
+
state: "incoming:failed"
|
|
3814
|
+
/* FAILED */
|
|
3815
|
+
}
|
|
3816
|
+
},
|
|
3817
|
+
on: {
|
|
3818
|
+
"INCOMING.CLEAR": {
|
|
3819
|
+
target: "incoming:idle",
|
|
3820
|
+
actions: [
|
|
3821
|
+
"clearIncoming",
|
|
3822
|
+
{
|
|
3823
|
+
type: "logTransition",
|
|
3824
|
+
params: {
|
|
3825
|
+
from: "incoming:failed",
|
|
3826
|
+
to: "incoming:idle",
|
|
3827
|
+
event: "INCOMING.CLEAR"
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
]
|
|
3831
|
+
},
|
|
3832
|
+
"INCOMING.RINGING": {
|
|
3833
|
+
target: "incoming:ringing",
|
|
3834
|
+
actions: [
|
|
3835
|
+
"rememberIncoming",
|
|
3836
|
+
{
|
|
3837
|
+
type: "logTransition",
|
|
3838
|
+
params: {
|
|
3839
|
+
from: "incoming:failed",
|
|
3840
|
+
to: "incoming:ringing",
|
|
3841
|
+
event: "INCOMING.RINGING"
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
]
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
});
|
|
3850
|
+
class Sn extends q {
|
|
3851
|
+
constructor({ incomingEvents: e, connectionEvents: t }) {
|
|
3852
|
+
super(Cn), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
|
|
3853
|
+
}
|
|
3854
|
+
get isIdle() {
|
|
3855
|
+
return this.state === "incoming:idle";
|
|
3856
|
+
}
|
|
3857
|
+
get isRinging() {
|
|
3858
|
+
return this.state === "incoming:ringing";
|
|
3859
|
+
}
|
|
3860
|
+
get isConsumed() {
|
|
3861
|
+
return this.state === "incoming:consumed";
|
|
3862
|
+
}
|
|
3863
|
+
get isDeclined() {
|
|
3864
|
+
return this.state === "incoming:declined";
|
|
3865
|
+
}
|
|
3866
|
+
get isTerminated() {
|
|
3867
|
+
return this.state === "incoming:terminated";
|
|
3868
|
+
}
|
|
3869
|
+
get isFailed() {
|
|
3870
|
+
return this.state === "incoming:failed";
|
|
3871
|
+
}
|
|
3872
|
+
get isActive() {
|
|
3873
|
+
return this.isRinging;
|
|
3874
|
+
}
|
|
3875
|
+
get isFinished() {
|
|
3876
|
+
return this.isConsumed || this.isDeclined || this.isTerminated || this.isFailed;
|
|
3877
|
+
}
|
|
3878
|
+
get remoteCallerData() {
|
|
3879
|
+
return this.getSnapshot().context.remoteCallerData;
|
|
3880
|
+
}
|
|
3881
|
+
get lastReason() {
|
|
3882
|
+
return this.getSnapshot().context.lastReason;
|
|
3883
|
+
}
|
|
3884
|
+
reset() {
|
|
3885
|
+
this.send({ type: "INCOMING.CLEAR" });
|
|
3886
|
+
}
|
|
3887
|
+
send(e) {
|
|
3888
|
+
if (!this.getSnapshot().can(e)) {
|
|
3889
|
+
console.warn(
|
|
3890
|
+
`[IncomingCallStateMachine] Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
|
|
3891
|
+
);
|
|
3892
|
+
return;
|
|
3893
|
+
}
|
|
3894
|
+
super.send(e);
|
|
3895
|
+
}
|
|
3896
|
+
toConsumed() {
|
|
3897
|
+
this.send({ type: "INCOMING.CONSUMED" });
|
|
3898
|
+
}
|
|
3899
|
+
subscribeIncomingEvents(e) {
|
|
3900
|
+
this.addSubscription(
|
|
3901
|
+
e.on("incomingCall", (t) => {
|
|
3902
|
+
this.send({ type: "INCOMING.RINGING", data: t });
|
|
3903
|
+
})
|
|
3904
|
+
), this.addSubscription(
|
|
3905
|
+
e.on("declinedIncomingCall", (t) => {
|
|
3906
|
+
this.send({ type: "INCOMING.DECLINED", data: t });
|
|
3907
|
+
})
|
|
3908
|
+
), this.addSubscription(
|
|
3909
|
+
e.on("terminatedIncomingCall", (t) => {
|
|
3910
|
+
this.send({ type: "INCOMING.TERMINATED", data: t });
|
|
3911
|
+
})
|
|
3912
|
+
), this.addSubscription(
|
|
3913
|
+
e.on("failedIncomingCall", (t) => {
|
|
3914
|
+
this.send({ type: "INCOMING.FAILED", data: t });
|
|
3915
|
+
})
|
|
3916
|
+
);
|
|
3917
|
+
}
|
|
3918
|
+
subscribeConnectionEvents(e) {
|
|
3919
|
+
this.addSubscription(
|
|
3920
|
+
e.on(S.DISCONNECTED, () => {
|
|
3921
|
+
this.toClearIncoming();
|
|
3922
|
+
})
|
|
3923
|
+
), this.addSubscription(
|
|
3924
|
+
e.on(S.REGISTRATION_FAILED, () => {
|
|
3925
|
+
this.toClearIncoming();
|
|
3926
|
+
})
|
|
3927
|
+
), this.addSubscription(
|
|
3928
|
+
e.on(S.CONNECT_FAILED, () => {
|
|
3929
|
+
this.toClearIncoming();
|
|
3930
|
+
})
|
|
3931
|
+
);
|
|
3932
|
+
}
|
|
3933
|
+
toClearIncoming() {
|
|
3934
|
+
this.send({ type: "INCOMING.CLEAR" });
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
const pn = 486, mn = 487;
|
|
3938
|
+
class Nn {
|
|
2790
3939
|
events;
|
|
3940
|
+
incomingStateMachine;
|
|
2791
3941
|
incomingRTCSession;
|
|
2792
3942
|
connectionManager;
|
|
2793
3943
|
constructor(e) {
|
|
2794
|
-
this.connectionManager = e, this.events =
|
|
3944
|
+
this.connectionManager = e, this.events = Tn(), this.incomingStateMachine = new Sn({
|
|
3945
|
+
incomingEvents: this.events,
|
|
3946
|
+
connectionEvents: this.connectionManager.events
|
|
3947
|
+
}), this.start();
|
|
3948
|
+
}
|
|
3949
|
+
get incomingActor() {
|
|
3950
|
+
return this.incomingStateMachine.actorRef;
|
|
2795
3951
|
}
|
|
2796
3952
|
get remoteCallerData() {
|
|
2797
3953
|
return {
|
|
@@ -2818,10 +3974,10 @@ class nn {
|
|
|
2818
3974
|
};
|
|
2819
3975
|
extractIncomingRTCSession = () => {
|
|
2820
3976
|
const e = this.getIncomingRTCSession();
|
|
2821
|
-
return this.removeIncomingSession(), e;
|
|
3977
|
+
return this.incomingStateMachine.toConsumed(), this.removeIncomingSession(), e;
|
|
2822
3978
|
};
|
|
2823
3979
|
async declineToIncomingCall({
|
|
2824
|
-
statusCode: e =
|
|
3980
|
+
statusCode: e = mn
|
|
2825
3981
|
} = {}) {
|
|
2826
3982
|
return new Promise((t, s) => {
|
|
2827
3983
|
try {
|
|
@@ -2833,7 +3989,7 @@ class nn {
|
|
|
2833
3989
|
});
|
|
2834
3990
|
}
|
|
2835
3991
|
async busyIncomingCall() {
|
|
2836
|
-
return this.declineToIncomingCall({ statusCode:
|
|
3992
|
+
return this.declineToIncomingCall({ statusCode: pn });
|
|
2837
3993
|
}
|
|
2838
3994
|
on(e, t) {
|
|
2839
3995
|
return this.events.on(e, t);
|
|
@@ -2873,41 +4029,91 @@ class nn {
|
|
|
2873
4029
|
delete this.incomingRTCSession;
|
|
2874
4030
|
}
|
|
2875
4031
|
}
|
|
2876
|
-
const
|
|
2877
|
-
|
|
2878
|
-
|
|
4032
|
+
const Rn = (n, e) => Object.is(n, e), se = (n) => ({
|
|
4033
|
+
connection: n.connection.getSnapshot(),
|
|
4034
|
+
call: n.call.getSnapshot(),
|
|
4035
|
+
incoming: n.incoming.getSnapshot(),
|
|
4036
|
+
presentation: n.presentation.getSnapshot()
|
|
4037
|
+
}), An = (n) => {
|
|
4038
|
+
const e = {
|
|
4039
|
+
connection: n.connectionManager.connectionActor,
|
|
4040
|
+
call: n.callManager.callActor,
|
|
4041
|
+
incoming: n.incomingCallManager.incomingActor,
|
|
4042
|
+
presentation: n.presentationManager.presentationActor
|
|
4043
|
+
};
|
|
4044
|
+
let t = se(e);
|
|
4045
|
+
const s = /* @__PURE__ */ new Set(), i = () => {
|
|
4046
|
+
t = se(e);
|
|
4047
|
+
for (const o of s) {
|
|
4048
|
+
const c = o.selector(t);
|
|
4049
|
+
o.equals(o.current, c) || (o.current = c, o.listener(c));
|
|
4050
|
+
}
|
|
4051
|
+
}, r = [
|
|
4052
|
+
e.connection.subscribe(i),
|
|
4053
|
+
e.call.subscribe(i),
|
|
4054
|
+
e.incoming.subscribe(i),
|
|
4055
|
+
e.presentation.subscribe(i)
|
|
4056
|
+
];
|
|
4057
|
+
function a(o, c, l) {
|
|
4058
|
+
const T = typeof c == "function", h = T ? o : (D) => D, u = T ? c : o, p = (T ? l : void 0) ?? Rn, A = h(t), N = {
|
|
4059
|
+
selector: h,
|
|
4060
|
+
listener: u,
|
|
4061
|
+
equals: p,
|
|
4062
|
+
current: A
|
|
4063
|
+
};
|
|
4064
|
+
return s.add(N), () => {
|
|
4065
|
+
s.delete(N);
|
|
4066
|
+
};
|
|
4067
|
+
}
|
|
4068
|
+
return {
|
|
4069
|
+
actor: e,
|
|
4070
|
+
actors: e,
|
|
4071
|
+
getSnapshot: () => t,
|
|
4072
|
+
subscribe: a,
|
|
4073
|
+
stop: () => {
|
|
4074
|
+
s.clear(), r.forEach((o) => {
|
|
4075
|
+
o.unsubscribe();
|
|
4076
|
+
});
|
|
4077
|
+
}
|
|
4078
|
+
};
|
|
4079
|
+
}, w = 1e3;
|
|
4080
|
+
var m = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", n.MEDIA_SOURCE = "media-source", n.OUTBOUND_RTP = "outbound-rtp", n.REMOTE_INBOUND_RTP = "remote-inbound-rtp", n.CODEC = "codec", n.CANDIDATE_PAIR = "candidate-pair", n.CERTIFICATE = "certificate", n.TRANSPORT = "transport", n.LOCAL_CANDIDATE = "local-candidate", n.REMOTE_CANDIDATE = "remote-candidate", n))(m || {});
|
|
4081
|
+
const _e = ["collected"], In = () => new M(_e), fn = "api/v2/rtp2webrtc/offer", Mn = async ({
|
|
2879
4082
|
serverUrl: n,
|
|
2880
4083
|
conferenceNumber: e,
|
|
2881
4084
|
quality: t,
|
|
2882
4085
|
audio: s,
|
|
2883
|
-
offer: i
|
|
4086
|
+
offer: i,
|
|
4087
|
+
token: r
|
|
2884
4088
|
}) => {
|
|
2885
|
-
const
|
|
2886
|
-
`https://${n.replace(/\/$/, "")}/${
|
|
4089
|
+
const a = new URL(
|
|
4090
|
+
`https://${n.replace(/\/$/, "")}/${fn}/${encodeURIComponent(e)}`
|
|
2887
4091
|
);
|
|
2888
|
-
|
|
2889
|
-
const
|
|
4092
|
+
a.searchParams.set("quality", t), a.searchParams.set("audio", String(s));
|
|
4093
|
+
const o = {
|
|
4094
|
+
"Content-Type": "application/json"
|
|
4095
|
+
};
|
|
4096
|
+
r !== void 0 && r !== "" && (o.Authorization = `Bearer ${r}`);
|
|
4097
|
+
const c = await fetch(a.toString(), {
|
|
2890
4098
|
method: "POST",
|
|
2891
|
-
headers:
|
|
2892
|
-
"Content-Type": "application/json"
|
|
2893
|
-
},
|
|
4099
|
+
headers: o,
|
|
2894
4100
|
credentials: "same-origin",
|
|
2895
4101
|
body: JSON.stringify(i)
|
|
2896
4102
|
});
|
|
2897
|
-
if (!
|
|
2898
|
-
throw new Error(`sendOffer failed with status ${
|
|
2899
|
-
const
|
|
4103
|
+
if (!c.ok)
|
|
4104
|
+
throw new Error(`sendOffer failed with status ${c.status}`);
|
|
4105
|
+
const l = await c.json();
|
|
2900
4106
|
return {
|
|
2901
|
-
type:
|
|
2902
|
-
sdp:
|
|
4107
|
+
type: l.type,
|
|
4108
|
+
sdp: l.sdp,
|
|
2903
4109
|
toJSON() {
|
|
2904
|
-
return
|
|
4110
|
+
return l;
|
|
2905
4111
|
}
|
|
2906
4112
|
};
|
|
2907
|
-
},
|
|
4113
|
+
}, ie = () => "performance" in window ? performance.now() : Date.now(), F = (n) => [...n.keys()].reduce((e, t) => {
|
|
2908
4114
|
const s = n.get(t);
|
|
2909
4115
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2910
|
-
}, {}),
|
|
4116
|
+
}, {}), vn = (n) => {
|
|
2911
4117
|
if (!n)
|
|
2912
4118
|
return {
|
|
2913
4119
|
outboundRtp: void 0,
|
|
@@ -2915,14 +4121,14 @@ const Ne = ["collected"], sn = () => new M(Ne), rn = "api/v2/rtp2webrtc/offer",
|
|
|
2915
4121
|
mediaSource: void 0,
|
|
2916
4122
|
remoteInboundRtp: void 0
|
|
2917
4123
|
};
|
|
2918
|
-
const e =
|
|
4124
|
+
const e = F(n);
|
|
2919
4125
|
return {
|
|
2920
|
-
outboundRtp: e[
|
|
2921
|
-
codec: e[
|
|
2922
|
-
mediaSource: e[
|
|
2923
|
-
remoteInboundRtp: e[
|
|
4126
|
+
outboundRtp: e[m.OUTBOUND_RTP],
|
|
4127
|
+
codec: e[m.CODEC],
|
|
4128
|
+
mediaSource: e[m.MEDIA_SOURCE],
|
|
4129
|
+
remoteInboundRtp: e[m.REMOTE_INBOUND_RTP]
|
|
2924
4130
|
};
|
|
2925
|
-
},
|
|
4131
|
+
}, re = (n) => {
|
|
2926
4132
|
if (!n)
|
|
2927
4133
|
return {
|
|
2928
4134
|
outboundRtp: void 0,
|
|
@@ -2930,14 +4136,14 @@ const Ne = ["collected"], sn = () => new M(Ne), rn = "api/v2/rtp2webrtc/offer",
|
|
|
2930
4136
|
mediaSource: void 0,
|
|
2931
4137
|
remoteInboundRtp: void 0
|
|
2932
4138
|
};
|
|
2933
|
-
const e =
|
|
4139
|
+
const e = F(n);
|
|
2934
4140
|
return {
|
|
2935
|
-
outboundRtp: e[
|
|
2936
|
-
codec: e[
|
|
2937
|
-
mediaSource: e[
|
|
2938
|
-
remoteInboundRtp: e[
|
|
4141
|
+
outboundRtp: e[m.OUTBOUND_RTP],
|
|
4142
|
+
codec: e[m.CODEC],
|
|
4143
|
+
mediaSource: e[m.MEDIA_SOURCE],
|
|
4144
|
+
remoteInboundRtp: e[m.REMOTE_INBOUND_RTP]
|
|
2939
4145
|
};
|
|
2940
|
-
},
|
|
4146
|
+
}, ae = ({
|
|
2941
4147
|
videoReceiversStats: n,
|
|
2942
4148
|
synchronizationSourcesVideo: e
|
|
2943
4149
|
}) => {
|
|
@@ -2947,13 +4153,13 @@ const Ne = ["collected"], sn = () => new M(Ne), rn = "api/v2/rtp2webrtc/offer",
|
|
|
2947
4153
|
codec: void 0,
|
|
2948
4154
|
synchronizationSources: e
|
|
2949
4155
|
};
|
|
2950
|
-
const t =
|
|
4156
|
+
const t = F(n);
|
|
2951
4157
|
return {
|
|
2952
|
-
inboundRtp: t[
|
|
2953
|
-
codec: t[
|
|
4158
|
+
inboundRtp: t[m.INBOUND_RTP],
|
|
4159
|
+
codec: t[m.CODEC],
|
|
2954
4160
|
synchronizationSources: e
|
|
2955
4161
|
};
|
|
2956
|
-
},
|
|
4162
|
+
}, _n = ({
|
|
2957
4163
|
audioReceiverStats: n,
|
|
2958
4164
|
synchronizationSourcesAudio: e
|
|
2959
4165
|
}) => {
|
|
@@ -2964,14 +4170,14 @@ const Ne = ["collected"], sn = () => new M(Ne), rn = "api/v2/rtp2webrtc/offer",
|
|
|
2964
4170
|
remoteOutboundRtp: void 0,
|
|
2965
4171
|
synchronizationSources: e
|
|
2966
4172
|
};
|
|
2967
|
-
const t =
|
|
4173
|
+
const t = F(n);
|
|
2968
4174
|
return {
|
|
2969
|
-
inboundRtp: t[
|
|
2970
|
-
codec: t[
|
|
2971
|
-
remoteOutboundRtp: t[
|
|
4175
|
+
inboundRtp: t[m.INBOUND_RTP],
|
|
4176
|
+
codec: t[m.CODEC],
|
|
4177
|
+
remoteOutboundRtp: t[m.REMOTE_OUTBOUND_RTP],
|
|
2972
4178
|
synchronizationSources: e
|
|
2973
4179
|
};
|
|
2974
|
-
},
|
|
4180
|
+
}, Oe = (n) => {
|
|
2975
4181
|
if (!n)
|
|
2976
4182
|
return {
|
|
2977
4183
|
candidatePair: void 0,
|
|
@@ -2980,47 +4186,47 @@ const Ne = ["collected"], sn = () => new M(Ne), rn = "api/v2/rtp2webrtc/offer",
|
|
|
2980
4186
|
remoteCandidate: void 0,
|
|
2981
4187
|
transport: void 0
|
|
2982
4188
|
};
|
|
2983
|
-
const e =
|
|
4189
|
+
const e = F(n);
|
|
2984
4190
|
return {
|
|
2985
|
-
candidatePair: e[
|
|
2986
|
-
certificate: e[
|
|
2987
|
-
localCandidate: e[
|
|
2988
|
-
remoteCandidate: e[
|
|
2989
|
-
transport: e[
|
|
4191
|
+
candidatePair: e[m.CANDIDATE_PAIR],
|
|
4192
|
+
certificate: e[m.CERTIFICATE],
|
|
4193
|
+
localCandidate: e[m.LOCAL_CANDIDATE],
|
|
4194
|
+
remoteCandidate: e[m.REMOTE_CANDIDATE],
|
|
4195
|
+
transport: e[m.TRANSPORT]
|
|
2990
4196
|
};
|
|
2991
|
-
},
|
|
4197
|
+
}, On = ({
|
|
2992
4198
|
audioSenderStats: n,
|
|
2993
4199
|
videoSenderFirstStats: e,
|
|
2994
4200
|
videoSenderSecondStats: t
|
|
2995
4201
|
}) => ({
|
|
2996
|
-
video:
|
|
2997
|
-
secondVideo:
|
|
2998
|
-
audio:
|
|
2999
|
-
additional:
|
|
4202
|
+
video: re(e),
|
|
4203
|
+
secondVideo: re(t),
|
|
4204
|
+
audio: vn(n),
|
|
4205
|
+
additional: Oe(
|
|
3000
4206
|
n ?? e ?? t
|
|
3001
4207
|
)
|
|
3002
|
-
}),
|
|
4208
|
+
}), Pn = ({
|
|
3003
4209
|
audioReceiverStats: n,
|
|
3004
4210
|
videoReceiverFirstStats: e,
|
|
3005
4211
|
videoReceiverSecondStats: t,
|
|
3006
4212
|
synchronizationSources: s
|
|
3007
4213
|
}) => ({
|
|
3008
|
-
video:
|
|
4214
|
+
video: ae({
|
|
3009
4215
|
videoReceiversStats: e,
|
|
3010
4216
|
synchronizationSourcesVideo: s.video
|
|
3011
4217
|
}),
|
|
3012
|
-
secondVideo:
|
|
4218
|
+
secondVideo: ae({
|
|
3013
4219
|
videoReceiversStats: t,
|
|
3014
4220
|
synchronizationSourcesVideo: s.video
|
|
3015
4221
|
}),
|
|
3016
|
-
audio:
|
|
4222
|
+
audio: _n({
|
|
3017
4223
|
audioReceiverStats: n,
|
|
3018
4224
|
synchronizationSourcesAudio: s.audio
|
|
3019
4225
|
}),
|
|
3020
|
-
additional:
|
|
4226
|
+
additional: Oe(
|
|
3021
4227
|
n ?? e ?? t
|
|
3022
4228
|
)
|
|
3023
|
-
}),
|
|
4229
|
+
}), bn = ({
|
|
3024
4230
|
audioSenderStats: n,
|
|
3025
4231
|
videoSenderFirstStats: e,
|
|
3026
4232
|
videoSenderSecondStats: t,
|
|
@@ -3029,11 +4235,11 @@ const Ne = ["collected"], sn = () => new M(Ne), rn = "api/v2/rtp2webrtc/offer",
|
|
|
3029
4235
|
videoReceiverSecondStats: r,
|
|
3030
4236
|
synchronizationSources: a
|
|
3031
4237
|
}) => {
|
|
3032
|
-
const o =
|
|
4238
|
+
const o = On({
|
|
3033
4239
|
audioSenderStats: n,
|
|
3034
4240
|
videoSenderFirstStats: e,
|
|
3035
4241
|
videoSenderSecondStats: t
|
|
3036
|
-
}), c =
|
|
4242
|
+
}), c = Pn({
|
|
3037
4243
|
audioReceiverStats: s,
|
|
3038
4244
|
videoReceiverFirstStats: i,
|
|
3039
4245
|
videoReceiverSecondStats: r,
|
|
@@ -3043,16 +4249,16 @@ const Ne = ["collected"], sn = () => new M(Ne), rn = "api/v2/rtp2webrtc/offer",
|
|
|
3043
4249
|
outbound: o,
|
|
3044
4250
|
inbound: c
|
|
3045
4251
|
};
|
|
3046
|
-
},
|
|
3047
|
-
const e = "audio", t = "video", s = n.getSenders(), i = s.find((
|
|
4252
|
+
}, Dn = async (n) => {
|
|
4253
|
+
const e = "audio", t = "video", s = n.getSenders(), i = s.find((u) => u.track?.kind === e), r = s.filter((u) => u.track?.kind === t), a = n.getReceivers(), o = a.find((u) => u.track.kind === e), c = a.filter((u) => u.track.kind === t), l = {
|
|
3048
4254
|
trackIdentifier: o?.track.id,
|
|
3049
4255
|
item: o?.getSynchronizationSources()[0]
|
|
3050
|
-
},
|
|
4256
|
+
}, T = {
|
|
3051
4257
|
trackIdentifier: c[0]?.track.id,
|
|
3052
4258
|
item: c[0]?.getSynchronizationSources()[0]
|
|
3053
|
-
},
|
|
3054
|
-
audio:
|
|
3055
|
-
video:
|
|
4259
|
+
}, h = {
|
|
4260
|
+
audio: l,
|
|
4261
|
+
video: T
|
|
3056
4262
|
};
|
|
3057
4263
|
return Promise.all([
|
|
3058
4264
|
i?.getStats() ?? Promise.resolve(void 0),
|
|
@@ -3061,41 +4267,41 @@ const Ne = ["collected"], sn = () => new M(Ne), rn = "api/v2/rtp2webrtc/offer",
|
|
|
3061
4267
|
o?.getStats() ?? Promise.resolve(void 0),
|
|
3062
4268
|
c[0]?.getStats() ?? Promise.resolve(void 0),
|
|
3063
4269
|
c[1]?.getStats() ?? Promise.resolve(void 0)
|
|
3064
|
-
]).then((
|
|
4270
|
+
]).then((u) => {
|
|
3065
4271
|
const [
|
|
3066
4272
|
p,
|
|
3067
|
-
P,
|
|
3068
4273
|
A,
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
4274
|
+
N,
|
|
4275
|
+
D,
|
|
4276
|
+
V,
|
|
4277
|
+
we
|
|
4278
|
+
] = u;
|
|
3073
4279
|
return {
|
|
3074
|
-
synchronizationSources:
|
|
4280
|
+
synchronizationSources: h,
|
|
3075
4281
|
audioSenderStats: p,
|
|
3076
|
-
videoSenderFirstStats:
|
|
3077
|
-
videoSenderSecondStats:
|
|
3078
|
-
audioReceiverStats:
|
|
3079
|
-
videoReceiverFirstStats:
|
|
3080
|
-
videoReceiverSecondStats:
|
|
4282
|
+
videoSenderFirstStats: A,
|
|
4283
|
+
videoSenderSecondStats: N,
|
|
4284
|
+
audioReceiverStats: D,
|
|
4285
|
+
videoReceiverFirstStats: V,
|
|
4286
|
+
videoReceiverSecondStats: we
|
|
3081
4287
|
};
|
|
3082
4288
|
});
|
|
3083
|
-
},
|
|
3084
|
-
|
|
4289
|
+
}, yn = (n) => {
|
|
4290
|
+
d(String(n));
|
|
3085
4291
|
};
|
|
3086
|
-
class
|
|
4292
|
+
class Ln {
|
|
3087
4293
|
events;
|
|
3088
4294
|
setTimeoutRequest;
|
|
3089
|
-
requesterAllStatistics = new
|
|
4295
|
+
requesterAllStatistics = new G(Dn);
|
|
3090
4296
|
constructor() {
|
|
3091
|
-
this.events =
|
|
4297
|
+
this.events = In(), this.setTimeoutRequest = new ce();
|
|
3092
4298
|
}
|
|
3093
4299
|
get requested() {
|
|
3094
4300
|
return this.setTimeoutRequest.requested;
|
|
3095
4301
|
}
|
|
3096
4302
|
start(e, {
|
|
3097
4303
|
interval: t = w,
|
|
3098
|
-
onError: s =
|
|
4304
|
+
onError: s = yn
|
|
3099
4305
|
} = {}) {
|
|
3100
4306
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
3101
4307
|
this.collectStatistics(e, {
|
|
@@ -3124,10 +4330,10 @@ class Tn {
|
|
|
3124
4330
|
collectStatistics = (e, {
|
|
3125
4331
|
onError: t
|
|
3126
4332
|
}) => {
|
|
3127
|
-
const s =
|
|
4333
|
+
const s = ie();
|
|
3128
4334
|
this.requesterAllStatistics.request(e).then((i) => {
|
|
3129
|
-
this.events.trigger("collected",
|
|
3130
|
-
const a =
|
|
4335
|
+
this.events.trigger("collected", bn(i));
|
|
4336
|
+
const a = ie() - s;
|
|
3131
4337
|
let o = w;
|
|
3132
4338
|
a > 48 ? o = w * 4 : a > 32 ? o = w * 3 : a > 16 && (o = w * 2), this.start(e, {
|
|
3133
4339
|
onError: t,
|
|
@@ -3138,7 +4344,7 @@ class Tn {
|
|
|
3138
4344
|
});
|
|
3139
4345
|
};
|
|
3140
4346
|
}
|
|
3141
|
-
class
|
|
4347
|
+
class wn {
|
|
3142
4348
|
statsPeerConnection;
|
|
3143
4349
|
availableStats;
|
|
3144
4350
|
previousAvailableStats;
|
|
@@ -3148,7 +4354,7 @@ class Sn {
|
|
|
3148
4354
|
callManager: e,
|
|
3149
4355
|
apiManager: t
|
|
3150
4356
|
}) {
|
|
3151
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
4357
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Ln(), this.subscribe();
|
|
3152
4358
|
}
|
|
3153
4359
|
get events() {
|
|
3154
4360
|
return this.statsPeerConnection.events;
|
|
@@ -3221,37 +4427,37 @@ class Sn {
|
|
|
3221
4427
|
};
|
|
3222
4428
|
maybeSendStats() {
|
|
3223
4429
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
3224
|
-
|
|
4430
|
+
d("Failed to send stats", e);
|
|
3225
4431
|
});
|
|
3226
4432
|
}
|
|
3227
4433
|
}
|
|
3228
|
-
const
|
|
4434
|
+
const Un = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), Fn = (n) => {
|
|
3229
4435
|
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
|
|
3230
|
-
return
|
|
3231
|
-
},
|
|
4436
|
+
return Un(s, i);
|
|
4437
|
+
}, Bn = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
3232
4438
|
const i = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), a = i === -1 ? Number.MAX_VALUE : i, o = r === -1 ? Number.MAX_VALUE : r;
|
|
3233
4439
|
return a - o;
|
|
3234
|
-
}),
|
|
4440
|
+
}), kn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Gn = (n, {
|
|
3235
4441
|
preferredMimeTypesVideoCodecs: e,
|
|
3236
4442
|
excludeMimeTypesVideoCodecs: t
|
|
3237
4443
|
}) => {
|
|
3238
4444
|
try {
|
|
3239
4445
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
3240
|
-
const s =
|
|
4446
|
+
const s = Fn("video"), i = kn(s, t), r = Bn(i, e);
|
|
3241
4447
|
n.setCodecPreferences(r);
|
|
3242
4448
|
}
|
|
3243
4449
|
} catch (s) {
|
|
3244
|
-
|
|
4450
|
+
d("setCodecPreferences error", s);
|
|
3245
4451
|
}
|
|
3246
|
-
},
|
|
3247
|
-
class
|
|
4452
|
+
}, $n = (n) => [...n.keys()].map((e) => n.get(e)), qn = (n, e) => $n(n).find((t) => t?.type === e), Vn = async (n) => n.getStats().then((e) => qn(e, "codec")?.mimeType);
|
|
4453
|
+
class Hn {
|
|
3248
4454
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
3249
4455
|
async getCodecFromSender(e) {
|
|
3250
|
-
return await
|
|
4456
|
+
return await Vn(e) ?? "";
|
|
3251
4457
|
}
|
|
3252
4458
|
}
|
|
3253
|
-
class
|
|
3254
|
-
stackPromises =
|
|
4459
|
+
class Wn {
|
|
4460
|
+
stackPromises = le({
|
|
3255
4461
|
noRunIsNotActual: !0
|
|
3256
4462
|
});
|
|
3257
4463
|
/**
|
|
@@ -3271,34 +4477,34 @@ class _n {
|
|
|
3271
4477
|
*/
|
|
3272
4478
|
async run() {
|
|
3273
4479
|
return this.stackPromises().catch((e) => {
|
|
3274
|
-
|
|
4480
|
+
d("TaskQueue: error", e);
|
|
3275
4481
|
});
|
|
3276
4482
|
}
|
|
3277
4483
|
}
|
|
3278
|
-
class
|
|
4484
|
+
class xn {
|
|
3279
4485
|
taskQueue;
|
|
3280
4486
|
onSetParameters;
|
|
3281
4487
|
constructor(e) {
|
|
3282
|
-
this.onSetParameters = e, this.taskQueue = new
|
|
4488
|
+
this.onSetParameters = e, this.taskQueue = new Wn();
|
|
3283
4489
|
}
|
|
3284
4490
|
async setEncodingsToSender(e, t) {
|
|
3285
|
-
return this.taskQueue.add(async () =>
|
|
4491
|
+
return this.taskQueue.add(async () => pe(e, t, this.onSetParameters));
|
|
3286
4492
|
}
|
|
3287
4493
|
stop() {
|
|
3288
4494
|
this.taskQueue.stop();
|
|
3289
4495
|
}
|
|
3290
4496
|
}
|
|
3291
|
-
const
|
|
3292
|
-
const t =
|
|
3293
|
-
return
|
|
3294
|
-
},
|
|
4497
|
+
const Pe = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Qn = 1e6, v = (n) => n * Qn, be = v(0.06), De = v(4), Yn = (n) => n <= 64 ? be : n <= 128 ? v(0.12) : n <= 256 ? v(0.25) : n <= 384 ? v(0.32) : n <= 426 ? v(0.38) : n <= 640 ? v(0.5) : n <= 848 ? v(0.7) : n <= 1280 ? v(1) : n <= 1920 ? v(2) : De, zn = "av1", Xn = (n) => Pe(n, zn), Jn = 0.6, j = (n, e) => Xn(e) ? n * Jn : n, Kn = (n) => j(be, n), jn = (n) => j(De, n), oe = (n, e) => {
|
|
4498
|
+
const t = Yn(n);
|
|
4499
|
+
return j(t, e);
|
|
4500
|
+
}, W = 1, Zn = ({
|
|
3295
4501
|
videoTrack: n,
|
|
3296
4502
|
targetSize: e
|
|
3297
4503
|
}) => {
|
|
3298
|
-
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ?
|
|
3299
|
-
return Math.max(r, a,
|
|
4504
|
+
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? W : s / e.width, a = i === void 0 ? W : i / e.height;
|
|
4505
|
+
return Math.max(r, a, W);
|
|
3300
4506
|
};
|
|
3301
|
-
class
|
|
4507
|
+
class es {
|
|
3302
4508
|
ignoreForCodec;
|
|
3303
4509
|
senderFinder;
|
|
3304
4510
|
codecProvider;
|
|
@@ -3331,7 +4537,7 @@ class Ln {
|
|
|
3331
4537
|
if (!i?.track)
|
|
3332
4538
|
return { ...this.resultNoChanged, sender: i };
|
|
3333
4539
|
const r = await this.codecProvider.getCodecFromSender(i);
|
|
3334
|
-
if (
|
|
4540
|
+
if (Pe(r, this.ignoreForCodec))
|
|
3335
4541
|
return { ...this.resultNoChanged, sender: i };
|
|
3336
4542
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
3337
4543
|
return this.processSender(
|
|
@@ -3373,7 +4579,7 @@ class Ln {
|
|
|
3373
4579
|
async downgradeResolutionSender(e) {
|
|
3374
4580
|
const { sender: t, codec: s } = e, i = {
|
|
3375
4581
|
scaleResolutionDownBy: 200,
|
|
3376
|
-
maxBitrate:
|
|
4582
|
+
maxBitrate: Kn(s)
|
|
3377
4583
|
};
|
|
3378
4584
|
return this.parametersSetter.setEncodingsToSender(t, i);
|
|
3379
4585
|
}
|
|
@@ -3383,7 +4589,7 @@ class Ln {
|
|
|
3383
4589
|
* @returns Promise с результатом
|
|
3384
4590
|
*/
|
|
3385
4591
|
async setBitrateByTrackResolution(e) {
|
|
3386
|
-
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ?
|
|
4592
|
+
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? jn(i) : oe(a, i);
|
|
3387
4593
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
3388
4594
|
scaleResolutionDownBy: 1,
|
|
3389
4595
|
maxBitrate: o
|
|
@@ -3399,24 +4605,24 @@ class Ln {
|
|
|
3399
4605
|
const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
|
|
3400
4606
|
width: Number(s),
|
|
3401
4607
|
height: Number(i)
|
|
3402
|
-
},
|
|
4608
|
+
}, l = Zn({
|
|
3403
4609
|
videoTrack: a,
|
|
3404
4610
|
targetSize: c
|
|
3405
|
-
}),
|
|
3406
|
-
scaleResolutionDownBy:
|
|
3407
|
-
maxBitrate:
|
|
4611
|
+
}), T = oe(c.width, o), h = {
|
|
4612
|
+
scaleResolutionDownBy: l,
|
|
4613
|
+
maxBitrate: T
|
|
3408
4614
|
};
|
|
3409
|
-
return this.parametersSetter.setEncodingsToSender(r,
|
|
4615
|
+
return this.parametersSetter.setEncodingsToSender(r, h);
|
|
3410
4616
|
}
|
|
3411
4617
|
}
|
|
3412
|
-
const
|
|
3413
|
-
class
|
|
4618
|
+
const ts = (n) => n.find((e) => e.track?.kind === "video");
|
|
4619
|
+
class ns {
|
|
3414
4620
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
3415
4621
|
findVideoSender(e) {
|
|
3416
|
-
return
|
|
4622
|
+
return ts(e);
|
|
3417
4623
|
}
|
|
3418
4624
|
}
|
|
3419
|
-
class
|
|
4625
|
+
class ss {
|
|
3420
4626
|
currentSender;
|
|
3421
4627
|
originalReplaceTrack;
|
|
3422
4628
|
lastWidth;
|
|
@@ -3429,7 +4635,7 @@ class kn {
|
|
|
3429
4635
|
pollIntervalMs: e = 1e3,
|
|
3430
4636
|
maxPollIntervalMs: t
|
|
3431
4637
|
}) {
|
|
3432
|
-
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new
|
|
4638
|
+
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ce();
|
|
3433
4639
|
}
|
|
3434
4640
|
/**
|
|
3435
4641
|
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
@@ -3480,7 +4686,7 @@ class kn {
|
|
|
3480
4686
|
this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
|
|
3481
4687
|
}
|
|
3482
4688
|
}
|
|
3483
|
-
class
|
|
4689
|
+
class is {
|
|
3484
4690
|
apiManager;
|
|
3485
4691
|
currentHandler;
|
|
3486
4692
|
constructor(e) {
|
|
@@ -3500,7 +4706,7 @@ class $n {
|
|
|
3500
4706
|
this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
3501
4707
|
}
|
|
3502
4708
|
}
|
|
3503
|
-
class
|
|
4709
|
+
class rs {
|
|
3504
4710
|
eventHandler;
|
|
3505
4711
|
senderBalancer;
|
|
3506
4712
|
parametersSetterWithQueue;
|
|
@@ -3512,16 +4718,16 @@ class qn {
|
|
|
3512
4718
|
onSetParameters: i,
|
|
3513
4719
|
pollIntervalMs: r
|
|
3514
4720
|
} = {}) {
|
|
3515
|
-
this.getConnection = t, this.eventHandler = new
|
|
4721
|
+
this.getConnection = t, this.eventHandler = new is(e), this.parametersSetterWithQueue = new xn(i), this.senderBalancer = new es(
|
|
3516
4722
|
{
|
|
3517
|
-
senderFinder: new
|
|
3518
|
-
codecProvider: new
|
|
4723
|
+
senderFinder: new ns(),
|
|
4724
|
+
codecProvider: new Hn(),
|
|
3519
4725
|
parametersSetter: this.parametersSetterWithQueue
|
|
3520
4726
|
},
|
|
3521
4727
|
{
|
|
3522
4728
|
ignoreForCodec: s
|
|
3523
4729
|
}
|
|
3524
|
-
), this.trackMonitor = new
|
|
4730
|
+
), this.trackMonitor = new ss({ pollIntervalMs: r });
|
|
3525
4731
|
}
|
|
3526
4732
|
/**
|
|
3527
4733
|
* Подписывается на события управления главной камерой
|
|
@@ -3552,7 +4758,7 @@ class qn {
|
|
|
3552
4758
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
3553
4759
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
3554
4760
|
this.balance().catch((s) => {
|
|
3555
|
-
|
|
4761
|
+
d("balance on track change: error", s);
|
|
3556
4762
|
});
|
|
3557
4763
|
}), t;
|
|
3558
4764
|
}
|
|
@@ -3562,17 +4768,17 @@ class qn {
|
|
|
3562
4768
|
*/
|
|
3563
4769
|
handleMainCamControl = (e) => {
|
|
3564
4770
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
3565
|
-
|
|
4771
|
+
d("handleMainCamControl: error", t);
|
|
3566
4772
|
});
|
|
3567
4773
|
};
|
|
3568
4774
|
}
|
|
3569
|
-
const
|
|
4775
|
+
const ye = [
|
|
3570
4776
|
"balancing-scheduled",
|
|
3571
4777
|
"balancing-started",
|
|
3572
4778
|
"balancing-stopped",
|
|
3573
4779
|
"parameters-updated"
|
|
3574
|
-
],
|
|
3575
|
-
class
|
|
4780
|
+
], as = () => new M(ye);
|
|
4781
|
+
class os {
|
|
3576
4782
|
isBalancingActive = !1;
|
|
3577
4783
|
events;
|
|
3578
4784
|
callManager;
|
|
@@ -3580,7 +4786,7 @@ class Hn {
|
|
|
3580
4786
|
videoSendingBalancer;
|
|
3581
4787
|
startBalancingTimer;
|
|
3582
4788
|
constructor(e, t, s = {}) {
|
|
3583
|
-
this.events =
|
|
4789
|
+
this.events = as(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new rs(
|
|
3584
4790
|
t,
|
|
3585
4791
|
() => e.connection,
|
|
3586
4792
|
{
|
|
@@ -3642,7 +4848,7 @@ class Hn {
|
|
|
3642
4848
|
scheduleBalancingStart() {
|
|
3643
4849
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
3644
4850
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
3645
|
-
|
|
4851
|
+
d("startBalancing: error", e);
|
|
3646
4852
|
});
|
|
3647
4853
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
3648
4854
|
}
|
|
@@ -3650,13 +4856,13 @@ class Hn {
|
|
|
3650
4856
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
3651
4857
|
}
|
|
3652
4858
|
}
|
|
3653
|
-
const
|
|
3654
|
-
class
|
|
4859
|
+
const Le = "no-inbound-frames", cs = [Le], ds = () => new M(cs);
|
|
4860
|
+
class ls {
|
|
3655
4861
|
events;
|
|
3656
4862
|
statsManager;
|
|
3657
4863
|
callManager;
|
|
3658
4864
|
constructor(e, t) {
|
|
3659
|
-
this.statsManager = e, this.callManager = t, this.events =
|
|
4865
|
+
this.statsManager = e, this.callManager = t, this.events = ds(), this.subscribe();
|
|
3660
4866
|
}
|
|
3661
4867
|
get mainVideoTrack() {
|
|
3662
4868
|
return this.callManager.getMainStream()?.getVideoTracks()[0];
|
|
@@ -3669,36 +4875,36 @@ class xn {
|
|
|
3669
4875
|
return this.events.on(e, t);
|
|
3670
4876
|
}
|
|
3671
4877
|
handleStatsCollected = () => {
|
|
3672
|
-
this.hasNoIncomingFrames() && this.events.trigger(
|
|
4878
|
+
this.hasNoIncomingFrames() && this.events.trigger(Le, {});
|
|
3673
4879
|
};
|
|
3674
4880
|
hasNoIncomingFrames = () => this.statsManager.isNotValidFramesStats && this.isMutedMainVideoTrack;
|
|
3675
4881
|
subscribe() {
|
|
3676
4882
|
this.statsManager.on("collected", this.handleStatsCollected);
|
|
3677
4883
|
}
|
|
3678
4884
|
}
|
|
3679
|
-
const
|
|
3680
|
-
class
|
|
4885
|
+
const hs = 3e3;
|
|
4886
|
+
class gs {
|
|
3681
4887
|
renegotiateRequester;
|
|
3682
4888
|
renegotiateThrottled;
|
|
3683
4889
|
callManager;
|
|
3684
|
-
constructor(e, t =
|
|
3685
|
-
this.callManager = e, this.renegotiateRequester = new
|
|
4890
|
+
constructor(e, t = hs) {
|
|
4891
|
+
this.callManager = e, this.renegotiateRequester = new G(e.renegotiate.bind(e)), this.renegotiateThrottled = He.throttle(
|
|
3686
4892
|
this.requestRenegotiate.bind(this),
|
|
3687
4893
|
t
|
|
3688
4894
|
), this.subscribe();
|
|
3689
4895
|
}
|
|
3690
4896
|
recover() {
|
|
3691
|
-
|
|
4897
|
+
d("trying to recover main stream"), this.renegotiateThrottled();
|
|
3692
4898
|
}
|
|
3693
4899
|
requestRenegotiate = () => {
|
|
3694
|
-
if (
|
|
3695
|
-
|
|
4900
|
+
if (d("trying to renegotiate"), this.renegotiateRequester.requested) {
|
|
4901
|
+
d("previous renegotiate is not finished yet");
|
|
3696
4902
|
return;
|
|
3697
4903
|
}
|
|
3698
4904
|
this.renegotiateRequester.request().then(() => {
|
|
3699
|
-
|
|
4905
|
+
d("renegotiate has successful");
|
|
3700
4906
|
}).catch((e) => {
|
|
3701
|
-
|
|
4907
|
+
d("failed to renegotiate main media stream", e);
|
|
3702
4908
|
});
|
|
3703
4909
|
};
|
|
3704
4910
|
subscribe() {
|
|
@@ -3707,28 +4913,29 @@ class Yn {
|
|
|
3707
4913
|
});
|
|
3708
4914
|
}
|
|
3709
4915
|
cancel() {
|
|
3710
|
-
|
|
4916
|
+
d("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
|
|
3711
4917
|
}
|
|
3712
4918
|
}
|
|
3713
|
-
const
|
|
4919
|
+
const us = 1e6, Ts = Me.map((n) => `auto-connect:${n}`), Es = Re.map((n) => `connection:${n}`), Cs = ue.map((n) => `call:${n}`), Ss = he.map((n) => `api:${n}`), ps = ve.map((n) => `incoming-call:${n}`), ms = me.map((n) => `presentation:${n}`), Ns = _e.map((n) => `stats:${n}`), Rs = ye.map((n) => `video-balancer:${n}`), As = [
|
|
3714
4920
|
"disconnected-from-out-of-call",
|
|
3715
4921
|
"connected-with-configuration-from-out-of-call",
|
|
3716
4922
|
"stopped-presentation-by-server-command"
|
|
3717
|
-
],
|
|
3718
|
-
...
|
|
3719
|
-
...
|
|
3720
|
-
...
|
|
3721
|
-
...
|
|
3722
|
-
...
|
|
3723
|
-
...
|
|
3724
|
-
...
|
|
3725
|
-
...
|
|
3726
|
-
...
|
|
3727
|
-
],
|
|
3728
|
-
class
|
|
4923
|
+
], Is = [
|
|
4924
|
+
...Ts,
|
|
4925
|
+
...Es,
|
|
4926
|
+
...Cs,
|
|
4927
|
+
...Ss,
|
|
4928
|
+
...ps,
|
|
4929
|
+
...ms,
|
|
4930
|
+
...Ns,
|
|
4931
|
+
...Rs,
|
|
4932
|
+
...As
|
|
4933
|
+
], fs = () => new M(Is);
|
|
4934
|
+
class ks {
|
|
3729
4935
|
events;
|
|
3730
4936
|
connectionManager;
|
|
3731
4937
|
connectionQueueManager;
|
|
4938
|
+
conferenceStateManager;
|
|
3732
4939
|
callManager;
|
|
3733
4940
|
autoConnectorManager;
|
|
3734
4941
|
apiManager;
|
|
@@ -3736,6 +4943,7 @@ class Rs {
|
|
|
3736
4943
|
presentationManager;
|
|
3737
4944
|
statsManager;
|
|
3738
4945
|
videoSendingBalancerManager;
|
|
4946
|
+
session;
|
|
3739
4947
|
mainStreamHealthMonitor;
|
|
3740
4948
|
mainStreamRecovery;
|
|
3741
4949
|
preferredMimeTypesVideoCodecs;
|
|
@@ -3746,29 +4954,34 @@ class Rs {
|
|
|
3746
4954
|
videoBalancerOptions: i,
|
|
3747
4955
|
autoConnectorOptions: r
|
|
3748
4956
|
} = {}) {
|
|
3749
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events =
|
|
4957
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = fs(), this.connectionManager = new zt({ JsSIP: e }), this.connectionQueueManager = new Xt({
|
|
3750
4958
|
connectionManager: this.connectionManager
|
|
3751
|
-
}), this.callManager = new
|
|
4959
|
+
}), this.conferenceStateManager = new un(), this.callManager = new lt(this.conferenceStateManager), this.apiManager = new Je({
|
|
3752
4960
|
connectionManager: this.connectionManager,
|
|
3753
4961
|
callManager: this.callManager
|
|
3754
|
-
}), this.incomingCallManager = new
|
|
4962
|
+
}), this.incomingCallManager = new Nn(this.connectionManager), this.presentationManager = new Pt({
|
|
3755
4963
|
callManager: this.callManager,
|
|
3756
|
-
maxBitrate:
|
|
3757
|
-
}), this.statsManager = new
|
|
4964
|
+
maxBitrate: us
|
|
4965
|
+
}), this.statsManager = new wn({
|
|
3758
4966
|
callManager: this.callManager,
|
|
3759
4967
|
apiManager: this.apiManager
|
|
3760
|
-
}), this.autoConnectorManager = new
|
|
4968
|
+
}), this.autoConnectorManager = new ln(
|
|
3761
4969
|
{
|
|
3762
4970
|
connectionQueueManager: this.connectionQueueManager,
|
|
3763
4971
|
connectionManager: this.connectionManager,
|
|
3764
4972
|
callManager: this.callManager
|
|
3765
4973
|
},
|
|
3766
4974
|
r
|
|
3767
|
-
), this.videoSendingBalancerManager = new
|
|
4975
|
+
), this.videoSendingBalancerManager = new os(
|
|
3768
4976
|
this.callManager,
|
|
3769
4977
|
this.apiManager,
|
|
3770
4978
|
i
|
|
3771
|
-
), this.mainStreamHealthMonitor = new
|
|
4979
|
+
), this.mainStreamHealthMonitor = new ls(this.statsManager, this.callManager), this.mainStreamRecovery = new gs(this.callManager), this.session = An({
|
|
4980
|
+
connectionManager: this.connectionManager,
|
|
4981
|
+
callManager: this.callManager,
|
|
4982
|
+
incomingCallManager: this.incomingCallManager,
|
|
4983
|
+
presentationManager: this.presentationManager
|
|
4984
|
+
}), this.subscribe();
|
|
3772
4985
|
}
|
|
3773
4986
|
get requestedConnection() {
|
|
3774
4987
|
return this.connectionManager.requested;
|
|
@@ -3859,7 +5072,13 @@ class Rs {
|
|
|
3859
5072
|
};
|
|
3860
5073
|
declineToIncomingCall = async (...e) => this.incomingCallManager.declineToIncomingCall(...e);
|
|
3861
5074
|
getEstablishedRTCSession = () => this.callManager.getEstablishedRTCSession();
|
|
3862
|
-
getCallConfiguration = () =>
|
|
5075
|
+
getCallConfiguration = () => {
|
|
5076
|
+
const e = this.conferenceStateManager.getState();
|
|
5077
|
+
return {
|
|
5078
|
+
number: e.number,
|
|
5079
|
+
answer: e.answer
|
|
5080
|
+
};
|
|
5081
|
+
};
|
|
3863
5082
|
getRemoteStreams = () => this.callManager.getRemoteStreams();
|
|
3864
5083
|
replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
|
|
3865
5084
|
async startPresentation(e, t = {}) {
|
|
@@ -3947,34 +5166,46 @@ class Rs {
|
|
|
3947
5166
|
this.isCallActive || this.events.trigger("connected-with-configuration-from-out-of-call", e);
|
|
3948
5167
|
});
|
|
3949
5168
|
}
|
|
5169
|
+
mayBeStopPresentationAndNotify() {
|
|
5170
|
+
this.presentationManager.isPresentationInProcess && (this.stopPresentation().catch(() => {
|
|
5171
|
+
}), this.events.trigger("stopped-presentation-by-server-command", {}));
|
|
5172
|
+
}
|
|
3950
5173
|
subscribeToApiEvents() {
|
|
3951
5174
|
this.apiManager.on("participant:move-request-to-participants", () => {
|
|
3952
5175
|
this.callManager.setCallRoleParticipant();
|
|
3953
5176
|
}), this.apiManager.on("participant:move-request-to-spectators-synthetic", () => {
|
|
3954
|
-
this.callManager.setCallRoleSpectatorSynthetic(), this.
|
|
3955
|
-
}), this.events.trigger("stopped-presentation-by-server-command", {});
|
|
5177
|
+
this.callManager.setCallRoleSpectatorSynthetic(), this.mayBeStopPresentationAndNotify();
|
|
3956
5178
|
}), this.apiManager.on("participant:move-request-to-spectators-with-audio-id", ({ audioId: e }) => {
|
|
3957
|
-
this.callManager.setCallRoleSpectator({ audioId: e, sendOffer: this.sendOffer }), this.
|
|
3958
|
-
}), this.events.trigger("stopped-presentation-by-server-command", {});
|
|
5179
|
+
this.callManager.setCallRoleSpectator({ audioId: e, sendOffer: this.sendOffer }), this.mayBeStopPresentationAndNotify();
|
|
3959
5180
|
}), this.apiManager.on("mustStopPresentation", () => {
|
|
3960
|
-
this.
|
|
3961
|
-
|
|
5181
|
+
this.mayBeStopPresentationAndNotify();
|
|
5182
|
+
}), this.apiManager.on("enterRoom", ({ room: e, participantName: t }) => {
|
|
5183
|
+
this.conferenceStateManager.updateState({ room: e, participantName: t });
|
|
5184
|
+
}), this.apiManager.on(
|
|
5185
|
+
"conference:participant-token-issued",
|
|
5186
|
+
({ jwt: e, conference: t, participant: s }) => {
|
|
5187
|
+
this.conferenceStateManager.updateState({ token: e, conference: t, participant: s });
|
|
5188
|
+
}
|
|
5189
|
+
), this.apiManager.on("channels", (e) => {
|
|
5190
|
+
this.conferenceStateManager.updateState({ channels: e });
|
|
3962
5191
|
});
|
|
3963
5192
|
}
|
|
3964
5193
|
sendOffer = async (e, t) => {
|
|
3965
5194
|
const i = this.connectionManager.getConnectionConfiguration()?.sipServerUrl;
|
|
3966
5195
|
if (i === void 0)
|
|
3967
5196
|
throw new Error("No sipServerUrl for sendOffer");
|
|
3968
|
-
|
|
5197
|
+
const r = this.conferenceStateManager.getToken();
|
|
5198
|
+
return Mn({
|
|
3969
5199
|
serverUrl: i,
|
|
3970
5200
|
offer: t,
|
|
5201
|
+
token: r,
|
|
3971
5202
|
conferenceNumber: e.conferenceNumber,
|
|
3972
5203
|
quality: e.quality,
|
|
3973
5204
|
audio: e.audioChannel
|
|
3974
5205
|
});
|
|
3975
5206
|
};
|
|
3976
5207
|
setCodecPreferences(e) {
|
|
3977
|
-
|
|
5208
|
+
Gn(e, {
|
|
3978
5209
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
3979
5210
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
3980
5211
|
});
|
|
@@ -3999,20 +5230,24 @@ class Rs {
|
|
|
3999
5230
|
};
|
|
4000
5231
|
}
|
|
4001
5232
|
export {
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
5233
|
+
Te as E,
|
|
5234
|
+
et as O,
|
|
5235
|
+
ks as S,
|
|
5236
|
+
Ke as a,
|
|
5237
|
+
En as b,
|
|
5238
|
+
pe as c,
|
|
5239
|
+
Rt as d,
|
|
5240
|
+
ze as e,
|
|
5241
|
+
Fs as f,
|
|
5242
|
+
Us as g,
|
|
5243
|
+
xt as h,
|
|
5244
|
+
Bs as i,
|
|
5245
|
+
m as j,
|
|
5246
|
+
Ln as k,
|
|
5247
|
+
d as l,
|
|
5248
|
+
Vn as m,
|
|
5249
|
+
Gt as n,
|
|
5250
|
+
Mt as o,
|
|
5251
|
+
k as p,
|
|
5252
|
+
Mn as s
|
|
4018
5253
|
};
|