sip-connector 20.2.0 → 20.3.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 +117 -2
- package/dist/@SipConnector-C-73R76v.cjs +1 -0
- package/dist/{@SipConnector-BDiunWqH.js → @SipConnector-D4SHRHKj.js} +2086 -810
- package/dist/ApiManager/@ApiManager.d.ts +1 -1
- package/dist/ApiManager/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/ApiManager/index.d.ts +2 -1
- package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +1 -1
- package/dist/AutoConnectorManager/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/AutoConnectorManager/index.d.ts +1 -0
- package/dist/CallManager/CallStateMachine.d.ts +83 -0
- package/dist/CallManager/MCUSession.d.ts +2 -1
- package/dist/CallManager/RemoteStreamsManager.d.ts +1 -0
- package/dist/CallManager/{eventNames.d.ts → events.d.ts} +2 -1
- package/dist/CallManager/index.d.ts +2 -3
- package/dist/CallManager/types.d.ts +2 -1
- package/dist/ConnectionManager/ConnectionFlow.d.ts +1 -1
- package/dist/ConnectionManager/ConnectionStateMachine.d.ts +61 -12
- package/dist/ConnectionManager/RegistrationManager.d.ts +1 -1
- package/dist/ConnectionManager/{eventNames.d.ts → events.d.ts} +2 -1
- package/dist/ConnectionManager/index.d.ts +3 -3
- package/dist/IncomingCallManager/IncomingCallStateMachine.d.ts +114 -0
- package/dist/IncomingCallManager/{eventNames.d.ts → events.d.ts} +2 -1
- package/dist/IncomingCallManager/index.d.ts +2 -1
- package/dist/MainStreamHealthMonitor/@MainStreamHealthMonitor.d.ts +16 -0
- package/dist/MainStreamHealthMonitor/events.d.ts +8 -0
- package/dist/MainStreamHealthMonitor/index.d.ts +1 -0
- package/dist/MainStreamRecovery/@MainStreamRecovery.d.ts +12 -0
- package/dist/MainStreamRecovery/index.d.ts +1 -0
- package/dist/PresentationManager/PresentationStateMachine.d.ts +101 -0
- package/dist/PresentationManager/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/PresentationManager/index.d.ts +1 -0
- package/dist/SipConnector/@SipConnector.d.ts +8 -2
- package/dist/SipConnector/events.d.ts +24 -0
- package/dist/SipConnector/index.d.ts +1 -1
- package/dist/StatsManager/@StatsManager.d.ts +14 -3
- package/dist/StatsManager/events.d.ts +2 -0
- package/dist/StatsManager/index.d.ts +1 -1
- package/dist/StatsPeerConnection/@StatsPeerConnection.d.ts +1 -1
- package/dist/StatsPeerConnection/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/StatsPeerConnection/index.d.ts +4 -3
- package/dist/StatsPeerConnection/types.d.ts +2 -0
- package/dist/VideoSendingBalancerManager/@VideoSendingBalancerManager.d.ts +1 -1
- package/dist/VideoSendingBalancerManager/{eventNames.d.ts → events.d.ts} +1 -0
- package/dist/VideoSendingBalancerManager/index.d.ts +2 -2
- package/dist/__fixtures__/RTCSessionMock.d.ts +1 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +10 -9
- 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/index.d.ts +1 -1
- package/package.json +12 -9
- package/dist/@SipConnector-YhZPG7vq.cjs +0 -1
- package/dist/CallManager/@CallManager.d.ts +0 -58
- package/dist/ConnectionManager/@ConnectionManager.d.ts +0 -57
- package/dist/IncomingCallManager/@IncomingCallManager.d.ts +0 -29
- package/dist/PresentationManager/@PresentationManager.d.ts +0 -49
- package/dist/SipConnector/eventNames.d.ts +0 -23
- package/dist/StatsManager/eventNames.d.ts +0 -2
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
import z from "debug";
|
|
1
2
|
import { TypedEvents as O } from "events-constructor";
|
|
2
|
-
import G from "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { createStackPromises as re, isPromiseIsNotActualError as Fe } from "stack-promises";
|
|
3
|
+
import { CancelableRequest as G, isCanceledError as we } from "@krivega/cancelable-promise";
|
|
4
|
+
import { resolveRequesterByTimeout as Ue, requesterByTimeoutsWithFailCalls as Fe, DelayRequester as Be, hasCanceledError as ke, SetTimeoutRequest as oe } from "@krivega/timeout-requester";
|
|
5
|
+
import { hasCanceledError as Ge, repeatedCallsAsync as ce } from "repeated-calls";
|
|
6
|
+
import { createActor as $e, setup as $, assign as b } from "xstate";
|
|
7
|
+
import { createStackPromises as le, isPromiseIsNotActualError as qe } from "stack-promises";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
import Ve from "lodash";
|
|
11
|
+
const X = "sip-connector", l = z(X), Ds = () => {
|
|
12
|
+
z.enable(X);
|
|
13
|
+
}, ys = () => {
|
|
14
|
+
z.enable(`-${X}`);
|
|
15
|
+
}, He = "Error decline with 603", We = 1006, xe = (n) => typeof n == "object" && n !== null && "code" in n && n.code === We, Qe = (n) => n.message === He;
|
|
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 || {}), v = /* @__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))(v || {}), 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 || {}), Ye = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Ye || {}), 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 de = [
|
|
17
18
|
"participation:accepting-word-request",
|
|
18
19
|
"participation:cancelling-word-request",
|
|
19
20
|
"participant:move-request-to-stream",
|
|
@@ -43,9 +44,9 @@ const ae = [
|
|
|
43
44
|
"notAvailableSecondRemoteStream",
|
|
44
45
|
"mustStopPresentation",
|
|
45
46
|
"newDTMF"
|
|
46
|
-
];
|
|
47
|
-
var
|
|
48
|
-
class
|
|
47
|
+
], ze = () => new O(de);
|
|
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 Xe {
|
|
49
50
|
events;
|
|
50
51
|
connectionManager;
|
|
51
52
|
callManager;
|
|
@@ -53,13 +54,13 @@ class Ve {
|
|
|
53
54
|
connectionManager: e,
|
|
54
55
|
callManager: t
|
|
55
56
|
}) {
|
|
56
|
-
this.connectionManager = e, this.callManager = t, this.events =
|
|
57
|
+
this.connectionManager = e, this.callManager = t, this.events = ze(), this.subscribe();
|
|
57
58
|
}
|
|
58
59
|
async waitChannels() {
|
|
59
|
-
return this.wait(
|
|
60
|
+
return this.wait(g.CHANNELS);
|
|
60
61
|
}
|
|
61
62
|
async waitSyncMediaState() {
|
|
62
|
-
return this.wait(
|
|
63
|
+
return this.wait(g.ADMIN_FORCE_SYNC_MEDIA_STATE);
|
|
63
64
|
}
|
|
64
65
|
async sendDTMF(e) {
|
|
65
66
|
return new Promise((t, s) => {
|
|
@@ -78,19 +79,19 @@ class Ve {
|
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
81
|
-
const s = this.getEstablishedRTCSessionProtected(), i = `${
|
|
82
|
+
const s = this.getEstablishedRTCSessionProtected(), i = `${E.INPUT_CHANNELS}: ${e}`, r = `${E.OUTPUT_CHANNELS}: ${t}`, o = [
|
|
82
83
|
i,
|
|
83
84
|
r
|
|
84
85
|
];
|
|
85
|
-
return s.sendInfo(
|
|
86
|
+
return s.sendInfo(I.CHANNELS, void 0, { extraHeaders: o });
|
|
86
87
|
}
|
|
87
88
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
88
|
-
const i = this.getEstablishedRTCSessionProtected(), r = `${
|
|
89
|
+
const i = this.getEstablishedRTCSessionProtected(), r = `${E.MEDIA_STATE}: currentstate`, o = `${E.MAIN_CAM_STATE}: ${Number(e)}`, a = `${E.MIC_STATE}: ${Number(t)}`, c = [
|
|
89
90
|
r,
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
o,
|
|
92
|
+
a
|
|
92
93
|
];
|
|
93
|
-
return i.sendInfo(
|
|
94
|
+
return i.sendInfo(I.MEDIA_STATE, void 0, {
|
|
94
95
|
noTerminateWhenError: !0,
|
|
95
96
|
...s,
|
|
96
97
|
extraHeaders: c
|
|
@@ -99,15 +100,15 @@ class Ve {
|
|
|
99
100
|
async sendStats({
|
|
100
101
|
availableIncomingBitrate: e
|
|
101
102
|
}) {
|
|
102
|
-
const t = this.getEstablishedRTCSessionProtected(), i = [`${
|
|
103
|
-
return t.sendInfo(
|
|
103
|
+
const t = this.getEstablishedRTCSessionProtected(), i = [`${E.AVAILABLE_INCOMING_BITRATE}: ${e}`];
|
|
104
|
+
return t.sendInfo(I.STATS, void 0, {
|
|
104
105
|
noTerminateWhenError: !0,
|
|
105
106
|
extraHeaders: i
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
async sendRefusalToTurnOn(e, t = {}) {
|
|
109
|
-
const s = this.getEstablishedRTCSessionProtected(),
|
|
110
|
-
return s.sendInfo(
|
|
110
|
+
const s = this.getEstablishedRTCSessionProtected(), o = e === "mic" ? 0 : 1, c = [`${E.MEDIA_TYPE}: ${o}`];
|
|
111
|
+
return s.sendInfo(I.REFUSAL, void 0, {
|
|
111
112
|
noTerminateWhenError: !0,
|
|
112
113
|
...t,
|
|
113
114
|
extraHeaders: c
|
|
@@ -120,38 +121,38 @@ class Ve {
|
|
|
120
121
|
return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
|
|
121
122
|
}
|
|
122
123
|
async sendMustStopPresentationP2P() {
|
|
123
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
124
|
-
extraHeaders: [
|
|
124
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
125
|
+
extraHeaders: [E.MUST_STOP_PRESENTATION_P2P]
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
128
|
async sendStoppedPresentationP2P() {
|
|
128
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
129
|
-
extraHeaders: [
|
|
129
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
130
|
+
extraHeaders: [E.STOP_PRESENTATION_P2P]
|
|
130
131
|
});
|
|
131
132
|
}
|
|
132
133
|
async sendStoppedPresentation() {
|
|
133
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
134
|
-
extraHeaders: [
|
|
134
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
135
|
+
extraHeaders: [E.STOP_PRESENTATION]
|
|
135
136
|
});
|
|
136
137
|
}
|
|
137
138
|
async askPermissionToStartPresentationP2P() {
|
|
138
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
139
|
-
extraHeaders: [
|
|
139
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
140
|
+
extraHeaders: [E.START_PRESENTATION_P2P]
|
|
140
141
|
});
|
|
141
142
|
}
|
|
142
143
|
async askPermissionToStartPresentation() {
|
|
143
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
144
|
-
extraHeaders: [
|
|
144
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
|
|
145
|
+
extraHeaders: [E.START_PRESENTATION]
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
148
|
async askPermissionToEnableCam(e = {}) {
|
|
148
|
-
const t = this.getEstablishedRTCSessionProtected(), s = [
|
|
149
|
-
return t.sendInfo(
|
|
149
|
+
const t = this.getEstablishedRTCSessionProtected(), s = [E.ENABLE_MAIN_CAM];
|
|
150
|
+
return t.sendInfo(I.MAIN_CAM, void 0, {
|
|
150
151
|
noTerminateWhenError: !0,
|
|
151
152
|
...e,
|
|
152
153
|
extraHeaders: s
|
|
153
154
|
}).catch((i) => {
|
|
154
|
-
if (
|
|
155
|
+
if (Qe(i))
|
|
155
156
|
throw i;
|
|
156
157
|
});
|
|
157
158
|
}
|
|
@@ -186,106 +187,106 @@ class Ve {
|
|
|
186
187
|
};
|
|
187
188
|
maybeHandleNotify = (e) => {
|
|
188
189
|
try {
|
|
189
|
-
const t = e.getHeader(
|
|
190
|
+
const t = e.getHeader(E.NOTIFY);
|
|
190
191
|
if (t) {
|
|
191
192
|
const s = JSON.parse(t);
|
|
192
193
|
this.handleNotify(s);
|
|
193
194
|
}
|
|
194
195
|
} catch (t) {
|
|
195
|
-
|
|
196
|
+
l("error parse notify", t);
|
|
196
197
|
}
|
|
197
198
|
};
|
|
198
199
|
handleNotify = (e) => {
|
|
199
200
|
switch (e.cmd) {
|
|
200
|
-
case
|
|
201
|
+
case R.CHANNELS: {
|
|
201
202
|
const t = e;
|
|
202
203
|
this.triggerChannelsNotify(t);
|
|
203
204
|
break;
|
|
204
205
|
}
|
|
205
|
-
case
|
|
206
|
+
case R.WEBCAST_STARTED: {
|
|
206
207
|
const t = e;
|
|
207
208
|
this.triggerWebcastStartedNotify(t);
|
|
208
209
|
break;
|
|
209
210
|
}
|
|
210
|
-
case
|
|
211
|
+
case R.WEBCAST_STOPPED: {
|
|
211
212
|
const t = e;
|
|
212
213
|
this.triggerWebcastStoppedNotify(t);
|
|
213
214
|
break;
|
|
214
215
|
}
|
|
215
|
-
case
|
|
216
|
+
case R.ADDED_TO_LIST_MODERATORS: {
|
|
216
217
|
const t = e;
|
|
217
218
|
this.triggerAddedToListModeratorsNotify(t);
|
|
218
219
|
break;
|
|
219
220
|
}
|
|
220
|
-
case
|
|
221
|
+
case R.REMOVED_FROM_LIST_MODERATORS: {
|
|
221
222
|
const t = e;
|
|
222
223
|
this.triggerRemovedFromListModeratorsNotify(t);
|
|
223
224
|
break;
|
|
224
225
|
}
|
|
225
|
-
case
|
|
226
|
+
case R.ACCEPTING_WORD_REQUEST: {
|
|
226
227
|
const t = e;
|
|
227
228
|
this.triggerParticipationAcceptingWordRequest(t);
|
|
228
229
|
break;
|
|
229
230
|
}
|
|
230
|
-
case
|
|
231
|
+
case R.CANCELLING_WORD_REQUEST: {
|
|
231
232
|
const t = e;
|
|
232
233
|
this.triggerParticipationCancellingWordRequest(t);
|
|
233
234
|
break;
|
|
234
235
|
}
|
|
235
|
-
case
|
|
236
|
+
case R.MOVE_REQUEST_TO_STREAM: {
|
|
236
237
|
const t = e;
|
|
237
238
|
this.triggerParticipantMoveRequestToStream(t);
|
|
238
239
|
break;
|
|
239
240
|
}
|
|
240
|
-
case
|
|
241
|
+
case R.ACCOUNT_CHANGED: {
|
|
241
242
|
this.triggerAccountChangedNotify();
|
|
242
243
|
break;
|
|
243
244
|
}
|
|
244
|
-
case
|
|
245
|
+
case R.ACCOUNT_DELETED: {
|
|
245
246
|
this.triggerAccountDeletedNotify();
|
|
246
247
|
break;
|
|
247
248
|
}
|
|
248
|
-
case
|
|
249
|
+
case R.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
|
|
249
250
|
const t = e;
|
|
250
251
|
this.triggerConferenceParticipantTokenIssued(t);
|
|
251
252
|
break;
|
|
252
253
|
}
|
|
253
254
|
default:
|
|
254
|
-
|
|
255
|
+
l("unknown cmd", e);
|
|
255
256
|
}
|
|
256
257
|
};
|
|
257
258
|
handleNewInfo = (e) => {
|
|
258
259
|
const { originator: t } = e;
|
|
259
260
|
if (t !== "remote")
|
|
260
261
|
return;
|
|
261
|
-
const { request: s } = e, i = s, r = i.getHeader(
|
|
262
|
+
const { request: s } = e, i = s, r = i.getHeader(E.CONTENT_TYPE);
|
|
262
263
|
if (r !== void 0)
|
|
263
264
|
switch (r) {
|
|
264
|
-
case
|
|
265
|
+
case y.ENTER_ROOM: {
|
|
265
266
|
this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
|
|
266
267
|
break;
|
|
267
268
|
}
|
|
268
|
-
case
|
|
269
|
+
case y.NOTIFY: {
|
|
269
270
|
this.maybeHandleNotify(i);
|
|
270
271
|
break;
|
|
271
272
|
}
|
|
272
|
-
case
|
|
273
|
+
case y.SHARE_STATE: {
|
|
273
274
|
this.triggerShareState(i);
|
|
274
275
|
break;
|
|
275
276
|
}
|
|
276
|
-
case
|
|
277
|
+
case y.MAIN_CAM: {
|
|
277
278
|
this.triggerMainCamControl(i);
|
|
278
279
|
break;
|
|
279
280
|
}
|
|
280
|
-
case
|
|
281
|
+
case y.MIC: {
|
|
281
282
|
this.triggerMicControl(i);
|
|
282
283
|
break;
|
|
283
284
|
}
|
|
284
|
-
case
|
|
285
|
+
case y.USE_LICENSE: {
|
|
285
286
|
this.triggerUseLicense(i);
|
|
286
287
|
break;
|
|
287
288
|
}
|
|
288
|
-
case
|
|
289
|
+
case y.PARTICIPANT_STATE: {
|
|
289
290
|
this.maybeTriggerParticipantMoveRequest(i);
|
|
290
291
|
break;
|
|
291
292
|
}
|
|
@@ -296,7 +297,7 @@ class Ve {
|
|
|
296
297
|
inputChannels: t,
|
|
297
298
|
outputChannels: s
|
|
298
299
|
};
|
|
299
|
-
this.events.trigger(
|
|
300
|
+
this.events.trigger(g.CHANNELS_NOTIFY, i);
|
|
300
301
|
};
|
|
301
302
|
triggerWebcastStartedNotify = ({
|
|
302
303
|
body: { conference: e, type: t }
|
|
@@ -305,7 +306,7 @@ class Ve {
|
|
|
305
306
|
conference: e,
|
|
306
307
|
type: t
|
|
307
308
|
};
|
|
308
|
-
this.events.trigger(
|
|
309
|
+
this.events.trigger(g.WEBCAST_STARTED, s);
|
|
309
310
|
};
|
|
310
311
|
triggerWebcastStoppedNotify = ({
|
|
311
312
|
body: { conference: e, type: t }
|
|
@@ -314,7 +315,7 @@ class Ve {
|
|
|
314
315
|
conference: e,
|
|
315
316
|
type: t
|
|
316
317
|
};
|
|
317
|
-
this.events.trigger(
|
|
318
|
+
this.events.trigger(g.WEBCAST_STOPPED, s);
|
|
318
319
|
};
|
|
319
320
|
triggerAddedToListModeratorsNotify = ({
|
|
320
321
|
conference: e
|
|
@@ -323,7 +324,7 @@ class Ve {
|
|
|
323
324
|
conference: e
|
|
324
325
|
};
|
|
325
326
|
this.events.trigger(
|
|
326
|
-
|
|
327
|
+
g.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
|
|
327
328
|
t
|
|
328
329
|
);
|
|
329
330
|
};
|
|
@@ -334,7 +335,7 @@ class Ve {
|
|
|
334
335
|
conference: e
|
|
335
336
|
};
|
|
336
337
|
this.events.trigger(
|
|
337
|
-
|
|
338
|
+
g.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
|
|
338
339
|
t
|
|
339
340
|
);
|
|
340
341
|
};
|
|
@@ -344,7 +345,7 @@ class Ve {
|
|
|
344
345
|
const t = {
|
|
345
346
|
conference: e
|
|
346
347
|
};
|
|
347
|
-
this.events.trigger(
|
|
348
|
+
this.events.trigger(g.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
|
|
348
349
|
};
|
|
349
350
|
triggerParticipationCancellingWordRequest = ({
|
|
350
351
|
body: { conference: e }
|
|
@@ -352,7 +353,7 @@ class Ve {
|
|
|
352
353
|
const t = {
|
|
353
354
|
conference: e
|
|
354
355
|
};
|
|
355
|
-
this.events.trigger(
|
|
356
|
+
this.events.trigger(g.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
|
|
356
357
|
};
|
|
357
358
|
triggerParticipantMoveRequestToStream = ({
|
|
358
359
|
body: { conference: e }
|
|
@@ -360,13 +361,13 @@ class Ve {
|
|
|
360
361
|
const t = {
|
|
361
362
|
conference: e
|
|
362
363
|
};
|
|
363
|
-
this.events.trigger(
|
|
364
|
+
this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
|
|
364
365
|
};
|
|
365
366
|
triggerAccountChangedNotify = () => {
|
|
366
|
-
this.events.trigger(
|
|
367
|
+
this.events.trigger(g.ACCOUNT_CHANGED, {});
|
|
367
368
|
};
|
|
368
369
|
triggerAccountDeletedNotify = () => {
|
|
369
|
-
this.events.trigger(
|
|
370
|
+
this.events.trigger(g.ACCOUNT_DELETED, {});
|
|
370
371
|
};
|
|
371
372
|
triggerConferenceParticipantTokenIssued = ({
|
|
372
373
|
body: { conference: e, participant: t, jwt: s }
|
|
@@ -377,79 +378,288 @@ class Ve {
|
|
|
377
378
|
jwt: s
|
|
378
379
|
};
|
|
379
380
|
this.events.trigger(
|
|
380
|
-
|
|
381
|
+
g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
|
|
381
382
|
i
|
|
382
383
|
);
|
|
383
384
|
};
|
|
384
385
|
maybeTriggerChannels = (e) => {
|
|
385
|
-
const t = e.getHeader(
|
|
386
|
+
const t = e.getHeader(E.INPUT_CHANNELS), s = e.getHeader(E.OUTPUT_CHANNELS);
|
|
386
387
|
if (t && s) {
|
|
387
388
|
const i = {
|
|
388
389
|
inputChannels: t,
|
|
389
390
|
outputChannels: s
|
|
390
391
|
};
|
|
391
|
-
this.events.trigger(
|
|
392
|
+
this.events.trigger(g.CHANNELS, i);
|
|
392
393
|
}
|
|
393
394
|
};
|
|
394
395
|
triggerEnterRoom = (e) => {
|
|
395
|
-
const t = e.getHeader(
|
|
396
|
-
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 });
|
|
397
398
|
};
|
|
398
399
|
triggerShareState = (e) => {
|
|
399
|
-
const t = e.getHeader(
|
|
400
|
+
const t = e.getHeader(E.CONTENT_SHARE_STATE);
|
|
400
401
|
if (t !== void 0)
|
|
401
402
|
switch (t) {
|
|
402
403
|
case B.AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
403
|
-
this.events.trigger(
|
|
404
|
+
this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, {});
|
|
404
405
|
break;
|
|
405
406
|
}
|
|
406
407
|
case B.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
407
|
-
this.events.trigger(
|
|
408
|
+
this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, {});
|
|
408
409
|
break;
|
|
409
410
|
}
|
|
410
411
|
case B.MUST_STOP_PRESENTATION: {
|
|
411
|
-
this.events.trigger(
|
|
412
|
+
this.events.trigger(g.MUST_STOP_PRESENTATION, {});
|
|
412
413
|
break;
|
|
413
414
|
}
|
|
414
415
|
}
|
|
415
416
|
};
|
|
416
417
|
maybeTriggerParticipantMoveRequest = (e) => {
|
|
417
|
-
const t = e.getHeader(
|
|
418
|
-
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, {
|
|
419
420
|
audioId: s
|
|
420
|
-
}), this.events.trigger(
|
|
421
|
+
}), this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, {
|
|
421
422
|
isSynthetic: !1,
|
|
422
423
|
audioId: s
|
|
423
|
-
})) : (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, {});
|
|
424
425
|
};
|
|
425
426
|
triggerMainCamControl = (e) => {
|
|
426
|
-
const t = e.getHeader(
|
|
427
|
-
if (t ===
|
|
428
|
-
this.events.trigger(
|
|
427
|
+
const t = e.getHeader(E.MAIN_CAM), s = e.getHeader(E.MEDIA_SYNC), i = s === Y.ADMIN_SYNC_FORCED;
|
|
428
|
+
if (t === v.ADMIN_START_MAIN_CAM) {
|
|
429
|
+
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
|
|
429
430
|
return;
|
|
430
431
|
}
|
|
431
|
-
if (t ===
|
|
432
|
-
this.events.trigger(
|
|
432
|
+
if (t === v.ADMIN_STOP_MAIN_CAM) {
|
|
433
|
+
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
|
|
433
434
|
return;
|
|
434
435
|
}
|
|
435
|
-
(t ===
|
|
436
|
-
const r = e.getHeader(
|
|
437
|
-
this.events.trigger(
|
|
436
|
+
(t === v.RESUME_MAIN_CAM || t === v.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, {
|
|
438
439
|
mainCam: t,
|
|
439
440
|
resolutionMainCam: r
|
|
440
441
|
});
|
|
441
442
|
};
|
|
442
443
|
triggerMicControl = (e) => {
|
|
443
|
-
const t = e.getHeader(
|
|
444
|
-
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 });
|
|
445
446
|
};
|
|
446
447
|
triggerUseLicense = (e) => {
|
|
447
|
-
const t = e.getHeader(
|
|
448
|
-
this.events.trigger(
|
|
448
|
+
const t = e.getHeader(E.CONTENT_USE_LICENSE);
|
|
449
|
+
this.events.trigger(g.USE_LICENSE, t);
|
|
449
450
|
};
|
|
450
451
|
}
|
|
451
|
-
|
|
452
|
-
|
|
452
|
+
class q {
|
|
453
|
+
actor;
|
|
454
|
+
subscriptions = [];
|
|
455
|
+
constructor(e) {
|
|
456
|
+
this.actor = $e(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 Je = /* @__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))(Je || {});
|
|
487
|
+
const Ke = $({
|
|
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 je extends q {
|
|
588
|
+
constructor(e) {
|
|
589
|
+
super(Ke), 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 || {}), Ze = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(Ze || {});
|
|
662
|
+
const he = [
|
|
453
663
|
"peerconnection",
|
|
454
664
|
"connecting",
|
|
455
665
|
"sending",
|
|
@@ -476,37 +686,37 @@ const oe = [
|
|
|
476
686
|
"peerconnection:createanswerfailed",
|
|
477
687
|
"peerconnection:setlocaldescriptionfailed",
|
|
478
688
|
"peerconnection:setremotedescriptionfailed"
|
|
479
|
-
],
|
|
689
|
+
], et = [
|
|
480
690
|
"peerconnection:confirmed",
|
|
481
691
|
"peerconnection:ontrack",
|
|
482
692
|
"ended:fromserver",
|
|
483
693
|
"call-status-changed",
|
|
484
694
|
"remote-streams-changed"
|
|
485
|
-
],
|
|
486
|
-
...
|
|
487
|
-
...
|
|
488
|
-
],
|
|
695
|
+
], ge = [
|
|
696
|
+
...he,
|
|
697
|
+
...et
|
|
698
|
+
], tt = () => new O(ge), nt = (n, e) => {
|
|
489
699
|
n.getVideoTracks().forEach((s) => {
|
|
490
700
|
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
491
701
|
});
|
|
492
|
-
},
|
|
702
|
+
}, k = (n, {
|
|
493
703
|
directionVideo: e,
|
|
494
704
|
directionAudio: t,
|
|
495
705
|
contentHint: s
|
|
496
706
|
} = {}) => {
|
|
497
707
|
if (!n || e === "recvonly" && t === "recvonly")
|
|
498
708
|
return;
|
|
499
|
-
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(),
|
|
500
|
-
return
|
|
709
|
+
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), o = [...i, ...r], a = new MediaStream(o);
|
|
710
|
+
return a.getTracks = () => [...a.getAudioTracks(), ...a.getVideoTracks()], s && s !== "none" && nt(a, s), a;
|
|
501
711
|
};
|
|
502
|
-
var
|
|
503
|
-
class
|
|
712
|
+
var ue = /* @__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))(ue || {});
|
|
713
|
+
class st {
|
|
504
714
|
events;
|
|
505
715
|
rtcSession;
|
|
506
716
|
disposers = /* @__PURE__ */ new Set();
|
|
507
717
|
onReset;
|
|
508
718
|
constructor(e, { onReset: t }) {
|
|
509
|
-
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);
|
|
510
720
|
}
|
|
511
721
|
get connection() {
|
|
512
722
|
return this.rtcSession?.connection;
|
|
@@ -515,52 +725,57 @@ class Ye {
|
|
|
515
725
|
return this.rtcSession?.isEstablished() === !0;
|
|
516
726
|
}
|
|
517
727
|
getEstablishedRTCSession = () => this.rtcSession?.isEstablished() === !0 ? this.rtcSession : void 0;
|
|
728
|
+
async renegotiate() {
|
|
729
|
+
if (this.rtcSession === void 0)
|
|
730
|
+
throw new Error("No rtcSession established");
|
|
731
|
+
return this.rtcSession.renegotiate();
|
|
732
|
+
}
|
|
518
733
|
startCall = async (e, t, {
|
|
519
734
|
number: s,
|
|
520
735
|
mediaStream: i,
|
|
521
736
|
extraHeaders: r = [],
|
|
522
|
-
iceServers:
|
|
523
|
-
directionVideo:
|
|
737
|
+
iceServers: o,
|
|
738
|
+
directionVideo: a,
|
|
524
739
|
directionAudio: c,
|
|
525
740
|
contentHint: d,
|
|
526
|
-
offerToReceiveAudio:
|
|
527
|
-
offerToReceiveVideo:
|
|
528
|
-
degradationPreference:
|
|
741
|
+
offerToReceiveAudio: T = !0,
|
|
742
|
+
offerToReceiveVideo: h = !0,
|
|
743
|
+
degradationPreference: u,
|
|
529
744
|
sendEncodings: p,
|
|
530
|
-
onAddedTransceiver:
|
|
531
|
-
}) => new Promise((
|
|
532
|
-
this.handleCall().then(
|
|
533
|
-
|
|
745
|
+
onAddedTransceiver: A
|
|
746
|
+
}) => new Promise((N, D) => {
|
|
747
|
+
this.handleCall().then(N).catch((V) => {
|
|
748
|
+
D(V);
|
|
534
749
|
}), this.rtcSession = e.call(t(s), {
|
|
535
|
-
mediaStream:
|
|
536
|
-
directionVideo:
|
|
750
|
+
mediaStream: k(i, {
|
|
751
|
+
directionVideo: a,
|
|
537
752
|
directionAudio: c,
|
|
538
753
|
contentHint: d
|
|
539
754
|
}),
|
|
540
755
|
pcConfig: {
|
|
541
|
-
iceServers:
|
|
756
|
+
iceServers: o
|
|
542
757
|
},
|
|
543
758
|
rtcOfferConstraints: {
|
|
544
|
-
offerToReceiveAudio:
|
|
545
|
-
offerToReceiveVideo:
|
|
759
|
+
offerToReceiveAudio: T,
|
|
760
|
+
offerToReceiveVideo: h
|
|
546
761
|
},
|
|
547
762
|
// необходимо передавать в методе call, чтобы подписаться на события peerconnection,
|
|
548
763
|
// так как в методе call создается RTCSession
|
|
549
764
|
// и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
|
|
550
765
|
eventHandlers: this.events.triggers,
|
|
551
766
|
extraHeaders: r,
|
|
552
|
-
directionVideo:
|
|
767
|
+
directionVideo: a,
|
|
553
768
|
directionAudio: c,
|
|
554
|
-
degradationPreference:
|
|
769
|
+
degradationPreference: u,
|
|
555
770
|
sendEncodings: p,
|
|
556
|
-
onAddedTransceiver:
|
|
771
|
+
onAddedTransceiver: A
|
|
557
772
|
});
|
|
558
773
|
});
|
|
559
774
|
async endCall() {
|
|
560
775
|
const { rtcSession: e } = this;
|
|
561
776
|
if (e && !e.isEnded())
|
|
562
777
|
return e.terminateAsync({
|
|
563
|
-
cause:
|
|
778
|
+
cause: ue.CANCELED
|
|
564
779
|
}).finally(() => {
|
|
565
780
|
this.reset();
|
|
566
781
|
});
|
|
@@ -571,45 +786,45 @@ class Ye {
|
|
|
571
786
|
extraHeaders: s = [],
|
|
572
787
|
iceServers: i,
|
|
573
788
|
directionVideo: r,
|
|
574
|
-
directionAudio:
|
|
575
|
-
offerToReceiveAudio:
|
|
789
|
+
directionAudio: o,
|
|
790
|
+
offerToReceiveAudio: a,
|
|
576
791
|
offerToReceiveVideo: c,
|
|
577
792
|
contentHint: d,
|
|
578
|
-
degradationPreference:
|
|
579
|
-
sendEncodings:
|
|
580
|
-
onAddedTransceiver:
|
|
581
|
-
}) => new Promise((p,
|
|
793
|
+
degradationPreference: T,
|
|
794
|
+
sendEncodings: h,
|
|
795
|
+
onAddedTransceiver: u
|
|
796
|
+
}) => new Promise((p, A) => {
|
|
582
797
|
try {
|
|
583
|
-
this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(p).catch((
|
|
584
|
-
|
|
798
|
+
this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(p).catch((N) => {
|
|
799
|
+
A(N);
|
|
585
800
|
}), e.answer({
|
|
586
801
|
pcConfig: {
|
|
587
802
|
iceServers: i
|
|
588
803
|
},
|
|
589
804
|
rtcOfferConstraints: {
|
|
590
|
-
offerToReceiveAudio:
|
|
805
|
+
offerToReceiveAudio: a,
|
|
591
806
|
offerToReceiveVideo: c
|
|
592
807
|
},
|
|
593
|
-
mediaStream:
|
|
808
|
+
mediaStream: k(t, {
|
|
594
809
|
directionVideo: r,
|
|
595
|
-
directionAudio:
|
|
810
|
+
directionAudio: o,
|
|
596
811
|
contentHint: d
|
|
597
812
|
}),
|
|
598
813
|
extraHeaders: s,
|
|
599
814
|
directionVideo: r,
|
|
600
|
-
directionAudio:
|
|
601
|
-
degradationPreference:
|
|
602
|
-
sendEncodings:
|
|
603
|
-
onAddedTransceiver:
|
|
815
|
+
directionAudio: o,
|
|
816
|
+
degradationPreference: T,
|
|
817
|
+
sendEncodings: h,
|
|
818
|
+
onAddedTransceiver: u
|
|
604
819
|
});
|
|
605
|
-
} catch (
|
|
606
|
-
|
|
820
|
+
} catch (N) {
|
|
821
|
+
A(N);
|
|
607
822
|
}
|
|
608
823
|
});
|
|
609
824
|
async replaceMediaStream(e, t) {
|
|
610
825
|
if (!this.rtcSession)
|
|
611
826
|
throw new Error("No rtcSession established");
|
|
612
|
-
const { contentHint: s } = t ?? {}, i =
|
|
827
|
+
const { contentHint: s } = t ?? {}, i = k(e, { contentHint: s });
|
|
613
828
|
if (i === void 0)
|
|
614
829
|
throw new Error("No preparedMediaStream");
|
|
615
830
|
return this.rtcSession.replaceMediaStream(i, t);
|
|
@@ -621,33 +836,33 @@ class Ye {
|
|
|
621
836
|
}
|
|
622
837
|
handleCall = async () => new Promise((e, t) => {
|
|
623
838
|
const s = () => {
|
|
624
|
-
this.events.on(
|
|
839
|
+
this.events.on(C.PEER_CONNECTION, d), this.events.on(C.CONFIRMED, T);
|
|
625
840
|
}, i = () => {
|
|
626
|
-
this.events.off(
|
|
841
|
+
this.events.off(C.PEER_CONNECTION, d), this.events.off(C.CONFIRMED, T);
|
|
627
842
|
}, r = () => {
|
|
628
|
-
this.events.on(
|
|
629
|
-
},
|
|
630
|
-
this.events.off(
|
|
631
|
-
},
|
|
632
|
-
i(),
|
|
843
|
+
this.events.on(C.FAILED, a), this.events.on(C.ENDED, a);
|
|
844
|
+
}, o = () => {
|
|
845
|
+
this.events.off(C.FAILED, a), this.events.off(C.ENDED, a);
|
|
846
|
+
}, a = (h) => {
|
|
847
|
+
i(), o(), t(h);
|
|
633
848
|
};
|
|
634
849
|
let c;
|
|
635
|
-
const d = ({ peerconnection:
|
|
636
|
-
c =
|
|
637
|
-
const
|
|
638
|
-
this.events.trigger(
|
|
850
|
+
const d = ({ peerconnection: h }) => {
|
|
851
|
+
c = h;
|
|
852
|
+
const u = (p) => {
|
|
853
|
+
this.events.trigger(C.PEER_CONNECTION_ONTRACK, p);
|
|
639
854
|
};
|
|
640
|
-
|
|
641
|
-
|
|
855
|
+
h.addEventListener("track", u), this.disposers.add(() => {
|
|
856
|
+
h.removeEventListener("track", u);
|
|
642
857
|
});
|
|
643
|
-
},
|
|
644
|
-
c !== void 0 && this.events.trigger(
|
|
858
|
+
}, T = () => {
|
|
859
|
+
c !== void 0 && this.events.trigger(C.PEER_CONNECTION_CONFIRMED, c), i(), o(), e(c);
|
|
645
860
|
};
|
|
646
861
|
s(), r();
|
|
647
862
|
});
|
|
648
863
|
subscribeToSessionEvents(e) {
|
|
649
864
|
this.events.eachTriggers((t, s) => {
|
|
650
|
-
const i =
|
|
865
|
+
const i = he.find((r) => r === s);
|
|
651
866
|
i && (e.on(i, t), this.disposers.add(() => {
|
|
652
867
|
e.off(i, t);
|
|
653
868
|
}));
|
|
@@ -660,13 +875,13 @@ class Ye {
|
|
|
660
875
|
}
|
|
661
876
|
handleEnded = (e) => {
|
|
662
877
|
const { originator: t } = e;
|
|
663
|
-
t === "remote" && this.events.trigger(
|
|
878
|
+
t === "remote" && this.events.trigger(C.ENDED_FROM_SERVER, e), this.reset();
|
|
664
879
|
};
|
|
665
880
|
reset = () => {
|
|
666
881
|
delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
|
|
667
882
|
};
|
|
668
883
|
}
|
|
669
|
-
class
|
|
884
|
+
class it {
|
|
670
885
|
config;
|
|
671
886
|
tools;
|
|
672
887
|
connection;
|
|
@@ -715,21 +930,25 @@ class ze {
|
|
|
715
930
|
return this.connection.addTransceiver(e, t);
|
|
716
931
|
}
|
|
717
932
|
}
|
|
718
|
-
const
|
|
719
|
-
const t =
|
|
933
|
+
const Te = (n) => n.getSettings(), rt = (n, e) => {
|
|
934
|
+
const t = Te(n);
|
|
720
935
|
let s = e;
|
|
721
936
|
s ??= n.label;
|
|
722
937
|
let i = t?.msid;
|
|
723
938
|
return i ??= s, i ??= n.id, i;
|
|
724
|
-
},
|
|
725
|
-
const t =
|
|
939
|
+
}, at = (n, e) => {
|
|
940
|
+
const t = Te(n);
|
|
726
941
|
let s = e;
|
|
727
942
|
return s ??= t?.msid, s ??= n.label, (s && s.length > 0 ? s : void 0) ?? n.id;
|
|
728
943
|
};
|
|
729
|
-
class
|
|
944
|
+
class j {
|
|
730
945
|
participantGroups = /* @__PURE__ */ new Map();
|
|
731
946
|
trackToGroup = /* @__PURE__ */ new Map();
|
|
732
947
|
trackDisposers = /* @__PURE__ */ new Map();
|
|
948
|
+
get mainStream() {
|
|
949
|
+
const e = this.getStreams(), [t] = e;
|
|
950
|
+
return t;
|
|
951
|
+
}
|
|
733
952
|
reset() {
|
|
734
953
|
this.participantGroups.clear(), this.trackToGroup.clear(), this.trackDisposers.forEach((e) => {
|
|
735
954
|
e();
|
|
@@ -739,17 +958,17 @@ class X {
|
|
|
739
958
|
onRemoved: t,
|
|
740
959
|
streamHint: s
|
|
741
960
|
} = {}) {
|
|
742
|
-
const i =
|
|
961
|
+
const i = at(e, s), r = rt(e, s);
|
|
743
962
|
if (this.trackToGroup.has(e.id))
|
|
744
963
|
return { isAdded: !1 };
|
|
745
|
-
const
|
|
746
|
-
let
|
|
747
|
-
|
|
964
|
+
const o = this.getParticipantGroups(i);
|
|
965
|
+
let a = o.get(r);
|
|
966
|
+
a || (a = {
|
|
748
967
|
participantId: i,
|
|
749
968
|
groupId: r,
|
|
750
969
|
stream: new MediaStream(),
|
|
751
970
|
trackIds: /* @__PURE__ */ new Set()
|
|
752
|
-
},
|
|
971
|
+
}, o.set(r, a)), a.stream.addTrack(e), a.trackIds.add(e.id), this.trackToGroup.set(e.id, { participantId: i, groupId: r });
|
|
753
972
|
const c = () => {
|
|
754
973
|
this.disposeTrackListener(e.id), this.removeTrack(e.id) && t?.({ trackId: e.id, participantId: i });
|
|
755
974
|
};
|
|
@@ -762,19 +981,19 @@ class X {
|
|
|
762
981
|
const t = this.trackToGroup.get(e);
|
|
763
982
|
if (!t)
|
|
764
983
|
return !1;
|
|
765
|
-
const { participantId: s, groupId: i } = t, r = this.participantGroups.get(s),
|
|
766
|
-
if (!
|
|
984
|
+
const { participantId: s, groupId: i } = t, r = this.participantGroups.get(s), o = r?.get(i);
|
|
985
|
+
if (!o)
|
|
767
986
|
return this.trackToGroup.delete(e), !1;
|
|
768
|
-
const
|
|
769
|
-
return
|
|
987
|
+
const a = o.stream.getTracks().find((c) => c.id === e);
|
|
988
|
+
return a && o.stream.removeTrack(a), o.trackIds.delete(e), this.trackToGroup.delete(e), o.trackIds.size === 0 && (r?.delete(i), r?.size === 0 && this.participantGroups.delete(s)), !0;
|
|
770
989
|
}
|
|
771
990
|
removeStaleTracks(e, t) {
|
|
772
991
|
const s = this.participantGroups.get(e);
|
|
773
992
|
if (!s)
|
|
774
993
|
return !1;
|
|
775
994
|
let i = !1;
|
|
776
|
-
return [...s.values()].forEach((
|
|
777
|
-
[...
|
|
995
|
+
return [...s.values()].forEach((o) => {
|
|
996
|
+
[...o.trackIds].filter((c) => !t.includes(c)).forEach((c) => {
|
|
778
997
|
const d = this.removeTrack(c);
|
|
779
998
|
i ||= d;
|
|
780
999
|
});
|
|
@@ -799,16 +1018,16 @@ class X {
|
|
|
799
1018
|
return this.participantGroups.set(e, s), s;
|
|
800
1019
|
}
|
|
801
1020
|
}
|
|
802
|
-
const
|
|
1021
|
+
const H = {
|
|
803
1022
|
type: "participant"
|
|
804
|
-
},
|
|
1023
|
+
}, ot = {
|
|
805
1024
|
type: "spectator_synthetic"
|
|
806
|
-
},
|
|
1025
|
+
}, ct = (n) => ({
|
|
807
1026
|
type: "spectator",
|
|
808
1027
|
recvParams: n
|
|
809
1028
|
});
|
|
810
|
-
class
|
|
811
|
-
role =
|
|
1029
|
+
class _ {
|
|
1030
|
+
role = H;
|
|
812
1031
|
mainManager;
|
|
813
1032
|
recvManager;
|
|
814
1033
|
onRoleChanged;
|
|
@@ -831,13 +1050,13 @@ class v {
|
|
|
831
1050
|
return this.role;
|
|
832
1051
|
}
|
|
833
1052
|
setCallRoleParticipant() {
|
|
834
|
-
this.changeRole(
|
|
1053
|
+
this.changeRole(H);
|
|
835
1054
|
}
|
|
836
1055
|
setCallRoleSpectatorSynthetic() {
|
|
837
|
-
this.changeRole(
|
|
1056
|
+
this.changeRole(ot);
|
|
838
1057
|
}
|
|
839
1058
|
setCallRoleSpectator(e) {
|
|
840
|
-
this.changeRole(
|
|
1059
|
+
this.changeRole(ct(e));
|
|
841
1060
|
}
|
|
842
1061
|
changeRole(e) {
|
|
843
1062
|
const t = this.role;
|
|
@@ -845,38 +1064,39 @@ class v {
|
|
|
845
1064
|
this.setRole(e);
|
|
846
1065
|
return;
|
|
847
1066
|
}
|
|
848
|
-
|
|
1067
|
+
_.hasSpectator(e) && _.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
|
|
849
1068
|
}
|
|
850
1069
|
reset() {
|
|
851
|
-
this.role =
|
|
1070
|
+
this.role = H, this.recvManager.reset();
|
|
852
1071
|
}
|
|
853
1072
|
getActiveManager() {
|
|
854
1073
|
return this.hasSpectator() ? this.recvManager : this.mainManager;
|
|
855
1074
|
}
|
|
856
1075
|
hasParticipant() {
|
|
857
|
-
return
|
|
1076
|
+
return _.hasParticipant(this.role);
|
|
858
1077
|
}
|
|
859
1078
|
hasSpectatorSynthetic() {
|
|
860
|
-
return
|
|
1079
|
+
return _.hasSpectatorSynthetic(this.role);
|
|
861
1080
|
}
|
|
862
1081
|
hasSpectator() {
|
|
863
|
-
return
|
|
1082
|
+
return _.hasSpectator(this.role);
|
|
864
1083
|
}
|
|
865
1084
|
setRole(e) {
|
|
866
1085
|
const t = this.role;
|
|
867
1086
|
this.role = e, this.onRoleChanged?.({ previous: t, next: e });
|
|
868
1087
|
}
|
|
869
1088
|
}
|
|
870
|
-
const
|
|
871
|
-
class
|
|
1089
|
+
const Z = (n) => n.streams[0]?.id;
|
|
1090
|
+
class lt {
|
|
872
1091
|
events;
|
|
1092
|
+
callStateMachine;
|
|
873
1093
|
isPendingCall = !1;
|
|
874
1094
|
isPendingAnswer = !1;
|
|
875
1095
|
rtcSession;
|
|
876
1096
|
callConfiguration = {};
|
|
877
|
-
mainRemoteStreamsManager = new
|
|
878
|
-
recvRemoteStreamsManager = new
|
|
879
|
-
roleManager = new
|
|
1097
|
+
mainRemoteStreamsManager = new j();
|
|
1098
|
+
recvRemoteStreamsManager = new j();
|
|
1099
|
+
roleManager = new _(
|
|
880
1100
|
{ mainManager: this.mainRemoteStreamsManager, recvManager: this.recvRemoteStreamsManager },
|
|
881
1101
|
(e) => {
|
|
882
1102
|
this.onRoleChanged(e);
|
|
@@ -886,7 +1106,10 @@ class Ze {
|
|
|
886
1106
|
recvSession;
|
|
887
1107
|
disposeRecvSessionTrackListener;
|
|
888
1108
|
constructor() {
|
|
889
|
-
this.events =
|
|
1109
|
+
this.events = tt(), this.mcuSession = new st(this.events, { onReset: this.reset }), this.callStateMachine = new je(this.events), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents();
|
|
1110
|
+
}
|
|
1111
|
+
get callActor() {
|
|
1112
|
+
return this.callStateMachine.actorRef;
|
|
890
1113
|
}
|
|
891
1114
|
get requested() {
|
|
892
1115
|
return this.isPendingCall || this.isPendingAnswer;
|
|
@@ -922,6 +1145,9 @@ class Ze {
|
|
|
922
1145
|
async endCall() {
|
|
923
1146
|
return this.mcuSession.endCall();
|
|
924
1147
|
}
|
|
1148
|
+
async renegotiate() {
|
|
1149
|
+
return this.mcuSession.renegotiate();
|
|
1150
|
+
}
|
|
925
1151
|
answerToIncomingCall = async (e, t) => {
|
|
926
1152
|
this.isPendingAnswer = !0;
|
|
927
1153
|
const s = e();
|
|
@@ -932,6 +1158,9 @@ class Ze {
|
|
|
932
1158
|
getCallConfiguration() {
|
|
933
1159
|
return { ...this.callConfiguration };
|
|
934
1160
|
}
|
|
1161
|
+
getMainStream() {
|
|
1162
|
+
return this.getActiveStreamsManager().mainStream;
|
|
1163
|
+
}
|
|
935
1164
|
getRemoteStreams() {
|
|
936
1165
|
return this.getActiveStreamsManager().getStreams();
|
|
937
1166
|
}
|
|
@@ -955,18 +1184,18 @@ class Ze {
|
|
|
955
1184
|
};
|
|
956
1185
|
subscribeCallStatusChange() {
|
|
957
1186
|
let { isCallActive: e } = this;
|
|
958
|
-
const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } =
|
|
1187
|
+
const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = C;
|
|
959
1188
|
this.onRace([t, s, i, r], () => {
|
|
960
1189
|
e = this.maybeTriggerCallStatus(e);
|
|
961
1190
|
});
|
|
962
1191
|
}
|
|
963
1192
|
maybeTriggerCallStatus(e) {
|
|
964
1193
|
const t = this.isCallActive;
|
|
965
|
-
return t !== e && this.events.trigger(
|
|
1194
|
+
return t !== e && this.events.trigger(C.CALL_STATUS_CHANGED, { isCallActive: t }), t;
|
|
966
1195
|
}
|
|
967
1196
|
subscribeMcuRemoteTrackEvents() {
|
|
968
|
-
this.on(
|
|
969
|
-
this.addRemoteTrack(this.mainRemoteStreamsManager, e.track,
|
|
1197
|
+
this.on(C.PEER_CONNECTION_ONTRACK, (e) => {
|
|
1198
|
+
this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, Z(e));
|
|
970
1199
|
});
|
|
971
1200
|
}
|
|
972
1201
|
addRemoteTrack(e, t, s) {
|
|
@@ -988,12 +1217,12 @@ class Ze {
|
|
|
988
1217
|
const r = this.getActiveStreamsManager();
|
|
989
1218
|
if (e !== r)
|
|
990
1219
|
return;
|
|
991
|
-
const
|
|
992
|
-
this.events.trigger(
|
|
1220
|
+
const o = [...r.getStreams()];
|
|
1221
|
+
this.events.trigger(C.REMOTE_STREAMS_CHANGED, {
|
|
993
1222
|
participantId: i,
|
|
994
1223
|
changeType: t,
|
|
995
1224
|
trackId: s,
|
|
996
|
-
streams:
|
|
1225
|
+
streams: o
|
|
997
1226
|
});
|
|
998
1227
|
}
|
|
999
1228
|
getActiveStreamsManager() {
|
|
@@ -1001,7 +1230,7 @@ class Ze {
|
|
|
1001
1230
|
}
|
|
1002
1231
|
attachRecvSessionTracks(e) {
|
|
1003
1232
|
const { peerConnection: t } = e, s = (i) => {
|
|
1004
|
-
this.addRemoteTrack(this.recvRemoteStreamsManager, i.track,
|
|
1233
|
+
this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, Z(i));
|
|
1005
1234
|
};
|
|
1006
1235
|
t.addEventListener("track", s), this.disposeRecvSessionTrackListener = () => {
|
|
1007
1236
|
t.removeEventListener("track", s);
|
|
@@ -1015,7 +1244,7 @@ class Ze {
|
|
|
1015
1244
|
const i = {
|
|
1016
1245
|
quality: "high",
|
|
1017
1246
|
audioChannel: e
|
|
1018
|
-
}, r = new
|
|
1247
|
+
}, r = new it(i, { sendOffer: t });
|
|
1019
1248
|
this.recvSession = r, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(r), r.call(s).catch(() => {
|
|
1020
1249
|
this.stopRecvSession();
|
|
1021
1250
|
});
|
|
@@ -1027,45 +1256,45 @@ class Ze {
|
|
|
1027
1256
|
previous: e,
|
|
1028
1257
|
next: t
|
|
1029
1258
|
}) => {
|
|
1030
|
-
if (
|
|
1259
|
+
if (_.hasSpectator(e) && !_.hasSpectator(t) && this.stopRecvSession(), _.hasSpectator(t)) {
|
|
1031
1260
|
const s = t.recvParams;
|
|
1032
1261
|
this.startRecvSession(s.audioId, s.sendOffer);
|
|
1033
1262
|
}
|
|
1034
1263
|
};
|
|
1035
1264
|
}
|
|
1036
|
-
const
|
|
1265
|
+
const dt = (n, e) => (n.degradationPreference = e.degradationPreference, n), ht = (n, e) => {
|
|
1037
1266
|
n.encodings ??= [];
|
|
1038
1267
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
1039
1268
|
n.encodings.push({});
|
|
1040
1269
|
return n;
|
|
1041
|
-
},
|
|
1042
|
-
if (
|
|
1270
|
+
}, Ee = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, gt = Ee(), ut = (n, e) => {
|
|
1271
|
+
if (gt(n, e))
|
|
1043
1272
|
return n;
|
|
1044
|
-
},
|
|
1045
|
-
const t = n.maxBitrate, s =
|
|
1273
|
+
}, Tt = (n, e) => {
|
|
1274
|
+
const t = n.maxBitrate, s = ut(e, t);
|
|
1046
1275
|
return s !== void 0 && (n.maxBitrate = s), n;
|
|
1047
|
-
},
|
|
1048
|
-
|
|
1049
|
-
),
|
|
1050
|
-
const t = n === void 0 ? void 0 : Math.max(n,
|
|
1051
|
-
if (t !== void 0 &&
|
|
1276
|
+
}, Ce = 1, Et = Ee(
|
|
1277
|
+
Ce
|
|
1278
|
+
), Ct = (n, e) => {
|
|
1279
|
+
const t = n === void 0 ? void 0 : Math.max(n, Ce);
|
|
1280
|
+
if (t !== void 0 && Et(
|
|
1052
1281
|
t,
|
|
1053
1282
|
e
|
|
1054
1283
|
))
|
|
1055
1284
|
return t;
|
|
1056
|
-
},
|
|
1057
|
-
const t = n.scaleResolutionDownBy, s =
|
|
1285
|
+
}, St = (n, e) => {
|
|
1286
|
+
const t = n.scaleResolutionDownBy, s = Ct(
|
|
1058
1287
|
e,
|
|
1059
1288
|
t
|
|
1060
1289
|
);
|
|
1061
1290
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
1062
|
-
},
|
|
1291
|
+
}, pt = (n, e) => {
|
|
1063
1292
|
const t = e.encodings?.length ?? 0;
|
|
1064
|
-
return
|
|
1065
|
-
const r = (e?.encodings ?? [])[i],
|
|
1066
|
-
|
|
1293
|
+
return ht(n, t), n.encodings.forEach((s, i) => {
|
|
1294
|
+
const r = (e?.encodings ?? [])[i], o = r?.maxBitrate, a = r?.scaleResolutionDownBy;
|
|
1295
|
+
Tt(s, o), St(s, a);
|
|
1067
1296
|
}), n;
|
|
1068
|
-
},
|
|
1297
|
+
}, mt = (n, e) => {
|
|
1069
1298
|
if (n.codecs?.length !== e.codecs?.length)
|
|
1070
1299
|
return !0;
|
|
1071
1300
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -1082,15 +1311,15 @@ const et = (n, e) => (n.degradationPreference = e.degradationPreference, n), tt
|
|
|
1082
1311
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
1083
1312
|
return !0;
|
|
1084
1313
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
1085
|
-
},
|
|
1314
|
+
}, Nt = async (n, e) => {
|
|
1086
1315
|
const t = n.getParameters(), s = JSON.parse(
|
|
1087
1316
|
JSON.stringify(t)
|
|
1088
1317
|
);
|
|
1089
|
-
|
|
1090
|
-
const i =
|
|
1318
|
+
pt(t, e), dt(t, e);
|
|
1319
|
+
const i = mt(s, t);
|
|
1091
1320
|
return i && await n.setParameters(t), { parameters: t, isChanged: i };
|
|
1092
|
-
},
|
|
1093
|
-
const { isChanged: s, parameters: i } = await
|
|
1321
|
+
}, Se = async (n, e, t) => {
|
|
1322
|
+
const { isChanged: s, parameters: i } = await Nt(n, {
|
|
1094
1323
|
encodings: [
|
|
1095
1324
|
{
|
|
1096
1325
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -1099,21 +1328,421 @@ const et = (n, e) => (n.degradationPreference = e.degradationPreference, n), tt
|
|
|
1099
1328
|
]
|
|
1100
1329
|
});
|
|
1101
1330
|
return s && t && t(i), { isChanged: s, parameters: i };
|
|
1102
|
-
},
|
|
1103
|
-
const s =
|
|
1331
|
+
}, Rt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), At = async (n, e, t) => {
|
|
1332
|
+
const s = Rt(n, e);
|
|
1104
1333
|
if (s)
|
|
1105
|
-
return
|
|
1334
|
+
return Se(s, { maxBitrate: t });
|
|
1106
1335
|
};
|
|
1107
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 || {});
|
|
1108
|
-
const
|
|
1337
|
+
const pe = [
|
|
1109
1338
|
"presentation:start",
|
|
1110
1339
|
"presentation:started",
|
|
1111
1340
|
"presentation:end",
|
|
1112
1341
|
"presentation:ended",
|
|
1113
1342
|
"presentation:failed"
|
|
1114
|
-
],
|
|
1115
|
-
|
|
1343
|
+
], It = () => new O(pe);
|
|
1344
|
+
var ft = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(ft || {});
|
|
1345
|
+
const Mt = $({
|
|
1346
|
+
types: {
|
|
1347
|
+
context: {},
|
|
1348
|
+
events: {}
|
|
1349
|
+
},
|
|
1350
|
+
actions: {
|
|
1351
|
+
logTransition: (n, e) => {
|
|
1352
|
+
l(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1353
|
+
},
|
|
1354
|
+
logStateChange: (n, e) => {
|
|
1355
|
+
l("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 vt extends q {
|
|
1671
|
+
constructor(e) {
|
|
1672
|
+
super(Mt), 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 _t = 1, Ls = (n) => Ge(n);
|
|
1743
|
+
class Ot {
|
|
1116
1744
|
events;
|
|
1745
|
+
presentationStateMachine;
|
|
1117
1746
|
promisePendingStartPresentation;
|
|
1118
1747
|
promisePendingStopPresentation;
|
|
1119
1748
|
streamPresentationCurrent;
|
|
@@ -1124,18 +1753,24 @@ class Tt {
|
|
|
1124
1753
|
callManager: e,
|
|
1125
1754
|
maxBitrate: t
|
|
1126
1755
|
}) {
|
|
1127
|
-
this.callManager = e, this.maxBitrate = t, this.events = new
|
|
1756
|
+
this.callManager = e, this.maxBitrate = t, this.events = It(), this.presentationStateMachine = new vt(this.callManager.events), this.subscribe();
|
|
1757
|
+
}
|
|
1758
|
+
get presentationActor() {
|
|
1759
|
+
return this.presentationStateMachine.actorRef;
|
|
1128
1760
|
}
|
|
1129
1761
|
get isPendingPresentation() {
|
|
1130
1762
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
1131
1763
|
}
|
|
1764
|
+
get isPresentationInProcess() {
|
|
1765
|
+
return !!this.streamPresentationCurrent || this.isPendingPresentation;
|
|
1766
|
+
}
|
|
1132
1767
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
1133
1768
|
async startPresentation(e, t, {
|
|
1134
1769
|
isNeedReinvite: s,
|
|
1135
1770
|
contentHint: i,
|
|
1136
1771
|
sendEncodings: r,
|
|
1137
|
-
onAddedTransceiver:
|
|
1138
|
-
} = {},
|
|
1772
|
+
onAddedTransceiver: o
|
|
1773
|
+
} = {}, a) {
|
|
1139
1774
|
const c = this.getRtcSessionProtected();
|
|
1140
1775
|
if (this.streamPresentationCurrent)
|
|
1141
1776
|
throw new Error("Presentation is already started");
|
|
@@ -1146,9 +1781,9 @@ class Tt {
|
|
|
1146
1781
|
isNeedReinvite: s,
|
|
1147
1782
|
contentHint: i,
|
|
1148
1783
|
sendEncodings: r,
|
|
1149
|
-
onAddedTransceiver:
|
|
1784
|
+
onAddedTransceiver: o
|
|
1150
1785
|
},
|
|
1151
|
-
options:
|
|
1786
|
+
options: a
|
|
1152
1787
|
});
|
|
1153
1788
|
}
|
|
1154
1789
|
async stopPresentation(e) {
|
|
@@ -1159,8 +1794,8 @@ class Tt {
|
|
|
1159
1794
|
});
|
|
1160
1795
|
const i = this.callManager.getEstablishedRTCSession();
|
|
1161
1796
|
return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
|
|
1162
|
-
const
|
|
1163
|
-
throw this.events.trigger(P.FAILED_PRESENTATION,
|
|
1797
|
+
const o = r instanceof Error ? r : new Error(String(r));
|
|
1798
|
+
throw this.events.trigger(P.FAILED_PRESENTATION, o), r;
|
|
1164
1799
|
}) : t && this.events.trigger(P.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
1165
1800
|
this.resetPresentation();
|
|
1166
1801
|
});
|
|
@@ -1170,15 +1805,15 @@ class Tt {
|
|
|
1170
1805
|
sendEncodings: i,
|
|
1171
1806
|
onAddedTransceiver: r
|
|
1172
1807
|
} = {}) {
|
|
1173
|
-
const
|
|
1808
|
+
const o = this.getRtcSessionProtected();
|
|
1174
1809
|
if (!this.streamPresentationCurrent)
|
|
1175
1810
|
throw new Error("Presentation has not started yet");
|
|
1176
|
-
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e,
|
|
1811
|
+
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, o, t, {
|
|
1177
1812
|
contentHint: s,
|
|
1178
1813
|
isNeedReinvite: !1,
|
|
1179
1814
|
sendEncodings: i,
|
|
1180
1815
|
onAddedTransceiver: r
|
|
1181
|
-
}).then(async (
|
|
1816
|
+
}).then(async (a) => (await this.setMaxBitrate(), a));
|
|
1182
1817
|
}
|
|
1183
1818
|
cancelSendPresentationWithRepeatedCalls() {
|
|
1184
1819
|
this.cancelableSendPresentationWithRepeatedCalls?.stopRepeatedCalls();
|
|
@@ -1216,18 +1851,18 @@ class Tt {
|
|
|
1216
1851
|
stream: s,
|
|
1217
1852
|
presentationOptions: i,
|
|
1218
1853
|
options: r = {
|
|
1219
|
-
callLimit:
|
|
1854
|
+
callLimit: _t
|
|
1220
1855
|
}
|
|
1221
1856
|
}) {
|
|
1222
|
-
const
|
|
1857
|
+
const o = async () => this.sendPresentation(
|
|
1223
1858
|
e,
|
|
1224
1859
|
t,
|
|
1225
1860
|
s,
|
|
1226
1861
|
i
|
|
1227
|
-
),
|
|
1228
|
-
return this.cancelableSendPresentationWithRepeatedCalls =
|
|
1229
|
-
targetFunction:
|
|
1230
|
-
isComplete:
|
|
1862
|
+
), a = () => !!this.streamPresentationCurrent;
|
|
1863
|
+
return this.cancelableSendPresentationWithRepeatedCalls = ce({
|
|
1864
|
+
targetFunction: o,
|
|
1865
|
+
isComplete: a,
|
|
1231
1866
|
isRejectAsValid: !0,
|
|
1232
1867
|
...r
|
|
1233
1868
|
}), this.cancelableSendPresentationWithRepeatedCalls.then((c) => c);
|
|
@@ -1236,24 +1871,24 @@ class Tt {
|
|
|
1236
1871
|
async sendPresentation(e, t, s, {
|
|
1237
1872
|
isNeedReinvite: i = !0,
|
|
1238
1873
|
contentHint: r = "detail",
|
|
1239
|
-
degradationPreference:
|
|
1240
|
-
sendEncodings:
|
|
1874
|
+
degradationPreference: o,
|
|
1875
|
+
sendEncodings: a,
|
|
1241
1876
|
onAddedTransceiver: c
|
|
1242
1877
|
}) {
|
|
1243
|
-
const d =
|
|
1878
|
+
const d = k(s, { contentHint: r });
|
|
1244
1879
|
if (d === void 0)
|
|
1245
1880
|
throw new Error("No streamPresentationTarget");
|
|
1246
1881
|
this.streamPresentationCurrent = d;
|
|
1247
|
-
const
|
|
1248
|
-
degradationPreference:
|
|
1249
|
-
sendEncodings:
|
|
1882
|
+
const T = e().then(async () => t.startPresentation(d, i, {
|
|
1883
|
+
degradationPreference: o,
|
|
1884
|
+
sendEncodings: a,
|
|
1250
1885
|
onAddedTransceiver: c
|
|
1251
|
-
})).then(this.setMaxBitrate).then(() => s).catch((
|
|
1886
|
+
})).then(this.setMaxBitrate).then(() => s).catch((h) => {
|
|
1252
1887
|
this.removeStreamPresentationCurrent();
|
|
1253
|
-
const
|
|
1254
|
-
throw this.events.trigger(P.FAILED_PRESENTATION,
|
|
1888
|
+
const u = h instanceof Error ? h : new Error(String(h));
|
|
1889
|
+
throw this.events.trigger(P.FAILED_PRESENTATION, u), h;
|
|
1255
1890
|
});
|
|
1256
|
-
return this.promisePendingStartPresentation =
|
|
1891
|
+
return this.promisePendingStartPresentation = T, T.finally(() => {
|
|
1257
1892
|
this.promisePendingStartPresentation = void 0;
|
|
1258
1893
|
});
|
|
1259
1894
|
}
|
|
@@ -1262,7 +1897,7 @@ class Tt {
|
|
|
1262
1897
|
if (!e || !t || s === void 0)
|
|
1263
1898
|
return;
|
|
1264
1899
|
const i = e.getSenders();
|
|
1265
|
-
await
|
|
1900
|
+
await At(i, t, s);
|
|
1266
1901
|
};
|
|
1267
1902
|
getRtcSessionProtected = () => {
|
|
1268
1903
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1283,7 +1918,7 @@ class Tt {
|
|
|
1283
1918
|
delete this.streamPresentationCurrent;
|
|
1284
1919
|
}
|
|
1285
1920
|
}
|
|
1286
|
-
class
|
|
1921
|
+
class Pt {
|
|
1287
1922
|
data;
|
|
1288
1923
|
getUa;
|
|
1289
1924
|
constructor(e) {
|
|
@@ -1369,8 +2004,8 @@ class St {
|
|
|
1369
2004
|
return this.data?.register === !0;
|
|
1370
2005
|
}
|
|
1371
2006
|
}
|
|
1372
|
-
var
|
|
1373
|
-
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 me = [
|
|
1374
2009
|
"connecting",
|
|
1375
2010
|
"connected",
|
|
1376
2011
|
"disconnected",
|
|
@@ -1380,7 +2015,7 @@ const Se = [
|
|
|
1380
2015
|
"registrationFailed",
|
|
1381
2016
|
"newMessage",
|
|
1382
2017
|
"sipEvent"
|
|
1383
|
-
],
|
|
2018
|
+
], bt = [
|
|
1384
2019
|
"disconnecting",
|
|
1385
2020
|
"connect-started",
|
|
1386
2021
|
"connect-succeeded",
|
|
@@ -1388,12 +2023,12 @@ const Se = [
|
|
|
1388
2023
|
"connect-parameters-resolve-success",
|
|
1389
2024
|
"connect-parameters-resolve-failed",
|
|
1390
2025
|
"connected-with-configuration"
|
|
1391
|
-
],
|
|
1392
|
-
function
|
|
2026
|
+
], Ne = [...me, ...bt], Dt = () => new O(Ne);
|
|
2027
|
+
function yt(n) {
|
|
1393
2028
|
return (e) => `sip:${e}@${n}`;
|
|
1394
2029
|
}
|
|
1395
|
-
const
|
|
1396
|
-
class
|
|
2030
|
+
const Lt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Re = (n) => n.trim().replaceAll(" ", "_"), wt = Lt(1e5, 99999999), Ut = 3;
|
|
2031
|
+
class Ft {
|
|
1397
2032
|
cancelableConnectWithRepeatedCalls;
|
|
1398
2033
|
JsSIP;
|
|
1399
2034
|
events;
|
|
@@ -1418,31 +2053,31 @@ class Nt {
|
|
|
1418
2053
|
return;
|
|
1419
2054
|
}
|
|
1420
2055
|
let r = !1;
|
|
1421
|
-
const
|
|
1422
|
-
e !== void 0 && e !==
|
|
1423
|
-
const
|
|
1424
|
-
|
|
2056
|
+
const o = this.getConnectionConfiguration();
|
|
2057
|
+
e !== void 0 && e !== o?.displayName && (r = i.set("display_name", Re(e)), this.updateConnectionConfiguration("displayName", e));
|
|
2058
|
+
const a = r;
|
|
2059
|
+
a ? t(a) : s(new Error("nothing changed"));
|
|
1425
2060
|
});
|
|
1426
2061
|
disconnect = async () => {
|
|
1427
|
-
this.events.trigger(
|
|
2062
|
+
this.events.trigger(S.DISCONNECTING, {});
|
|
1428
2063
|
const e = new Promise((s) => {
|
|
1429
|
-
this.events.once(
|
|
2064
|
+
this.events.once(S.DISCONNECTED, () => {
|
|
1430
2065
|
s();
|
|
1431
2066
|
});
|
|
1432
2067
|
}), t = this.getUa();
|
|
1433
|
-
return t ? t.stop() : this.events.trigger(
|
|
2068
|
+
return t ? t.stop() : this.events.trigger(S.DISCONNECTED, { socket: {}, error: !1 }), e.finally(() => {
|
|
1434
2069
|
t?.removeAllListeners(), this.setUa(void 0), this.stateMachine.reset();
|
|
1435
2070
|
});
|
|
1436
2071
|
};
|
|
1437
2072
|
cancelRequests() {
|
|
1438
2073
|
this.cancelConnectWithRepeatedCalls();
|
|
1439
2074
|
}
|
|
1440
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
2075
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = Ut } = {}) => {
|
|
1441
2076
|
const s = async () => this.connectInner(e), i = (r) => {
|
|
1442
|
-
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !
|
|
2077
|
+
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !xe(r);
|
|
1443
2078
|
return c || d;
|
|
1444
2079
|
};
|
|
1445
|
-
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls =
|
|
2080
|
+
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ce({
|
|
1446
2081
|
targetFunction: s,
|
|
1447
2082
|
isComplete: i,
|
|
1448
2083
|
callLimit: t,
|
|
@@ -1473,42 +2108,42 @@ class Nt {
|
|
|
1473
2108
|
sipServerIp: s,
|
|
1474
2109
|
sipServerUrl: i,
|
|
1475
2110
|
remoteAddress: r,
|
|
1476
|
-
sessionTimers:
|
|
1477
|
-
registerExpires:
|
|
2111
|
+
sessionTimers: o,
|
|
2112
|
+
registerExpires: a,
|
|
1478
2113
|
connectionRecoveryMinInterval: c,
|
|
1479
2114
|
connectionRecoveryMaxInterval: d,
|
|
1480
|
-
userAgent:
|
|
1481
|
-
displayName:
|
|
1482
|
-
register:
|
|
2115
|
+
userAgent: T,
|
|
2116
|
+
displayName: h = "",
|
|
2117
|
+
register: u = !1,
|
|
1483
2118
|
extraHeaders: p = []
|
|
1484
2119
|
}) => {
|
|
1485
2120
|
this.stateMachine.startInitUa(), this.setConnectionConfiguration({
|
|
1486
2121
|
sipServerIp: s,
|
|
1487
2122
|
sipServerUrl: i,
|
|
1488
|
-
displayName:
|
|
1489
|
-
register:
|
|
2123
|
+
displayName: h,
|
|
2124
|
+
register: u,
|
|
1490
2125
|
user: e,
|
|
1491
2126
|
password: t
|
|
1492
2127
|
}), this.getUa() && await this.disconnect();
|
|
1493
|
-
const { ua:
|
|
2128
|
+
const { ua: N, helpers: D } = this.uaFactory.createUAWithConfiguration(
|
|
1494
2129
|
{
|
|
1495
2130
|
user: e,
|
|
1496
2131
|
password: t,
|
|
1497
2132
|
sipServerIp: s,
|
|
1498
2133
|
sipServerUrl: i,
|
|
1499
|
-
displayName:
|
|
1500
|
-
register:
|
|
1501
|
-
sessionTimers:
|
|
1502
|
-
registerExpires:
|
|
2134
|
+
displayName: h,
|
|
2135
|
+
register: u,
|
|
2136
|
+
sessionTimers: o,
|
|
2137
|
+
registerExpires: a,
|
|
1503
2138
|
connectionRecoveryMinInterval: c,
|
|
1504
2139
|
connectionRecoveryMaxInterval: d,
|
|
1505
|
-
userAgent:
|
|
2140
|
+
userAgent: T,
|
|
1506
2141
|
remoteAddress: r,
|
|
1507
2142
|
extraHeaders: p
|
|
1508
2143
|
},
|
|
1509
2144
|
this.events
|
|
1510
2145
|
);
|
|
1511
|
-
return this.setUa(
|
|
2146
|
+
return this.setUa(N), this.setGetUri(D.getUri), this.setSocket(D.socket), N;
|
|
1512
2147
|
};
|
|
1513
2148
|
start = async () => new Promise((e, t) => {
|
|
1514
2149
|
const s = this.getUa();
|
|
@@ -1520,11 +2155,11 @@ class Nt {
|
|
|
1520
2155
|
i = ((c, d) => {
|
|
1521
2156
|
if (this.getConnectionConfiguration()?.register === !0)
|
|
1522
2157
|
return this.registrationManager.subscribeToStartEvents(c, d);
|
|
1523
|
-
const
|
|
1524
|
-
return this.events.on(
|
|
2158
|
+
const h = S.CONNECTED, u = [S.DISCONNECTED];
|
|
2159
|
+
return this.events.on(h, c), u.forEach((p) => {
|
|
1525
2160
|
this.events.on(p, d);
|
|
1526
2161
|
}), () => {
|
|
1527
|
-
this.events.off(
|
|
2162
|
+
this.events.off(h, c), u.forEach((p) => {
|
|
1528
2163
|
this.events.off(p, d);
|
|
1529
2164
|
});
|
|
1530
2165
|
};
|
|
@@ -1538,50 +2173,62 @@ class Nt {
|
|
|
1538
2173
|
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
1539
2174
|
}
|
|
1540
2175
|
proxyEvents() {
|
|
1541
|
-
this.events.on(
|
|
2176
|
+
this.events.on(S.CONNECTED, () => {
|
|
1542
2177
|
const e = this.getConnectionConfiguration(), t = this.getUa();
|
|
1543
|
-
e !== void 0 && t !== void 0 && this.events.trigger(
|
|
2178
|
+
e !== void 0 && t !== void 0 && this.events.trigger(S.CONNECTED_WITH_CONFIGURATION, {
|
|
1544
2179
|
...e,
|
|
1545
2180
|
ua: t
|
|
1546
2181
|
});
|
|
1547
2182
|
});
|
|
1548
2183
|
}
|
|
1549
2184
|
}
|
|
1550
|
-
var
|
|
1551
|
-
const
|
|
2185
|
+
var Ae = /* @__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))(Ae || {});
|
|
2186
|
+
const Bt = Object.values(Ae);
|
|
2187
|
+
var kt = /* @__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))(kt || {});
|
|
2188
|
+
const Gt = $({
|
|
1552
2189
|
types: {
|
|
1553
2190
|
context: {},
|
|
1554
2191
|
events: {}
|
|
1555
2192
|
},
|
|
1556
2193
|
actions: {
|
|
1557
2194
|
logTransition: (n, e) => {
|
|
1558
|
-
|
|
2195
|
+
l(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1559
2196
|
},
|
|
1560
2197
|
logStateChange: (n, e) => {
|
|
1561
|
-
|
|
1562
|
-
}
|
|
2198
|
+
l("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
|
+
})
|
|
1563
2210
|
}
|
|
1564
2211
|
}).createMachine({
|
|
1565
2212
|
id: "connection",
|
|
1566
|
-
initial: "idle",
|
|
2213
|
+
initial: "connection:idle",
|
|
1567
2214
|
context: {},
|
|
1568
2215
|
states: {
|
|
1569
|
-
idle: {
|
|
2216
|
+
"connection:idle": {
|
|
1570
2217
|
entry: {
|
|
1571
2218
|
type: "logStateChange",
|
|
1572
2219
|
params: {
|
|
1573
|
-
state: "idle"
|
|
2220
|
+
state: "connection:idle"
|
|
1574
2221
|
/* IDLE */
|
|
1575
2222
|
}
|
|
1576
2223
|
},
|
|
1577
2224
|
on: {
|
|
1578
2225
|
START_CONNECT: {
|
|
1579
|
-
target: "connecting",
|
|
2226
|
+
target: "connection:connecting",
|
|
1580
2227
|
actions: {
|
|
1581
2228
|
type: "logTransition",
|
|
1582
2229
|
params: {
|
|
1583
|
-
from: "idle",
|
|
1584
|
-
to: "connecting",
|
|
2230
|
+
from: "connection:idle",
|
|
2231
|
+
to: "connection:connecting",
|
|
1585
2232
|
event: "START_CONNECT"
|
|
1586
2233
|
/* START_CONNECT */
|
|
1587
2234
|
}
|
|
@@ -1589,235 +2236,258 @@ const mt = Le({
|
|
|
1589
2236
|
}
|
|
1590
2237
|
}
|
|
1591
2238
|
},
|
|
1592
|
-
connecting: {
|
|
2239
|
+
"connection:connecting": {
|
|
1593
2240
|
entry: {
|
|
1594
2241
|
type: "logStateChange",
|
|
1595
2242
|
params: {
|
|
1596
|
-
state: "connecting"
|
|
2243
|
+
state: "connection:connecting"
|
|
1597
2244
|
/* CONNECTING */
|
|
1598
2245
|
}
|
|
1599
2246
|
},
|
|
1600
2247
|
on: {
|
|
1601
2248
|
START_INIT_UA: {
|
|
1602
|
-
target: "initializing",
|
|
2249
|
+
target: "connection:initializing",
|
|
1603
2250
|
actions: {
|
|
1604
2251
|
type: "logTransition",
|
|
1605
2252
|
params: {
|
|
1606
|
-
from: "connecting",
|
|
1607
|
-
to: "initializing",
|
|
2253
|
+
from: "connection:connecting",
|
|
2254
|
+
to: "connection:initializing",
|
|
1608
2255
|
event: "START_INIT_UA"
|
|
1609
2256
|
/* START_INIT_UA */
|
|
1610
|
-
// TODO: remove
|
|
1611
2257
|
}
|
|
1612
2258
|
}
|
|
1613
2259
|
},
|
|
1614
2260
|
UA_DISCONNECTED: {
|
|
1615
|
-
target: "disconnected",
|
|
2261
|
+
target: "connection:disconnected",
|
|
1616
2262
|
actions: {
|
|
1617
2263
|
type: "logTransition",
|
|
1618
2264
|
params: {
|
|
1619
|
-
from: "connecting",
|
|
1620
|
-
to: "disconnected",
|
|
2265
|
+
from: "connection:connecting",
|
|
2266
|
+
to: "connection:disconnected",
|
|
1621
2267
|
event: "UA_DISCONNECTED"
|
|
1622
2268
|
/* UA_DISCONNECTED */
|
|
1623
2269
|
}
|
|
1624
2270
|
}
|
|
1625
2271
|
},
|
|
1626
2272
|
CONNECTION_FAILED: {
|
|
1627
|
-
target: "failed",
|
|
1628
|
-
actions:
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
2273
|
+
target: "connection:failed",
|
|
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 */
|
|
1635
2287
|
}
|
|
1636
|
-
|
|
2288
|
+
]
|
|
1637
2289
|
}
|
|
1638
2290
|
}
|
|
1639
2291
|
},
|
|
1640
|
-
initializing: {
|
|
2292
|
+
"connection:initializing": {
|
|
1641
2293
|
entry: {
|
|
1642
2294
|
type: "logStateChange",
|
|
1643
2295
|
params: {
|
|
1644
|
-
state: "initializing"
|
|
2296
|
+
state: "connection:initializing"
|
|
1645
2297
|
/* INITIALIZING */
|
|
1646
2298
|
}
|
|
1647
2299
|
},
|
|
1648
2300
|
on: {
|
|
1649
2301
|
UA_CONNECTED: {
|
|
1650
|
-
target: "connected",
|
|
2302
|
+
target: "connection:connected",
|
|
1651
2303
|
actions: {
|
|
1652
2304
|
type: "logTransition",
|
|
1653
2305
|
params: {
|
|
1654
|
-
from: "initializing",
|
|
1655
|
-
to: "connected",
|
|
2306
|
+
from: "connection:initializing",
|
|
2307
|
+
to: "connection:connected",
|
|
1656
2308
|
event: "UA_CONNECTED"
|
|
1657
2309
|
/* UA_CONNECTED */
|
|
1658
2310
|
}
|
|
1659
2311
|
}
|
|
1660
2312
|
},
|
|
1661
2313
|
UA_REGISTERED: {
|
|
1662
|
-
target: "registered",
|
|
2314
|
+
target: "connection:registered",
|
|
1663
2315
|
actions: {
|
|
1664
2316
|
type: "logTransition",
|
|
1665
2317
|
params: {
|
|
1666
|
-
from: "initializing",
|
|
1667
|
-
to: "registered",
|
|
2318
|
+
from: "connection:initializing",
|
|
2319
|
+
to: "connection:registered",
|
|
1668
2320
|
event: "UA_REGISTERED"
|
|
1669
2321
|
/* UA_REGISTERED */
|
|
1670
2322
|
}
|
|
1671
2323
|
}
|
|
1672
2324
|
},
|
|
1673
2325
|
UA_DISCONNECTED: {
|
|
1674
|
-
target: "disconnected",
|
|
2326
|
+
target: "connection:disconnected",
|
|
1675
2327
|
actions: {
|
|
1676
2328
|
type: "logTransition",
|
|
1677
2329
|
params: {
|
|
1678
|
-
from: "initializing",
|
|
1679
|
-
to: "disconnected",
|
|
2330
|
+
from: "connection:initializing",
|
|
2331
|
+
to: "connection:disconnected",
|
|
1680
2332
|
event: "UA_DISCONNECTED"
|
|
1681
2333
|
/* UA_DISCONNECTED */
|
|
1682
2334
|
}
|
|
1683
2335
|
}
|
|
1684
2336
|
},
|
|
1685
2337
|
CONNECTION_FAILED: {
|
|
1686
|
-
target: "failed",
|
|
1687
|
-
actions:
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
2338
|
+
target: "connection:failed",
|
|
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 */
|
|
1694
2352
|
}
|
|
1695
|
-
|
|
2353
|
+
]
|
|
1696
2354
|
}
|
|
1697
2355
|
}
|
|
1698
2356
|
},
|
|
1699
|
-
connected: {
|
|
2357
|
+
"connection:connected": {
|
|
1700
2358
|
entry: {
|
|
1701
2359
|
type: "logStateChange",
|
|
1702
2360
|
params: {
|
|
1703
|
-
state: "connected"
|
|
2361
|
+
state: "connection:connected"
|
|
1704
2362
|
/* CONNECTED */
|
|
1705
2363
|
}
|
|
1706
2364
|
},
|
|
1707
2365
|
on: {
|
|
1708
2366
|
UA_REGISTERED: {
|
|
1709
|
-
target: "registered",
|
|
2367
|
+
target: "connection:registered",
|
|
1710
2368
|
actions: {
|
|
1711
2369
|
type: "logTransition",
|
|
1712
2370
|
params: {
|
|
1713
|
-
from: "connected",
|
|
1714
|
-
to: "registered",
|
|
2371
|
+
from: "connection:connected",
|
|
2372
|
+
to: "connection:registered",
|
|
1715
2373
|
event: "UA_REGISTERED"
|
|
1716
2374
|
/* UA_REGISTERED */
|
|
1717
2375
|
}
|
|
1718
2376
|
}
|
|
1719
2377
|
},
|
|
1720
2378
|
UA_DISCONNECTED: {
|
|
1721
|
-
target: "disconnected",
|
|
2379
|
+
target: "connection:disconnected",
|
|
1722
2380
|
actions: {
|
|
1723
2381
|
type: "logTransition",
|
|
1724
2382
|
params: {
|
|
1725
|
-
from: "connected",
|
|
1726
|
-
to: "disconnected",
|
|
2383
|
+
from: "connection:connected",
|
|
2384
|
+
to: "connection:disconnected",
|
|
1727
2385
|
event: "UA_DISCONNECTED"
|
|
1728
2386
|
/* UA_DISCONNECTED */
|
|
1729
2387
|
}
|
|
1730
2388
|
}
|
|
1731
2389
|
},
|
|
1732
2390
|
CONNECTION_FAILED: {
|
|
1733
|
-
target: "failed",
|
|
1734
|
-
actions:
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
2391
|
+
target: "connection:failed",
|
|
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 */
|
|
1741
2405
|
}
|
|
1742
|
-
|
|
2406
|
+
]
|
|
1743
2407
|
}
|
|
1744
2408
|
}
|
|
1745
2409
|
},
|
|
1746
|
-
registered: {
|
|
2410
|
+
"connection:registered": {
|
|
1747
2411
|
entry: {
|
|
1748
2412
|
type: "logStateChange",
|
|
1749
2413
|
params: {
|
|
1750
|
-
state: "registered"
|
|
2414
|
+
state: "connection:registered"
|
|
1751
2415
|
/* REGISTERED */
|
|
1752
2416
|
}
|
|
1753
2417
|
},
|
|
1754
2418
|
on: {
|
|
1755
2419
|
UA_UNREGISTERED: {
|
|
1756
|
-
target: "connected",
|
|
2420
|
+
target: "connection:connected",
|
|
1757
2421
|
actions: {
|
|
1758
2422
|
type: "logTransition",
|
|
1759
2423
|
params: {
|
|
1760
|
-
from: "registered",
|
|
1761
|
-
to: "connected",
|
|
2424
|
+
from: "connection:registered",
|
|
2425
|
+
to: "connection:connected",
|
|
1762
2426
|
event: "UA_UNREGISTERED"
|
|
1763
2427
|
/* UA_UNREGISTERED */
|
|
1764
2428
|
}
|
|
1765
2429
|
}
|
|
1766
2430
|
},
|
|
1767
2431
|
UA_DISCONNECTED: {
|
|
1768
|
-
target: "disconnected",
|
|
2432
|
+
target: "connection:disconnected",
|
|
1769
2433
|
actions: {
|
|
1770
2434
|
type: "logTransition",
|
|
1771
2435
|
params: {
|
|
1772
|
-
from: "registered",
|
|
1773
|
-
to: "disconnected",
|
|
2436
|
+
from: "connection:registered",
|
|
2437
|
+
to: "connection:disconnected",
|
|
1774
2438
|
event: "UA_DISCONNECTED"
|
|
1775
2439
|
/* UA_DISCONNECTED */
|
|
1776
2440
|
}
|
|
1777
2441
|
}
|
|
1778
2442
|
},
|
|
1779
2443
|
CONNECTION_FAILED: {
|
|
1780
|
-
target: "failed",
|
|
1781
|
-
actions:
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
2444
|
+
target: "connection:failed",
|
|
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 */
|
|
1788
2458
|
}
|
|
1789
|
-
|
|
2459
|
+
]
|
|
1790
2460
|
}
|
|
1791
2461
|
}
|
|
1792
2462
|
},
|
|
1793
|
-
disconnected: {
|
|
2463
|
+
"connection:disconnected": {
|
|
1794
2464
|
entry: {
|
|
1795
2465
|
type: "logStateChange",
|
|
1796
2466
|
params: {
|
|
1797
|
-
state: "disconnected"
|
|
2467
|
+
state: "connection:disconnected"
|
|
1798
2468
|
/* DISCONNECTED */
|
|
1799
2469
|
}
|
|
1800
2470
|
},
|
|
1801
2471
|
on: {
|
|
1802
2472
|
RESET: {
|
|
1803
|
-
target: "idle",
|
|
2473
|
+
target: "connection:idle",
|
|
1804
2474
|
actions: {
|
|
1805
2475
|
type: "logTransition",
|
|
1806
2476
|
params: {
|
|
1807
|
-
from: "disconnected",
|
|
1808
|
-
to: "idle",
|
|
2477
|
+
from: "connection:disconnected",
|
|
2478
|
+
to: "connection:idle",
|
|
1809
2479
|
event: "RESET"
|
|
1810
2480
|
/* RESET */
|
|
1811
2481
|
}
|
|
1812
2482
|
}
|
|
1813
2483
|
},
|
|
1814
2484
|
START_CONNECT: {
|
|
1815
|
-
target: "connecting",
|
|
2485
|
+
target: "connection:connecting",
|
|
1816
2486
|
actions: {
|
|
1817
2487
|
type: "logTransition",
|
|
1818
2488
|
params: {
|
|
1819
|
-
from: "disconnected",
|
|
1820
|
-
to: "connecting",
|
|
2489
|
+
from: "connection:disconnected",
|
|
2490
|
+
to: "connection:connecting",
|
|
1821
2491
|
event: "START_CONNECT"
|
|
1822
2492
|
/* START_CONNECT */
|
|
1823
2493
|
}
|
|
@@ -1825,102 +2495,114 @@ const mt = Le({
|
|
|
1825
2495
|
}
|
|
1826
2496
|
}
|
|
1827
2497
|
},
|
|
1828
|
-
failed: {
|
|
2498
|
+
"connection:failed": {
|
|
1829
2499
|
entry: {
|
|
1830
2500
|
type: "logStateChange",
|
|
1831
2501
|
params: {
|
|
1832
|
-
state: "failed"
|
|
2502
|
+
state: "connection:failed"
|
|
1833
2503
|
/* FAILED */
|
|
1834
2504
|
}
|
|
1835
2505
|
},
|
|
1836
2506
|
on: {
|
|
1837
2507
|
RESET: {
|
|
1838
|
-
target: "idle",
|
|
1839
|
-
actions:
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
2508
|
+
target: "connection:idle",
|
|
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 */
|
|
1846
2522
|
}
|
|
1847
|
-
|
|
2523
|
+
]
|
|
1848
2524
|
},
|
|
1849
2525
|
START_CONNECT: {
|
|
1850
|
-
target: "connecting",
|
|
1851
|
-
actions:
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
2526
|
+
target: "connection:connecting",
|
|
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 */
|
|
1858
2540
|
}
|
|
1859
|
-
|
|
2541
|
+
]
|
|
1860
2542
|
}
|
|
1861
2543
|
}
|
|
1862
2544
|
}
|
|
1863
2545
|
}
|
|
1864
2546
|
});
|
|
1865
|
-
class
|
|
1866
|
-
actor;
|
|
2547
|
+
class $t extends q {
|
|
1867
2548
|
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
1868
2549
|
events;
|
|
1869
2550
|
unsubscribeFromEvents;
|
|
1870
|
-
actorSubscription;
|
|
1871
2551
|
constructor(e) {
|
|
1872
|
-
this.events = e, this.
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
i
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
return this.actor.getSnapshot().value;
|
|
2552
|
+
super(Gt), 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();
|
|
1881
2560
|
}
|
|
1882
2561
|
get isIdle() {
|
|
1883
2562
|
return this.hasState(
|
|
1884
|
-
"idle"
|
|
2563
|
+
"connection:idle"
|
|
1885
2564
|
/* IDLE */
|
|
1886
2565
|
);
|
|
1887
2566
|
}
|
|
1888
2567
|
get isConnecting() {
|
|
1889
2568
|
return this.hasState(
|
|
1890
|
-
"connecting"
|
|
2569
|
+
"connection:connecting"
|
|
1891
2570
|
/* CONNECTING */
|
|
1892
2571
|
);
|
|
1893
2572
|
}
|
|
1894
2573
|
get isInitializing() {
|
|
1895
2574
|
return this.hasState(
|
|
1896
|
-
"initializing"
|
|
2575
|
+
"connection:initializing"
|
|
1897
2576
|
/* INITIALIZING */
|
|
1898
2577
|
);
|
|
1899
2578
|
}
|
|
1900
2579
|
get isConnected() {
|
|
1901
2580
|
return this.hasState(
|
|
1902
|
-
"connected"
|
|
2581
|
+
"connection:connected"
|
|
1903
2582
|
/* CONNECTED */
|
|
1904
2583
|
);
|
|
1905
2584
|
}
|
|
1906
2585
|
get isRegistered() {
|
|
1907
2586
|
return this.hasState(
|
|
1908
|
-
"registered"
|
|
2587
|
+
"connection:registered"
|
|
1909
2588
|
/* REGISTERED */
|
|
1910
2589
|
);
|
|
1911
2590
|
}
|
|
1912
2591
|
get isDisconnected() {
|
|
1913
2592
|
return this.hasState(
|
|
1914
|
-
"disconnected"
|
|
2593
|
+
"connection:disconnected"
|
|
1915
2594
|
/* DISCONNECTED */
|
|
1916
2595
|
);
|
|
1917
2596
|
}
|
|
1918
2597
|
get isFailed() {
|
|
1919
2598
|
return this.hasState(
|
|
1920
|
-
"failed"
|
|
2599
|
+
"connection:failed"
|
|
1921
2600
|
/* FAILED */
|
|
1922
2601
|
);
|
|
1923
2602
|
}
|
|
2603
|
+
get error() {
|
|
2604
|
+
return this.getSnapshot().context.error;
|
|
2605
|
+
}
|
|
1924
2606
|
get isPending() {
|
|
1925
2607
|
return this.isConnecting || this.isInitializing;
|
|
1926
2608
|
}
|
|
@@ -1944,7 +2626,7 @@ class It {
|
|
|
1944
2626
|
this.toIdle();
|
|
1945
2627
|
}
|
|
1946
2628
|
destroy() {
|
|
1947
|
-
this.
|
|
2629
|
+
this.stateChangeListeners.clear(), this.unsubscribeFromEvents?.(), this.stop();
|
|
1948
2630
|
}
|
|
1949
2631
|
onStateChange(e) {
|
|
1950
2632
|
return this.stateChangeListeners.add(e), () => {
|
|
@@ -1952,79 +2634,82 @@ class It {
|
|
|
1952
2634
|
};
|
|
1953
2635
|
}
|
|
1954
2636
|
canTransition(e) {
|
|
1955
|
-
return this.
|
|
2637
|
+
return this.getSnapshot().can({ type: e });
|
|
1956
2638
|
}
|
|
1957
2639
|
getValidEvents() {
|
|
1958
|
-
return
|
|
2640
|
+
return Bt.filter((e) => this.canTransition(e));
|
|
1959
2641
|
}
|
|
1960
2642
|
hasState(e) {
|
|
1961
|
-
return this.
|
|
2643
|
+
return this.getSnapshot().matches(e);
|
|
1962
2644
|
}
|
|
1963
2645
|
sendEvent(e) {
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
2646
|
+
if (!this.getSnapshot().can(e)) {
|
|
2647
|
+
l(
|
|
2648
|
+
`Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1968
2649
|
);
|
|
1969
2650
|
return;
|
|
1970
2651
|
}
|
|
1971
|
-
this.
|
|
2652
|
+
this.send(e);
|
|
1972
2653
|
}
|
|
1973
2654
|
toStartConnect = () => {
|
|
1974
|
-
this.sendEvent(
|
|
1975
|
-
"START_CONNECT"
|
|
2655
|
+
this.sendEvent({
|
|
2656
|
+
type: "START_CONNECT"
|
|
1976
2657
|
/* START_CONNECT */
|
|
1977
|
-
);
|
|
2658
|
+
});
|
|
1978
2659
|
};
|
|
1979
2660
|
toStartInitUa = () => {
|
|
1980
|
-
this.sendEvent(
|
|
1981
|
-
"START_INIT_UA"
|
|
2661
|
+
this.sendEvent({
|
|
2662
|
+
type: "START_INIT_UA"
|
|
1982
2663
|
/* START_INIT_UA */
|
|
1983
|
-
);
|
|
2664
|
+
});
|
|
1984
2665
|
};
|
|
1985
2666
|
toConnected = () => {
|
|
1986
|
-
this.sendEvent(
|
|
1987
|
-
"UA_CONNECTED"
|
|
2667
|
+
this.sendEvent({
|
|
2668
|
+
type: "UA_CONNECTED"
|
|
1988
2669
|
/* UA_CONNECTED */
|
|
1989
|
-
);
|
|
2670
|
+
});
|
|
1990
2671
|
};
|
|
1991
2672
|
toRegistered = () => {
|
|
1992
|
-
this.sendEvent(
|
|
1993
|
-
"UA_REGISTERED"
|
|
2673
|
+
this.sendEvent({
|
|
2674
|
+
type: "UA_REGISTERED"
|
|
1994
2675
|
/* UA_REGISTERED */
|
|
1995
|
-
);
|
|
2676
|
+
});
|
|
1996
2677
|
};
|
|
1997
2678
|
toUnregistered = () => {
|
|
1998
|
-
this.sendEvent(
|
|
1999
|
-
"UA_UNREGISTERED"
|
|
2679
|
+
this.sendEvent({
|
|
2680
|
+
type: "UA_UNREGISTERED"
|
|
2000
2681
|
/* UA_UNREGISTERED */
|
|
2001
|
-
);
|
|
2682
|
+
});
|
|
2002
2683
|
};
|
|
2003
2684
|
toDisconnected = () => {
|
|
2004
|
-
this.sendEvent(
|
|
2005
|
-
"UA_DISCONNECTED"
|
|
2685
|
+
this.sendEvent({
|
|
2686
|
+
type: "UA_DISCONNECTED"
|
|
2006
2687
|
/* UA_DISCONNECTED */
|
|
2007
|
-
);
|
|
2688
|
+
});
|
|
2008
2689
|
};
|
|
2009
|
-
toFailed = () => {
|
|
2010
|
-
this.sendEvent(
|
|
2011
|
-
"CONNECTION_FAILED"
|
|
2012
|
-
/* CONNECTION_FAILED */
|
|
2013
|
-
);
|
|
2690
|
+
toFailed = (e) => {
|
|
2691
|
+
this.sendEvent({ type: "CONNECTION_FAILED", error: e });
|
|
2014
2692
|
};
|
|
2015
2693
|
toIdle = () => {
|
|
2016
|
-
this.sendEvent(
|
|
2017
|
-
"RESET"
|
|
2694
|
+
this.sendEvent({
|
|
2695
|
+
type: "RESET"
|
|
2018
2696
|
/* RESET */
|
|
2019
|
-
);
|
|
2697
|
+
});
|
|
2020
2698
|
};
|
|
2021
2699
|
subscribeToEvents() {
|
|
2022
|
-
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.
|
|
2023
|
-
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);
|
|
2024
2702
|
};
|
|
2025
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
|
+
};
|
|
2026
2711
|
}
|
|
2027
|
-
class
|
|
2712
|
+
class qt {
|
|
2028
2713
|
events;
|
|
2029
2714
|
getUaProtected;
|
|
2030
2715
|
constructor(e) {
|
|
@@ -2033,25 +2718,25 @@ class _t {
|
|
|
2033
2718
|
async register() {
|
|
2034
2719
|
const e = this.getUaProtected();
|
|
2035
2720
|
return new Promise((t, s) => {
|
|
2036
|
-
e.on(
|
|
2721
|
+
e.on(S.REGISTERED, t), e.on(S.REGISTRATION_FAILED, s), e.register();
|
|
2037
2722
|
});
|
|
2038
2723
|
}
|
|
2039
2724
|
async unregister() {
|
|
2040
2725
|
const e = this.getUaProtected();
|
|
2041
2726
|
return new Promise((t) => {
|
|
2042
|
-
e.on(
|
|
2727
|
+
e.on(S.UNREGISTERED, t), e.unregister();
|
|
2043
2728
|
});
|
|
2044
2729
|
}
|
|
2045
2730
|
async tryRegister() {
|
|
2046
2731
|
try {
|
|
2047
2732
|
await this.unregister();
|
|
2048
2733
|
} catch (e) {
|
|
2049
|
-
|
|
2734
|
+
l("tryRegister", e);
|
|
2050
2735
|
}
|
|
2051
2736
|
return this.register();
|
|
2052
2737
|
}
|
|
2053
2738
|
subscribeToStartEvents(e, t) {
|
|
2054
|
-
const s =
|
|
2739
|
+
const s = S.REGISTERED, i = [S.REGISTRATION_FAILED, S.DISCONNECTED];
|
|
2055
2740
|
return this.events.on(s, e), i.forEach((r) => {
|
|
2056
2741
|
this.events.on(r, t);
|
|
2057
2742
|
}), () => {
|
|
@@ -2061,7 +2746,7 @@ class _t {
|
|
|
2061
2746
|
};
|
|
2062
2747
|
}
|
|
2063
2748
|
}
|
|
2064
|
-
class
|
|
2749
|
+
class Vt {
|
|
2065
2750
|
uaFactory;
|
|
2066
2751
|
getUaProtected;
|
|
2067
2752
|
constructor(e) {
|
|
@@ -2072,7 +2757,7 @@ class ft {
|
|
|
2072
2757
|
*/
|
|
2073
2758
|
async sendOptions(e, t, s) {
|
|
2074
2759
|
const i = this.getUaProtected();
|
|
2075
|
-
return new Promise((r,
|
|
2760
|
+
return new Promise((r, o) => {
|
|
2076
2761
|
try {
|
|
2077
2762
|
i.sendOptions(e, t, {
|
|
2078
2763
|
extraHeaders: s,
|
|
@@ -2080,11 +2765,11 @@ class ft {
|
|
|
2080
2765
|
succeeded: () => {
|
|
2081
2766
|
r();
|
|
2082
2767
|
},
|
|
2083
|
-
failed:
|
|
2768
|
+
failed: o
|
|
2084
2769
|
}
|
|
2085
2770
|
});
|
|
2086
|
-
} catch (
|
|
2087
|
-
a
|
|
2771
|
+
} catch (a) {
|
|
2772
|
+
o(a);
|
|
2088
2773
|
}
|
|
2089
2774
|
});
|
|
2090
2775
|
}
|
|
@@ -2104,33 +2789,33 @@ class ft {
|
|
|
2104
2789
|
sipServerIp: s,
|
|
2105
2790
|
sipServerUrl: i,
|
|
2106
2791
|
remoteAddress: r,
|
|
2107
|
-
extraHeaders:
|
|
2792
|
+
extraHeaders: o
|
|
2108
2793
|
}) {
|
|
2109
|
-
return new Promise((
|
|
2794
|
+
return new Promise((a, c) => {
|
|
2110
2795
|
const { configuration: d } = this.uaFactory.createConfiguration({
|
|
2111
2796
|
sipServerUrl: i,
|
|
2112
2797
|
displayName: t,
|
|
2113
2798
|
userAgent: e,
|
|
2114
2799
|
sipServerIp: s
|
|
2115
|
-
}),
|
|
2800
|
+
}), T = this.uaFactory.createUA({ ...d, remoteAddress: r, extraHeaders: o }), h = () => {
|
|
2116
2801
|
const p = new Error("Telephony is not available");
|
|
2117
2802
|
c(p);
|
|
2118
2803
|
};
|
|
2119
|
-
|
|
2120
|
-
const
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
}),
|
|
2804
|
+
T.once(S.DISCONNECTED, h);
|
|
2805
|
+
const u = () => {
|
|
2806
|
+
T.removeAllListeners(), T.once(S.DISCONNECTED, () => {
|
|
2807
|
+
a();
|
|
2808
|
+
}), T.stop();
|
|
2124
2809
|
};
|
|
2125
|
-
|
|
2810
|
+
T.once(S.CONNECTED, u), T.start();
|
|
2126
2811
|
});
|
|
2127
2812
|
}
|
|
2128
2813
|
}
|
|
2129
|
-
const
|
|
2814
|
+
const Ht = (n) => {
|
|
2130
2815
|
const e = [];
|
|
2131
2816
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
2132
2817
|
};
|
|
2133
|
-
class
|
|
2818
|
+
class L {
|
|
2134
2819
|
JsSIP;
|
|
2135
2820
|
constructor(e) {
|
|
2136
2821
|
this.JsSIP = e;
|
|
@@ -2155,10 +2840,10 @@ class D {
|
|
|
2155
2840
|
throw new Error("user is required for authorized connection");
|
|
2156
2841
|
}
|
|
2157
2842
|
static resolveAuthorizationUser(e, t) {
|
|
2158
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
2843
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${wt()}`;
|
|
2159
2844
|
}
|
|
2160
2845
|
static buildExtraHeaders(e, t) {
|
|
2161
|
-
const s = e !== void 0 && e !== "" ?
|
|
2846
|
+
const s = e !== void 0 && e !== "" ? Ht(e) : [];
|
|
2162
2847
|
return t === void 0 ? s : [...s, ...t];
|
|
2163
2848
|
}
|
|
2164
2849
|
createConfiguration({
|
|
@@ -2167,44 +2852,44 @@ class D {
|
|
|
2167
2852
|
sipServerUrl: s,
|
|
2168
2853
|
displayName: i = "",
|
|
2169
2854
|
sipServerIp: r,
|
|
2170
|
-
register:
|
|
2171
|
-
sessionTimers:
|
|
2855
|
+
register: o = !1,
|
|
2856
|
+
sessionTimers: a = !1,
|
|
2172
2857
|
registerExpires: c = 300,
|
|
2173
2858
|
// 5 minutes in sec
|
|
2174
2859
|
connectionRecoveryMinInterval: d = 2,
|
|
2175
|
-
connectionRecoveryMaxInterval:
|
|
2176
|
-
userAgent:
|
|
2860
|
+
connectionRecoveryMaxInterval: T = 6,
|
|
2861
|
+
userAgent: h
|
|
2177
2862
|
}) {
|
|
2178
|
-
|
|
2179
|
-
register:
|
|
2863
|
+
L.validateParametersConnection({
|
|
2864
|
+
register: o,
|
|
2180
2865
|
password: t,
|
|
2181
2866
|
user: e,
|
|
2182
2867
|
sipServerIp: r,
|
|
2183
2868
|
sipServerUrl: s
|
|
2184
2869
|
});
|
|
2185
|
-
const
|
|
2870
|
+
const u = L.resolveAuthorizationUser(o, e), p = yt(r), A = p(u), N = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
|
|
2186
2871
|
return {
|
|
2187
2872
|
configuration: {
|
|
2188
2873
|
password: t,
|
|
2189
|
-
register:
|
|
2190
|
-
uri:
|
|
2191
|
-
display_name:
|
|
2192
|
-
user_agent:
|
|
2874
|
+
register: o,
|
|
2875
|
+
uri: A,
|
|
2876
|
+
display_name: Re(i),
|
|
2877
|
+
user_agent: h,
|
|
2193
2878
|
sdpSemantics: "unified-plan",
|
|
2194
|
-
sockets: [
|
|
2195
|
-
session_timers:
|
|
2879
|
+
sockets: [N],
|
|
2880
|
+
session_timers: a,
|
|
2196
2881
|
register_expires: c,
|
|
2197
2882
|
connection_recovery_min_interval: d,
|
|
2198
|
-
connection_recovery_max_interval:
|
|
2883
|
+
connection_recovery_max_interval: T
|
|
2199
2884
|
},
|
|
2200
2885
|
helpers: {
|
|
2201
|
-
socket:
|
|
2886
|
+
socket: N,
|
|
2202
2887
|
getUri: p
|
|
2203
2888
|
}
|
|
2204
2889
|
};
|
|
2205
2890
|
}
|
|
2206
2891
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
2207
|
-
const i = new this.JsSIP.UA(s), r =
|
|
2892
|
+
const i = new this.JsSIP.UA(s), r = L.buildExtraHeaders(e, t);
|
|
2208
2893
|
return r.length > 0 && i.registrator().setExtraHeaders(r), i;
|
|
2209
2894
|
}
|
|
2210
2895
|
/**
|
|
@@ -2216,14 +2901,14 @@ class D {
|
|
|
2216
2901
|
remoteAddress: e.remoteAddress,
|
|
2217
2902
|
extraHeaders: e.extraHeaders
|
|
2218
2903
|
});
|
|
2219
|
-
return t.eachTriggers((
|
|
2220
|
-
const c =
|
|
2221
|
-
c && r.on(c,
|
|
2904
|
+
return t.eachTriggers((o, a) => {
|
|
2905
|
+
const c = me.find((d) => d === a);
|
|
2906
|
+
c && r.on(c, o);
|
|
2222
2907
|
}), { ua: r, helpers: i };
|
|
2223
2908
|
}
|
|
2224
2909
|
}
|
|
2225
|
-
const
|
|
2226
|
-
class
|
|
2910
|
+
const Ie = "Not ready for connection", Wt = (n) => n instanceof Error && n.message === Ie, xt = () => new Error(Ie), Qt = async (n) => typeof n == "function" ? n() : n;
|
|
2911
|
+
class Yt {
|
|
2227
2912
|
events;
|
|
2228
2913
|
ua;
|
|
2229
2914
|
socket;
|
|
@@ -2235,15 +2920,15 @@ class bt {
|
|
|
2235
2920
|
configurationManager;
|
|
2236
2921
|
JsSIP;
|
|
2237
2922
|
constructor({ JsSIP: e }) {
|
|
2238
|
-
this.JsSIP = e, this.events =
|
|
2923
|
+
this.JsSIP = e, this.events = Dt(), this.uaFactory = new L(e), this.registrationManager = new qt({
|
|
2239
2924
|
events: this.events,
|
|
2240
2925
|
getUaProtected: this.getUaProtected
|
|
2241
|
-
}), this.stateMachine = new
|
|
2926
|
+
}), this.stateMachine = new $t(this.events), this.configurationManager = new Pt({
|
|
2242
2927
|
getUa: this.getUa
|
|
2243
|
-
}), this.sipOperations = new
|
|
2928
|
+
}), this.sipOperations = new Vt({
|
|
2244
2929
|
uaFactory: this.uaFactory,
|
|
2245
2930
|
getUaProtected: this.getUaProtected
|
|
2246
|
-
}), this.connectionFlow = new
|
|
2931
|
+
}), this.connectionFlow = new Ft({
|
|
2247
2932
|
JsSIP: this.JsSIP,
|
|
2248
2933
|
events: this.events,
|
|
2249
2934
|
uaFactory: this.uaFactory,
|
|
@@ -2286,17 +2971,20 @@ class bt {
|
|
|
2286
2971
|
get isFailed() {
|
|
2287
2972
|
return this.stateMachine.isFailed;
|
|
2288
2973
|
}
|
|
2974
|
+
get connectionActor() {
|
|
2975
|
+
return this.stateMachine.actorRef;
|
|
2976
|
+
}
|
|
2289
2977
|
get connectionState() {
|
|
2290
2978
|
return this.stateMachine.state;
|
|
2291
2979
|
}
|
|
2292
2980
|
get isRegistered() {
|
|
2293
|
-
return
|
|
2981
|
+
return L.isRegisteredUA(this.ua);
|
|
2294
2982
|
}
|
|
2295
2983
|
get isRegisterConfig() {
|
|
2296
2984
|
return this.configurationManager.isRegister();
|
|
2297
2985
|
}
|
|
2298
2986
|
connect = async (e, t) => this.disconnect().catch((s) => {
|
|
2299
|
-
|
|
2987
|
+
l("connect: disconnect error", s);
|
|
2300
2988
|
}).then(async () => this.connectWithProcessError(e, t));
|
|
2301
2989
|
set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
|
|
2302
2990
|
disconnect = async () => {
|
|
@@ -2345,7 +3033,7 @@ class bt {
|
|
|
2345
3033
|
getUa = () => this.ua;
|
|
2346
3034
|
connectWithProcessError = async (e, t) => {
|
|
2347
3035
|
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
2348
|
-
throw
|
|
3036
|
+
throw xt();
|
|
2349
3037
|
return this.processConnect(e, t).catch(async (i) => {
|
|
2350
3038
|
const r = i;
|
|
2351
3039
|
return this.disconnect().then(() => {
|
|
@@ -2355,18 +3043,18 @@ class bt {
|
|
|
2355
3043
|
});
|
|
2356
3044
|
});
|
|
2357
3045
|
};
|
|
2358
|
-
processConnect = async (e, t) => (this.events.trigger(
|
|
2359
|
-
throw this.events.trigger(
|
|
2360
|
-
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(
|
|
3046
|
+
processConnect = async (e, t) => (this.events.trigger(S.CONNECT_STARTED, {}), Qt(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, {
|
|
2361
3049
|
...s
|
|
2362
3050
|
}), s)).catch((s) => {
|
|
2363
3051
|
const i = s ?? new Error("Failed to connect to server");
|
|
2364
|
-
throw this.events.trigger(
|
|
3052
|
+
throw this.events.trigger(S.CONNECT_FAILED, i), i;
|
|
2365
3053
|
}));
|
|
2366
3054
|
}
|
|
2367
|
-
class
|
|
3055
|
+
class zt {
|
|
2368
3056
|
connectionManager;
|
|
2369
|
-
stackPromises =
|
|
3057
|
+
stackPromises = le({
|
|
2370
3058
|
noRunIsNotActual: !0
|
|
2371
3059
|
});
|
|
2372
3060
|
constructor({ connectionManager: e }) {
|
|
@@ -2378,11 +3066,11 @@ class yt {
|
|
|
2378
3066
|
this.stackPromises.stop();
|
|
2379
3067
|
}
|
|
2380
3068
|
}
|
|
2381
|
-
const
|
|
2382
|
-
class
|
|
2383
|
-
countInner =
|
|
2384
|
-
initialCount =
|
|
2385
|
-
limitInner =
|
|
3069
|
+
const ee = 0, Xt = 30;
|
|
3070
|
+
class Jt {
|
|
3071
|
+
countInner = ee;
|
|
3072
|
+
initialCount = ee;
|
|
3073
|
+
limitInner = Xt;
|
|
2386
3074
|
isInProgress = !1;
|
|
2387
3075
|
onStatusChange;
|
|
2388
3076
|
constructor({
|
|
@@ -2415,7 +3103,7 @@ class wt {
|
|
|
2415
3103
|
this.countInner = this.initialCount, this.finishAttempt();
|
|
2416
3104
|
}
|
|
2417
3105
|
}
|
|
2418
|
-
class
|
|
3106
|
+
class Kt {
|
|
2419
3107
|
connectionManager;
|
|
2420
3108
|
interval;
|
|
2421
3109
|
checkTelephonyByTimeout = void 0;
|
|
@@ -2431,7 +3119,7 @@ class Ut {
|
|
|
2431
3119
|
onSuccessRequest: t,
|
|
2432
3120
|
onFailRequest: s
|
|
2433
3121
|
}) {
|
|
2434
|
-
this.stop(), this.cancelableBeforeRequest = new
|
|
3122
|
+
this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Ue({
|
|
2435
3123
|
isDontStopOnFail: !0,
|
|
2436
3124
|
requestInterval: this.interval,
|
|
2437
3125
|
request: async () => {
|
|
@@ -2451,8 +3139,8 @@ class Ut {
|
|
|
2451
3139
|
this.checkTelephonyByTimeout?.stop(), this.checkTelephonyByTimeout = void 0, this.cancelableBeforeRequest?.cancelRequest(), this.cancelableBeforeRequest = void 0;
|
|
2452
3140
|
}
|
|
2453
3141
|
}
|
|
2454
|
-
var
|
|
2455
|
-
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 fe = [
|
|
2456
3144
|
"before-attempt",
|
|
2457
3145
|
"success",
|
|
2458
3146
|
"failed-all-attempts",
|
|
@@ -2460,8 +3148,8 @@ const Ae = [
|
|
|
2460
3148
|
"changed-attempt-status",
|
|
2461
3149
|
"stop-attempts-by-error",
|
|
2462
3150
|
"limit-reached-attempts"
|
|
2463
|
-
];
|
|
2464
|
-
class
|
|
3151
|
+
], jt = () => new O(fe);
|
|
3152
|
+
class J {
|
|
2465
3153
|
callManager;
|
|
2466
3154
|
disposers = [];
|
|
2467
3155
|
constructor({ callManager: e }) {
|
|
@@ -2486,40 +3174,40 @@ class Y {
|
|
|
2486
3174
|
this.callManager.isCallActive ? e?.() : t();
|
|
2487
3175
|
}
|
|
2488
3176
|
}
|
|
2489
|
-
const
|
|
2490
|
-
class
|
|
3177
|
+
const Zt = 15e3, en = 2;
|
|
3178
|
+
class tn {
|
|
2491
3179
|
connectionManager;
|
|
2492
3180
|
pingServerByTimeoutWithFailCalls;
|
|
2493
3181
|
constructor({ connectionManager: e }) {
|
|
2494
|
-
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls =
|
|
3182
|
+
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Fe(en, {
|
|
2495
3183
|
whenPossibleRequest: async () => {
|
|
2496
3184
|
},
|
|
2497
|
-
requestInterval:
|
|
2498
|
-
request: async () => (
|
|
2499
|
-
|
|
3185
|
+
requestInterval: Zt,
|
|
3186
|
+
request: async () => (l("ping"), this.connectionManager.ping().then(() => {
|
|
3187
|
+
l("ping success");
|
|
2500
3188
|
}))
|
|
2501
3189
|
});
|
|
2502
3190
|
}
|
|
2503
3191
|
start({ onFailRequest: e }) {
|
|
2504
|
-
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(
|
|
3192
|
+
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(l);
|
|
2505
3193
|
}
|
|
2506
3194
|
stop() {
|
|
2507
3195
|
this.pingServerByTimeoutWithFailCalls.stop();
|
|
2508
3196
|
}
|
|
2509
3197
|
}
|
|
2510
|
-
class
|
|
3198
|
+
class nn {
|
|
2511
3199
|
pingServerRequester;
|
|
2512
3200
|
notActiveCallSubscriber;
|
|
2513
3201
|
constructor({
|
|
2514
3202
|
connectionManager: e,
|
|
2515
3203
|
callManager: t
|
|
2516
3204
|
}) {
|
|
2517
|
-
this.pingServerRequester = new
|
|
3205
|
+
this.pingServerRequester = new tn({
|
|
2518
3206
|
connectionManager: e
|
|
2519
|
-
}), this.notActiveCallSubscriber = new
|
|
3207
|
+
}), this.notActiveCallSubscriber = new J({ callManager: t });
|
|
2520
3208
|
}
|
|
2521
3209
|
start({ onFailRequest: e }) {
|
|
2522
|
-
|
|
3210
|
+
l("start"), this.notActiveCallSubscriber.subscribe({
|
|
2523
3211
|
onActive: () => {
|
|
2524
3212
|
this.pingServerRequester.stop();
|
|
2525
3213
|
},
|
|
@@ -2529,13 +3217,13 @@ class kt {
|
|
|
2529
3217
|
});
|
|
2530
3218
|
}
|
|
2531
3219
|
stop() {
|
|
2532
|
-
|
|
3220
|
+
l("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
|
|
2533
3221
|
}
|
|
2534
3222
|
unsubscribeCallStatusChange() {
|
|
2535
3223
|
this.notActiveCallSubscriber.unsubscribe();
|
|
2536
3224
|
}
|
|
2537
3225
|
}
|
|
2538
|
-
class
|
|
3226
|
+
class sn {
|
|
2539
3227
|
connectionManager;
|
|
2540
3228
|
isRegistrationFailed = !1;
|
|
2541
3229
|
disposers = [];
|
|
@@ -2544,7 +3232,7 @@ class $t {
|
|
|
2544
3232
|
connectionManager: e,
|
|
2545
3233
|
callManager: t
|
|
2546
3234
|
}) {
|
|
2547
|
-
this.connectionManager = e, this.notActiveCallSubscriber = new
|
|
3235
|
+
this.connectionManager = e, this.notActiveCallSubscriber = new J({ callManager: t });
|
|
2548
3236
|
}
|
|
2549
3237
|
subscribe(e) {
|
|
2550
3238
|
this.unsubscribe(), this.disposers.push(
|
|
@@ -2571,12 +3259,12 @@ class $t {
|
|
|
2571
3259
|
this.isRegistrationFailed = !1;
|
|
2572
3260
|
}
|
|
2573
3261
|
}
|
|
2574
|
-
const
|
|
3262
|
+
const rn = 3e3, an = 15e3, te = {
|
|
2575
3263
|
LIMIT_REACHED: "Limit reached",
|
|
2576
3264
|
FAILED_TO_RECONNECT: "Failed to reconnect"
|
|
2577
|
-
},
|
|
2578
|
-
},
|
|
2579
|
-
class
|
|
3265
|
+
}, on = async () => {
|
|
3266
|
+
}, cn = (n) => !0;
|
|
3267
|
+
class ln {
|
|
2580
3268
|
events;
|
|
2581
3269
|
connectionManager;
|
|
2582
3270
|
connectionQueueManager;
|
|
@@ -2596,28 +3284,28 @@ class Gt {
|
|
|
2596
3284
|
connectionManager: t,
|
|
2597
3285
|
callManager: s
|
|
2598
3286
|
}, i) {
|
|
2599
|
-
const r = i?.onBeforeRetry ??
|
|
2600
|
-
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError =
|
|
3287
|
+
const r = i?.onBeforeRetry ?? on, o = i?.canRetryOnError ?? cn;
|
|
3288
|
+
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = o, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = jt(), this.checkTelephonyRequester = new Kt({
|
|
2601
3289
|
connectionManager: t,
|
|
2602
|
-
interval: i?.checkTelephonyRequestInterval ??
|
|
2603
|
-
}), this.pingServerIfNotActiveCallRequester = new
|
|
3290
|
+
interval: i?.checkTelephonyRequestInterval ?? an
|
|
3291
|
+
}), this.pingServerIfNotActiveCallRequester = new nn({
|
|
2604
3292
|
connectionManager: t,
|
|
2605
3293
|
callManager: s
|
|
2606
|
-
}), this.registrationFailedOutOfCallSubscriber = new
|
|
3294
|
+
}), this.registrationFailedOutOfCallSubscriber = new sn({
|
|
2607
3295
|
connectionManager: t,
|
|
2608
3296
|
callManager: s
|
|
2609
|
-
}), this.attemptsState = new
|
|
3297
|
+
}), this.attemptsState = new Jt({
|
|
2610
3298
|
onStatusChange: this.emitStatusChange
|
|
2611
|
-
}), this.cancelableRequestBeforeRetry = new
|
|
2612
|
-
i?.timeoutBetweenAttempts ??
|
|
2613
|
-
), this.notActiveCallSubscriber = new
|
|
3299
|
+
}), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new Be(
|
|
3300
|
+
i?.timeoutBetweenAttempts ?? rn
|
|
3301
|
+
), this.notActiveCallSubscriber = new J({ callManager: s });
|
|
2614
3302
|
}
|
|
2615
3303
|
start(e) {
|
|
2616
|
-
|
|
3304
|
+
l("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
|
|
2617
3305
|
}
|
|
2618
3306
|
stop() {
|
|
2619
|
-
|
|
2620
|
-
|
|
3307
|
+
l("auto connector stop"), this.unsubscribeFromNotActiveCall(), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow().catch((e) => {
|
|
3308
|
+
l("auto connector stop from stop method: error", e);
|
|
2621
3309
|
});
|
|
2622
3310
|
}
|
|
2623
3311
|
on(e, t) {
|
|
@@ -2636,77 +3324,77 @@ class Gt {
|
|
|
2636
3324
|
this.events.off(e, t);
|
|
2637
3325
|
}
|
|
2638
3326
|
restartConnectionAttempts(e) {
|
|
2639
|
-
|
|
2640
|
-
|
|
3327
|
+
l("auto connector restart connection attempts"), this.stopConnectionFlow().then(async () => this.attemptConnection(e)).catch((t) => {
|
|
3328
|
+
l("auto connector failed to restart connection attempts:", t);
|
|
2641
3329
|
});
|
|
2642
3330
|
}
|
|
2643
3331
|
async stopConnectionFlow() {
|
|
2644
|
-
|
|
3332
|
+
l("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), await this.connectionQueueManager.disconnect();
|
|
2645
3333
|
}
|
|
2646
3334
|
stopAttempts() {
|
|
2647
3335
|
this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
|
|
2648
3336
|
}
|
|
2649
3337
|
stopConnectTriggers() {
|
|
2650
|
-
|
|
3338
|
+
l("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
|
|
2651
3339
|
}
|
|
2652
3340
|
startCheckTelephony(e) {
|
|
2653
|
-
|
|
3341
|
+
l("startCheckTelephony"), this.checkTelephonyRequester.start({
|
|
2654
3342
|
onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
|
|
2655
3343
|
onSuccessRequest: () => {
|
|
2656
|
-
|
|
3344
|
+
l("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
|
|
2657
3345
|
},
|
|
2658
3346
|
onFailRequest: (t) => {
|
|
2659
|
-
|
|
3347
|
+
l("startCheckTelephony: onFailRequest", t.message);
|
|
2660
3348
|
}
|
|
2661
3349
|
});
|
|
2662
3350
|
}
|
|
2663
3351
|
async attemptConnection(e) {
|
|
2664
|
-
if (
|
|
2665
|
-
|
|
3352
|
+
if (l("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(f.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
|
|
3353
|
+
l("attemptConnection: limit reached"), this.handleLimitReached(e);
|
|
2666
3354
|
return;
|
|
2667
3355
|
}
|
|
2668
3356
|
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.executeConnectionAttempt(e);
|
|
2669
3357
|
}
|
|
2670
3358
|
async executeConnectionAttempt(e) {
|
|
2671
3359
|
try {
|
|
2672
|
-
await this.connectionQueueManager.connect(e.getParameters, e.options),
|
|
3360
|
+
await this.connectionQueueManager.connect(e.getParameters, e.options), l("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
|
|
2673
3361
|
} catch (t) {
|
|
2674
3362
|
this.handleConnectionError(t, e);
|
|
2675
3363
|
}
|
|
2676
3364
|
}
|
|
2677
3365
|
handleConnectionError(e, t) {
|
|
2678
|
-
if (
|
|
2679
|
-
this.attemptsState.finishAttempt(), this.events.trigger(
|
|
3366
|
+
if (Wt(e)) {
|
|
3367
|
+
this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
|
|
2680
3368
|
return;
|
|
2681
3369
|
}
|
|
2682
3370
|
if (!this.canRetryOnError(e)) {
|
|
2683
|
-
|
|
3371
|
+
l("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
|
|
2684
3372
|
return;
|
|
2685
3373
|
}
|
|
2686
|
-
if (
|
|
2687
|
-
|
|
3374
|
+
if (qe(e)) {
|
|
3375
|
+
l("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(f.CANCELLED_ATTEMPTS, e);
|
|
2688
3376
|
return;
|
|
2689
3377
|
}
|
|
2690
|
-
|
|
3378
|
+
l("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
|
|
2691
3379
|
}
|
|
2692
3380
|
handleLimitReached(e) {
|
|
2693
|
-
this.attemptsState.finishAttempt(), this.events.trigger(
|
|
3381
|
+
this.attemptsState.finishAttempt(), this.events.trigger(f.LIMIT_REACHED_ATTEMPTS, new Error(te.LIMIT_REACHED)), this.startCheckTelephony(e);
|
|
2694
3382
|
}
|
|
2695
3383
|
handleSucceededAttempt(e) {
|
|
2696
|
-
|
|
3384
|
+
l("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(f.SUCCESS);
|
|
2697
3385
|
}
|
|
2698
3386
|
subscribeToConnectTriggers(e) {
|
|
2699
3387
|
this.startPingRequester(e), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2700
|
-
|
|
3388
|
+
l("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
|
|
2701
3389
|
});
|
|
2702
3390
|
}
|
|
2703
3391
|
subscribeToNotActiveCall(e) {
|
|
2704
3392
|
this.notActiveCallSubscriber.subscribe({
|
|
2705
3393
|
onActive: () => {
|
|
2706
|
-
|
|
3394
|
+
l("subscribeToNotActiveCall onActive"), this.unsubscribeFromHardwareTriggers();
|
|
2707
3395
|
},
|
|
2708
3396
|
onInactive: () => {
|
|
2709
|
-
|
|
3397
|
+
l("subscribeToNotActiveCall onInactive"), this.subscribeToHardwareTriggers(e);
|
|
2710
3398
|
}
|
|
2711
3399
|
});
|
|
2712
3400
|
}
|
|
@@ -2714,13 +3402,13 @@ class Gt {
|
|
|
2714
3402
|
this.notActiveCallSubscriber.unsubscribe();
|
|
2715
3403
|
}
|
|
2716
3404
|
subscribeToHardwareTriggers(e) {
|
|
2717
|
-
this.unsubscribeFromHardwareTriggers(),
|
|
3405
|
+
this.unsubscribeFromHardwareTriggers(), l("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
|
|
2718
3406
|
onChange: () => {
|
|
2719
|
-
|
|
3407
|
+
l("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
|
|
2720
3408
|
},
|
|
2721
3409
|
onUnavailable: () => {
|
|
2722
|
-
|
|
2723
|
-
|
|
3410
|
+
l("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow().catch((t) => {
|
|
3411
|
+
l(
|
|
2724
3412
|
"auto connector stop from networkInterfacesSubscriber onUnavailable: error",
|
|
2725
3413
|
t
|
|
2726
3414
|
);
|
|
@@ -2728,12 +3416,12 @@ class Gt {
|
|
|
2728
3416
|
}
|
|
2729
3417
|
}), this.resumeFromSleepModeSubscriber?.subscribe({
|
|
2730
3418
|
onResume: () => {
|
|
2731
|
-
|
|
3419
|
+
l("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
|
|
2732
3420
|
}
|
|
2733
3421
|
});
|
|
2734
3422
|
}
|
|
2735
3423
|
unsubscribeFromHardwareTriggers() {
|
|
2736
|
-
|
|
3424
|
+
l("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
|
|
2737
3425
|
}
|
|
2738
3426
|
stopPingRequester() {
|
|
2739
3427
|
this.pingServerIfNotActiveCallRequester.stop();
|
|
@@ -2741,18 +3429,18 @@ class Gt {
|
|
|
2741
3429
|
startPingRequester(e) {
|
|
2742
3430
|
this.pingServerIfNotActiveCallRequester.start({
|
|
2743
3431
|
onFailRequest: () => {
|
|
2744
|
-
|
|
3432
|
+
l("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
|
|
2745
3433
|
}
|
|
2746
3434
|
});
|
|
2747
3435
|
}
|
|
2748
3436
|
connectIfDisconnected(e) {
|
|
2749
3437
|
const t = this.isConnectionUnavailable();
|
|
2750
|
-
|
|
3438
|
+
l("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(f.SUCCESS));
|
|
2751
3439
|
}
|
|
2752
3440
|
scheduleReconnect(e) {
|
|
2753
|
-
|
|
2754
|
-
const s = t instanceof Error ? t : new Error(
|
|
2755
|
-
this.attemptsState.finishAttempt(),
|
|
3441
|
+
l("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (l("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (l("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
|
|
3442
|
+
const s = t instanceof Error ? t : new Error(te.FAILED_TO_RECONNECT);
|
|
3443
|
+
this.attemptsState.finishAttempt(), we(t) || ke(t) ? this.events.trigger(f.CANCELLED_ATTEMPTS, s) : this.events.trigger(f.FAILED_ALL_ATTEMPTS, s), l("scheduleReconnect: error", t);
|
|
2756
3444
|
});
|
|
2757
3445
|
}
|
|
2758
3446
|
isConnectionUnavailable() {
|
|
@@ -2760,22 +3448,450 @@ class Gt {
|
|
|
2760
3448
|
return e || t || s;
|
|
2761
3449
|
}
|
|
2762
3450
|
emitStatusChange = ({ isInProgress: e }) => {
|
|
2763
|
-
this.events.trigger(
|
|
3451
|
+
this.events.trigger(f.CHANGED_ATTEMPT_STATUS, { isInProgress: e });
|
|
2764
3452
|
};
|
|
2765
3453
|
}
|
|
2766
3454
|
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 || {});
|
|
2767
|
-
const
|
|
3455
|
+
const Me = [
|
|
2768
3456
|
"incomingCall",
|
|
2769
3457
|
"declinedIncomingCall",
|
|
2770
3458
|
"terminatedIncomingCall",
|
|
2771
3459
|
"failedIncomingCall"
|
|
2772
|
-
],
|
|
2773
|
-
|
|
3460
|
+
], dn = () => new O(Me);
|
|
3461
|
+
var hn = /* @__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))(hn || {});
|
|
3462
|
+
const gn = $({
|
|
3463
|
+
types: {
|
|
3464
|
+
context: {},
|
|
3465
|
+
events: {}
|
|
3466
|
+
},
|
|
3467
|
+
actions: {
|
|
3468
|
+
logTransition: (n, e) => {
|
|
3469
|
+
l(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
3470
|
+
},
|
|
3471
|
+
logStateChange: (n, e) => {
|
|
3472
|
+
l("IncomingCallStateMachine state changed", e.state);
|
|
3473
|
+
},
|
|
3474
|
+
rememberIncoming: b(({ event: n }) => {
|
|
3475
|
+
const { data: e } = n;
|
|
3476
|
+
return { remoteCallerData: e, lastReason: void 0 };
|
|
3477
|
+
}),
|
|
3478
|
+
rememberReason: b(({ event: n, context: e }) => n.type === "INCOMING.CONSUMED" ? {
|
|
3479
|
+
remoteCallerData: e.remoteCallerData,
|
|
3480
|
+
lastReason: "incoming:consumed"
|
|
3481
|
+
/* CONSUMED */
|
|
3482
|
+
} : n.type === "INCOMING.DECLINED" ? {
|
|
3483
|
+
remoteCallerData: n.data,
|
|
3484
|
+
lastReason: "incoming:declined"
|
|
3485
|
+
/* DECLINED */
|
|
3486
|
+
} : n.type === "INCOMING.TERMINATED" ? {
|
|
3487
|
+
remoteCallerData: n.data,
|
|
3488
|
+
lastReason: "incoming:terminated"
|
|
3489
|
+
/* TERMINATED */
|
|
3490
|
+
} : {
|
|
3491
|
+
remoteCallerData: n.data,
|
|
3492
|
+
lastReason: "incoming:failed"
|
|
3493
|
+
/* FAILED */
|
|
3494
|
+
}),
|
|
3495
|
+
clearIncoming: b(() => ({ remoteCallerData: void 0, lastReason: void 0 }))
|
|
3496
|
+
}
|
|
3497
|
+
}).createMachine({
|
|
3498
|
+
id: "incoming",
|
|
3499
|
+
initial: "incoming:idle",
|
|
3500
|
+
context: {},
|
|
3501
|
+
states: {
|
|
3502
|
+
"incoming:idle": {
|
|
3503
|
+
entry: {
|
|
3504
|
+
type: "logStateChange",
|
|
3505
|
+
params: {
|
|
3506
|
+
state: "incoming:idle"
|
|
3507
|
+
/* IDLE */
|
|
3508
|
+
}
|
|
3509
|
+
},
|
|
3510
|
+
on: {
|
|
3511
|
+
"INCOMING.RINGING": {
|
|
3512
|
+
target: "incoming:ringing",
|
|
3513
|
+
actions: [
|
|
3514
|
+
"rememberIncoming",
|
|
3515
|
+
{
|
|
3516
|
+
type: "logTransition",
|
|
3517
|
+
params: {
|
|
3518
|
+
from: "incoming:idle",
|
|
3519
|
+
to: "incoming:ringing",
|
|
3520
|
+
event: "INCOMING.RINGING"
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
]
|
|
3524
|
+
},
|
|
3525
|
+
"INCOMING.CLEAR": {
|
|
3526
|
+
target: "incoming:idle",
|
|
3527
|
+
actions: [
|
|
3528
|
+
"clearIncoming",
|
|
3529
|
+
{
|
|
3530
|
+
type: "logTransition",
|
|
3531
|
+
params: {
|
|
3532
|
+
from: "incoming:idle",
|
|
3533
|
+
to: "incoming:idle",
|
|
3534
|
+
event: "INCOMING.CLEAR"
|
|
3535
|
+
}
|
|
3536
|
+
}
|
|
3537
|
+
]
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
},
|
|
3541
|
+
"incoming:ringing": {
|
|
3542
|
+
entry: {
|
|
3543
|
+
type: "logStateChange",
|
|
3544
|
+
params: {
|
|
3545
|
+
state: "incoming:ringing"
|
|
3546
|
+
/* RINGING */
|
|
3547
|
+
}
|
|
3548
|
+
},
|
|
3549
|
+
on: {
|
|
3550
|
+
"INCOMING.RINGING": {
|
|
3551
|
+
target: "incoming:ringing",
|
|
3552
|
+
actions: [
|
|
3553
|
+
"rememberIncoming",
|
|
3554
|
+
{
|
|
3555
|
+
type: "logTransition",
|
|
3556
|
+
params: {
|
|
3557
|
+
from: "incoming:ringing",
|
|
3558
|
+
to: "incoming:ringing",
|
|
3559
|
+
event: "INCOMING.RINGING"
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
]
|
|
3563
|
+
},
|
|
3564
|
+
"INCOMING.CONSUMED": {
|
|
3565
|
+
target: "incoming:consumed",
|
|
3566
|
+
actions: [
|
|
3567
|
+
"rememberReason",
|
|
3568
|
+
{
|
|
3569
|
+
type: "logTransition",
|
|
3570
|
+
params: {
|
|
3571
|
+
from: "incoming:ringing",
|
|
3572
|
+
to: "incoming:consumed",
|
|
3573
|
+
event: "INCOMING.CONSUMED"
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
]
|
|
3577
|
+
},
|
|
3578
|
+
"INCOMING.DECLINED": {
|
|
3579
|
+
target: "incoming:declined",
|
|
3580
|
+
actions: [
|
|
3581
|
+
"rememberReason",
|
|
3582
|
+
{
|
|
3583
|
+
type: "logTransition",
|
|
3584
|
+
params: {
|
|
3585
|
+
from: "incoming:ringing",
|
|
3586
|
+
to: "incoming:declined",
|
|
3587
|
+
event: "INCOMING.DECLINED"
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
]
|
|
3591
|
+
},
|
|
3592
|
+
"INCOMING.TERMINATED": {
|
|
3593
|
+
target: "incoming:terminated",
|
|
3594
|
+
actions: [
|
|
3595
|
+
"rememberReason",
|
|
3596
|
+
{
|
|
3597
|
+
type: "logTransition",
|
|
3598
|
+
params: {
|
|
3599
|
+
from: "incoming:ringing",
|
|
3600
|
+
to: "incoming:terminated",
|
|
3601
|
+
event: "INCOMING.TERMINATED"
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
]
|
|
3605
|
+
},
|
|
3606
|
+
"INCOMING.FAILED": {
|
|
3607
|
+
target: "incoming:failed",
|
|
3608
|
+
actions: [
|
|
3609
|
+
"rememberReason",
|
|
3610
|
+
{
|
|
3611
|
+
type: "logTransition",
|
|
3612
|
+
params: {
|
|
3613
|
+
from: "incoming:ringing",
|
|
3614
|
+
to: "incoming:failed",
|
|
3615
|
+
event: "INCOMING.FAILED"
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
]
|
|
3619
|
+
},
|
|
3620
|
+
"INCOMING.CLEAR": {
|
|
3621
|
+
target: "incoming:idle",
|
|
3622
|
+
actions: [
|
|
3623
|
+
"clearIncoming",
|
|
3624
|
+
{
|
|
3625
|
+
type: "logTransition",
|
|
3626
|
+
params: {
|
|
3627
|
+
from: "incoming:ringing",
|
|
3628
|
+
to: "incoming:idle",
|
|
3629
|
+
event: "INCOMING.CLEAR"
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
]
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
},
|
|
3636
|
+
"incoming:consumed": {
|
|
3637
|
+
entry: {
|
|
3638
|
+
type: "logStateChange",
|
|
3639
|
+
params: {
|
|
3640
|
+
state: "incoming:consumed"
|
|
3641
|
+
/* CONSUMED */
|
|
3642
|
+
}
|
|
3643
|
+
},
|
|
3644
|
+
on: {
|
|
3645
|
+
"INCOMING.CLEAR": {
|
|
3646
|
+
target: "incoming:idle",
|
|
3647
|
+
actions: [
|
|
3648
|
+
"clearIncoming",
|
|
3649
|
+
{
|
|
3650
|
+
type: "logTransition",
|
|
3651
|
+
params: {
|
|
3652
|
+
from: "incoming:consumed",
|
|
3653
|
+
to: "incoming:idle",
|
|
3654
|
+
event: "INCOMING.CLEAR"
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
]
|
|
3658
|
+
},
|
|
3659
|
+
"INCOMING.RINGING": {
|
|
3660
|
+
target: "incoming:ringing",
|
|
3661
|
+
actions: [
|
|
3662
|
+
"rememberIncoming",
|
|
3663
|
+
{
|
|
3664
|
+
type: "logTransition",
|
|
3665
|
+
params: {
|
|
3666
|
+
from: "incoming:consumed",
|
|
3667
|
+
to: "incoming:ringing",
|
|
3668
|
+
event: "INCOMING.RINGING"
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
]
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
},
|
|
3675
|
+
"incoming:declined": {
|
|
3676
|
+
entry: {
|
|
3677
|
+
type: "logStateChange",
|
|
3678
|
+
params: {
|
|
3679
|
+
state: "incoming:declined"
|
|
3680
|
+
/* DECLINED */
|
|
3681
|
+
}
|
|
3682
|
+
},
|
|
3683
|
+
on: {
|
|
3684
|
+
"INCOMING.CLEAR": {
|
|
3685
|
+
target: "incoming:idle",
|
|
3686
|
+
actions: [
|
|
3687
|
+
"clearIncoming",
|
|
3688
|
+
{
|
|
3689
|
+
type: "logTransition",
|
|
3690
|
+
params: {
|
|
3691
|
+
from: "incoming:declined",
|
|
3692
|
+
to: "incoming:idle",
|
|
3693
|
+
event: "INCOMING.CLEAR"
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
]
|
|
3697
|
+
},
|
|
3698
|
+
"INCOMING.RINGING": {
|
|
3699
|
+
target: "incoming:ringing",
|
|
3700
|
+
actions: [
|
|
3701
|
+
"rememberIncoming",
|
|
3702
|
+
{
|
|
3703
|
+
type: "logTransition",
|
|
3704
|
+
params: {
|
|
3705
|
+
from: "incoming:declined",
|
|
3706
|
+
to: "incoming:ringing",
|
|
3707
|
+
event: "INCOMING.RINGING"
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
]
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
},
|
|
3714
|
+
"incoming:terminated": {
|
|
3715
|
+
entry: {
|
|
3716
|
+
type: "logStateChange",
|
|
3717
|
+
params: {
|
|
3718
|
+
state: "incoming:terminated"
|
|
3719
|
+
/* TERMINATED */
|
|
3720
|
+
}
|
|
3721
|
+
},
|
|
3722
|
+
on: {
|
|
3723
|
+
"INCOMING.CLEAR": {
|
|
3724
|
+
target: "incoming:idle",
|
|
3725
|
+
actions: [
|
|
3726
|
+
"clearIncoming",
|
|
3727
|
+
{
|
|
3728
|
+
type: "logTransition",
|
|
3729
|
+
params: {
|
|
3730
|
+
from: "incoming:terminated",
|
|
3731
|
+
to: "incoming:idle",
|
|
3732
|
+
event: "INCOMING.CLEAR"
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
]
|
|
3736
|
+
},
|
|
3737
|
+
"INCOMING.RINGING": {
|
|
3738
|
+
target: "incoming:ringing",
|
|
3739
|
+
actions: [
|
|
3740
|
+
"rememberIncoming",
|
|
3741
|
+
{
|
|
3742
|
+
type: "logTransition",
|
|
3743
|
+
params: {
|
|
3744
|
+
from: "incoming:terminated",
|
|
3745
|
+
to: "incoming:ringing",
|
|
3746
|
+
event: "INCOMING.RINGING"
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
]
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
},
|
|
3753
|
+
"incoming:failed": {
|
|
3754
|
+
entry: {
|
|
3755
|
+
type: "logStateChange",
|
|
3756
|
+
params: {
|
|
3757
|
+
state: "incoming:failed"
|
|
3758
|
+
/* FAILED */
|
|
3759
|
+
}
|
|
3760
|
+
},
|
|
3761
|
+
on: {
|
|
3762
|
+
"INCOMING.CLEAR": {
|
|
3763
|
+
target: "incoming:idle",
|
|
3764
|
+
actions: [
|
|
3765
|
+
"clearIncoming",
|
|
3766
|
+
{
|
|
3767
|
+
type: "logTransition",
|
|
3768
|
+
params: {
|
|
3769
|
+
from: "incoming:failed",
|
|
3770
|
+
to: "incoming:idle",
|
|
3771
|
+
event: "INCOMING.CLEAR"
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
]
|
|
3775
|
+
},
|
|
3776
|
+
"INCOMING.RINGING": {
|
|
3777
|
+
target: "incoming:ringing",
|
|
3778
|
+
actions: [
|
|
3779
|
+
"rememberIncoming",
|
|
3780
|
+
{
|
|
3781
|
+
type: "logTransition",
|
|
3782
|
+
params: {
|
|
3783
|
+
from: "incoming:failed",
|
|
3784
|
+
to: "incoming:ringing",
|
|
3785
|
+
event: "INCOMING.RINGING"
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
]
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
});
|
|
3794
|
+
class un extends q {
|
|
3795
|
+
constructor({ incomingEvents: e, connectionEvents: t }) {
|
|
3796
|
+
super(gn), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
|
|
3797
|
+
}
|
|
3798
|
+
get isIdle() {
|
|
3799
|
+
return this.state === "incoming:idle";
|
|
3800
|
+
}
|
|
3801
|
+
get isRinging() {
|
|
3802
|
+
return this.state === "incoming:ringing";
|
|
3803
|
+
}
|
|
3804
|
+
get isConsumed() {
|
|
3805
|
+
return this.state === "incoming:consumed";
|
|
3806
|
+
}
|
|
3807
|
+
get isDeclined() {
|
|
3808
|
+
return this.state === "incoming:declined";
|
|
3809
|
+
}
|
|
3810
|
+
get isTerminated() {
|
|
3811
|
+
return this.state === "incoming:terminated";
|
|
3812
|
+
}
|
|
3813
|
+
get isFailed() {
|
|
3814
|
+
return this.state === "incoming:failed";
|
|
3815
|
+
}
|
|
3816
|
+
get isActive() {
|
|
3817
|
+
return this.isRinging;
|
|
3818
|
+
}
|
|
3819
|
+
get isFinished() {
|
|
3820
|
+
return this.isConsumed || this.isDeclined || this.isTerminated || this.isFailed;
|
|
3821
|
+
}
|
|
3822
|
+
get remoteCallerData() {
|
|
3823
|
+
return this.getSnapshot().context.remoteCallerData;
|
|
3824
|
+
}
|
|
3825
|
+
get lastReason() {
|
|
3826
|
+
return this.getSnapshot().context.lastReason;
|
|
3827
|
+
}
|
|
3828
|
+
reset() {
|
|
3829
|
+
this.send({ type: "INCOMING.CLEAR" });
|
|
3830
|
+
}
|
|
3831
|
+
send(e) {
|
|
3832
|
+
if (!this.getSnapshot().can(e)) {
|
|
3833
|
+
console.warn(
|
|
3834
|
+
`[IncomingCallStateMachine] Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
|
|
3835
|
+
);
|
|
3836
|
+
return;
|
|
3837
|
+
}
|
|
3838
|
+
super.send(e);
|
|
3839
|
+
}
|
|
3840
|
+
toConsumed() {
|
|
3841
|
+
this.send({ type: "INCOMING.CONSUMED" });
|
|
3842
|
+
}
|
|
3843
|
+
subscribeIncomingEvents(e) {
|
|
3844
|
+
this.addSubscription(
|
|
3845
|
+
e.on("incomingCall", (t) => {
|
|
3846
|
+
this.send({ type: "INCOMING.RINGING", data: t });
|
|
3847
|
+
})
|
|
3848
|
+
), this.addSubscription(
|
|
3849
|
+
e.on("declinedIncomingCall", (t) => {
|
|
3850
|
+
this.send({ type: "INCOMING.DECLINED", data: t });
|
|
3851
|
+
})
|
|
3852
|
+
), this.addSubscription(
|
|
3853
|
+
e.on("terminatedIncomingCall", (t) => {
|
|
3854
|
+
this.send({ type: "INCOMING.TERMINATED", data: t });
|
|
3855
|
+
})
|
|
3856
|
+
), this.addSubscription(
|
|
3857
|
+
e.on("failedIncomingCall", (t) => {
|
|
3858
|
+
this.send({ type: "INCOMING.FAILED", data: t });
|
|
3859
|
+
})
|
|
3860
|
+
);
|
|
3861
|
+
}
|
|
3862
|
+
subscribeConnectionEvents(e) {
|
|
3863
|
+
this.addSubscription(
|
|
3864
|
+
e.on(S.DISCONNECTED, () => {
|
|
3865
|
+
this.toClearIncoming();
|
|
3866
|
+
})
|
|
3867
|
+
), this.addSubscription(
|
|
3868
|
+
e.on(S.REGISTRATION_FAILED, () => {
|
|
3869
|
+
this.toClearIncoming();
|
|
3870
|
+
})
|
|
3871
|
+
), this.addSubscription(
|
|
3872
|
+
e.on(S.CONNECT_FAILED, () => {
|
|
3873
|
+
this.toClearIncoming();
|
|
3874
|
+
})
|
|
3875
|
+
);
|
|
3876
|
+
}
|
|
3877
|
+
toClearIncoming() {
|
|
3878
|
+
this.send({ type: "INCOMING.CLEAR" });
|
|
3879
|
+
}
|
|
3880
|
+
}
|
|
3881
|
+
const Tn = 486, En = 487;
|
|
3882
|
+
class Cn {
|
|
2774
3883
|
events;
|
|
3884
|
+
incomingStateMachine;
|
|
2775
3885
|
incomingRTCSession;
|
|
2776
3886
|
connectionManager;
|
|
2777
3887
|
constructor(e) {
|
|
2778
|
-
this.connectionManager = e, this.events =
|
|
3888
|
+
this.connectionManager = e, this.events = dn(), this.incomingStateMachine = new un({
|
|
3889
|
+
incomingEvents: this.events,
|
|
3890
|
+
connectionEvents: this.connectionManager.events
|
|
3891
|
+
}), this.start();
|
|
3892
|
+
}
|
|
3893
|
+
get incomingActor() {
|
|
3894
|
+
return this.incomingStateMachine.actorRef;
|
|
2779
3895
|
}
|
|
2780
3896
|
get remoteCallerData() {
|
|
2781
3897
|
return {
|
|
@@ -2802,10 +3918,10 @@ class Yt {
|
|
|
2802
3918
|
};
|
|
2803
3919
|
extractIncomingRTCSession = () => {
|
|
2804
3920
|
const e = this.getIncomingRTCSession();
|
|
2805
|
-
return this.removeIncomingSession(), e;
|
|
3921
|
+
return this.incomingStateMachine.toConsumed(), this.removeIncomingSession(), e;
|
|
2806
3922
|
};
|
|
2807
3923
|
async declineToIncomingCall({
|
|
2808
|
-
statusCode: e =
|
|
3924
|
+
statusCode: e = En
|
|
2809
3925
|
} = {}) {
|
|
2810
3926
|
return new Promise((t, s) => {
|
|
2811
3927
|
try {
|
|
@@ -2817,7 +3933,7 @@ class Yt {
|
|
|
2817
3933
|
});
|
|
2818
3934
|
}
|
|
2819
3935
|
async busyIncomingCall() {
|
|
2820
|
-
return this.declineToIncomingCall({ statusCode:
|
|
3936
|
+
return this.declineToIncomingCall({ statusCode: Tn });
|
|
2821
3937
|
}
|
|
2822
3938
|
on(e, t) {
|
|
2823
3939
|
return this.events.on(e, t);
|
|
@@ -2857,9 +3973,56 @@ class Yt {
|
|
|
2857
3973
|
delete this.incomingRTCSession;
|
|
2858
3974
|
}
|
|
2859
3975
|
}
|
|
2860
|
-
const
|
|
2861
|
-
|
|
2862
|
-
|
|
3976
|
+
const Sn = (n, e) => Object.is(n, e), ne = (n) => ({
|
|
3977
|
+
connection: n.connection.getSnapshot(),
|
|
3978
|
+
call: n.call.getSnapshot(),
|
|
3979
|
+
incoming: n.incoming.getSnapshot(),
|
|
3980
|
+
presentation: n.presentation.getSnapshot()
|
|
3981
|
+
}), pn = (n) => {
|
|
3982
|
+
const e = {
|
|
3983
|
+
connection: n.connectionManager.connectionActor,
|
|
3984
|
+
call: n.callManager.callActor,
|
|
3985
|
+
incoming: n.incomingCallManager.incomingActor,
|
|
3986
|
+
presentation: n.presentationManager.presentationActor
|
|
3987
|
+
};
|
|
3988
|
+
let t = ne(e);
|
|
3989
|
+
const s = /* @__PURE__ */ new Set(), i = () => {
|
|
3990
|
+
t = ne(e);
|
|
3991
|
+
for (const a of s) {
|
|
3992
|
+
const c = a.selector(t);
|
|
3993
|
+
a.equals(a.current, c) || (a.current = c, a.listener(c));
|
|
3994
|
+
}
|
|
3995
|
+
}, r = [
|
|
3996
|
+
e.connection.subscribe(i),
|
|
3997
|
+
e.call.subscribe(i),
|
|
3998
|
+
e.incoming.subscribe(i),
|
|
3999
|
+
e.presentation.subscribe(i)
|
|
4000
|
+
];
|
|
4001
|
+
function o(a, c, d) {
|
|
4002
|
+
const T = typeof c == "function", h = T ? a : (D) => D, u = T ? c : a, p = (T ? d : void 0) ?? Sn, A = h(t), N = {
|
|
4003
|
+
selector: h,
|
|
4004
|
+
listener: u,
|
|
4005
|
+
equals: p,
|
|
4006
|
+
current: A
|
|
4007
|
+
};
|
|
4008
|
+
return s.add(N), () => {
|
|
4009
|
+
s.delete(N);
|
|
4010
|
+
};
|
|
4011
|
+
}
|
|
4012
|
+
return {
|
|
4013
|
+
actor: e,
|
|
4014
|
+
actors: e,
|
|
4015
|
+
getSnapshot: () => t,
|
|
4016
|
+
subscribe: o,
|
|
4017
|
+
stop: () => {
|
|
4018
|
+
s.clear(), r.forEach((a) => {
|
|
4019
|
+
a.unsubscribe();
|
|
4020
|
+
});
|
|
4021
|
+
}
|
|
4022
|
+
};
|
|
4023
|
+
}, w = 1e3;
|
|
4024
|
+
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 || {});
|
|
4025
|
+
const ve = ["collected"], mn = () => new O(ve), Nn = "api/v2/rtp2webrtc/offer", Rn = async ({
|
|
2863
4026
|
serverUrl: n,
|
|
2864
4027
|
conferenceNumber: e,
|
|
2865
4028
|
quality: t,
|
|
@@ -2867,10 +4030,10 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
|
|
|
2867
4030
|
offer: i
|
|
2868
4031
|
}) => {
|
|
2869
4032
|
const r = new URL(
|
|
2870
|
-
`https://${n.replace(/\/$/, "")}/${
|
|
4033
|
+
`https://${n.replace(/\/$/, "")}/${Nn}/${encodeURIComponent(e)}`
|
|
2871
4034
|
);
|
|
2872
4035
|
r.searchParams.set("quality", t), r.searchParams.set("audio", String(s));
|
|
2873
|
-
const
|
|
4036
|
+
const o = await fetch(r.toString(), {
|
|
2874
4037
|
method: "POST",
|
|
2875
4038
|
headers: {
|
|
2876
4039
|
"Content-Type": "application/json"
|
|
@@ -2878,20 +4041,20 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
|
|
|
2878
4041
|
credentials: "same-origin",
|
|
2879
4042
|
body: JSON.stringify(i)
|
|
2880
4043
|
});
|
|
2881
|
-
if (!
|
|
2882
|
-
throw new Error(`sendOffer failed with status ${
|
|
2883
|
-
const
|
|
4044
|
+
if (!o.ok)
|
|
4045
|
+
throw new Error(`sendOffer failed with status ${o.status}`);
|
|
4046
|
+
const a = await o.json();
|
|
2884
4047
|
return {
|
|
2885
|
-
type:
|
|
2886
|
-
sdp:
|
|
4048
|
+
type: a.type,
|
|
4049
|
+
sdp: a.sdp,
|
|
2887
4050
|
toJSON() {
|
|
2888
|
-
return
|
|
4051
|
+
return a;
|
|
2889
4052
|
}
|
|
2890
4053
|
};
|
|
2891
|
-
},
|
|
4054
|
+
}, se = () => "performance" in window ? performance.now() : Date.now(), F = (n) => [...n.keys()].reduce((e, t) => {
|
|
2892
4055
|
const s = n.get(t);
|
|
2893
4056
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2894
|
-
}, {}),
|
|
4057
|
+
}, {}), An = (n) => {
|
|
2895
4058
|
if (!n)
|
|
2896
4059
|
return {
|
|
2897
4060
|
outboundRtp: void 0,
|
|
@@ -2899,14 +4062,14 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
|
|
|
2899
4062
|
mediaSource: void 0,
|
|
2900
4063
|
remoteInboundRtp: void 0
|
|
2901
4064
|
};
|
|
2902
|
-
const e =
|
|
4065
|
+
const e = F(n);
|
|
2903
4066
|
return {
|
|
2904
|
-
outboundRtp: e[
|
|
2905
|
-
codec: e[
|
|
2906
|
-
mediaSource: e[
|
|
2907
|
-
remoteInboundRtp: e[
|
|
4067
|
+
outboundRtp: e[m.OUTBOUND_RTP],
|
|
4068
|
+
codec: e[m.CODEC],
|
|
4069
|
+
mediaSource: e[m.MEDIA_SOURCE],
|
|
4070
|
+
remoteInboundRtp: e[m.REMOTE_INBOUND_RTP]
|
|
2908
4071
|
};
|
|
2909
|
-
},
|
|
4072
|
+
}, ie = (n) => {
|
|
2910
4073
|
if (!n)
|
|
2911
4074
|
return {
|
|
2912
4075
|
outboundRtp: void 0,
|
|
@@ -2914,14 +4077,14 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
|
|
|
2914
4077
|
mediaSource: void 0,
|
|
2915
4078
|
remoteInboundRtp: void 0
|
|
2916
4079
|
};
|
|
2917
|
-
const e =
|
|
4080
|
+
const e = F(n);
|
|
2918
4081
|
return {
|
|
2919
|
-
outboundRtp: e[
|
|
2920
|
-
codec: e[
|
|
2921
|
-
mediaSource: e[
|
|
2922
|
-
remoteInboundRtp: e[
|
|
4082
|
+
outboundRtp: e[m.OUTBOUND_RTP],
|
|
4083
|
+
codec: e[m.CODEC],
|
|
4084
|
+
mediaSource: e[m.MEDIA_SOURCE],
|
|
4085
|
+
remoteInboundRtp: e[m.REMOTE_INBOUND_RTP]
|
|
2923
4086
|
};
|
|
2924
|
-
},
|
|
4087
|
+
}, re = ({
|
|
2925
4088
|
videoReceiversStats: n,
|
|
2926
4089
|
synchronizationSourcesVideo: e
|
|
2927
4090
|
}) => {
|
|
@@ -2931,13 +4094,13 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
|
|
|
2931
4094
|
codec: void 0,
|
|
2932
4095
|
synchronizationSources: e
|
|
2933
4096
|
};
|
|
2934
|
-
const t =
|
|
4097
|
+
const t = F(n);
|
|
2935
4098
|
return {
|
|
2936
|
-
inboundRtp: t[
|
|
2937
|
-
codec: t[
|
|
4099
|
+
inboundRtp: t[m.INBOUND_RTP],
|
|
4100
|
+
codec: t[m.CODEC],
|
|
2938
4101
|
synchronizationSources: e
|
|
2939
4102
|
};
|
|
2940
|
-
},
|
|
4103
|
+
}, In = ({
|
|
2941
4104
|
audioReceiverStats: n,
|
|
2942
4105
|
synchronizationSourcesAudio: e
|
|
2943
4106
|
}) => {
|
|
@@ -2948,14 +4111,14 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
|
|
|
2948
4111
|
remoteOutboundRtp: void 0,
|
|
2949
4112
|
synchronizationSources: e
|
|
2950
4113
|
};
|
|
2951
|
-
const t =
|
|
4114
|
+
const t = F(n);
|
|
2952
4115
|
return {
|
|
2953
|
-
inboundRtp: t[
|
|
2954
|
-
codec: t[
|
|
2955
|
-
remoteOutboundRtp: t[
|
|
4116
|
+
inboundRtp: t[m.INBOUND_RTP],
|
|
4117
|
+
codec: t[m.CODEC],
|
|
4118
|
+
remoteOutboundRtp: t[m.REMOTE_OUTBOUND_RTP],
|
|
2956
4119
|
synchronizationSources: e
|
|
2957
4120
|
};
|
|
2958
|
-
},
|
|
4121
|
+
}, _e = (n) => {
|
|
2959
4122
|
if (!n)
|
|
2960
4123
|
return {
|
|
2961
4124
|
candidatePair: void 0,
|
|
@@ -2964,122 +4127,122 @@ const me = ["collected"], zt = "api/v2/rtp2webrtc/offer", Xt = async ({
|
|
|
2964
4127
|
remoteCandidate: void 0,
|
|
2965
4128
|
transport: void 0
|
|
2966
4129
|
};
|
|
2967
|
-
const e =
|
|
4130
|
+
const e = F(n);
|
|
2968
4131
|
return {
|
|
2969
|
-
candidatePair: e[
|
|
2970
|
-
certificate: e[
|
|
2971
|
-
localCandidate: e[
|
|
2972
|
-
remoteCandidate: e[
|
|
2973
|
-
transport: e[
|
|
4132
|
+
candidatePair: e[m.CANDIDATE_PAIR],
|
|
4133
|
+
certificate: e[m.CERTIFICATE],
|
|
4134
|
+
localCandidate: e[m.LOCAL_CANDIDATE],
|
|
4135
|
+
remoteCandidate: e[m.REMOTE_CANDIDATE],
|
|
4136
|
+
transport: e[m.TRANSPORT]
|
|
2974
4137
|
};
|
|
2975
|
-
},
|
|
4138
|
+
}, fn = ({
|
|
2976
4139
|
audioSenderStats: n,
|
|
2977
4140
|
videoSenderFirstStats: e,
|
|
2978
4141
|
videoSenderSecondStats: t
|
|
2979
4142
|
}) => ({
|
|
2980
|
-
video:
|
|
2981
|
-
secondVideo:
|
|
2982
|
-
audio:
|
|
2983
|
-
additional:
|
|
4143
|
+
video: ie(e),
|
|
4144
|
+
secondVideo: ie(t),
|
|
4145
|
+
audio: An(n),
|
|
4146
|
+
additional: _e(
|
|
2984
4147
|
n ?? e ?? t
|
|
2985
4148
|
)
|
|
2986
|
-
}),
|
|
4149
|
+
}), Mn = ({
|
|
2987
4150
|
audioReceiverStats: n,
|
|
2988
4151
|
videoReceiverFirstStats: e,
|
|
2989
4152
|
videoReceiverSecondStats: t,
|
|
2990
4153
|
synchronizationSources: s
|
|
2991
4154
|
}) => ({
|
|
2992
|
-
video:
|
|
4155
|
+
video: re({
|
|
2993
4156
|
videoReceiversStats: e,
|
|
2994
4157
|
synchronizationSourcesVideo: s.video
|
|
2995
4158
|
}),
|
|
2996
|
-
secondVideo:
|
|
4159
|
+
secondVideo: re({
|
|
2997
4160
|
videoReceiversStats: t,
|
|
2998
4161
|
synchronizationSourcesVideo: s.video
|
|
2999
4162
|
}),
|
|
3000
|
-
audio:
|
|
4163
|
+
audio: In({
|
|
3001
4164
|
audioReceiverStats: n,
|
|
3002
4165
|
synchronizationSourcesAudio: s.audio
|
|
3003
4166
|
}),
|
|
3004
|
-
additional:
|
|
4167
|
+
additional: _e(
|
|
3005
4168
|
n ?? e ?? t
|
|
3006
4169
|
)
|
|
3007
|
-
}),
|
|
4170
|
+
}), vn = ({
|
|
3008
4171
|
audioSenderStats: n,
|
|
3009
4172
|
videoSenderFirstStats: e,
|
|
3010
4173
|
videoSenderSecondStats: t,
|
|
3011
4174
|
audioReceiverStats: s,
|
|
3012
4175
|
videoReceiverFirstStats: i,
|
|
3013
4176
|
videoReceiverSecondStats: r,
|
|
3014
|
-
synchronizationSources:
|
|
4177
|
+
synchronizationSources: o
|
|
3015
4178
|
}) => {
|
|
3016
|
-
const
|
|
4179
|
+
const a = fn({
|
|
3017
4180
|
audioSenderStats: n,
|
|
3018
4181
|
videoSenderFirstStats: e,
|
|
3019
4182
|
videoSenderSecondStats: t
|
|
3020
|
-
}), c =
|
|
4183
|
+
}), c = Mn({
|
|
3021
4184
|
audioReceiverStats: s,
|
|
3022
4185
|
videoReceiverFirstStats: i,
|
|
3023
4186
|
videoReceiverSecondStats: r,
|
|
3024
|
-
synchronizationSources:
|
|
4187
|
+
synchronizationSources: o
|
|
3025
4188
|
});
|
|
3026
4189
|
return {
|
|
3027
|
-
outbound:
|
|
4190
|
+
outbound: a,
|
|
3028
4191
|
inbound: c
|
|
3029
4192
|
};
|
|
3030
|
-
},
|
|
3031
|
-
const e = "audio", t = "video", s = n.getSenders(), i = s.find((
|
|
3032
|
-
trackIdentifier:
|
|
3033
|
-
item:
|
|
3034
|
-
},
|
|
4193
|
+
}, _n = async (n) => {
|
|
4194
|
+
const e = "audio", t = "video", s = n.getSenders(), i = s.find((u) => u.track?.kind === e), r = s.filter((u) => u.track?.kind === t), o = n.getReceivers(), a = o.find((u) => u.track.kind === e), c = o.filter((u) => u.track.kind === t), d = {
|
|
4195
|
+
trackIdentifier: a?.track.id,
|
|
4196
|
+
item: a?.getSynchronizationSources()[0]
|
|
4197
|
+
}, T = {
|
|
3035
4198
|
trackIdentifier: c[0]?.track.id,
|
|
3036
4199
|
item: c[0]?.getSynchronizationSources()[0]
|
|
3037
|
-
},
|
|
4200
|
+
}, h = {
|
|
3038
4201
|
audio: d,
|
|
3039
|
-
video:
|
|
4202
|
+
video: T
|
|
3040
4203
|
};
|
|
3041
4204
|
return Promise.all([
|
|
3042
4205
|
i?.getStats() ?? Promise.resolve(void 0),
|
|
3043
4206
|
r[0]?.getStats() ?? Promise.resolve(void 0),
|
|
3044
4207
|
r[1]?.getStats() ?? Promise.resolve(void 0),
|
|
3045
|
-
|
|
4208
|
+
a?.getStats() ?? Promise.resolve(void 0),
|
|
3046
4209
|
c[0]?.getStats() ?? Promise.resolve(void 0),
|
|
3047
4210
|
c[1]?.getStats() ?? Promise.resolve(void 0)
|
|
3048
|
-
]).then((
|
|
4211
|
+
]).then((u) => {
|
|
3049
4212
|
const [
|
|
3050
4213
|
p,
|
|
3051
|
-
M,
|
|
3052
4214
|
A,
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
4215
|
+
N,
|
|
4216
|
+
D,
|
|
4217
|
+
V,
|
|
4218
|
+
Le
|
|
4219
|
+
] = u;
|
|
3057
4220
|
return {
|
|
3058
|
-
synchronizationSources:
|
|
4221
|
+
synchronizationSources: h,
|
|
3059
4222
|
audioSenderStats: p,
|
|
3060
|
-
videoSenderFirstStats:
|
|
3061
|
-
videoSenderSecondStats:
|
|
3062
|
-
audioReceiverStats:
|
|
3063
|
-
videoReceiverFirstStats:
|
|
3064
|
-
videoReceiverSecondStats:
|
|
4223
|
+
videoSenderFirstStats: A,
|
|
4224
|
+
videoSenderSecondStats: N,
|
|
4225
|
+
audioReceiverStats: D,
|
|
4226
|
+
videoReceiverFirstStats: V,
|
|
4227
|
+
videoReceiverSecondStats: Le
|
|
3065
4228
|
};
|
|
3066
4229
|
});
|
|
3067
|
-
},
|
|
3068
|
-
|
|
4230
|
+
}, On = (n) => {
|
|
4231
|
+
l(String(n));
|
|
3069
4232
|
};
|
|
3070
|
-
class
|
|
4233
|
+
class Pn {
|
|
3071
4234
|
events;
|
|
3072
4235
|
setTimeoutRequest;
|
|
3073
|
-
requesterAllStatistics = new
|
|
4236
|
+
requesterAllStatistics = new G(_n);
|
|
3074
4237
|
constructor() {
|
|
3075
|
-
this.events =
|
|
4238
|
+
this.events = mn(), this.setTimeoutRequest = new oe();
|
|
3076
4239
|
}
|
|
3077
4240
|
get requested() {
|
|
3078
4241
|
return this.setTimeoutRequest.requested;
|
|
3079
4242
|
}
|
|
3080
4243
|
start(e, {
|
|
3081
4244
|
interval: t = w,
|
|
3082
|
-
onError: s =
|
|
4245
|
+
onError: s = On
|
|
3083
4246
|
} = {}) {
|
|
3084
4247
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
3085
4248
|
this.collectStatistics(e, {
|
|
@@ -3108,35 +4271,70 @@ class sn {
|
|
|
3108
4271
|
collectStatistics = (e, {
|
|
3109
4272
|
onError: t
|
|
3110
4273
|
}) => {
|
|
3111
|
-
const s =
|
|
4274
|
+
const s = se();
|
|
3112
4275
|
this.requesterAllStatistics.request(e).then((i) => {
|
|
3113
|
-
this.events.trigger("collected",
|
|
3114
|
-
const
|
|
3115
|
-
let
|
|
3116
|
-
|
|
4276
|
+
this.events.trigger("collected", vn(i));
|
|
4277
|
+
const o = se() - s;
|
|
4278
|
+
let a = w;
|
|
4279
|
+
o > 48 ? a = w * 4 : o > 32 ? a = w * 3 : o > 16 && (a = w * 2), this.start(e, {
|
|
3117
4280
|
onError: t,
|
|
3118
|
-
interval:
|
|
4281
|
+
interval: a
|
|
3119
4282
|
});
|
|
3120
4283
|
}).catch((i) => {
|
|
3121
4284
|
t && t(i);
|
|
3122
4285
|
});
|
|
3123
4286
|
};
|
|
3124
4287
|
}
|
|
3125
|
-
class
|
|
3126
|
-
availableIncomingBitrate;
|
|
4288
|
+
class bn {
|
|
3127
4289
|
statsPeerConnection;
|
|
4290
|
+
availableStats;
|
|
4291
|
+
previousAvailableStats;
|
|
3128
4292
|
callManager;
|
|
3129
4293
|
apiManager;
|
|
3130
|
-
previousAvailableIncomingBitrate;
|
|
3131
4294
|
constructor({
|
|
3132
4295
|
callManager: e,
|
|
3133
4296
|
apiManager: t
|
|
3134
4297
|
}) {
|
|
3135
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
4298
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Pn(), this.subscribe();
|
|
3136
4299
|
}
|
|
3137
4300
|
get events() {
|
|
3138
4301
|
return this.statsPeerConnection.events;
|
|
3139
4302
|
}
|
|
4303
|
+
get availableIncomingBitrate() {
|
|
4304
|
+
return this.availableStats?.inbound.additional.candidatePair?.availableIncomingBitrate;
|
|
4305
|
+
}
|
|
4306
|
+
get isNotValidFramesStats() {
|
|
4307
|
+
return !this.isFramesReceived || !this.isFramesDecoded;
|
|
4308
|
+
}
|
|
4309
|
+
get previousAvailableIncomingBitrate() {
|
|
4310
|
+
return this.previousAvailableStats?.inbound.additional.candidatePair?.availableIncomingBitrate;
|
|
4311
|
+
}
|
|
4312
|
+
get previousInboundRtp() {
|
|
4313
|
+
return this.previousAvailableStats?.inbound.video.inboundRtp;
|
|
4314
|
+
}
|
|
4315
|
+
get previousFramesReceived() {
|
|
4316
|
+
return this.previousInboundRtp?.framesReceived;
|
|
4317
|
+
}
|
|
4318
|
+
get previousFramesDecoded() {
|
|
4319
|
+
return this.previousInboundRtp?.framesDecoded;
|
|
4320
|
+
}
|
|
4321
|
+
get inboundRtp() {
|
|
4322
|
+
return this.availableStats?.inbound.video.inboundRtp;
|
|
4323
|
+
}
|
|
4324
|
+
get framesReceived() {
|
|
4325
|
+
return this.inboundRtp?.framesReceived;
|
|
4326
|
+
}
|
|
4327
|
+
get framesDecoded() {
|
|
4328
|
+
return this.inboundRtp?.framesDecoded;
|
|
4329
|
+
}
|
|
4330
|
+
get isFramesReceived() {
|
|
4331
|
+
const e = this.framesReceived !== void 0 && this.framesReceived > 0, t = this.framesReceived !== this.previousFramesReceived;
|
|
4332
|
+
return e && t;
|
|
4333
|
+
}
|
|
4334
|
+
get isFramesDecoded() {
|
|
4335
|
+
const e = this.framesDecoded !== void 0 && this.framesDecoded > 0, t = this.framesDecoded !== this.previousFramesDecoded;
|
|
4336
|
+
return e && t;
|
|
4337
|
+
}
|
|
3140
4338
|
on(e, t) {
|
|
3141
4339
|
return this.statsPeerConnection.on(e, t);
|
|
3142
4340
|
}
|
|
@@ -3160,47 +4358,47 @@ class rn {
|
|
|
3160
4358
|
this.callManager.on("peerconnection:confirmed", this.handleStarted), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded), this.statsPeerConnection.on("collected", this.handleStatsCollected);
|
|
3161
4359
|
}
|
|
3162
4360
|
handleStatsCollected = (e) => {
|
|
3163
|
-
this.
|
|
4361
|
+
this.previousAvailableStats = this.availableStats, this.availableStats = e, this.maybeSendStats();
|
|
3164
4362
|
};
|
|
3165
4363
|
handleStarted = (e) => {
|
|
3166
4364
|
this.statsPeerConnection.start(e);
|
|
3167
4365
|
};
|
|
3168
4366
|
handleEnded = () => {
|
|
3169
|
-
this.statsPeerConnection.stop(), this.
|
|
4367
|
+
this.statsPeerConnection.stop(), this.availableStats = void 0, this.previousAvailableStats = void 0;
|
|
3170
4368
|
};
|
|
3171
4369
|
maybeSendStats() {
|
|
3172
4370
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
3173
|
-
|
|
4371
|
+
l("Failed to send stats", e);
|
|
3174
4372
|
});
|
|
3175
4373
|
}
|
|
3176
4374
|
}
|
|
3177
|
-
const
|
|
4375
|
+
const Dn = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), yn = (n) => {
|
|
3178
4376
|
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
|
|
3179
|
-
return
|
|
3180
|
-
},
|
|
3181
|
-
const i = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType),
|
|
3182
|
-
return
|
|
3183
|
-
}),
|
|
4377
|
+
return Dn(s, i);
|
|
4378
|
+
}, Ln = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
4379
|
+
const i = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), o = i === -1 ? Number.MAX_VALUE : i, a = r === -1 ? Number.MAX_VALUE : r;
|
|
4380
|
+
return o - a;
|
|
4381
|
+
}), wn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Un = (n, {
|
|
3184
4382
|
preferredMimeTypesVideoCodecs: e,
|
|
3185
4383
|
excludeMimeTypesVideoCodecs: t
|
|
3186
4384
|
}) => {
|
|
3187
4385
|
try {
|
|
3188
4386
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
3189
|
-
const s =
|
|
4387
|
+
const s = yn("video"), i = wn(s, t), r = Ln(i, e);
|
|
3190
4388
|
n.setCodecPreferences(r);
|
|
3191
4389
|
}
|
|
3192
4390
|
} catch (s) {
|
|
3193
|
-
|
|
4391
|
+
l("setCodecPreferences error", s);
|
|
3194
4392
|
}
|
|
3195
|
-
},
|
|
3196
|
-
class
|
|
4393
|
+
}, Fn = (n) => [...n.keys()].map((e) => n.get(e)), Bn = (n, e) => Fn(n).find((t) => t?.type === e), kn = async (n) => n.getStats().then((e) => Bn(e, "codec")?.mimeType);
|
|
4394
|
+
class Gn {
|
|
3197
4395
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
3198
4396
|
async getCodecFromSender(e) {
|
|
3199
|
-
return await
|
|
4397
|
+
return await kn(e) ?? "";
|
|
3200
4398
|
}
|
|
3201
4399
|
}
|
|
3202
|
-
class
|
|
3203
|
-
stackPromises =
|
|
4400
|
+
class $n {
|
|
4401
|
+
stackPromises = le({
|
|
3204
4402
|
noRunIsNotActual: !0
|
|
3205
4403
|
});
|
|
3206
4404
|
/**
|
|
@@ -3220,34 +4418,34 @@ class Sn {
|
|
|
3220
4418
|
*/
|
|
3221
4419
|
async run() {
|
|
3222
4420
|
return this.stackPromises().catch((e) => {
|
|
3223
|
-
|
|
4421
|
+
l("TaskQueue: error", e);
|
|
3224
4422
|
});
|
|
3225
4423
|
}
|
|
3226
4424
|
}
|
|
3227
|
-
class
|
|
4425
|
+
class qn {
|
|
3228
4426
|
taskQueue;
|
|
3229
4427
|
onSetParameters;
|
|
3230
4428
|
constructor(e) {
|
|
3231
|
-
this.onSetParameters = e, this.taskQueue = new
|
|
4429
|
+
this.onSetParameters = e, this.taskQueue = new $n();
|
|
3232
4430
|
}
|
|
3233
4431
|
async setEncodingsToSender(e, t) {
|
|
3234
|
-
return this.taskQueue.add(async () =>
|
|
4432
|
+
return this.taskQueue.add(async () => Se(e, t, this.onSetParameters));
|
|
3235
4433
|
}
|
|
3236
4434
|
stop() {
|
|
3237
4435
|
this.taskQueue.stop();
|
|
3238
4436
|
}
|
|
3239
4437
|
}
|
|
3240
|
-
const
|
|
3241
|
-
const t =
|
|
3242
|
-
return
|
|
3243
|
-
},
|
|
4438
|
+
const Oe = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Vn = 1e6, M = (n) => n * Vn, Pe = M(0.06), be = M(4), Hn = (n) => n <= 64 ? Pe : n <= 128 ? M(0.12) : n <= 256 ? M(0.25) : n <= 384 ? M(0.32) : n <= 426 ? M(0.38) : n <= 640 ? M(0.5) : n <= 848 ? M(0.7) : n <= 1280 ? M(1) : n <= 1920 ? M(2) : be, Wn = "av1", xn = (n) => Oe(n, Wn), Qn = 0.6, K = (n, e) => xn(e) ? n * Qn : n, Yn = (n) => K(Pe, n), zn = (n) => K(be, n), ae = (n, e) => {
|
|
4439
|
+
const t = Hn(n);
|
|
4440
|
+
return K(t, e);
|
|
4441
|
+
}, W = 1, Xn = ({
|
|
3244
4442
|
videoTrack: n,
|
|
3245
4443
|
targetSize: e
|
|
3246
4444
|
}) => {
|
|
3247
|
-
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ?
|
|
3248
|
-
return Math.max(r,
|
|
4445
|
+
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? W : s / e.width, o = i === void 0 ? W : i / e.height;
|
|
4446
|
+
return Math.max(r, o, W);
|
|
3249
4447
|
};
|
|
3250
|
-
class
|
|
4448
|
+
class Jn {
|
|
3251
4449
|
ignoreForCodec;
|
|
3252
4450
|
senderFinder;
|
|
3253
4451
|
codecProvider;
|
|
@@ -3280,11 +4478,11 @@ class fn {
|
|
|
3280
4478
|
if (!i?.track)
|
|
3281
4479
|
return { ...this.resultNoChanged, sender: i };
|
|
3282
4480
|
const r = await this.codecProvider.getCodecFromSender(i);
|
|
3283
|
-
if (
|
|
4481
|
+
if (Oe(r, this.ignoreForCodec))
|
|
3284
4482
|
return { ...this.resultNoChanged, sender: i };
|
|
3285
|
-
const { mainCam:
|
|
4483
|
+
const { mainCam: o, resolutionMainCam: a } = t ?? {};
|
|
3286
4484
|
return this.processSender(
|
|
3287
|
-
{ mainCam:
|
|
4485
|
+
{ mainCam: o, resolutionMainCam: a },
|
|
3288
4486
|
{
|
|
3289
4487
|
sender: i,
|
|
3290
4488
|
codec: r,
|
|
@@ -3300,14 +4498,14 @@ class fn {
|
|
|
3300
4498
|
async processSender(e, t) {
|
|
3301
4499
|
const { mainCam: s, resolutionMainCam: i } = e;
|
|
3302
4500
|
switch (s) {
|
|
3303
|
-
case
|
|
4501
|
+
case v.PAUSE_MAIN_CAM:
|
|
3304
4502
|
return this.downgradeResolutionSender(t);
|
|
3305
|
-
case
|
|
4503
|
+
case v.RESUME_MAIN_CAM:
|
|
3306
4504
|
return this.setBitrateByTrackResolution(t);
|
|
3307
|
-
case
|
|
4505
|
+
case v.MAX_MAIN_CAM_RESOLUTION:
|
|
3308
4506
|
return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
|
|
3309
|
-
case
|
|
3310
|
-
case
|
|
4507
|
+
case v.ADMIN_STOP_MAIN_CAM:
|
|
4508
|
+
case v.ADMIN_START_MAIN_CAM:
|
|
3311
4509
|
case void 0:
|
|
3312
4510
|
return this.setBitrateByTrackResolution(t);
|
|
3313
4511
|
default:
|
|
@@ -3322,7 +4520,7 @@ class fn {
|
|
|
3322
4520
|
async downgradeResolutionSender(e) {
|
|
3323
4521
|
const { sender: t, codec: s } = e, i = {
|
|
3324
4522
|
scaleResolutionDownBy: 200,
|
|
3325
|
-
maxBitrate:
|
|
4523
|
+
maxBitrate: Yn(s)
|
|
3326
4524
|
};
|
|
3327
4525
|
return this.parametersSetter.setEncodingsToSender(t, i);
|
|
3328
4526
|
}
|
|
@@ -3332,10 +4530,10 @@ class fn {
|
|
|
3332
4530
|
* @returns Promise с результатом
|
|
3333
4531
|
*/
|
|
3334
4532
|
async setBitrateByTrackResolution(e) {
|
|
3335
|
-
const { sender: t, videoTrack: s, codec: i } = e,
|
|
4533
|
+
const { sender: t, videoTrack: s, codec: i } = e, o = s.getSettings().width, a = o === void 0 ? zn(i) : ae(o, i);
|
|
3336
4534
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
3337
4535
|
scaleResolutionDownBy: 1,
|
|
3338
|
-
maxBitrate:
|
|
4536
|
+
maxBitrate: a
|
|
3339
4537
|
});
|
|
3340
4538
|
}
|
|
3341
4539
|
/**
|
|
@@ -3345,27 +4543,27 @@ class fn {
|
|
|
3345
4543
|
* @returns Promise с результатом
|
|
3346
4544
|
*/
|
|
3347
4545
|
async setResolutionSender(e, t) {
|
|
3348
|
-
const [s, i] = e.split("x"), { sender: r, videoTrack:
|
|
4546
|
+
const [s, i] = e.split("x"), { sender: r, videoTrack: o, codec: a } = t, c = {
|
|
3349
4547
|
width: Number(s),
|
|
3350
4548
|
height: Number(i)
|
|
3351
|
-
}, d =
|
|
3352
|
-
videoTrack:
|
|
4549
|
+
}, d = Xn({
|
|
4550
|
+
videoTrack: o,
|
|
3353
4551
|
targetSize: c
|
|
3354
|
-
}),
|
|
4552
|
+
}), T = ae(c.width, a), h = {
|
|
3355
4553
|
scaleResolutionDownBy: d,
|
|
3356
|
-
maxBitrate:
|
|
4554
|
+
maxBitrate: T
|
|
3357
4555
|
};
|
|
3358
|
-
return this.parametersSetter.setEncodingsToSender(r,
|
|
4556
|
+
return this.parametersSetter.setEncodingsToSender(r, h);
|
|
3359
4557
|
}
|
|
3360
4558
|
}
|
|
3361
|
-
const
|
|
3362
|
-
class
|
|
4559
|
+
const Kn = (n) => n.find((e) => e.track?.kind === "video");
|
|
4560
|
+
class jn {
|
|
3363
4561
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
3364
4562
|
findVideoSender(e) {
|
|
3365
|
-
return
|
|
4563
|
+
return Kn(e);
|
|
3366
4564
|
}
|
|
3367
4565
|
}
|
|
3368
|
-
class
|
|
4566
|
+
class Zn {
|
|
3369
4567
|
currentSender;
|
|
3370
4568
|
originalReplaceTrack;
|
|
3371
4569
|
lastWidth;
|
|
@@ -3378,7 +4576,7 @@ class Pn {
|
|
|
3378
4576
|
pollIntervalMs: e = 1e3,
|
|
3379
4577
|
maxPollIntervalMs: t
|
|
3380
4578
|
}) {
|
|
3381
|
-
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new
|
|
4579
|
+
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new oe();
|
|
3382
4580
|
}
|
|
3383
4581
|
/**
|
|
3384
4582
|
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
@@ -3429,7 +4627,7 @@ class Pn {
|
|
|
3429
4627
|
this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
|
|
3430
4628
|
}
|
|
3431
4629
|
}
|
|
3432
|
-
class
|
|
4630
|
+
class es {
|
|
3433
4631
|
apiManager;
|
|
3434
4632
|
currentHandler;
|
|
3435
4633
|
constructor(e) {
|
|
@@ -3449,7 +4647,7 @@ class On {
|
|
|
3449
4647
|
this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
3450
4648
|
}
|
|
3451
4649
|
}
|
|
3452
|
-
class
|
|
4650
|
+
class ts {
|
|
3453
4651
|
eventHandler;
|
|
3454
4652
|
senderBalancer;
|
|
3455
4653
|
parametersSetterWithQueue;
|
|
@@ -3461,16 +4659,16 @@ class bn {
|
|
|
3461
4659
|
onSetParameters: i,
|
|
3462
4660
|
pollIntervalMs: r
|
|
3463
4661
|
} = {}) {
|
|
3464
|
-
this.getConnection = t, this.eventHandler = new
|
|
4662
|
+
this.getConnection = t, this.eventHandler = new es(e), this.parametersSetterWithQueue = new qn(i), this.senderBalancer = new Jn(
|
|
3465
4663
|
{
|
|
3466
|
-
senderFinder: new
|
|
3467
|
-
codecProvider: new
|
|
4664
|
+
senderFinder: new jn(),
|
|
4665
|
+
codecProvider: new Gn(),
|
|
3468
4666
|
parametersSetter: this.parametersSetterWithQueue
|
|
3469
4667
|
},
|
|
3470
4668
|
{
|
|
3471
4669
|
ignoreForCodec: s
|
|
3472
4670
|
}
|
|
3473
|
-
), this.trackMonitor = new
|
|
4671
|
+
), this.trackMonitor = new Zn({ pollIntervalMs: r });
|
|
3474
4672
|
}
|
|
3475
4673
|
/**
|
|
3476
4674
|
* Подписывается на события управления главной камерой
|
|
@@ -3501,7 +4699,7 @@ class bn {
|
|
|
3501
4699
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
3502
4700
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
3503
4701
|
this.balance().catch((s) => {
|
|
3504
|
-
|
|
4702
|
+
l("balance on track change: error", s);
|
|
3505
4703
|
});
|
|
3506
4704
|
}), t;
|
|
3507
4705
|
}
|
|
@@ -3511,17 +4709,17 @@ class bn {
|
|
|
3511
4709
|
*/
|
|
3512
4710
|
handleMainCamControl = (e) => {
|
|
3513
4711
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
3514
|
-
|
|
4712
|
+
l("handleMainCamControl: error", t);
|
|
3515
4713
|
});
|
|
3516
4714
|
};
|
|
3517
4715
|
}
|
|
3518
|
-
const
|
|
4716
|
+
const De = [
|
|
3519
4717
|
"balancing-scheduled",
|
|
3520
4718
|
"balancing-started",
|
|
3521
4719
|
"balancing-stopped",
|
|
3522
4720
|
"parameters-updated"
|
|
3523
|
-
];
|
|
3524
|
-
class
|
|
4721
|
+
], ns = () => new O(De);
|
|
4722
|
+
class ss {
|
|
3525
4723
|
isBalancingActive = !1;
|
|
3526
4724
|
events;
|
|
3527
4725
|
callManager;
|
|
@@ -3529,7 +4727,7 @@ class yn {
|
|
|
3529
4727
|
videoSendingBalancer;
|
|
3530
4728
|
startBalancingTimer;
|
|
3531
4729
|
constructor(e, t, s = {}) {
|
|
3532
|
-
this.events =
|
|
4730
|
+
this.events = ns(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new ts(
|
|
3533
4731
|
t,
|
|
3534
4732
|
() => e.connection,
|
|
3535
4733
|
{
|
|
@@ -3591,7 +4789,7 @@ class yn {
|
|
|
3591
4789
|
scheduleBalancingStart() {
|
|
3592
4790
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
3593
4791
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
3594
|
-
|
|
4792
|
+
l("startBalancing: error", e);
|
|
3595
4793
|
});
|
|
3596
4794
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
3597
4795
|
}
|
|
@@ -3599,22 +4797,82 @@ class yn {
|
|
|
3599
4797
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
3600
4798
|
}
|
|
3601
4799
|
}
|
|
3602
|
-
const
|
|
4800
|
+
const ye = "no-inbound-frames", is = [ye], rs = () => new O(is);
|
|
4801
|
+
class as {
|
|
4802
|
+
events;
|
|
4803
|
+
statsManager;
|
|
4804
|
+
callManager;
|
|
4805
|
+
constructor(e, t) {
|
|
4806
|
+
this.statsManager = e, this.callManager = t, this.events = rs(), this.subscribe();
|
|
4807
|
+
}
|
|
4808
|
+
get mainVideoTrack() {
|
|
4809
|
+
return this.callManager.getMainStream()?.getVideoTracks()[0];
|
|
4810
|
+
}
|
|
4811
|
+
get isMutedMainVideoTrack() {
|
|
4812
|
+
const { mainVideoTrack: e } = this;
|
|
4813
|
+
return e === void 0 ? !1 : e.muted;
|
|
4814
|
+
}
|
|
4815
|
+
on(e, t) {
|
|
4816
|
+
return this.events.on(e, t);
|
|
4817
|
+
}
|
|
4818
|
+
handleStatsCollected = () => {
|
|
4819
|
+
this.hasNoIncomingFrames() && this.events.trigger(ye, {});
|
|
4820
|
+
};
|
|
4821
|
+
hasNoIncomingFrames = () => this.statsManager.isNotValidFramesStats && this.isMutedMainVideoTrack;
|
|
4822
|
+
subscribe() {
|
|
4823
|
+
this.statsManager.on("collected", this.handleStatsCollected);
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
const os = 3e3;
|
|
4827
|
+
class cs {
|
|
4828
|
+
renegotiateRequester;
|
|
4829
|
+
renegotiateThrottled;
|
|
4830
|
+
callManager;
|
|
4831
|
+
constructor(e, t = os) {
|
|
4832
|
+
this.callManager = e, this.renegotiateRequester = new G(e.renegotiate.bind(e)), this.renegotiateThrottled = Ve.throttle(
|
|
4833
|
+
this.requestRenegotiate.bind(this),
|
|
4834
|
+
t
|
|
4835
|
+
), this.subscribe();
|
|
4836
|
+
}
|
|
4837
|
+
recover() {
|
|
4838
|
+
l("trying to recover main stream"), this.renegotiateThrottled();
|
|
4839
|
+
}
|
|
4840
|
+
requestRenegotiate = () => {
|
|
4841
|
+
if (l("trying to renegotiate"), this.renegotiateRequester.requested) {
|
|
4842
|
+
l("previous renegotiate is not finished yet");
|
|
4843
|
+
return;
|
|
4844
|
+
}
|
|
4845
|
+
this.renegotiateRequester.request().then(() => {
|
|
4846
|
+
l("renegotiate has successful");
|
|
4847
|
+
}).catch((e) => {
|
|
4848
|
+
l("failed to renegotiate main media stream", e);
|
|
4849
|
+
});
|
|
4850
|
+
};
|
|
4851
|
+
subscribe() {
|
|
4852
|
+
this.callManager.on("ended", () => {
|
|
4853
|
+
this.cancel();
|
|
4854
|
+
});
|
|
4855
|
+
}
|
|
4856
|
+
cancel() {
|
|
4857
|
+
l("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
const ls = 1e6, ds = fe.map((n) => `auto-connect:${n}`), hs = Ne.map((n) => `connection:${n}`), gs = ge.map((n) => `call:${n}`), us = de.map((n) => `api:${n}`), Ts = Me.map((n) => `incoming-call:${n}`), Es = pe.map((n) => `presentation:${n}`), Cs = ve.map((n) => `stats:${n}`), Ss = De.map((n) => `video-balancer:${n}`), ps = [
|
|
3603
4861
|
"disconnected-from-out-of-call",
|
|
3604
4862
|
"connected-with-configuration-from-out-of-call",
|
|
3605
4863
|
"stopped-presentation-by-server-command"
|
|
3606
|
-
],
|
|
3607
|
-
...
|
|
3608
|
-
...
|
|
3609
|
-
...
|
|
3610
|
-
...
|
|
3611
|
-
...
|
|
3612
|
-
...
|
|
3613
|
-
|
|
3614
|
-
...
|
|
3615
|
-
...
|
|
3616
|
-
];
|
|
3617
|
-
class
|
|
4864
|
+
], ms = [
|
|
4865
|
+
...ds,
|
|
4866
|
+
...hs,
|
|
4867
|
+
...gs,
|
|
4868
|
+
...us,
|
|
4869
|
+
...Ts,
|
|
4870
|
+
...Es,
|
|
4871
|
+
...Cs,
|
|
4872
|
+
...Ss,
|
|
4873
|
+
...ps
|
|
4874
|
+
], Ns = () => new O(ms);
|
|
4875
|
+
class ws {
|
|
3618
4876
|
events;
|
|
3619
4877
|
connectionManager;
|
|
3620
4878
|
connectionQueueManager;
|
|
@@ -3625,6 +4883,9 @@ class ts {
|
|
|
3625
4883
|
presentationManager;
|
|
3626
4884
|
statsManager;
|
|
3627
4885
|
videoSendingBalancerManager;
|
|
4886
|
+
session;
|
|
4887
|
+
mainStreamHealthMonitor;
|
|
4888
|
+
mainStreamRecovery;
|
|
3628
4889
|
preferredMimeTypesVideoCodecs;
|
|
3629
4890
|
excludeMimeTypesVideoCodecs;
|
|
3630
4891
|
constructor({ JsSIP: e }, {
|
|
@@ -3633,29 +4894,34 @@ class ts {
|
|
|
3633
4894
|
videoBalancerOptions: i,
|
|
3634
4895
|
autoConnectorOptions: r
|
|
3635
4896
|
} = {}) {
|
|
3636
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events =
|
|
4897
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = Ns(), this.connectionManager = new Yt({ JsSIP: e }), this.connectionQueueManager = new zt({
|
|
3637
4898
|
connectionManager: this.connectionManager
|
|
3638
|
-
}), this.callManager = new
|
|
4899
|
+
}), this.callManager = new lt(), this.apiManager = new Xe({
|
|
3639
4900
|
connectionManager: this.connectionManager,
|
|
3640
4901
|
callManager: this.callManager
|
|
3641
|
-
}), this.incomingCallManager = new
|
|
4902
|
+
}), this.incomingCallManager = new Cn(this.connectionManager), this.presentationManager = new Ot({
|
|
3642
4903
|
callManager: this.callManager,
|
|
3643
|
-
maxBitrate:
|
|
3644
|
-
}), this.statsManager = new
|
|
4904
|
+
maxBitrate: ls
|
|
4905
|
+
}), this.statsManager = new bn({
|
|
3645
4906
|
callManager: this.callManager,
|
|
3646
4907
|
apiManager: this.apiManager
|
|
3647
|
-
}), this.autoConnectorManager = new
|
|
4908
|
+
}), this.autoConnectorManager = new ln(
|
|
3648
4909
|
{
|
|
3649
4910
|
connectionQueueManager: this.connectionQueueManager,
|
|
3650
4911
|
connectionManager: this.connectionManager,
|
|
3651
4912
|
callManager: this.callManager
|
|
3652
4913
|
},
|
|
3653
4914
|
r
|
|
3654
|
-
), this.videoSendingBalancerManager = new
|
|
4915
|
+
), this.videoSendingBalancerManager = new ss(
|
|
3655
4916
|
this.callManager,
|
|
3656
4917
|
this.apiManager,
|
|
3657
4918
|
i
|
|
3658
|
-
), this.
|
|
4919
|
+
), this.mainStreamHealthMonitor = new as(this.statsManager, this.callManager), this.mainStreamRecovery = new cs(this.callManager), this.session = pn({
|
|
4920
|
+
connectionManager: this.connectionManager,
|
|
4921
|
+
callManager: this.callManager,
|
|
4922
|
+
incomingCallManager: this.incomingCallManager,
|
|
4923
|
+
presentationManager: this.presentationManager
|
|
4924
|
+
}), this.subscribe();
|
|
3659
4925
|
}
|
|
3660
4926
|
get requestedConnection() {
|
|
3661
4927
|
return this.connectionManager.requested;
|
|
@@ -3750,14 +5016,14 @@ class ts {
|
|
|
3750
5016
|
getRemoteStreams = () => this.callManager.getRemoteStreams();
|
|
3751
5017
|
replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
|
|
3752
5018
|
async startPresentation(e, t = {}) {
|
|
3753
|
-
const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...
|
|
5019
|
+
const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...o } = t;
|
|
3754
5020
|
return this.presentationManager.startPresentation(
|
|
3755
5021
|
async () => {
|
|
3756
5022
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
3757
5023
|
},
|
|
3758
5024
|
e,
|
|
3759
5025
|
{
|
|
3760
|
-
...
|
|
5026
|
+
...o,
|
|
3761
5027
|
onAddedTransceiver: this.resolveHandleAddTransceiver(r)
|
|
3762
5028
|
},
|
|
3763
5029
|
i === void 0 ? void 0 : { callLimit: i }
|
|
@@ -3834,25 +5100,26 @@ class ts {
|
|
|
3834
5100
|
this.isCallActive || this.events.trigger("connected-with-configuration-from-out-of-call", e);
|
|
3835
5101
|
});
|
|
3836
5102
|
}
|
|
5103
|
+
mayBeStopPresentationAndNotify() {
|
|
5104
|
+
this.presentationManager.isPresentationInProcess && (this.stopPresentation().catch(() => {
|
|
5105
|
+
}), this.events.trigger("stopped-presentation-by-server-command", {}));
|
|
5106
|
+
}
|
|
3837
5107
|
subscribeToApiEvents() {
|
|
3838
5108
|
this.apiManager.on("participant:move-request-to-participants", () => {
|
|
3839
5109
|
this.callManager.setCallRoleParticipant();
|
|
3840
5110
|
}), this.apiManager.on("participant:move-request-to-spectators-synthetic", () => {
|
|
3841
|
-
this.callManager.setCallRoleSpectatorSynthetic(), this.
|
|
3842
|
-
}), this.events.trigger("stopped-presentation-by-server-command", {});
|
|
5111
|
+
this.callManager.setCallRoleSpectatorSynthetic(), this.mayBeStopPresentationAndNotify();
|
|
3843
5112
|
}), this.apiManager.on("participant:move-request-to-spectators-with-audio-id", ({ audioId: e }) => {
|
|
3844
|
-
this.callManager.setCallRoleSpectator({ audioId: e, sendOffer: this.sendOffer }), this.
|
|
3845
|
-
}), this.events.trigger("stopped-presentation-by-server-command", {});
|
|
5113
|
+
this.callManager.setCallRoleSpectator({ audioId: e, sendOffer: this.sendOffer }), this.mayBeStopPresentationAndNotify();
|
|
3846
5114
|
}), this.apiManager.on("mustStopPresentation", () => {
|
|
3847
|
-
this.
|
|
3848
|
-
}), this.events.trigger("stopped-presentation-by-server-command", {});
|
|
5115
|
+
this.mayBeStopPresentationAndNotify();
|
|
3849
5116
|
});
|
|
3850
5117
|
}
|
|
3851
5118
|
sendOffer = async (e, t) => {
|
|
3852
5119
|
const i = this.connectionManager.getConnectionConfiguration()?.sipServerUrl;
|
|
3853
5120
|
if (i === void 0)
|
|
3854
5121
|
throw new Error("No sipServerUrl for sendOffer");
|
|
3855
|
-
return
|
|
5122
|
+
return Rn({
|
|
3856
5123
|
serverUrl: i,
|
|
3857
5124
|
offer: t,
|
|
3858
5125
|
conferenceNumber: e.conferenceNumber,
|
|
@@ -3861,13 +5128,18 @@ class ts {
|
|
|
3861
5128
|
});
|
|
3862
5129
|
};
|
|
3863
5130
|
setCodecPreferences(e) {
|
|
3864
|
-
|
|
5131
|
+
Un(e, {
|
|
3865
5132
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
3866
5133
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
3867
5134
|
});
|
|
3868
5135
|
}
|
|
3869
5136
|
subscribe() {
|
|
3870
|
-
this.bridgeEvents("auto-connect", this.autoConnectorManager), this.bridgeEvents("connection", this.connectionManager), this.bridgeEvents("call", this.callManager), this.bridgeEvents("api", this.apiManager), this.bridgeEvents("incoming-call", this.incomingCallManager), this.bridgeEvents("presentation", this.presentationManager), this.bridgeEvents("stats", this.statsManager), this.bridgeEvents("video-balancer", this.videoSendingBalancerManager), this.subscribeToApiEvents(), this.subscribeDisconnectedFromOutOfCall(), this.subscribeConnectedWithConfigurationFromOutOfCall();
|
|
5137
|
+
this.bridgeEvents("auto-connect", this.autoConnectorManager), this.bridgeEvents("connection", this.connectionManager), this.bridgeEvents("call", this.callManager), this.bridgeEvents("api", this.apiManager), this.bridgeEvents("incoming-call", this.incomingCallManager), this.bridgeEvents("presentation", this.presentationManager), this.bridgeEvents("stats", this.statsManager), this.bridgeEvents("video-balancer", this.videoSendingBalancerManager), this.subscribeToApiEvents(), this.subscribeDisconnectedFromOutOfCall(), this.subscribeConnectedWithConfigurationFromOutOfCall(), this.subscribeToMainStreamHealthMonitorEvents();
|
|
5138
|
+
}
|
|
5139
|
+
subscribeToMainStreamHealthMonitorEvents() {
|
|
5140
|
+
this.mainStreamHealthMonitor.on("no-inbound-frames", () => {
|
|
5141
|
+
this.mainStreamRecovery.recover();
|
|
5142
|
+
});
|
|
3871
5143
|
}
|
|
3872
5144
|
bridgeEvents = (e, t) => {
|
|
3873
5145
|
t.events.eachTriggers((s, i) => {
|
|
@@ -3881,20 +5153,24 @@ class ts {
|
|
|
3881
5153
|
};
|
|
3882
5154
|
}
|
|
3883
5155
|
export {
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
5156
|
+
ue as E,
|
|
5157
|
+
Ze as O,
|
|
5158
|
+
ws as S,
|
|
5159
|
+
Je as a,
|
|
5160
|
+
hn as b,
|
|
5161
|
+
Se as c,
|
|
5162
|
+
Nt as d,
|
|
5163
|
+
Ye as e,
|
|
5164
|
+
ys as f,
|
|
5165
|
+
Ds as g,
|
|
5166
|
+
Wt as h,
|
|
5167
|
+
Ls as i,
|
|
5168
|
+
m as j,
|
|
5169
|
+
Pn as k,
|
|
5170
|
+
l,
|
|
5171
|
+
kn as m,
|
|
5172
|
+
kt as n,
|
|
5173
|
+
ft as o,
|
|
5174
|
+
k as p,
|
|
5175
|
+
Rn as s
|
|
3900
5176
|
};
|