sip-connector 19.7.0 → 19.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@SipConnector-CwZJgOxs.cjs +1 -0
- package/dist/{@SipConnector-DXMX6l2G.js → @SipConnector-Dlsv1V3D.js} +601 -595
- package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +12 -11
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/@SipConnector-CMDm0Voo.cjs +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Events as k, TypedEvents as U } from "events-constructor";
|
|
2
2
|
import x from "debug";
|
|
3
|
-
import { CancelableRequest as G, isCanceledError as
|
|
4
|
-
import { resolveRequesterByTimeout as
|
|
5
|
-
import { hasCanceledError as
|
|
6
|
-
import { setup as
|
|
7
|
-
import { createStackPromises as
|
|
3
|
+
import { CancelableRequest as G, isCanceledError as _e } from "@krivega/cancelable-promise";
|
|
4
|
+
import { resolveRequesterByTimeout as Me, requesterByTimeoutsWithFailCalls as fe, DelayRequester as ve, hasCanceledError as Pe, SetTimeoutRequest as ee } from "@krivega/timeout-requester";
|
|
5
|
+
import { hasCanceledError as Oe, repeatedCallsAsync as te } from "repeated-calls";
|
|
6
|
+
import { setup as ye, createActor as be } from "xstate";
|
|
7
|
+
import { createStackPromises as ne, isPromiseIsNotActualError as De } from "stack-promises";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
const Q = "sip-connector",
|
|
10
|
+
const Q = "sip-connector", c = x(Q), Wn = () => {
|
|
11
11
|
x.enable(Q);
|
|
12
|
-
},
|
|
12
|
+
}, xn = () => {
|
|
13
13
|
x.enable(`-${Q}`);
|
|
14
|
-
},
|
|
15
|
-
var l = /* @__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))(l || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), V = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(V || {}), P = /* @__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.RESTART = "application/vinteo.webrtc.restart", n))(P || {}), _ = /* @__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))(_ || {}), 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 || {}),
|
|
16
|
-
const
|
|
14
|
+
}, we = "Error decline with 603", Ue = 1006, Le = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Ue, Be = (n) => n.message === we;
|
|
15
|
+
var l = /* @__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))(l || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), V = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(V || {}), P = /* @__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.RESTART = "application/vinteo.webrtc.restart", n))(P || {}), _ = /* @__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))(_ || {}), 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 || {}), H = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(H || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(W || {}), Fe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Fe || {}), 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_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.RESTART = "restart", n))(g || {});
|
|
16
|
+
const se = [
|
|
17
17
|
"participation:accepting-word-request",
|
|
18
18
|
"participation:cancelling-word-request",
|
|
19
19
|
"participant:move-request-to-stream",
|
|
@@ -43,8 +43,8 @@ const ne = [
|
|
|
43
43
|
"newDTMF",
|
|
44
44
|
"restart"
|
|
45
45
|
];
|
|
46
|
-
var
|
|
47
|
-
class
|
|
46
|
+
var I = /* @__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))(I || {});
|
|
47
|
+
class ke {
|
|
48
48
|
events;
|
|
49
49
|
connectionManager;
|
|
50
50
|
callManager;
|
|
@@ -52,7 +52,7 @@ class Fe {
|
|
|
52
52
|
connectionManager: e,
|
|
53
53
|
callManager: t
|
|
54
54
|
}) {
|
|
55
|
-
this.connectionManager = e, this.callManager = t, this.events = new k(
|
|
55
|
+
this.connectionManager = e, this.callManager = t, this.events = new k(se), this.subscribe();
|
|
56
56
|
}
|
|
57
57
|
async waitChannels() {
|
|
58
58
|
return this.wait(g.CHANNELS);
|
|
@@ -62,54 +62,54 @@ class Fe {
|
|
|
62
62
|
}
|
|
63
63
|
async sendDTMF(e) {
|
|
64
64
|
return new Promise((t, s) => {
|
|
65
|
-
let
|
|
65
|
+
let i;
|
|
66
66
|
try {
|
|
67
|
-
|
|
68
|
-
} catch (
|
|
69
|
-
s(
|
|
67
|
+
i = this.getEstablishedRTCSessionProtected();
|
|
68
|
+
} catch (r) {
|
|
69
|
+
s(r);
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}),
|
|
71
|
+
i && (this.callManager.once("newDTMF", ({ originator: r }) => {
|
|
72
|
+
r === "local" && t();
|
|
73
|
+
}), i.sendDTMF(e, {
|
|
74
74
|
duration: 120,
|
|
75
75
|
interToneGap: 600
|
|
76
76
|
}));
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
80
|
-
const s = this.getEstablishedRTCSessionProtected(),
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const s = this.getEstablishedRTCSessionProtected(), i = `${l.INPUT_CHANNELS}: ${e}`, r = `${l.OUTPUT_CHANNELS}: ${t}`, a = [
|
|
81
|
+
i,
|
|
82
|
+
r
|
|
83
83
|
];
|
|
84
84
|
return s.sendInfo(_.CHANNELS, void 0, { extraHeaders: a });
|
|
85
85
|
}
|
|
86
86
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const i = this.getEstablishedRTCSessionProtected(), r = `${l.MEDIA_STATE}: currentstate`, a = `${l.MAIN_CAM_STATE}: ${Number(e)}`, o = `${l.MIC_STATE}: ${Number(t)}`, d = [
|
|
88
|
+
r,
|
|
89
89
|
a,
|
|
90
90
|
o
|
|
91
91
|
];
|
|
92
|
-
return
|
|
92
|
+
return i.sendInfo(_.MEDIA_STATE, void 0, {
|
|
93
93
|
noTerminateWhenError: !0,
|
|
94
94
|
...s,
|
|
95
|
-
extraHeaders:
|
|
95
|
+
extraHeaders: d
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
async sendStats({
|
|
99
99
|
availableIncomingBitrate: e
|
|
100
100
|
}) {
|
|
101
|
-
const t = this.getEstablishedRTCSessionProtected(),
|
|
101
|
+
const t = this.getEstablishedRTCSessionProtected(), i = [`${l.AVAILABLE_INCOMING_BITRATE}: ${e}`];
|
|
102
102
|
return t.sendInfo(_.STATS, void 0, {
|
|
103
103
|
noTerminateWhenError: !0,
|
|
104
|
-
extraHeaders:
|
|
104
|
+
extraHeaders: i
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
async sendRefusalToTurnOn(e, t = {}) {
|
|
108
|
-
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1,
|
|
108
|
+
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, d = [`${l.MEDIA_TYPE}: ${a}`];
|
|
109
109
|
return s.sendInfo(_.REFUSAL, void 0, {
|
|
110
110
|
noTerminateWhenError: !0,
|
|
111
111
|
...t,
|
|
112
|
-
extraHeaders:
|
|
112
|
+
extraHeaders: d
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
async sendRefusalToTurnOnMic(e = {}) {
|
|
@@ -149,9 +149,9 @@ class Fe {
|
|
|
149
149
|
noTerminateWhenError: !0,
|
|
150
150
|
...e,
|
|
151
151
|
extraHeaders: s
|
|
152
|
-
}).catch((
|
|
153
|
-
if (
|
|
154
|
-
throw
|
|
152
|
+
}).catch((i) => {
|
|
153
|
+
if (Be(i))
|
|
154
|
+
throw i;
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
@@ -195,115 +195,115 @@ class Fe {
|
|
|
195
195
|
this.handleNotify(s);
|
|
196
196
|
}
|
|
197
197
|
} catch (t) {
|
|
198
|
-
|
|
198
|
+
c("error parse notify", t);
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
handleNotify = (e) => {
|
|
202
202
|
switch (e.cmd) {
|
|
203
|
-
case
|
|
203
|
+
case I.CHANNELS: {
|
|
204
204
|
const t = e;
|
|
205
205
|
this.triggerChannelsNotify(t);
|
|
206
206
|
break;
|
|
207
207
|
}
|
|
208
|
-
case
|
|
208
|
+
case I.WEBCAST_STARTED: {
|
|
209
209
|
const t = e;
|
|
210
210
|
this.triggerWebcastStartedNotify(t);
|
|
211
211
|
break;
|
|
212
212
|
}
|
|
213
|
-
case
|
|
213
|
+
case I.WEBCAST_STOPPED: {
|
|
214
214
|
const t = e;
|
|
215
215
|
this.triggerWebcastStoppedNotify(t);
|
|
216
216
|
break;
|
|
217
217
|
}
|
|
218
|
-
case
|
|
218
|
+
case I.ADDED_TO_LIST_MODERATORS: {
|
|
219
219
|
const t = e;
|
|
220
220
|
this.triggerAddedToListModeratorsNotify(t);
|
|
221
221
|
break;
|
|
222
222
|
}
|
|
223
|
-
case
|
|
223
|
+
case I.REMOVED_FROM_LIST_MODERATORS: {
|
|
224
224
|
const t = e;
|
|
225
225
|
this.triggerRemovedFromListModeratorsNotify(t);
|
|
226
226
|
break;
|
|
227
227
|
}
|
|
228
|
-
case
|
|
228
|
+
case I.ACCEPTING_WORD_REQUEST: {
|
|
229
229
|
const t = e;
|
|
230
230
|
this.triggerParticipationAcceptingWordRequest(t);
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
|
-
case
|
|
233
|
+
case I.CANCELLING_WORD_REQUEST: {
|
|
234
234
|
const t = e;
|
|
235
235
|
this.triggerParticipationCancellingWordRequest(t);
|
|
236
236
|
break;
|
|
237
237
|
}
|
|
238
|
-
case
|
|
238
|
+
case I.MOVE_REQUEST_TO_STREAM: {
|
|
239
239
|
const t = e;
|
|
240
240
|
this.triggerParticipantMoveRequestToStream(t);
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
|
-
case
|
|
243
|
+
case I.ACCOUNT_CHANGED: {
|
|
244
244
|
this.triggerAccountChangedNotify();
|
|
245
245
|
break;
|
|
246
246
|
}
|
|
247
|
-
case
|
|
247
|
+
case I.ACCOUNT_DELETED: {
|
|
248
248
|
this.triggerAccountDeletedNotify();
|
|
249
249
|
break;
|
|
250
250
|
}
|
|
251
|
-
case
|
|
251
|
+
case I.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
|
|
252
252
|
const t = e;
|
|
253
253
|
this.triggerConferenceParticipantTokenIssued(t);
|
|
254
254
|
break;
|
|
255
255
|
}
|
|
256
256
|
default:
|
|
257
|
-
|
|
257
|
+
c("unknown cmd", e);
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
handleNewInfo = (e) => {
|
|
261
261
|
const { originator: t } = e;
|
|
262
262
|
if (t !== "remote")
|
|
263
263
|
return;
|
|
264
|
-
const { request: s } = e,
|
|
265
|
-
if (
|
|
266
|
-
switch (
|
|
264
|
+
const { request: s } = e, i = s, r = i.getHeader(l.CONTENT_TYPE);
|
|
265
|
+
if (r !== void 0)
|
|
266
|
+
switch (r) {
|
|
267
267
|
case P.ENTER_ROOM: {
|
|
268
|
-
this.triggerEnterRoom(
|
|
268
|
+
this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
|
|
269
269
|
break;
|
|
270
270
|
}
|
|
271
271
|
case P.NOTIFY: {
|
|
272
|
-
this.maybeHandleNotify(
|
|
272
|
+
this.maybeHandleNotify(i);
|
|
273
273
|
break;
|
|
274
274
|
}
|
|
275
275
|
case P.SHARE_STATE: {
|
|
276
|
-
this.triggerShareState(
|
|
276
|
+
this.triggerShareState(i);
|
|
277
277
|
break;
|
|
278
278
|
}
|
|
279
279
|
case P.MAIN_CAM: {
|
|
280
|
-
this.triggerMainCamControl(
|
|
280
|
+
this.triggerMainCamControl(i);
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
283
|
case P.MIC: {
|
|
284
|
-
this.triggerMicControl(
|
|
284
|
+
this.triggerMicControl(i);
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
287
|
case P.USE_LICENSE: {
|
|
288
|
-
this.triggerUseLicense(
|
|
288
|
+
this.triggerUseLicense(i);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
291
|
case P.PARTICIPANT_STATE: {
|
|
292
|
-
this.maybeTriggerParticipantMoveRequest(
|
|
292
|
+
this.maybeTriggerParticipantMoveRequest(i);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
case P.RESTART: {
|
|
296
|
-
this.triggerRestart(
|
|
296
|
+
this.triggerRestart(i);
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
301
|
triggerChannelsNotify = (e) => {
|
|
302
|
-
const t = e.input, s = e.output,
|
|
302
|
+
const t = e.input, s = e.output, i = {
|
|
303
303
|
inputChannels: t,
|
|
304
304
|
outputChannels: s
|
|
305
305
|
};
|
|
306
|
-
this.events.trigger(g.CHANNELS_NOTIFY,
|
|
306
|
+
this.events.trigger(g.CHANNELS_NOTIFY, i);
|
|
307
307
|
};
|
|
308
308
|
triggerWebcastStartedNotify = ({
|
|
309
309
|
body: { conference: e, type: t }
|
|
@@ -378,24 +378,24 @@ class Fe {
|
|
|
378
378
|
triggerConferenceParticipantTokenIssued = ({
|
|
379
379
|
body: { conference: e, participant: t, jwt: s }
|
|
380
380
|
}) => {
|
|
381
|
-
const
|
|
381
|
+
const i = {
|
|
382
382
|
conference: e,
|
|
383
383
|
participant: t,
|
|
384
384
|
jwt: s
|
|
385
385
|
};
|
|
386
386
|
this.events.trigger(
|
|
387
387
|
g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
|
|
388
|
-
|
|
388
|
+
i
|
|
389
389
|
);
|
|
390
390
|
};
|
|
391
391
|
maybeTriggerChannels = (e) => {
|
|
392
392
|
const t = e.getHeader(l.INPUT_CHANNELS), s = e.getHeader(l.OUTPUT_CHANNELS);
|
|
393
393
|
if (t && s) {
|
|
394
|
-
const
|
|
394
|
+
const i = {
|
|
395
395
|
inputChannels: t,
|
|
396
396
|
outputChannels: s
|
|
397
397
|
};
|
|
398
|
-
this.events.trigger(g.CHANNELS,
|
|
398
|
+
this.events.trigger(g.CHANNELS, i);
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
triggerEnterRoom = (e) => {
|
|
@@ -425,25 +425,25 @@ class Fe {
|
|
|
425
425
|
t === V.SPECTATOR && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === V.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
|
|
426
426
|
};
|
|
427
427
|
triggerMainCamControl = (e) => {
|
|
428
|
-
const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC),
|
|
428
|
+
const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC), i = s === W.ADMIN_SYNC_FORCED;
|
|
429
429
|
if (t === v.ADMIN_START_MAIN_CAM) {
|
|
430
|
-
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced:
|
|
430
|
+
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
433
|
if (t === v.ADMIN_STOP_MAIN_CAM) {
|
|
434
|
-
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced:
|
|
434
|
+
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
|
|
435
435
|
return;
|
|
436
436
|
}
|
|
437
|
-
(t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced:
|
|
438
|
-
const
|
|
437
|
+
(t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
|
|
438
|
+
const r = e.getHeader(l.MAIN_CAM_RESOLUTION);
|
|
439
439
|
this.events.trigger(g.MAIN_CAM_CONTROL, {
|
|
440
440
|
mainCam: t,
|
|
441
|
-
resolutionMainCam:
|
|
441
|
+
resolutionMainCam: r
|
|
442
442
|
});
|
|
443
443
|
};
|
|
444
444
|
triggerMicControl = (e) => {
|
|
445
|
-
const t = e.getHeader(l.MIC),
|
|
446
|
-
t ===
|
|
445
|
+
const t = e.getHeader(l.MIC), i = e.getHeader(l.MEDIA_SYNC) === W.ADMIN_SYNC_FORCED;
|
|
446
|
+
t === H.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === H.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
|
|
447
447
|
};
|
|
448
448
|
triggerUseLicense = (e) => {
|
|
449
449
|
const t = e.getHeader(l.CONTENT_USE_LICENSE);
|
|
@@ -454,14 +454,14 @@ class Fe {
|
|
|
454
454
|
l.TRACKS_DIRECTION
|
|
455
455
|
), s = Number(
|
|
456
456
|
e.getHeader(l.AUDIO_TRACK_COUNT)
|
|
457
|
-
),
|
|
457
|
+
), i = Number(
|
|
458
458
|
e.getHeader(l.VIDEO_TRACK_COUNT)
|
|
459
|
-
),
|
|
460
|
-
this.events.trigger(g.RESTART,
|
|
459
|
+
), r = { tracksDirection: t, audioTrackCount: s, videoTrackCount: i };
|
|
460
|
+
this.events.trigger(g.RESTART, r);
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
|
-
var
|
|
464
|
-
const
|
|
463
|
+
var R = /* @__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))(R || {}), $e = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($e || {});
|
|
464
|
+
const ie = [
|
|
465
465
|
"peerconnection",
|
|
466
466
|
"connecting",
|
|
467
467
|
"sending",
|
|
@@ -488,15 +488,15 @@ const se = [
|
|
|
488
488
|
"peerconnection:createanswerfailed",
|
|
489
489
|
"peerconnection:setlocaldescriptionfailed",
|
|
490
490
|
"peerconnection:setremotedescriptionfailed"
|
|
491
|
-
],
|
|
491
|
+
], qe = [
|
|
492
492
|
"peerconnection:confirmed",
|
|
493
493
|
"peerconnection:ontrack",
|
|
494
494
|
"ended:fromserver",
|
|
495
495
|
"call-status-changed"
|
|
496
496
|
], re = [
|
|
497
|
-
...
|
|
498
|
-
|
|
499
|
-
],
|
|
497
|
+
...ie,
|
|
498
|
+
...qe
|
|
499
|
+
], Ve = (n, e) => {
|
|
500
500
|
n.getVideoTracks().forEach((s) => {
|
|
501
501
|
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
502
502
|
});
|
|
@@ -507,17 +507,17 @@ const se = [
|
|
|
507
507
|
} = {}) => {
|
|
508
508
|
if (!n || e === "recvonly" && t === "recvonly")
|
|
509
509
|
return;
|
|
510
|
-
const
|
|
511
|
-
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" &&
|
|
510
|
+
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
|
|
511
|
+
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Ve(o, s), o;
|
|
512
512
|
};
|
|
513
|
-
function
|
|
513
|
+
function He(n) {
|
|
514
514
|
return (e) => `sip:${e}@${n}`;
|
|
515
515
|
}
|
|
516
|
-
const We = (n, e) => () => Math.floor(Math.random() * (e - n)) + n,
|
|
516
|
+
const We = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, ae = (n) => n.trim().replaceAll(" ", "_"), xe = We(1e5, 99999999), Ge = (n) => n.some((t) => {
|
|
517
517
|
const { kind: s } = t;
|
|
518
518
|
return s === "video";
|
|
519
519
|
});
|
|
520
|
-
class
|
|
520
|
+
class Qe {
|
|
521
521
|
isPendingCall = !1;
|
|
522
522
|
isPendingAnswer = !1;
|
|
523
523
|
rtcSession;
|
|
@@ -528,15 +528,15 @@ class Ge {
|
|
|
528
528
|
this.events = e;
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
|
-
var
|
|
532
|
-
class
|
|
531
|
+
var oe = /* @__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))(oe || {});
|
|
532
|
+
class Ye {
|
|
533
533
|
remoteStreams = {};
|
|
534
534
|
reset() {
|
|
535
535
|
this.remoteStreams = {};
|
|
536
536
|
}
|
|
537
537
|
generateStream(e, t) {
|
|
538
|
-
const { id: s } = e,
|
|
539
|
-
return t &&
|
|
538
|
+
const { id: s } = e, i = this.remoteStreams[s] ?? new MediaStream();
|
|
539
|
+
return t && i.addTrack(t), i.addTrack(e), this.remoteStreams[s] = i, i;
|
|
540
540
|
}
|
|
541
541
|
generateAudioStream(e) {
|
|
542
542
|
const { id: t } = e, s = this.remoteStreams[t] ?? new MediaStream();
|
|
@@ -544,25 +544,25 @@ class Qe {
|
|
|
544
544
|
}
|
|
545
545
|
generateStreams(e) {
|
|
546
546
|
const t = [];
|
|
547
|
-
return e.forEach((s,
|
|
547
|
+
return e.forEach((s, i) => {
|
|
548
548
|
if (s.kind === "audio")
|
|
549
549
|
return;
|
|
550
|
-
const
|
|
550
|
+
const r = s, a = e[i - 1];
|
|
551
551
|
let o;
|
|
552
552
|
a?.kind === "audio" && (o = a);
|
|
553
|
-
const
|
|
554
|
-
t.push(
|
|
553
|
+
const d = this.generateStream(r, o);
|
|
554
|
+
t.push(d);
|
|
555
555
|
}), t;
|
|
556
556
|
}
|
|
557
557
|
generateAudioStreams(e) {
|
|
558
558
|
return e.map((t) => this.generateAudioStream(t));
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
class
|
|
562
|
-
remoteStreamsManager = new
|
|
561
|
+
class ze extends Qe {
|
|
562
|
+
remoteStreamsManager = new Ye();
|
|
563
563
|
disposers = /* @__PURE__ */ new Set();
|
|
564
564
|
constructor(e) {
|
|
565
|
-
super(e), e.on(
|
|
565
|
+
super(e), e.on(R.FAILED, this.handleEnded), e.on(R.ENDED, this.handleEnded);
|
|
566
566
|
}
|
|
567
567
|
get requested() {
|
|
568
568
|
return this.isPendingCall || this.isPendingAnswer;
|
|
@@ -578,25 +578,25 @@ class Ye extends Ge {
|
|
|
578
578
|
}
|
|
579
579
|
startCall = async (e, t, {
|
|
580
580
|
number: s,
|
|
581
|
-
mediaStream:
|
|
582
|
-
extraHeaders:
|
|
581
|
+
mediaStream: i,
|
|
582
|
+
extraHeaders: r = [],
|
|
583
583
|
ontrack: a,
|
|
584
584
|
iceServers: o,
|
|
585
|
-
directionVideo:
|
|
586
|
-
directionAudio:
|
|
585
|
+
directionVideo: d,
|
|
586
|
+
directionAudio: h,
|
|
587
587
|
contentHint: T,
|
|
588
588
|
offerToReceiveAudio: S = !0,
|
|
589
589
|
offerToReceiveVideo: u = !0,
|
|
590
590
|
degradationPreference: E,
|
|
591
591
|
sendEncodings: m,
|
|
592
|
-
onAddedTransceiver:
|
|
593
|
-
}) => (this.isPendingCall = !0, new Promise((
|
|
594
|
-
this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(
|
|
595
|
-
|
|
592
|
+
onAddedTransceiver: p
|
|
593
|
+
}) => (this.isPendingCall = !0, new Promise((N, b) => {
|
|
594
|
+
this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(N).catch(($) => {
|
|
595
|
+
b($);
|
|
596
596
|
}), this.rtcSession = e.call(t(s), {
|
|
597
|
-
mediaStream: F(
|
|
598
|
-
directionVideo:
|
|
599
|
-
directionAudio:
|
|
597
|
+
mediaStream: F(i, {
|
|
598
|
+
directionVideo: d,
|
|
599
|
+
directionAudio: h,
|
|
600
600
|
contentHint: T
|
|
601
601
|
}),
|
|
602
602
|
pcConfig: {
|
|
@@ -610,12 +610,12 @@ class Ye extends Ge {
|
|
|
610
610
|
// так как в методе call создается RTCSession
|
|
611
611
|
// и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
|
|
612
612
|
eventHandlers: this.events.triggers,
|
|
613
|
-
extraHeaders:
|
|
614
|
-
directionVideo:
|
|
615
|
-
directionAudio:
|
|
613
|
+
extraHeaders: r,
|
|
614
|
+
directionVideo: d,
|
|
615
|
+
directionAudio: h,
|
|
616
616
|
degradationPreference: E,
|
|
617
617
|
sendEncodings: m,
|
|
618
|
-
onAddedTransceiver:
|
|
618
|
+
onAddedTransceiver: p
|
|
619
619
|
});
|
|
620
620
|
}).finally(() => {
|
|
621
621
|
this.isPendingCall = !1;
|
|
@@ -624,7 +624,7 @@ class Ye extends Ge {
|
|
|
624
624
|
const { rtcSession: e } = this;
|
|
625
625
|
if (e && !e.isEnded())
|
|
626
626
|
return e.terminateAsync({
|
|
627
|
-
cause:
|
|
627
|
+
cause: oe.CANCELED
|
|
628
628
|
}).finally(() => {
|
|
629
629
|
this.reset();
|
|
630
630
|
});
|
|
@@ -633,43 +633,43 @@ class Ye extends Ge {
|
|
|
633
633
|
answerToIncomingCall = async (e, {
|
|
634
634
|
mediaStream: t,
|
|
635
635
|
ontrack: s,
|
|
636
|
-
extraHeaders:
|
|
637
|
-
iceServers:
|
|
636
|
+
extraHeaders: i = [],
|
|
637
|
+
iceServers: r,
|
|
638
638
|
directionVideo: a,
|
|
639
639
|
directionAudio: o,
|
|
640
|
-
offerToReceiveAudio:
|
|
641
|
-
offerToReceiveVideo:
|
|
640
|
+
offerToReceiveAudio: d,
|
|
641
|
+
offerToReceiveVideo: h,
|
|
642
642
|
contentHint: T,
|
|
643
643
|
degradationPreference: S,
|
|
644
644
|
sendEncodings: u,
|
|
645
645
|
onAddedTransceiver: E
|
|
646
|
-
}) => (this.isPendingAnswer = !0, new Promise((m,
|
|
646
|
+
}) => (this.isPendingAnswer = !0, new Promise((m, p) => {
|
|
647
647
|
try {
|
|
648
|
-
const
|
|
649
|
-
this.rtcSession =
|
|
650
|
-
|
|
651
|
-
}),
|
|
648
|
+
const N = e();
|
|
649
|
+
this.rtcSession = N, this.subscribeToSessionEvents(N), this.callConfiguration.answer = !0, this.callConfiguration.number = N.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(m).catch((b) => {
|
|
650
|
+
p(b);
|
|
651
|
+
}), N.answer({
|
|
652
652
|
pcConfig: {
|
|
653
|
-
iceServers:
|
|
653
|
+
iceServers: r
|
|
654
654
|
},
|
|
655
655
|
rtcOfferConstraints: {
|
|
656
|
-
offerToReceiveAudio:
|
|
657
|
-
offerToReceiveVideo:
|
|
656
|
+
offerToReceiveAudio: d,
|
|
657
|
+
offerToReceiveVideo: h
|
|
658
658
|
},
|
|
659
659
|
mediaStream: F(t, {
|
|
660
660
|
directionVideo: a,
|
|
661
661
|
directionAudio: o,
|
|
662
662
|
contentHint: T
|
|
663
663
|
}),
|
|
664
|
-
extraHeaders:
|
|
664
|
+
extraHeaders: i,
|
|
665
665
|
directionVideo: a,
|
|
666
666
|
directionAudio: o,
|
|
667
667
|
degradationPreference: S,
|
|
668
668
|
sendEncodings: u,
|
|
669
669
|
onAddedTransceiver: E
|
|
670
670
|
});
|
|
671
|
-
} catch (
|
|
672
|
-
|
|
671
|
+
} catch (N) {
|
|
672
|
+
p(N);
|
|
673
673
|
}
|
|
674
674
|
}).finally(() => {
|
|
675
675
|
this.isPendingAnswer = !1;
|
|
@@ -684,15 +684,15 @@ class Ye extends Ge {
|
|
|
684
684
|
if (!this.connection)
|
|
685
685
|
return;
|
|
686
686
|
const t = this.connection.getReceivers().map(({ track: s }) => s);
|
|
687
|
-
return
|
|
687
|
+
return Ge(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
|
|
688
688
|
}
|
|
689
689
|
async replaceMediaStream(e, t) {
|
|
690
690
|
if (!this.rtcSession)
|
|
691
691
|
throw new Error("No rtcSession established");
|
|
692
|
-
const { contentHint: s } = t ?? {},
|
|
693
|
-
if (
|
|
692
|
+
const { contentHint: s } = t ?? {}, i = F(e, { contentHint: s });
|
|
693
|
+
if (i === void 0)
|
|
694
694
|
throw new Error("No preparedMediaStream");
|
|
695
|
-
return this.rtcSession.replaceMediaStream(
|
|
695
|
+
return this.rtcSession.replaceMediaStream(i, t);
|
|
696
696
|
}
|
|
697
697
|
async restartIce(e) {
|
|
698
698
|
if (!this.rtcSession)
|
|
@@ -707,36 +707,36 @@ class Ye extends Ge {
|
|
|
707
707
|
handleCall = async ({
|
|
708
708
|
ontrack: e
|
|
709
709
|
}) => new Promise((t, s) => {
|
|
710
|
-
const
|
|
711
|
-
this.events.on(
|
|
712
|
-
},
|
|
713
|
-
this.events.off(
|
|
710
|
+
const i = () => {
|
|
711
|
+
this.events.on(R.PEER_CONNECTION, T), this.events.on(R.CONFIRMED, S);
|
|
712
|
+
}, r = () => {
|
|
713
|
+
this.events.off(R.PEER_CONNECTION, T), this.events.off(R.CONFIRMED, S);
|
|
714
714
|
}, a = () => {
|
|
715
|
-
this.events.on(
|
|
715
|
+
this.events.on(R.FAILED, d), this.events.on(R.ENDED, d);
|
|
716
716
|
}, o = () => {
|
|
717
|
-
this.events.off(
|
|
718
|
-
},
|
|
719
|
-
|
|
717
|
+
this.events.off(R.FAILED, d), this.events.off(R.ENDED, d);
|
|
718
|
+
}, d = (u) => {
|
|
719
|
+
r(), o(), s(u);
|
|
720
720
|
};
|
|
721
|
-
let
|
|
721
|
+
let h;
|
|
722
722
|
const T = ({ peerconnection: u }) => {
|
|
723
|
-
|
|
723
|
+
h = u;
|
|
724
724
|
const E = (m) => {
|
|
725
|
-
this.events.trigger(
|
|
725
|
+
this.events.trigger(R.PEER_CONNECTION_ONTRACK, m), e && e(m);
|
|
726
726
|
};
|
|
727
727
|
u.addEventListener("track", E), this.disposers.add(() => {
|
|
728
728
|
u.removeEventListener("track", E);
|
|
729
729
|
});
|
|
730
730
|
}, S = () => {
|
|
731
|
-
|
|
731
|
+
h !== void 0 && this.events.trigger(R.PEER_CONNECTION_CONFIRMED, h), r(), o(), t(h);
|
|
732
732
|
};
|
|
733
|
-
|
|
733
|
+
i(), a();
|
|
734
734
|
});
|
|
735
735
|
subscribeToSessionEvents(e) {
|
|
736
736
|
this.events.eachTriggers((t, s) => {
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
e.off(
|
|
737
|
+
const i = ie.find((r) => r === s);
|
|
738
|
+
i && (e.on(i, t), this.disposers.add(() => {
|
|
739
|
+
e.off(i, t);
|
|
740
740
|
}));
|
|
741
741
|
});
|
|
742
742
|
}
|
|
@@ -747,17 +747,17 @@ class Ye extends Ge {
|
|
|
747
747
|
}
|
|
748
748
|
handleEnded = (e) => {
|
|
749
749
|
const { originator: t } = e;
|
|
750
|
-
t === "remote" && this.events.trigger(
|
|
750
|
+
t === "remote" && this.events.trigger(R.ENDED_FROM_SERVER, e), this.reset();
|
|
751
751
|
};
|
|
752
752
|
reset = () => {
|
|
753
753
|
delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
|
|
754
754
|
};
|
|
755
755
|
}
|
|
756
|
-
class
|
|
756
|
+
class Xe {
|
|
757
757
|
events;
|
|
758
758
|
strategy;
|
|
759
759
|
constructor(e) {
|
|
760
|
-
this.events = new U(re), this.strategy = e ?? new
|
|
760
|
+
this.events = new U(re), this.strategy = e ?? new ze(this.events), this.subscribeCallStatusChange();
|
|
761
761
|
}
|
|
762
762
|
get requested() {
|
|
763
763
|
return this.strategy.requested;
|
|
@@ -803,47 +803,47 @@ class ze {
|
|
|
803
803
|
restartIce = async (e) => this.strategy.restartIce(e);
|
|
804
804
|
subscribeCallStatusChange() {
|
|
805
805
|
let { isCallActive: e } = this;
|
|
806
|
-
const { ACCEPTED: t, CONFIRMED: s, ENDED:
|
|
807
|
-
this.onRace([t, s,
|
|
806
|
+
const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = R;
|
|
807
|
+
this.onRace([t, s, i, r], () => {
|
|
808
808
|
e = this.maybeTriggerCallStatus(e);
|
|
809
809
|
});
|
|
810
810
|
}
|
|
811
811
|
maybeTriggerCallStatus(e) {
|
|
812
812
|
const t = this.isCallActive;
|
|
813
|
-
return t !== e && this.events.trigger(
|
|
813
|
+
return t !== e && this.events.trigger(R.CALL_STATUS_CHANGED, { isCallActive: t }), t;
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
|
-
const
|
|
816
|
+
const Je = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ke = (n, e) => {
|
|
817
817
|
n.encodings ??= [];
|
|
818
818
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
819
819
|
n.encodings.push({});
|
|
820
820
|
return n;
|
|
821
|
-
},
|
|
822
|
-
if (
|
|
821
|
+
}, ce = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, je = ce(), Ze = (n, e) => {
|
|
822
|
+
if (je(n, e))
|
|
823
823
|
return n;
|
|
824
|
-
},
|
|
825
|
-
const t = n.maxBitrate, s =
|
|
824
|
+
}, et = (n, e) => {
|
|
825
|
+
const t = n.maxBitrate, s = Ze(e, t);
|
|
826
826
|
return s !== void 0 && (n.maxBitrate = s), n;
|
|
827
|
-
},
|
|
828
|
-
|
|
829
|
-
),
|
|
830
|
-
const t = n === void 0 ? void 0 : Math.max(n,
|
|
831
|
-
if (t !== void 0 &&
|
|
827
|
+
}, de = 1, tt = ce(
|
|
828
|
+
de
|
|
829
|
+
), nt = (n, e) => {
|
|
830
|
+
const t = n === void 0 ? void 0 : Math.max(n, de);
|
|
831
|
+
if (t !== void 0 && tt(
|
|
832
832
|
t,
|
|
833
833
|
e
|
|
834
834
|
))
|
|
835
835
|
return t;
|
|
836
|
-
},
|
|
837
|
-
const t = n.scaleResolutionDownBy, s =
|
|
836
|
+
}, st = (n, e) => {
|
|
837
|
+
const t = n.scaleResolutionDownBy, s = nt(
|
|
838
838
|
e,
|
|
839
839
|
t
|
|
840
840
|
);
|
|
841
841
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
842
|
-
},
|
|
842
|
+
}, it = (n, e) => {
|
|
843
843
|
const t = e.encodings?.length ?? 0;
|
|
844
|
-
return
|
|
845
|
-
const
|
|
846
|
-
|
|
844
|
+
return Ke(n, t), n.encodings.forEach((s, i) => {
|
|
845
|
+
const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
|
|
846
|
+
et(s, a), st(s, o);
|
|
847
847
|
}), n;
|
|
848
848
|
}, rt = (n, e) => {
|
|
849
849
|
if (n.codecs?.length !== e.codecs?.length)
|
|
@@ -862,15 +862,15 @@ const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je
|
|
|
862
862
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
863
863
|
return !0;
|
|
864
864
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
865
|
-
},
|
|
865
|
+
}, at = async (n, e) => {
|
|
866
866
|
const t = n.getParameters(), s = JSON.parse(
|
|
867
867
|
JSON.stringify(t)
|
|
868
868
|
);
|
|
869
|
-
|
|
870
|
-
const
|
|
871
|
-
return
|
|
869
|
+
it(t, e), Je(t, e);
|
|
870
|
+
const i = rt(s, t);
|
|
871
|
+
return i && await n.setParameters(t), { parameters: t, isChanged: i };
|
|
872
872
|
}, he = async (n, e, t) => {
|
|
873
|
-
const { isChanged: s, parameters:
|
|
873
|
+
const { isChanged: s, parameters: i } = await at(n, {
|
|
874
874
|
encodings: [
|
|
875
875
|
{
|
|
876
876
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -878,20 +878,20 @@ const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je
|
|
|
878
878
|
}
|
|
879
879
|
]
|
|
880
880
|
});
|
|
881
|
-
return s && t && t(
|
|
882
|
-
},
|
|
883
|
-
const s =
|
|
881
|
+
return s && t && t(i), { isChanged: s, parameters: i };
|
|
882
|
+
}, ot = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ct = async (n, e, t) => {
|
|
883
|
+
const s = ot(n, e);
|
|
884
884
|
if (s)
|
|
885
885
|
return he(s, { maxBitrate: t });
|
|
886
886
|
};
|
|
887
887
|
var O = /* @__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))(O || {});
|
|
888
|
-
const
|
|
888
|
+
const le = [
|
|
889
889
|
"presentation:start",
|
|
890
890
|
"presentation:started",
|
|
891
891
|
"presentation:end",
|
|
892
892
|
"presentation:ended",
|
|
893
893
|
"presentation:failed"
|
|
894
|
-
],
|
|
894
|
+
], dt = 1, Gn = (n) => Oe(n);
|
|
895
895
|
class ht {
|
|
896
896
|
events;
|
|
897
897
|
promisePendingStartPresentation;
|
|
@@ -904,7 +904,7 @@ class ht {
|
|
|
904
904
|
callManager: e,
|
|
905
905
|
maxBitrate: t
|
|
906
906
|
}) {
|
|
907
|
-
this.callManager = e, this.maxBitrate = t, this.events = new k(
|
|
907
|
+
this.callManager = e, this.maxBitrate = t, this.events = new k(le), this.subscribe();
|
|
908
908
|
}
|
|
909
909
|
get isPendingPresentation() {
|
|
910
910
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
@@ -912,20 +912,20 @@ class ht {
|
|
|
912
912
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
913
913
|
async startPresentation(e, t, {
|
|
914
914
|
isNeedReinvite: s,
|
|
915
|
-
contentHint:
|
|
916
|
-
sendEncodings:
|
|
915
|
+
contentHint: i,
|
|
916
|
+
sendEncodings: r,
|
|
917
917
|
onAddedTransceiver: a
|
|
918
918
|
} = {}, o) {
|
|
919
|
-
const
|
|
919
|
+
const d = this.getRtcSessionProtected();
|
|
920
920
|
if (this.streamPresentationCurrent)
|
|
921
921
|
throw new Error("Presentation is already started");
|
|
922
922
|
return this.sendPresentationWithDuplicatedCalls(e, {
|
|
923
|
-
rtcSession:
|
|
923
|
+
rtcSession: d,
|
|
924
924
|
stream: t,
|
|
925
925
|
presentationOptions: {
|
|
926
926
|
isNeedReinvite: s,
|
|
927
|
-
contentHint:
|
|
928
|
-
sendEncodings:
|
|
927
|
+
contentHint: i,
|
|
928
|
+
sendEncodings: r,
|
|
929
929
|
onAddedTransceiver: a
|
|
930
930
|
},
|
|
931
931
|
options: o
|
|
@@ -937,17 +937,17 @@ class ht {
|
|
|
937
937
|
let s = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
|
|
938
938
|
this.promisePendingStartPresentation && await this.promisePendingStartPresentation.catch(() => {
|
|
939
939
|
});
|
|
940
|
-
const
|
|
941
|
-
return
|
|
942
|
-
throw this.events.trigger(O.FAILED_PRESENTATION,
|
|
940
|
+
const i = this.callManager.getEstablishedRTCSession();
|
|
941
|
+
return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
|
|
942
|
+
throw this.events.trigger(O.FAILED_PRESENTATION, r), r;
|
|
943
943
|
}) : t && this.events.trigger(O.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
944
944
|
this.resetPresentation();
|
|
945
945
|
});
|
|
946
946
|
}
|
|
947
947
|
async updatePresentation(e, t, {
|
|
948
948
|
contentHint: s,
|
|
949
|
-
sendEncodings:
|
|
950
|
-
onAddedTransceiver:
|
|
949
|
+
sendEncodings: i,
|
|
950
|
+
onAddedTransceiver: r
|
|
951
951
|
} = {}) {
|
|
952
952
|
const a = this.getRtcSessionProtected();
|
|
953
953
|
if (!this.streamPresentationCurrent)
|
|
@@ -955,8 +955,8 @@ class ht {
|
|
|
955
955
|
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, a, t, {
|
|
956
956
|
contentHint: s,
|
|
957
957
|
isNeedReinvite: !1,
|
|
958
|
-
sendEncodings:
|
|
959
|
-
onAddedTransceiver:
|
|
958
|
+
sendEncodings: i,
|
|
959
|
+
onAddedTransceiver: r
|
|
960
960
|
}).then(async (o) => (await this.setMaxBitrate(), o));
|
|
961
961
|
}
|
|
962
962
|
cancelSendPresentationWithRepeatedCalls() {
|
|
@@ -997,40 +997,40 @@ class ht {
|
|
|
997
997
|
async sendPresentationWithDuplicatedCalls(e, {
|
|
998
998
|
rtcSession: t,
|
|
999
999
|
stream: s,
|
|
1000
|
-
presentationOptions:
|
|
1001
|
-
options:
|
|
1002
|
-
callLimit:
|
|
1000
|
+
presentationOptions: i,
|
|
1001
|
+
options: r = {
|
|
1002
|
+
callLimit: dt
|
|
1003
1003
|
}
|
|
1004
1004
|
}) {
|
|
1005
1005
|
const a = async () => this.sendPresentation(
|
|
1006
1006
|
e,
|
|
1007
1007
|
t,
|
|
1008
1008
|
s,
|
|
1009
|
-
|
|
1009
|
+
i
|
|
1010
1010
|
), o = () => !!this.streamPresentationCurrent;
|
|
1011
|
-
return this.cancelableSendPresentationWithRepeatedCalls =
|
|
1011
|
+
return this.cancelableSendPresentationWithRepeatedCalls = te({
|
|
1012
1012
|
targetFunction: a,
|
|
1013
1013
|
isComplete: o,
|
|
1014
1014
|
isRejectAsValid: !0,
|
|
1015
|
-
...
|
|
1016
|
-
}), this.cancelableSendPresentationWithRepeatedCalls.then((
|
|
1015
|
+
...r
|
|
1016
|
+
}), this.cancelableSendPresentationWithRepeatedCalls.then((d) => d);
|
|
1017
1017
|
}
|
|
1018
1018
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
1019
1019
|
async sendPresentation(e, t, s, {
|
|
1020
|
-
isNeedReinvite:
|
|
1021
|
-
contentHint:
|
|
1020
|
+
isNeedReinvite: i = !0,
|
|
1021
|
+
contentHint: r = "detail",
|
|
1022
1022
|
degradationPreference: a,
|
|
1023
1023
|
sendEncodings: o,
|
|
1024
|
-
onAddedTransceiver:
|
|
1024
|
+
onAddedTransceiver: d
|
|
1025
1025
|
}) {
|
|
1026
|
-
const
|
|
1027
|
-
if (
|
|
1026
|
+
const h = F(s, { contentHint: r });
|
|
1027
|
+
if (h === void 0)
|
|
1028
1028
|
throw new Error("No streamPresentationTarget");
|
|
1029
|
-
this.streamPresentationCurrent =
|
|
1030
|
-
const T = e().then(async () => t.startPresentation(
|
|
1029
|
+
this.streamPresentationCurrent = h;
|
|
1030
|
+
const T = e().then(async () => t.startPresentation(h, i, {
|
|
1031
1031
|
degradationPreference: a,
|
|
1032
1032
|
sendEncodings: o,
|
|
1033
|
-
onAddedTransceiver:
|
|
1033
|
+
onAddedTransceiver: d
|
|
1034
1034
|
})).then(this.setMaxBitrate).then(() => s).catch((S) => {
|
|
1035
1035
|
throw this.removeStreamPresentationCurrent(), this.events.trigger(O.FAILED_PRESENTATION, S), S;
|
|
1036
1036
|
});
|
|
@@ -1042,8 +1042,8 @@ class ht {
|
|
|
1042
1042
|
const { connection: e } = this.callManager, { streamPresentationCurrent: t } = this, { maxBitrate: s } = this;
|
|
1043
1043
|
if (!e || !t || s === void 0)
|
|
1044
1044
|
return;
|
|
1045
|
-
const
|
|
1046
|
-
await
|
|
1045
|
+
const i = e.getSenders();
|
|
1046
|
+
await ct(i, t, s);
|
|
1047
1047
|
};
|
|
1048
1048
|
getRtcSessionProtected = () => {
|
|
1049
1049
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1064,7 +1064,7 @@ class ht {
|
|
|
1064
1064
|
delete this.streamPresentationCurrent;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
|
-
class
|
|
1067
|
+
class lt {
|
|
1068
1068
|
data;
|
|
1069
1069
|
getUa;
|
|
1070
1070
|
constructor(e) {
|
|
@@ -1145,7 +1145,7 @@ class dt {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
1147
|
var C = /* @__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))(C || {});
|
|
1148
|
-
const
|
|
1148
|
+
const ue = [
|
|
1149
1149
|
"connecting",
|
|
1150
1150
|
"connected",
|
|
1151
1151
|
"disconnected",
|
|
@@ -1155,15 +1155,15 @@ const le = [
|
|
|
1155
1155
|
"registrationFailed",
|
|
1156
1156
|
"newMessage",
|
|
1157
1157
|
"sipEvent"
|
|
1158
|
-
],
|
|
1158
|
+
], ut = [
|
|
1159
1159
|
"disconnecting",
|
|
1160
1160
|
"connect-started",
|
|
1161
1161
|
"connect-succeeded",
|
|
1162
1162
|
"connect-failed",
|
|
1163
1163
|
"connect-parameters-resolve-success",
|
|
1164
1164
|
"connect-parameters-resolve-failed"
|
|
1165
|
-
],
|
|
1166
|
-
class
|
|
1165
|
+
], ge = [...ue, ...ut], gt = 3;
|
|
1166
|
+
class Tt {
|
|
1167
1167
|
cancelableConnectWithRepeatedCalls;
|
|
1168
1168
|
JsSIP;
|
|
1169
1169
|
events;
|
|
@@ -1182,15 +1182,15 @@ class gt {
|
|
|
1182
1182
|
}
|
|
1183
1183
|
connect = async (e, t) => (this.cancelRequests(), this.connectWithDuplicatedCalls(e, t));
|
|
1184
1184
|
set = async ({ displayName: e }) => new Promise((t, s) => {
|
|
1185
|
-
const
|
|
1186
|
-
if (!
|
|
1185
|
+
const i = this.getUa();
|
|
1186
|
+
if (!i) {
|
|
1187
1187
|
s(new Error("this.ua is not initialized"));
|
|
1188
1188
|
return;
|
|
1189
1189
|
}
|
|
1190
|
-
let
|
|
1190
|
+
let r = !1;
|
|
1191
1191
|
const a = this.getConnectionConfiguration();
|
|
1192
|
-
e !== void 0 && e !== a?.displayName && (
|
|
1193
|
-
const o =
|
|
1192
|
+
e !== void 0 && e !== a?.displayName && (r = i.set("display_name", ae(e)), this.updateConnectionConfiguration("displayName", e));
|
|
1193
|
+
const o = r;
|
|
1194
1194
|
o ? t(o) : s(new Error("nothing changed"));
|
|
1195
1195
|
});
|
|
1196
1196
|
disconnect = async () => {
|
|
@@ -1207,26 +1207,26 @@ class gt {
|
|
|
1207
1207
|
cancelRequests() {
|
|
1208
1208
|
this.cancelConnectWithRepeatedCalls();
|
|
1209
1209
|
}
|
|
1210
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
1211
|
-
const s = async () => this.connectInner(e),
|
|
1212
|
-
const
|
|
1213
|
-
return
|
|
1210
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = gt } = {}) => {
|
|
1211
|
+
const s = async () => this.connectInner(e), i = (r) => {
|
|
1212
|
+
const d = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), h = r != null && !Le(r);
|
|
1213
|
+
return d || h;
|
|
1214
1214
|
};
|
|
1215
|
-
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls =
|
|
1215
|
+
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = te({
|
|
1216
1216
|
targetFunction: s,
|
|
1217
|
-
isComplete:
|
|
1217
|
+
isComplete: i,
|
|
1218
1218
|
callLimit: t,
|
|
1219
1219
|
isRejectAsValid: !0,
|
|
1220
1220
|
isCheckBeforeCall: !1
|
|
1221
|
-
}), this.cancelableConnectWithRepeatedCalls.then((
|
|
1222
|
-
if ("ua" in
|
|
1223
|
-
return
|
|
1224
|
-
throw
|
|
1221
|
+
}), this.cancelableConnectWithRepeatedCalls.then((r) => {
|
|
1222
|
+
if ("ua" in r && r.ua instanceof this.JsSIP.UA)
|
|
1223
|
+
return r;
|
|
1224
|
+
throw r;
|
|
1225
1225
|
});
|
|
1226
1226
|
};
|
|
1227
1227
|
hasEqualConnectionConfiguration(e) {
|
|
1228
|
-
const { configuration: t } = this.uaFactory.createConfiguration(e),
|
|
1229
|
-
return
|
|
1228
|
+
const { configuration: t } = this.uaFactory.createConfiguration(e), i = this.getUa()?.configuration;
|
|
1229
|
+
return i ? i.password === t.password && i.register === t.register && i.uri.toString() === t.uri && i.display_name === t.display_name && i.user_agent === t.user_agent && i.sockets === t.sockets && i.session_timers === t.session_timers && i.register_expires === t.register_expires && i.connection_recovery_min_interval === t.connection_recovery_min_interval && i.connection_recovery_max_interval === t.connection_recovery_max_interval : !1;
|
|
1230
1230
|
}
|
|
1231
1231
|
connectInner = async (e) => this.initUa(e).then(async () => this.start()).then((t) => {
|
|
1232
1232
|
const s = this.getConnectionConfiguration();
|
|
@@ -1241,12 +1241,12 @@ class gt {
|
|
|
1241
1241
|
user: e,
|
|
1242
1242
|
password: t,
|
|
1243
1243
|
sipServerUrl: s,
|
|
1244
|
-
sipWebSocketServerURL:
|
|
1245
|
-
remoteAddress:
|
|
1244
|
+
sipWebSocketServerURL: i,
|
|
1245
|
+
remoteAddress: r,
|
|
1246
1246
|
sessionTimers: a,
|
|
1247
1247
|
registerExpires: o,
|
|
1248
|
-
connectionRecoveryMinInterval:
|
|
1249
|
-
connectionRecoveryMaxInterval:
|
|
1248
|
+
connectionRecoveryMinInterval: d,
|
|
1249
|
+
connectionRecoveryMaxInterval: h,
|
|
1250
1250
|
userAgent: T,
|
|
1251
1251
|
displayName: S = "",
|
|
1252
1252
|
register: u = !1,
|
|
@@ -1259,25 +1259,25 @@ class gt {
|
|
|
1259
1259
|
user: e,
|
|
1260
1260
|
password: t
|
|
1261
1261
|
}), this.getUa() && await this.disconnect();
|
|
1262
|
-
const { ua:
|
|
1262
|
+
const { ua: p, helpers: N } = this.uaFactory.createUAWithConfiguration(
|
|
1263
1263
|
{
|
|
1264
1264
|
user: e,
|
|
1265
1265
|
password: t,
|
|
1266
1266
|
sipServerUrl: s,
|
|
1267
|
-
sipWebSocketServerURL:
|
|
1267
|
+
sipWebSocketServerURL: i,
|
|
1268
1268
|
displayName: S,
|
|
1269
1269
|
register: u,
|
|
1270
1270
|
sessionTimers: a,
|
|
1271
1271
|
registerExpires: o,
|
|
1272
|
-
connectionRecoveryMinInterval:
|
|
1273
|
-
connectionRecoveryMaxInterval:
|
|
1272
|
+
connectionRecoveryMinInterval: d,
|
|
1273
|
+
connectionRecoveryMaxInterval: h,
|
|
1274
1274
|
userAgent: T,
|
|
1275
|
-
remoteAddress:
|
|
1275
|
+
remoteAddress: r,
|
|
1276
1276
|
extraHeaders: E
|
|
1277
1277
|
},
|
|
1278
1278
|
this.events
|
|
1279
1279
|
);
|
|
1280
|
-
return this.setUa(
|
|
1280
|
+
return this.setUa(p), this.setSipServerUrl(N.getSipServerUrl), this.setSocket(N.socket), p;
|
|
1281
1281
|
};
|
|
1282
1282
|
start = async () => new Promise((e, t) => {
|
|
1283
1283
|
const s = this.getUa();
|
|
@@ -1285,40 +1285,40 @@ class gt {
|
|
|
1285
1285
|
t(new Error("this.ua is not initialized"));
|
|
1286
1286
|
return;
|
|
1287
1287
|
}
|
|
1288
|
-
let
|
|
1289
|
-
|
|
1288
|
+
let i;
|
|
1289
|
+
i = ((d, h) => {
|
|
1290
1290
|
if (this.getConnectionConfiguration()?.register === !0)
|
|
1291
|
-
return this.registrationManager.subscribeToStartEvents(
|
|
1291
|
+
return this.registrationManager.subscribeToStartEvents(d, h);
|
|
1292
1292
|
const S = C.CONNECTED, u = [C.DISCONNECTED];
|
|
1293
|
-
return this.events.on(S,
|
|
1294
|
-
this.events.on(E,
|
|
1293
|
+
return this.events.on(S, d), u.forEach((E) => {
|
|
1294
|
+
this.events.on(E, h);
|
|
1295
1295
|
}), () => {
|
|
1296
|
-
this.events.off(S,
|
|
1297
|
-
this.events.off(E,
|
|
1296
|
+
this.events.off(S, d), u.forEach((E) => {
|
|
1297
|
+
this.events.off(E, h);
|
|
1298
1298
|
});
|
|
1299
1299
|
};
|
|
1300
1300
|
})(() => {
|
|
1301
|
-
|
|
1302
|
-
}, (
|
|
1303
|
-
|
|
1301
|
+
i?.(), e(s);
|
|
1302
|
+
}, (d) => {
|
|
1303
|
+
i?.(), t(d);
|
|
1304
1304
|
}), s.start();
|
|
1305
1305
|
});
|
|
1306
1306
|
cancelConnectWithRepeatedCalls() {
|
|
1307
1307
|
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
1308
1308
|
}
|
|
1309
1309
|
}
|
|
1310
|
-
var
|
|
1311
|
-
const
|
|
1310
|
+
var Te = /* @__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))(Te || {});
|
|
1311
|
+
const St = ye({
|
|
1312
1312
|
types: {
|
|
1313
1313
|
context: {},
|
|
1314
1314
|
events: {}
|
|
1315
1315
|
},
|
|
1316
1316
|
actions: {
|
|
1317
1317
|
logTransition: (n, e) => {
|
|
1318
|
-
|
|
1318
|
+
c(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1319
1319
|
},
|
|
1320
1320
|
logStateChange: (n, e) => {
|
|
1321
|
-
|
|
1321
|
+
c("ConnectionStateMachine state changed", e.state);
|
|
1322
1322
|
}
|
|
1323
1323
|
}
|
|
1324
1324
|
}).createMachine({
|
|
@@ -1622,17 +1622,17 @@ const Tt = Oe({
|
|
|
1622
1622
|
}
|
|
1623
1623
|
}
|
|
1624
1624
|
});
|
|
1625
|
-
class
|
|
1625
|
+
class Ct {
|
|
1626
1626
|
actor;
|
|
1627
1627
|
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
1628
1628
|
events;
|
|
1629
1629
|
unsubscribeFromEvents;
|
|
1630
1630
|
actorSubscription;
|
|
1631
1631
|
constructor(e) {
|
|
1632
|
-
this.events = e, this.actor =
|
|
1632
|
+
this.events = e, this.actor = be(St), this.actorSubscription = this.actor.subscribe((t) => {
|
|
1633
1633
|
const s = t.value;
|
|
1634
|
-
this.stateChangeListeners.forEach((
|
|
1635
|
-
|
|
1634
|
+
this.stateChangeListeners.forEach((i) => {
|
|
1635
|
+
i(s);
|
|
1636
1636
|
});
|
|
1637
1637
|
}), this.actor.start(), this.subscribeToEvents();
|
|
1638
1638
|
}
|
|
@@ -1715,7 +1715,7 @@ class St {
|
|
|
1715
1715
|
return this.actor.getSnapshot().can({ type: e });
|
|
1716
1716
|
}
|
|
1717
1717
|
getValidEvents() {
|
|
1718
|
-
return Object.values(
|
|
1718
|
+
return Object.values(Te).filter((e) => this.canTransition(e));
|
|
1719
1719
|
}
|
|
1720
1720
|
hasState(e) {
|
|
1721
1721
|
return this.actor.getSnapshot().matches(e);
|
|
@@ -1723,7 +1723,7 @@ class St {
|
|
|
1723
1723
|
sendEvent(e) {
|
|
1724
1724
|
const t = this.actor.getSnapshot(), s = { type: e };
|
|
1725
1725
|
if (!t.can(s)) {
|
|
1726
|
-
|
|
1726
|
+
c(
|
|
1727
1727
|
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1728
1728
|
);
|
|
1729
1729
|
return;
|
|
@@ -1784,7 +1784,7 @@ class St {
|
|
|
1784
1784
|
};
|
|
1785
1785
|
}
|
|
1786
1786
|
}
|
|
1787
|
-
class
|
|
1787
|
+
class Et {
|
|
1788
1788
|
events;
|
|
1789
1789
|
getUaProtected;
|
|
1790
1790
|
constructor(e) {
|
|
@@ -1806,22 +1806,22 @@ class Ct {
|
|
|
1806
1806
|
try {
|
|
1807
1807
|
await this.unregister();
|
|
1808
1808
|
} catch (e) {
|
|
1809
|
-
|
|
1809
|
+
c("tryRegister", e);
|
|
1810
1810
|
}
|
|
1811
1811
|
return this.register();
|
|
1812
1812
|
}
|
|
1813
1813
|
subscribeToStartEvents(e, t) {
|
|
1814
|
-
const s = C.REGISTERED,
|
|
1815
|
-
return this.events.on(s, e),
|
|
1816
|
-
this.events.on(
|
|
1814
|
+
const s = C.REGISTERED, i = [C.REGISTRATION_FAILED, C.DISCONNECTED];
|
|
1815
|
+
return this.events.on(s, e), i.forEach((r) => {
|
|
1816
|
+
this.events.on(r, t);
|
|
1817
1817
|
}), () => {
|
|
1818
|
-
this.events.off(s, e),
|
|
1819
|
-
this.events.off(
|
|
1818
|
+
this.events.off(s, e), i.forEach((r) => {
|
|
1819
|
+
this.events.off(r, t);
|
|
1820
1820
|
});
|
|
1821
1821
|
};
|
|
1822
1822
|
}
|
|
1823
1823
|
}
|
|
1824
|
-
class
|
|
1824
|
+
class At {
|
|
1825
1825
|
uaFactory;
|
|
1826
1826
|
getUaProtected;
|
|
1827
1827
|
constructor(e) {
|
|
@@ -1831,14 +1831,14 @@ class Et {
|
|
|
1831
1831
|
* Отправляет SIP OPTIONS запрос к указанному адресу
|
|
1832
1832
|
*/
|
|
1833
1833
|
async sendOptions(e, t, s) {
|
|
1834
|
-
const
|
|
1835
|
-
return new Promise((
|
|
1834
|
+
const i = this.getUaProtected();
|
|
1835
|
+
return new Promise((r, a) => {
|
|
1836
1836
|
try {
|
|
1837
|
-
|
|
1837
|
+
i.sendOptions(e, t, {
|
|
1838
1838
|
extraHeaders: s,
|
|
1839
1839
|
eventHandlers: {
|
|
1840
1840
|
succeeded: () => {
|
|
1841
|
-
|
|
1841
|
+
r();
|
|
1842
1842
|
},
|
|
1843
1843
|
failed: a
|
|
1844
1844
|
}
|
|
@@ -1852,8 +1852,8 @@ class Et {
|
|
|
1852
1852
|
* Отправляет SIP OPTIONS запрос к собственному URI (ping)
|
|
1853
1853
|
*/
|
|
1854
1854
|
async ping(e, t) {
|
|
1855
|
-
const
|
|
1856
|
-
return this.sendOptions(
|
|
1855
|
+
const i = this.getUaProtected().configuration.uri;
|
|
1856
|
+
return this.sendOptions(i, e, t);
|
|
1857
1857
|
}
|
|
1858
1858
|
/**
|
|
1859
1859
|
* Проверяет доступность телефонии, создавая временное соединение
|
|
@@ -1862,19 +1862,19 @@ class Et {
|
|
|
1862
1862
|
userAgent: e,
|
|
1863
1863
|
displayName: t,
|
|
1864
1864
|
sipServerUrl: s,
|
|
1865
|
-
sipWebSocketServerURL:
|
|
1866
|
-
remoteAddress:
|
|
1865
|
+
sipWebSocketServerURL: i,
|
|
1866
|
+
remoteAddress: r,
|
|
1867
1867
|
extraHeaders: a
|
|
1868
1868
|
}) {
|
|
1869
|
-
return new Promise((o,
|
|
1870
|
-
const { configuration:
|
|
1871
|
-
sipWebSocketServerURL:
|
|
1869
|
+
return new Promise((o, d) => {
|
|
1870
|
+
const { configuration: h } = this.uaFactory.createConfiguration({
|
|
1871
|
+
sipWebSocketServerURL: i,
|
|
1872
1872
|
displayName: t,
|
|
1873
1873
|
userAgent: e,
|
|
1874
1874
|
sipServerUrl: s
|
|
1875
|
-
}), T = this.uaFactory.createUA({ ...
|
|
1875
|
+
}), T = this.uaFactory.createUA({ ...h, remoteAddress: r, extraHeaders: a }), S = () => {
|
|
1876
1876
|
const E = new Error("Telephony is not available");
|
|
1877
|
-
|
|
1877
|
+
d(E);
|
|
1878
1878
|
};
|
|
1879
1879
|
T.once(C.DISCONNECTED, S);
|
|
1880
1880
|
const u = () => {
|
|
@@ -1886,7 +1886,7 @@ class Et {
|
|
|
1886
1886
|
});
|
|
1887
1887
|
}
|
|
1888
1888
|
}
|
|
1889
|
-
const
|
|
1889
|
+
const Rt = (n) => {
|
|
1890
1890
|
const e = [];
|
|
1891
1891
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
1892
1892
|
};
|
|
@@ -1902,12 +1902,12 @@ class y {
|
|
|
1902
1902
|
register: e,
|
|
1903
1903
|
password: t,
|
|
1904
1904
|
user: s,
|
|
1905
|
-
sipServerUrl:
|
|
1906
|
-
sipWebSocketServerURL:
|
|
1905
|
+
sipServerUrl: i,
|
|
1906
|
+
sipWebSocketServerURL: r
|
|
1907
1907
|
}) {
|
|
1908
|
-
if (!r)
|
|
1909
|
-
throw new Error("sipServerUrl is required");
|
|
1910
1908
|
if (!i)
|
|
1909
|
+
throw new Error("sipServerUrl is required");
|
|
1910
|
+
if (!r)
|
|
1911
1911
|
throw new Error("sipWebSocketServerURL is required");
|
|
1912
1912
|
if (e && (t === void 0 || t === ""))
|
|
1913
1913
|
throw new Error("password is required for authorized connection");
|
|
@@ -1915,23 +1915,23 @@ class y {
|
|
|
1915
1915
|
throw new Error("user is required for authorized connection");
|
|
1916
1916
|
}
|
|
1917
1917
|
static resolveAuthorizationUser(e, t) {
|
|
1918
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
1918
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${xe()}`;
|
|
1919
1919
|
}
|
|
1920
1920
|
static buildExtraHeaders(e, t) {
|
|
1921
|
-
const s = e !== void 0 && e !== "" ?
|
|
1921
|
+
const s = e !== void 0 && e !== "" ? Rt(e) : [];
|
|
1922
1922
|
return t === void 0 ? s : [...s, ...t];
|
|
1923
1923
|
}
|
|
1924
1924
|
createConfiguration({
|
|
1925
1925
|
user: e,
|
|
1926
1926
|
password: t,
|
|
1927
1927
|
sipWebSocketServerURL: s,
|
|
1928
|
-
displayName:
|
|
1929
|
-
sipServerUrl:
|
|
1928
|
+
displayName: i = "",
|
|
1929
|
+
sipServerUrl: r,
|
|
1930
1930
|
register: a = !1,
|
|
1931
1931
|
sessionTimers: o = !1,
|
|
1932
|
-
registerExpires:
|
|
1932
|
+
registerExpires: d = 300,
|
|
1933
1933
|
// 5 minutes in sec
|
|
1934
|
-
connectionRecoveryMinInterval:
|
|
1934
|
+
connectionRecoveryMinInterval: h = 2,
|
|
1935
1935
|
connectionRecoveryMaxInterval: T = 6,
|
|
1936
1936
|
userAgent: S
|
|
1937
1937
|
}) {
|
|
@@ -1939,51 +1939,51 @@ class y {
|
|
|
1939
1939
|
register: a,
|
|
1940
1940
|
password: t,
|
|
1941
1941
|
user: e,
|
|
1942
|
-
sipServerUrl:
|
|
1942
|
+
sipServerUrl: r,
|
|
1943
1943
|
sipWebSocketServerURL: s
|
|
1944
1944
|
});
|
|
1945
|
-
const u = y.resolveAuthorizationUser(a, e), E =
|
|
1945
|
+
const u = y.resolveAuthorizationUser(a, e), E = He(r), m = E(u), p = new this.JsSIP.WebSocketInterface(s);
|
|
1946
1946
|
return {
|
|
1947
1947
|
configuration: {
|
|
1948
1948
|
password: t,
|
|
1949
1949
|
register: a,
|
|
1950
1950
|
uri: m,
|
|
1951
|
-
display_name:
|
|
1951
|
+
display_name: ae(i),
|
|
1952
1952
|
user_agent: S,
|
|
1953
1953
|
sdpSemantics: "unified-plan",
|
|
1954
|
-
sockets: [
|
|
1954
|
+
sockets: [p],
|
|
1955
1955
|
session_timers: o,
|
|
1956
|
-
register_expires:
|
|
1957
|
-
connection_recovery_min_interval:
|
|
1956
|
+
register_expires: d,
|
|
1957
|
+
connection_recovery_min_interval: h,
|
|
1958
1958
|
connection_recovery_max_interval: T
|
|
1959
1959
|
},
|
|
1960
1960
|
helpers: {
|
|
1961
|
-
socket:
|
|
1961
|
+
socket: p,
|
|
1962
1962
|
getSipServerUrl: E
|
|
1963
1963
|
}
|
|
1964
1964
|
};
|
|
1965
1965
|
}
|
|
1966
1966
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
1967
|
-
const
|
|
1968
|
-
return
|
|
1967
|
+
const i = new this.JsSIP.UA(s), r = y.buildExtraHeaders(e, t);
|
|
1968
|
+
return r.length > 0 && i.registrator().setExtraHeaders(r), i;
|
|
1969
1969
|
}
|
|
1970
1970
|
/**
|
|
1971
1971
|
* Создает UA с полным жизненным циклом - конфигурация + создание + настройка событий
|
|
1972
1972
|
*/
|
|
1973
1973
|
createUAWithConfiguration(e, t) {
|
|
1974
|
-
const { configuration: s, helpers:
|
|
1974
|
+
const { configuration: s, helpers: i } = this.createConfiguration(e), r = this.createUA({
|
|
1975
1975
|
...s,
|
|
1976
1976
|
remoteAddress: e.remoteAddress,
|
|
1977
1977
|
extraHeaders: e.extraHeaders
|
|
1978
1978
|
});
|
|
1979
1979
|
return t.eachTriggers((a, o) => {
|
|
1980
|
-
const
|
|
1981
|
-
|
|
1982
|
-
}), { ua:
|
|
1980
|
+
const d = ue.find((h) => h === o);
|
|
1981
|
+
d && r.on(d, a);
|
|
1982
|
+
}), { ua: r, helpers: i };
|
|
1983
1983
|
}
|
|
1984
1984
|
}
|
|
1985
|
-
const
|
|
1986
|
-
class
|
|
1985
|
+
const Se = "Not ready for connection", Nt = (n) => n instanceof Error && n.message === Se, pt = () => new Error(Se), It = async (n) => typeof n == "function" ? n() : n;
|
|
1986
|
+
class mt {
|
|
1987
1987
|
events;
|
|
1988
1988
|
ua;
|
|
1989
1989
|
socket;
|
|
@@ -1995,15 +1995,15 @@ class pt {
|
|
|
1995
1995
|
configurationManager;
|
|
1996
1996
|
JsSIP;
|
|
1997
1997
|
constructor({ JsSIP: e }) {
|
|
1998
|
-
this.JsSIP = e, this.events = new U(
|
|
1998
|
+
this.JsSIP = e, this.events = new U(ge), this.uaFactory = new y(e), this.registrationManager = new Et({
|
|
1999
1999
|
events: this.events,
|
|
2000
2000
|
getUaProtected: this.getUaProtected
|
|
2001
|
-
}), this.stateMachine = new
|
|
2001
|
+
}), this.stateMachine = new Ct(this.events), this.configurationManager = new lt({
|
|
2002
2002
|
getUa: this.getUa
|
|
2003
|
-
}), this.sipOperations = new
|
|
2003
|
+
}), this.sipOperations = new At({
|
|
2004
2004
|
uaFactory: this.uaFactory,
|
|
2005
2005
|
getUaProtected: this.getUaProtected
|
|
2006
|
-
}), this.connectionFlow = new
|
|
2006
|
+
}), this.connectionFlow = new Tt({
|
|
2007
2007
|
JsSIP: this.JsSIP,
|
|
2008
2008
|
events: this.events,
|
|
2009
2009
|
uaFactory: this.uaFactory,
|
|
@@ -2056,7 +2056,7 @@ class pt {
|
|
|
2056
2056
|
return this.configurationManager.isRegister();
|
|
2057
2057
|
}
|
|
2058
2058
|
connect = async (e, t) => this.disconnect().catch((s) => {
|
|
2059
|
-
|
|
2059
|
+
c("connect: disconnect error", s);
|
|
2060
2060
|
}).then(async () => this.connectWithProcessError(e, t));
|
|
2061
2061
|
set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
|
|
2062
2062
|
disconnect = async () => {
|
|
@@ -2105,13 +2105,13 @@ class pt {
|
|
|
2105
2105
|
getUa = () => this.ua;
|
|
2106
2106
|
connectWithProcessError = async (e, t) => {
|
|
2107
2107
|
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
2108
|
-
throw
|
|
2109
|
-
return this.processConnect(e, t).catch(async (
|
|
2110
|
-
const
|
|
2108
|
+
throw pt();
|
|
2109
|
+
return this.processConnect(e, t).catch(async (i) => {
|
|
2110
|
+
const r = i;
|
|
2111
2111
|
return this.disconnect().then(() => {
|
|
2112
|
-
throw
|
|
2112
|
+
throw r;
|
|
2113
2113
|
}).catch(() => {
|
|
2114
|
-
throw
|
|
2114
|
+
throw r;
|
|
2115
2115
|
});
|
|
2116
2116
|
});
|
|
2117
2117
|
};
|
|
@@ -2120,13 +2120,13 @@ class pt {
|
|
|
2120
2120
|
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
|
|
2121
2121
|
...s
|
|
2122
2122
|
}), s)).catch((s) => {
|
|
2123
|
-
const
|
|
2124
|
-
throw this.events.trigger(C.CONNECT_FAILED,
|
|
2123
|
+
const i = s ?? new Error("Failed to connect to server");
|
|
2124
|
+
throw this.events.trigger(C.CONNECT_FAILED, i), i;
|
|
2125
2125
|
}));
|
|
2126
2126
|
}
|
|
2127
|
-
class
|
|
2127
|
+
class _t {
|
|
2128
2128
|
connectionManager;
|
|
2129
|
-
stackPromises =
|
|
2129
|
+
stackPromises = ne({
|
|
2130
2130
|
noRunIsNotActual: !0
|
|
2131
2131
|
});
|
|
2132
2132
|
constructor({ connectionManager: e }) {
|
|
@@ -2138,11 +2138,11 @@ class mt {
|
|
|
2138
2138
|
this.stackPromises.stop();
|
|
2139
2139
|
}
|
|
2140
2140
|
}
|
|
2141
|
-
const z = 0,
|
|
2142
|
-
class
|
|
2141
|
+
const z = 0, Mt = 30;
|
|
2142
|
+
class ft {
|
|
2143
2143
|
countInner = z;
|
|
2144
2144
|
initialCount = z;
|
|
2145
|
-
limitInner =
|
|
2145
|
+
limitInner = Mt;
|
|
2146
2146
|
isInProgress = !1;
|
|
2147
2147
|
onStatusChange;
|
|
2148
2148
|
constructor({
|
|
@@ -2175,7 +2175,7 @@ class Mt {
|
|
|
2175
2175
|
this.countInner = this.initialCount, this.finishAttempt();
|
|
2176
2176
|
}
|
|
2177
2177
|
}
|
|
2178
|
-
class
|
|
2178
|
+
class vt {
|
|
2179
2179
|
connectionManager;
|
|
2180
2180
|
interval;
|
|
2181
2181
|
checkTelephonyByTimeout = void 0;
|
|
@@ -2191,14 +2191,14 @@ class ft {
|
|
|
2191
2191
|
onSuccessRequest: t,
|
|
2192
2192
|
onFailRequest: s
|
|
2193
2193
|
}) {
|
|
2194
|
-
this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout =
|
|
2194
|
+
this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Me({
|
|
2195
2195
|
isDontStopOnFail: !0,
|
|
2196
2196
|
requestInterval: this.interval,
|
|
2197
2197
|
request: async () => {
|
|
2198
2198
|
if (!this.cancelableBeforeRequest)
|
|
2199
2199
|
throw new Error("cancelableBeforeRequest is not defined");
|
|
2200
|
-
const
|
|
2201
|
-
return this.connectionManager.checkTelephony(
|
|
2200
|
+
const i = await this.cancelableBeforeRequest.request();
|
|
2201
|
+
return this.connectionManager.checkTelephony(i);
|
|
2202
2202
|
}
|
|
2203
2203
|
}), this.checkTelephonyByTimeout.start(void 0, {
|
|
2204
2204
|
onFailRequest: s,
|
|
@@ -2212,7 +2212,7 @@ class ft {
|
|
|
2212
2212
|
}
|
|
2213
2213
|
}
|
|
2214
2214
|
var M = /* @__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))(M || {});
|
|
2215
|
-
const
|
|
2215
|
+
const Ce = [
|
|
2216
2216
|
"before-attempt",
|
|
2217
2217
|
"success",
|
|
2218
2218
|
"failed-all-attempts",
|
|
@@ -2220,28 +2220,28 @@ const Se = [
|
|
|
2220
2220
|
"changed-attempt-status",
|
|
2221
2221
|
"stop-attempts-by-error",
|
|
2222
2222
|
"limit-reached-attempts"
|
|
2223
|
-
],
|
|
2224
|
-
class
|
|
2223
|
+
], Pt = 15e3, Ot = 2;
|
|
2224
|
+
class yt {
|
|
2225
2225
|
connectionManager;
|
|
2226
2226
|
pingServerByTimeoutWithFailCalls;
|
|
2227
2227
|
constructor({ connectionManager: e }) {
|
|
2228
|
-
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls =
|
|
2228
|
+
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = fe(Ot, {
|
|
2229
2229
|
whenPossibleRequest: async () => {
|
|
2230
2230
|
},
|
|
2231
|
-
requestInterval:
|
|
2232
|
-
request: async () => (
|
|
2233
|
-
|
|
2231
|
+
requestInterval: Pt,
|
|
2232
|
+
request: async () => (c("ping"), this.connectionManager.ping().then(() => {
|
|
2233
|
+
c("ping success");
|
|
2234
2234
|
}))
|
|
2235
2235
|
});
|
|
2236
2236
|
}
|
|
2237
2237
|
start({ onFailRequest: e }) {
|
|
2238
|
-
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(
|
|
2238
|
+
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(c);
|
|
2239
2239
|
}
|
|
2240
2240
|
stop() {
|
|
2241
2241
|
this.pingServerByTimeoutWithFailCalls.stop();
|
|
2242
2242
|
}
|
|
2243
2243
|
}
|
|
2244
|
-
class
|
|
2244
|
+
class bt {
|
|
2245
2245
|
callManager;
|
|
2246
2246
|
pingServerRequester;
|
|
2247
2247
|
disposeCallStatusChange;
|
|
@@ -2249,17 +2249,17 @@ class yt {
|
|
|
2249
2249
|
connectionManager: e,
|
|
2250
2250
|
callManager: t
|
|
2251
2251
|
}) {
|
|
2252
|
-
this.callManager = t, this.pingServerRequester = new
|
|
2252
|
+
this.callManager = t, this.pingServerRequester = new yt({
|
|
2253
2253
|
connectionManager: e
|
|
2254
2254
|
});
|
|
2255
2255
|
}
|
|
2256
2256
|
start({ onFailRequest: e }) {
|
|
2257
|
-
|
|
2257
|
+
c("start"), this.disposeCallStatusChange = this.callManager.on("call-status-changed", () => {
|
|
2258
2258
|
this.handleCallStatusChange({ onFailRequest: e });
|
|
2259
2259
|
}), this.handleCallStatusChange({ onFailRequest: e });
|
|
2260
2260
|
}
|
|
2261
2261
|
stop() {
|
|
2262
|
-
|
|
2262
|
+
c("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
|
|
2263
2263
|
}
|
|
2264
2264
|
unsubscribeCallStatusChange() {
|
|
2265
2265
|
this.disposeCallStatusChange?.(), this.disposeCallStatusChange = void 0;
|
|
@@ -2302,9 +2302,12 @@ class Dt {
|
|
|
2302
2302
|
this.isRegistrationFailed = !1;
|
|
2303
2303
|
}
|
|
2304
2304
|
}
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2307
|
-
|
|
2305
|
+
const wt = 3e3, Ut = 15e3, X = {
|
|
2306
|
+
LIMIT_REACHED: "Limit reached",
|
|
2307
|
+
FAILED_TO_RECONNECT: "Failed to reconnect"
|
|
2308
|
+
}, Lt = async () => {
|
|
2309
|
+
}, Bt = (n) => !0;
|
|
2310
|
+
class Ft {
|
|
2308
2311
|
events;
|
|
2309
2312
|
connectionManager;
|
|
2310
2313
|
connectionQueueManager;
|
|
@@ -2322,30 +2325,28 @@ class Bt {
|
|
|
2322
2325
|
connectionQueueManager: e,
|
|
2323
2326
|
connectionManager: t,
|
|
2324
2327
|
callManager: s
|
|
2325
|
-
},
|
|
2326
|
-
const
|
|
2327
|
-
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry =
|
|
2328
|
+
}, i) {
|
|
2329
|
+
const r = i?.onBeforeRetry ?? Lt, a = i?.canRetryOnError ?? Bt;
|
|
2330
|
+
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = new U(Ce), this.checkTelephonyRequester = new vt({
|
|
2328
2331
|
connectionManager: t,
|
|
2329
|
-
interval:
|
|
2330
|
-
}), this.pingServerIfNotActiveCallRequester = new
|
|
2332
|
+
interval: i?.checkTelephonyRequestInterval ?? Ut
|
|
2333
|
+
}), this.pingServerIfNotActiveCallRequester = new bt({
|
|
2331
2334
|
connectionManager: t,
|
|
2332
2335
|
callManager: s
|
|
2333
2336
|
}), this.registrationFailedOutOfCallSubscriber = new Dt({
|
|
2334
2337
|
connectionManager: t,
|
|
2335
2338
|
callManager: s
|
|
2336
|
-
}), this.attemptsState = new
|
|
2339
|
+
}), this.attemptsState = new ft({
|
|
2337
2340
|
onStatusChange: this.emitStatusChange
|
|
2338
|
-
}), this.cancelableRequestBeforeRetry = new G(
|
|
2339
|
-
|
|
2341
|
+
}), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new ve(
|
|
2342
|
+
i?.timeoutBetweenAttempts ?? wt
|
|
2340
2343
|
);
|
|
2341
2344
|
}
|
|
2342
2345
|
start(e) {
|
|
2343
|
-
|
|
2344
|
-
h("auto connector failed to connect:", t);
|
|
2345
|
-
});
|
|
2346
|
+
c("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToHardwareTriggers(e);
|
|
2346
2347
|
}
|
|
2347
2348
|
stop() {
|
|
2348
|
-
|
|
2349
|
+
c("auto connector stop"), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow();
|
|
2349
2350
|
}
|
|
2350
2351
|
on(e, t) {
|
|
2351
2352
|
return this.events.on(e, t);
|
|
@@ -2362,106 +2363,111 @@ class Bt {
|
|
|
2362
2363
|
off(e, t) {
|
|
2363
2364
|
this.events.off(e, t);
|
|
2364
2365
|
}
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2366
|
+
restartConnectionAttempts(e) {
|
|
2367
|
+
c("auto connector restart connection attempts"), this.stopConnectionFlow(), this.attemptConnection(e).catch((t) => {
|
|
2368
|
+
c("auto connector failed to connect:", t);
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
stopConnectionFlow() {
|
|
2372
|
+
c("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), this.connectionQueueManager.disconnect().catch((e) => {
|
|
2373
|
+
c("auto connector disconnect: error", e);
|
|
2368
2374
|
});
|
|
2369
2375
|
}
|
|
2370
2376
|
stopAttempts() {
|
|
2371
2377
|
this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
|
|
2372
2378
|
}
|
|
2373
2379
|
stopConnectTriggers() {
|
|
2374
|
-
|
|
2380
|
+
c("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
|
|
2375
2381
|
}
|
|
2376
|
-
|
|
2377
|
-
|
|
2382
|
+
startCheckTelephony(e) {
|
|
2383
|
+
c("startCheckTelephony"), this.checkTelephonyRequester.start({
|
|
2378
2384
|
onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
|
|
2379
2385
|
onSuccessRequest: () => {
|
|
2380
|
-
|
|
2386
|
+
c("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
|
|
2381
2387
|
},
|
|
2382
2388
|
onFailRequest: (t) => {
|
|
2383
|
-
|
|
2389
|
+
c("startCheckTelephony: onFailRequest", t.message);
|
|
2384
2390
|
}
|
|
2385
2391
|
});
|
|
2386
2392
|
}
|
|
2387
|
-
async
|
|
2388
|
-
if (
|
|
2389
|
-
|
|
2393
|
+
async attemptConnection(e) {
|
|
2394
|
+
if (c("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(M.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
|
|
2395
|
+
c("attemptConnection: limit reached"), this.handleLimitReached(e);
|
|
2390
2396
|
return;
|
|
2391
2397
|
}
|
|
2392
|
-
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.
|
|
2398
|
+
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.executeConnectionAttempt(e);
|
|
2393
2399
|
}
|
|
2394
|
-
async
|
|
2400
|
+
async executeConnectionAttempt(e) {
|
|
2395
2401
|
try {
|
|
2396
|
-
await this.connectionQueueManager.connect(e.getParameters, e.options),
|
|
2402
|
+
await this.connectionQueueManager.connect(e.getParameters, e.options), c("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
|
|
2397
2403
|
} catch (t) {
|
|
2398
|
-
|
|
2399
|
-
this.attemptsState.finishAttempt(), this.handleSucceededAttempt(e);
|
|
2400
|
-
return;
|
|
2401
|
-
}
|
|
2402
|
-
if (!this.canRetryOnError(t)) {
|
|
2403
|
-
h("processConnect: error does not allow retry", t), this.attemptsState.finishAttempt(), this.events.trigger(M.STOP_ATTEMPTS_BY_ERROR, t);
|
|
2404
|
-
return;
|
|
2405
|
-
}
|
|
2406
|
-
if (De(t)) {
|
|
2407
|
-
h("processConnect: not actual error", t), this.attemptsState.finishAttempt(), this.events.trigger(M.CANCELLED_ATTEMPTS, t);
|
|
2408
|
-
return;
|
|
2409
|
-
}
|
|
2410
|
-
h("processConnect: error", t), this.reconnect(e);
|
|
2404
|
+
this.handleConnectionError(t, e);
|
|
2411
2405
|
}
|
|
2412
2406
|
}
|
|
2407
|
+
handleConnectionError(e, t) {
|
|
2408
|
+
if (Nt(e)) {
|
|
2409
|
+
this.attemptsState.finishAttempt(), this.handleSucceededAttempt(t);
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
2412
|
+
if (!this.canRetryOnError(e)) {
|
|
2413
|
+
c("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(M.STOP_ATTEMPTS_BY_ERROR, e);
|
|
2414
|
+
return;
|
|
2415
|
+
}
|
|
2416
|
+
if (De(e)) {
|
|
2417
|
+
c("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(M.CANCELLED_ATTEMPTS, e);
|
|
2418
|
+
return;
|
|
2419
|
+
}
|
|
2420
|
+
c("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
|
|
2421
|
+
}
|
|
2413
2422
|
handleLimitReached(e) {
|
|
2414
|
-
this.attemptsState.finishAttempt(), this.events.trigger(M.LIMIT_REACHED_ATTEMPTS, new Error(
|
|
2423
|
+
this.attemptsState.finishAttempt(), this.events.trigger(M.LIMIT_REACHED_ATTEMPTS, new Error(X.LIMIT_REACHED)), this.startCheckTelephony(e);
|
|
2415
2424
|
}
|
|
2416
2425
|
handleSucceededAttempt(e) {
|
|
2417
|
-
|
|
2426
|
+
c("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(M.SUCCESS);
|
|
2418
2427
|
}
|
|
2419
2428
|
subscribeToConnectTriggers(e) {
|
|
2420
|
-
this.
|
|
2421
|
-
|
|
2422
|
-
h("resumeFromSleepModeSubscriber onResume"), this.restartPingServerIfNotActiveCallRequester(e);
|
|
2423
|
-
}
|
|
2424
|
-
}), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2425
|
-
h("registrationFailedOutOfCallListener callback"), this.start(e);
|
|
2429
|
+
this.startPingRequester(e), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2430
|
+
c("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
|
|
2426
2431
|
});
|
|
2427
2432
|
}
|
|
2428
|
-
|
|
2429
|
-
this.
|
|
2433
|
+
subscribeToHardwareTriggers(e) {
|
|
2434
|
+
this.unsubscribeFromHardwareTriggers(), c("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
|
|
2430
2435
|
onChange: () => {
|
|
2431
|
-
|
|
2436
|
+
c("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
|
|
2432
2437
|
},
|
|
2433
2438
|
onUnavailable: () => {
|
|
2434
|
-
|
|
2439
|
+
c("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow();
|
|
2440
|
+
}
|
|
2441
|
+
}), this.resumeFromSleepModeSubscriber?.subscribe({
|
|
2442
|
+
onResume: () => {
|
|
2443
|
+
c("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
|
|
2435
2444
|
}
|
|
2436
2445
|
});
|
|
2437
2446
|
}
|
|
2438
|
-
|
|
2439
|
-
this.networkInterfacesSubscriber?.unsubscribe();
|
|
2440
|
-
}
|
|
2441
|
-
restartPingServerIfNotActiveCallRequester(e) {
|
|
2442
|
-
this.stopPingServerIfNotActiveCallRequester(), this.startPingServerIfNotActiveCallRequester(e);
|
|
2447
|
+
unsubscribeFromHardwareTriggers() {
|
|
2448
|
+
c("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
|
|
2443
2449
|
}
|
|
2444
|
-
|
|
2450
|
+
stopPingRequester() {
|
|
2445
2451
|
this.pingServerIfNotActiveCallRequester.stop();
|
|
2446
2452
|
}
|
|
2447
|
-
|
|
2453
|
+
startPingRequester(e) {
|
|
2448
2454
|
this.pingServerIfNotActiveCallRequester.start({
|
|
2449
2455
|
onFailRequest: () => {
|
|
2450
|
-
|
|
2456
|
+
c("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
|
|
2451
2457
|
}
|
|
2452
2458
|
});
|
|
2453
2459
|
}
|
|
2454
2460
|
connectIfDisconnected(e) {
|
|
2455
|
-
const t = this.
|
|
2456
|
-
|
|
2461
|
+
const t = this.isConnectionUnavailable();
|
|
2462
|
+
c("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(M.SUCCESS));
|
|
2457
2463
|
}
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
const s = t instanceof Error ? t : new Error(
|
|
2461
|
-
this.attemptsState.finishAttempt(),
|
|
2464
|
+
scheduleReconnect(e) {
|
|
2465
|
+
c("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (c("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (c("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
|
|
2466
|
+
const s = t instanceof Error ? t : new Error(X.FAILED_TO_RECONNECT);
|
|
2467
|
+
this.attemptsState.finishAttempt(), _e(t) || Pe(t) ? this.events.trigger(M.CANCELLED_ATTEMPTS, s) : this.events.trigger(M.FAILED_ALL_ATTEMPTS, s), c("scheduleReconnect: error", t);
|
|
2462
2468
|
});
|
|
2463
2469
|
}
|
|
2464
|
-
|
|
2470
|
+
isConnectionUnavailable() {
|
|
2465
2471
|
const { isFailed: e, isDisconnected: t, isIdle: s } = this.connectionManager;
|
|
2466
2472
|
return e || t || s;
|
|
2467
2473
|
}
|
|
@@ -2470,18 +2476,18 @@ class Bt {
|
|
|
2470
2476
|
};
|
|
2471
2477
|
}
|
|
2472
2478
|
var w = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(w || {});
|
|
2473
|
-
const
|
|
2479
|
+
const Ee = [
|
|
2474
2480
|
"incomingCall",
|
|
2475
2481
|
"declinedIncomingCall",
|
|
2476
2482
|
"terminatedIncomingCall",
|
|
2477
2483
|
"failedIncomingCall"
|
|
2478
|
-
],
|
|
2479
|
-
class
|
|
2484
|
+
], kt = 486, $t = 487;
|
|
2485
|
+
class qt {
|
|
2480
2486
|
events;
|
|
2481
2487
|
incomingRTCSession;
|
|
2482
2488
|
connectionManager;
|
|
2483
2489
|
constructor(e) {
|
|
2484
|
-
this.connectionManager = e, this.events = new k(
|
|
2490
|
+
this.connectionManager = e, this.events = new k(Ee), this.start();
|
|
2485
2491
|
}
|
|
2486
2492
|
get remoteCallerData() {
|
|
2487
2493
|
return {
|
|
@@ -2511,19 +2517,19 @@ class $t {
|
|
|
2511
2517
|
return this.removeIncomingSession(), e;
|
|
2512
2518
|
};
|
|
2513
2519
|
async declineToIncomingCall({
|
|
2514
|
-
statusCode: e =
|
|
2520
|
+
statusCode: e = $t
|
|
2515
2521
|
} = {}) {
|
|
2516
2522
|
return new Promise((t, s) => {
|
|
2517
2523
|
try {
|
|
2518
|
-
const
|
|
2519
|
-
this.removeIncomingSession(), this.events.trigger(w.DECLINED_INCOMING_CALL,
|
|
2520
|
-
} catch (
|
|
2521
|
-
s(
|
|
2524
|
+
const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
|
|
2525
|
+
this.removeIncomingSession(), this.events.trigger(w.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
|
|
2526
|
+
} catch (i) {
|
|
2527
|
+
s(i);
|
|
2522
2528
|
}
|
|
2523
2529
|
});
|
|
2524
2530
|
}
|
|
2525
2531
|
async busyIncomingCall() {
|
|
2526
|
-
return this.declineToIncomingCall({ statusCode:
|
|
2532
|
+
return this.declineToIncomingCall({ statusCode: kt });
|
|
2527
2533
|
}
|
|
2528
2534
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
2529
2535
|
on(e, t) {
|
|
@@ -2567,12 +2573,12 @@ class $t {
|
|
|
2567
2573
|
delete this.incomingRTCSession;
|
|
2568
2574
|
}
|
|
2569
2575
|
}
|
|
2570
|
-
const
|
|
2576
|
+
const D = 1e3;
|
|
2571
2577
|
var A = /* @__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))(A || {});
|
|
2572
|
-
const
|
|
2578
|
+
const Ae = ["collected"], J = () => "performance" in window ? performance.now() : Date.now(), L = (n) => [...n.keys()].reduce((e, t) => {
|
|
2573
2579
|
const s = n.get(t);
|
|
2574
2580
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2575
|
-
}, {}),
|
|
2581
|
+
}, {}), Vt = (n) => {
|
|
2576
2582
|
if (!n)
|
|
2577
2583
|
return {
|
|
2578
2584
|
outboundRtp: void 0,
|
|
@@ -2587,7 +2593,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2587
2593
|
mediaSource: e[A.MEDIA_SOURCE],
|
|
2588
2594
|
remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
|
|
2589
2595
|
};
|
|
2590
|
-
},
|
|
2596
|
+
}, K = (n) => {
|
|
2591
2597
|
if (!n)
|
|
2592
2598
|
return {
|
|
2593
2599
|
outboundRtp: void 0,
|
|
@@ -2602,7 +2608,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2602
2608
|
mediaSource: e[A.MEDIA_SOURCE],
|
|
2603
2609
|
remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
|
|
2604
2610
|
};
|
|
2605
|
-
},
|
|
2611
|
+
}, j = ({
|
|
2606
2612
|
videoReceiversStats: n,
|
|
2607
2613
|
synchronizationSourcesVideo: e
|
|
2608
2614
|
}) => {
|
|
@@ -2618,7 +2624,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2618
2624
|
codec: t[A.CODEC],
|
|
2619
2625
|
synchronizationSources: e
|
|
2620
2626
|
};
|
|
2621
|
-
},
|
|
2627
|
+
}, Ht = ({
|
|
2622
2628
|
audioReceiverStats: n,
|
|
2623
2629
|
synchronizationSourcesAudio: e
|
|
2624
2630
|
}) => {
|
|
@@ -2636,7 +2642,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2636
2642
|
remoteOutboundRtp: t[A.REMOTE_OUTBOUND_RTP],
|
|
2637
2643
|
synchronizationSources: e
|
|
2638
2644
|
};
|
|
2639
|
-
},
|
|
2645
|
+
}, Re = (n) => {
|
|
2640
2646
|
if (!n)
|
|
2641
2647
|
return {
|
|
2642
2648
|
candidatePair: void 0,
|
|
@@ -2658,109 +2664,109 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2658
2664
|
videoSenderFirstStats: e,
|
|
2659
2665
|
videoSenderSecondStats: t
|
|
2660
2666
|
}) => ({
|
|
2661
|
-
video:
|
|
2662
|
-
secondVideo:
|
|
2663
|
-
audio:
|
|
2664
|
-
additional:
|
|
2667
|
+
video: K(e),
|
|
2668
|
+
secondVideo: K(t),
|
|
2669
|
+
audio: Vt(n),
|
|
2670
|
+
additional: Re(
|
|
2665
2671
|
n ?? e ?? t
|
|
2666
2672
|
)
|
|
2667
|
-
}),
|
|
2673
|
+
}), xt = ({
|
|
2668
2674
|
audioReceiverStats: n,
|
|
2669
2675
|
videoReceiverFirstStats: e,
|
|
2670
2676
|
videoReceiverSecondStats: t,
|
|
2671
2677
|
synchronizationSources: s
|
|
2672
2678
|
}) => ({
|
|
2673
|
-
video:
|
|
2679
|
+
video: j({
|
|
2674
2680
|
videoReceiversStats: e,
|
|
2675
2681
|
synchronizationSourcesVideo: s.video
|
|
2676
2682
|
}),
|
|
2677
|
-
secondVideo:
|
|
2683
|
+
secondVideo: j({
|
|
2678
2684
|
videoReceiversStats: t,
|
|
2679
2685
|
synchronizationSourcesVideo: s.video
|
|
2680
2686
|
}),
|
|
2681
|
-
audio:
|
|
2687
|
+
audio: Ht({
|
|
2682
2688
|
audioReceiverStats: n,
|
|
2683
2689
|
synchronizationSourcesAudio: s.audio
|
|
2684
2690
|
}),
|
|
2685
|
-
additional:
|
|
2691
|
+
additional: Re(
|
|
2686
2692
|
n ?? e ?? t
|
|
2687
2693
|
)
|
|
2688
|
-
}),
|
|
2694
|
+
}), Gt = ({
|
|
2689
2695
|
audioSenderStats: n,
|
|
2690
2696
|
videoSenderFirstStats: e,
|
|
2691
2697
|
videoSenderSecondStats: t,
|
|
2692
2698
|
audioReceiverStats: s,
|
|
2693
|
-
videoReceiverFirstStats:
|
|
2694
|
-
videoReceiverSecondStats:
|
|
2699
|
+
videoReceiverFirstStats: i,
|
|
2700
|
+
videoReceiverSecondStats: r,
|
|
2695
2701
|
synchronizationSources: a
|
|
2696
2702
|
}) => {
|
|
2697
2703
|
const o = Wt({
|
|
2698
2704
|
audioSenderStats: n,
|
|
2699
2705
|
videoSenderFirstStats: e,
|
|
2700
2706
|
videoSenderSecondStats: t
|
|
2701
|
-
}),
|
|
2707
|
+
}), d = xt({
|
|
2702
2708
|
audioReceiverStats: s,
|
|
2703
|
-
videoReceiverFirstStats:
|
|
2704
|
-
videoReceiverSecondStats:
|
|
2709
|
+
videoReceiverFirstStats: i,
|
|
2710
|
+
videoReceiverSecondStats: r,
|
|
2705
2711
|
synchronizationSources: a
|
|
2706
2712
|
});
|
|
2707
2713
|
return {
|
|
2708
2714
|
outbound: o,
|
|
2709
|
-
inbound:
|
|
2715
|
+
inbound: d
|
|
2710
2716
|
};
|
|
2711
|
-
},
|
|
2712
|
-
const e = "audio", t = "video", s = n.getSenders(),
|
|
2717
|
+
}, Qt = async (n) => {
|
|
2718
|
+
const e = "audio", t = "video", s = n.getSenders(), i = s.find((u) => u.track?.kind === e), r = s.filter((u) => u.track?.kind === t), a = n.getReceivers(), o = a.find((u) => u.track.kind === e), d = a.filter((u) => u.track.kind === t), h = {
|
|
2713
2719
|
trackIdentifier: o?.track.id,
|
|
2714
2720
|
item: o?.getSynchronizationSources()[0]
|
|
2715
2721
|
}, T = {
|
|
2716
|
-
trackIdentifier:
|
|
2717
|
-
item:
|
|
2722
|
+
trackIdentifier: d[0]?.track.id,
|
|
2723
|
+
item: d[0]?.getSynchronizationSources()[0]
|
|
2718
2724
|
}, S = {
|
|
2719
|
-
audio:
|
|
2725
|
+
audio: h,
|
|
2720
2726
|
video: T
|
|
2721
2727
|
};
|
|
2722
2728
|
return Promise.all([
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2729
|
+
i?.getStats() ?? Promise.resolve(void 0),
|
|
2730
|
+
r[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2731
|
+
r[1]?.getStats() ?? Promise.resolve(void 0),
|
|
2726
2732
|
o?.getStats() ?? Promise.resolve(void 0),
|
|
2727
|
-
|
|
2728
|
-
|
|
2733
|
+
d[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2734
|
+
d[1]?.getStats() ?? Promise.resolve(void 0)
|
|
2729
2735
|
]).then((u) => {
|
|
2730
2736
|
const [
|
|
2731
2737
|
E,
|
|
2732
2738
|
m,
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2739
|
+
p,
|
|
2740
|
+
N,
|
|
2741
|
+
b,
|
|
2736
2742
|
$
|
|
2737
2743
|
] = u;
|
|
2738
2744
|
return {
|
|
2739
2745
|
synchronizationSources: S,
|
|
2740
2746
|
audioSenderStats: E,
|
|
2741
2747
|
videoSenderFirstStats: m,
|
|
2742
|
-
videoSenderSecondStats:
|
|
2743
|
-
audioReceiverStats:
|
|
2744
|
-
videoReceiverFirstStats:
|
|
2748
|
+
videoSenderSecondStats: p,
|
|
2749
|
+
audioReceiverStats: N,
|
|
2750
|
+
videoReceiverFirstStats: b,
|
|
2745
2751
|
videoReceiverSecondStats: $
|
|
2746
2752
|
};
|
|
2747
2753
|
});
|
|
2748
|
-
},
|
|
2749
|
-
|
|
2754
|
+
}, Yt = (n) => {
|
|
2755
|
+
c(String(n));
|
|
2750
2756
|
};
|
|
2751
|
-
class
|
|
2757
|
+
class zt {
|
|
2752
2758
|
events;
|
|
2753
2759
|
setTimeoutRequest;
|
|
2754
|
-
requesterAllStatistics = new G(
|
|
2760
|
+
requesterAllStatistics = new G(Qt);
|
|
2755
2761
|
constructor() {
|
|
2756
|
-
this.events = new U(
|
|
2762
|
+
this.events = new U(Ae), this.setTimeoutRequest = new ee();
|
|
2757
2763
|
}
|
|
2758
2764
|
get requested() {
|
|
2759
2765
|
return this.setTimeoutRequest.requested;
|
|
2760
2766
|
}
|
|
2761
2767
|
start(e, {
|
|
2762
|
-
interval: t =
|
|
2763
|
-
onError: s =
|
|
2768
|
+
interval: t = D,
|
|
2769
|
+
onError: s = Yt
|
|
2764
2770
|
} = {}) {
|
|
2765
2771
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
2766
2772
|
this.collectStatistics(e, {
|
|
@@ -2789,21 +2795,21 @@ class Yt {
|
|
|
2789
2795
|
collectStatistics = (e, {
|
|
2790
2796
|
onError: t
|
|
2791
2797
|
}) => {
|
|
2792
|
-
const s =
|
|
2793
|
-
this.requesterAllStatistics.request(e).then((
|
|
2794
|
-
this.events.trigger("collected",
|
|
2795
|
-
const a =
|
|
2796
|
-
let o =
|
|
2797
|
-
a > 48 ? o =
|
|
2798
|
+
const s = J();
|
|
2799
|
+
this.requesterAllStatistics.request(e).then((i) => {
|
|
2800
|
+
this.events.trigger("collected", Gt(i));
|
|
2801
|
+
const a = J() - s;
|
|
2802
|
+
let o = D;
|
|
2803
|
+
a > 48 ? o = D * 4 : a > 32 ? o = D * 3 : a > 16 && (o = D * 2), this.start(e, {
|
|
2798
2804
|
onError: t,
|
|
2799
2805
|
interval: o
|
|
2800
2806
|
});
|
|
2801
|
-
}).catch((
|
|
2802
|
-
t && t(
|
|
2807
|
+
}).catch((i) => {
|
|
2808
|
+
t && t(i);
|
|
2803
2809
|
});
|
|
2804
2810
|
};
|
|
2805
2811
|
}
|
|
2806
|
-
class
|
|
2812
|
+
class Xt {
|
|
2807
2813
|
availableIncomingBitrate;
|
|
2808
2814
|
statsPeerConnection;
|
|
2809
2815
|
callManager;
|
|
@@ -2813,7 +2819,7 @@ class zt {
|
|
|
2813
2819
|
callManager: e,
|
|
2814
2820
|
apiManager: t
|
|
2815
2821
|
}) {
|
|
2816
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
2822
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new zt(), this.subscribe();
|
|
2817
2823
|
}
|
|
2818
2824
|
get events() {
|
|
2819
2825
|
return this.statsPeerConnection.events;
|
|
@@ -2851,30 +2857,30 @@ class zt {
|
|
|
2851
2857
|
};
|
|
2852
2858
|
maybeSendStats() {
|
|
2853
2859
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
2854
|
-
|
|
2860
|
+
c("Failed to send stats", e);
|
|
2855
2861
|
});
|
|
2856
2862
|
}
|
|
2857
2863
|
}
|
|
2858
|
-
const
|
|
2859
|
-
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs,
|
|
2860
|
-
return
|
|
2861
|
-
},
|
|
2862
|
-
const
|
|
2864
|
+
const Jt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), Kt = (n) => {
|
|
2865
|
+
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
|
|
2866
|
+
return Jt(s, i);
|
|
2867
|
+
}, jt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
2868
|
+
const i = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), a = i === -1 ? Number.MAX_VALUE : i, o = r === -1 ? Number.MAX_VALUE : r;
|
|
2863
2869
|
return a - o;
|
|
2864
|
-
}),
|
|
2870
|
+
}), Zt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), en = (n, {
|
|
2865
2871
|
preferredMimeTypesVideoCodecs: e,
|
|
2866
2872
|
excludeMimeTypesVideoCodecs: t
|
|
2867
2873
|
}) => {
|
|
2868
2874
|
try {
|
|
2869
2875
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
2870
|
-
const s =
|
|
2871
|
-
n.setCodecPreferences(
|
|
2876
|
+
const s = Kt("video"), i = Zt(s, t), r = jt(i, e);
|
|
2877
|
+
n.setCodecPreferences(r);
|
|
2872
2878
|
}
|
|
2873
2879
|
} catch (s) {
|
|
2874
|
-
|
|
2880
|
+
c("setCodecPreferences error", s);
|
|
2875
2881
|
}
|
|
2876
2882
|
};
|
|
2877
|
-
class
|
|
2883
|
+
class tn {
|
|
2878
2884
|
/**
|
|
2879
2885
|
* Хранилище основных transceiver'ов
|
|
2880
2886
|
*/
|
|
@@ -2895,8 +2901,8 @@ class en {
|
|
|
2895
2901
|
if (s === "audio")
|
|
2896
2902
|
this.transceivers.mainAudio ??= e;
|
|
2897
2903
|
else {
|
|
2898
|
-
const { mid:
|
|
2899
|
-
|
|
2904
|
+
const { mid: i } = e;
|
|
2905
|
+
i === "2" ? this.transceivers.presentationVideo ??= e : this.transceivers.mainVideo ??= e;
|
|
2900
2906
|
}
|
|
2901
2907
|
}
|
|
2902
2908
|
/**
|
|
@@ -2953,10 +2959,10 @@ class en {
|
|
|
2953
2959
|
*/
|
|
2954
2960
|
handleRestart = (e) => {
|
|
2955
2961
|
this.updateTransceivers(e).catch((t) => {
|
|
2956
|
-
|
|
2962
|
+
c("Failed to update transceivers", t);
|
|
2957
2963
|
}).finally(() => {
|
|
2958
2964
|
this.callManager.restartIce().catch((t) => {
|
|
2959
|
-
|
|
2965
|
+
c("Failed to restart ICE", t);
|
|
2960
2966
|
});
|
|
2961
2967
|
});
|
|
2962
2968
|
};
|
|
@@ -2967,8 +2973,8 @@ class en {
|
|
|
2967
2973
|
const { videoTrackCount: t } = e;
|
|
2968
2974
|
t === 2 && (this.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
|
|
2969
2975
|
direction: "recvonly"
|
|
2970
|
-
}).catch((
|
|
2971
|
-
|
|
2976
|
+
}).catch((r) => {
|
|
2977
|
+
c("Failed to add presentation video transceiver", r);
|
|
2972
2978
|
}));
|
|
2973
2979
|
};
|
|
2974
2980
|
subscribe() {
|
|
@@ -2981,15 +2987,15 @@ class en {
|
|
|
2981
2987
|
this.clear();
|
|
2982
2988
|
};
|
|
2983
2989
|
}
|
|
2984
|
-
const
|
|
2985
|
-
class
|
|
2990
|
+
const nn = (n) => [...n.keys()].map((e) => n.get(e)), sn = (n, e) => nn(n).find((t) => t?.type === e), rn = async (n) => n.getStats().then((e) => sn(e, "codec")?.mimeType);
|
|
2991
|
+
class an {
|
|
2986
2992
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2987
2993
|
async getCodecFromSender(e) {
|
|
2988
|
-
return await
|
|
2994
|
+
return await rn(e) ?? "";
|
|
2989
2995
|
}
|
|
2990
2996
|
}
|
|
2991
|
-
class
|
|
2992
|
-
stackPromises =
|
|
2997
|
+
class on {
|
|
2998
|
+
stackPromises = ne({
|
|
2993
2999
|
noRunIsNotActual: !0
|
|
2994
3000
|
});
|
|
2995
3001
|
/**
|
|
@@ -3009,15 +3015,15 @@ class an {
|
|
|
3009
3015
|
*/
|
|
3010
3016
|
async run() {
|
|
3011
3017
|
return this.stackPromises().catch((e) => {
|
|
3012
|
-
|
|
3018
|
+
c("TaskQueue: error", e);
|
|
3013
3019
|
});
|
|
3014
3020
|
}
|
|
3015
3021
|
}
|
|
3016
|
-
class
|
|
3022
|
+
class cn {
|
|
3017
3023
|
taskQueue;
|
|
3018
3024
|
onSetParameters;
|
|
3019
3025
|
constructor(e) {
|
|
3020
|
-
this.onSetParameters = e, this.taskQueue = new
|
|
3026
|
+
this.onSetParameters = e, this.taskQueue = new on();
|
|
3021
3027
|
}
|
|
3022
3028
|
async setEncodingsToSender(e, t) {
|
|
3023
3029
|
return this.taskQueue.add(async () => he(e, t, this.onSetParameters));
|
|
@@ -3026,17 +3032,17 @@ class on {
|
|
|
3026
3032
|
this.taskQueue.stop();
|
|
3027
3033
|
}
|
|
3028
3034
|
}
|
|
3029
|
-
const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()),
|
|
3035
|
+
const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), dn = 1e6, f = (n) => n * dn, pe = f(0.06), Ie = f(4), hn = (n) => n <= 64 ? pe : n <= 128 ? f(0.12) : n <= 256 ? f(0.25) : n <= 384 ? f(0.32) : n <= 426 ? f(0.38) : n <= 640 ? f(0.5) : n <= 848 ? f(0.7) : n <= 1280 ? f(1) : n <= 1920 ? f(2) : Ie, ln = "av1", un = (n) => Ne(n, ln), gn = 0.6, Y = (n, e) => un(e) ? n * gn : n, Tn = (n) => Y(pe, n), Sn = (n) => Y(Ie, n), Z = (n, e) => {
|
|
3030
3036
|
const t = hn(n);
|
|
3031
3037
|
return Y(t, e);
|
|
3032
|
-
}, q = 1,
|
|
3038
|
+
}, q = 1, Cn = ({
|
|
3033
3039
|
videoTrack: n,
|
|
3034
3040
|
targetSize: e
|
|
3035
3041
|
}) => {
|
|
3036
|
-
const t = n.getSettings(), s = t.width,
|
|
3037
|
-
return Math.max(
|
|
3042
|
+
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? q : s / e.width, a = i === void 0 ? q : i / e.height;
|
|
3043
|
+
return Math.max(r, a, q);
|
|
3038
3044
|
};
|
|
3039
|
-
class
|
|
3045
|
+
class En {
|
|
3040
3046
|
ignoreForCodec;
|
|
3041
3047
|
senderFinder;
|
|
3042
3048
|
codecProvider;
|
|
@@ -3055,8 +3061,8 @@ class Cn {
|
|
|
3055
3061
|
senderFinder: e,
|
|
3056
3062
|
codecProvider: t,
|
|
3057
3063
|
parametersSetter: s
|
|
3058
|
-
},
|
|
3059
|
-
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec =
|
|
3064
|
+
}, i) {
|
|
3065
|
+
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec = i.ignoreForCodec;
|
|
3060
3066
|
}
|
|
3061
3067
|
/**
|
|
3062
3068
|
* Выполняет балансировку на основе заголовков от сервера
|
|
@@ -3065,21 +3071,21 @@ class Cn {
|
|
|
3065
3071
|
* @returns Promise с результатом балансировки
|
|
3066
3072
|
*/
|
|
3067
3073
|
async balance(e, t) {
|
|
3068
|
-
const s = e.getSenders(),
|
|
3069
|
-
if (!
|
|
3070
|
-
return { ...this.resultNoChanged, sender:
|
|
3071
|
-
const
|
|
3072
|
-
if (Ne(
|
|
3073
|
-
return { ...this.resultNoChanged, sender:
|
|
3074
|
+
const s = e.getSenders(), i = this.senderFinder.findVideoSender(s);
|
|
3075
|
+
if (!i?.track)
|
|
3076
|
+
return { ...this.resultNoChanged, sender: i };
|
|
3077
|
+
const r = await this.codecProvider.getCodecFromSender(i);
|
|
3078
|
+
if (Ne(r, this.ignoreForCodec))
|
|
3079
|
+
return { ...this.resultNoChanged, sender: i };
|
|
3074
3080
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
3075
3081
|
return this.processSender(
|
|
3076
3082
|
{ mainCam: a, resolutionMainCam: o },
|
|
3077
3083
|
{
|
|
3078
|
-
sender:
|
|
3079
|
-
codec:
|
|
3080
|
-
videoTrack:
|
|
3084
|
+
sender: i,
|
|
3085
|
+
codec: r,
|
|
3086
|
+
videoTrack: i.track
|
|
3081
3087
|
}
|
|
3082
|
-
).then((
|
|
3088
|
+
).then((d) => ({ ...d, sender: i }));
|
|
3083
3089
|
}
|
|
3084
3090
|
/**
|
|
3085
3091
|
* Обрабатывает отправитель в зависимости от команды управления
|
|
@@ -3087,14 +3093,14 @@ class Cn {
|
|
|
3087
3093
|
* @returns Promise с результатом обработки
|
|
3088
3094
|
*/
|
|
3089
3095
|
async processSender(e, t) {
|
|
3090
|
-
const { mainCam: s, resolutionMainCam:
|
|
3096
|
+
const { mainCam: s, resolutionMainCam: i } = e;
|
|
3091
3097
|
switch (s) {
|
|
3092
3098
|
case v.PAUSE_MAIN_CAM:
|
|
3093
3099
|
return this.downgradeResolutionSender(t);
|
|
3094
3100
|
case v.RESUME_MAIN_CAM:
|
|
3095
3101
|
return this.setBitrateByTrackResolution(t);
|
|
3096
3102
|
case v.MAX_MAIN_CAM_RESOLUTION:
|
|
3097
|
-
return
|
|
3103
|
+
return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
|
|
3098
3104
|
case v.ADMIN_STOP_MAIN_CAM:
|
|
3099
3105
|
case v.ADMIN_START_MAIN_CAM:
|
|
3100
3106
|
case void 0:
|
|
@@ -3109,11 +3115,11 @@ class Cn {
|
|
|
3109
3115
|
* @returns Promise с результатом
|
|
3110
3116
|
*/
|
|
3111
3117
|
async downgradeResolutionSender(e) {
|
|
3112
|
-
const { sender: t, codec: s } = e,
|
|
3118
|
+
const { sender: t, codec: s } = e, i = {
|
|
3113
3119
|
scaleResolutionDownBy: 200,
|
|
3114
|
-
maxBitrate:
|
|
3120
|
+
maxBitrate: Tn(s)
|
|
3115
3121
|
};
|
|
3116
|
-
return this.parametersSetter.setEncodingsToSender(t,
|
|
3122
|
+
return this.parametersSetter.setEncodingsToSender(t, i);
|
|
3117
3123
|
}
|
|
3118
3124
|
/**
|
|
3119
3125
|
* Устанавливает битрейт на основе разрешения трека
|
|
@@ -3121,7 +3127,7 @@ class Cn {
|
|
|
3121
3127
|
* @returns Promise с результатом
|
|
3122
3128
|
*/
|
|
3123
3129
|
async setBitrateByTrackResolution(e) {
|
|
3124
|
-
const { sender: t, videoTrack: s, codec:
|
|
3130
|
+
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Sn(i) : Z(a, i);
|
|
3125
3131
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
3126
3132
|
scaleResolutionDownBy: 1,
|
|
3127
3133
|
maxBitrate: o
|
|
@@ -3134,24 +3140,24 @@ class Cn {
|
|
|
3134
3140
|
* @returns Promise с результатом
|
|
3135
3141
|
*/
|
|
3136
3142
|
async setResolutionSender(e, t) {
|
|
3137
|
-
const [s,
|
|
3143
|
+
const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, d = {
|
|
3138
3144
|
width: Number(s),
|
|
3139
|
-
height: Number(
|
|
3140
|
-
},
|
|
3145
|
+
height: Number(i)
|
|
3146
|
+
}, h = Cn({
|
|
3141
3147
|
videoTrack: a,
|
|
3142
|
-
targetSize:
|
|
3143
|
-
}), T =
|
|
3144
|
-
scaleResolutionDownBy:
|
|
3148
|
+
targetSize: d
|
|
3149
|
+
}), T = Z(d.width, o), S = {
|
|
3150
|
+
scaleResolutionDownBy: h,
|
|
3145
3151
|
maxBitrate: T
|
|
3146
3152
|
};
|
|
3147
|
-
return this.parametersSetter.setEncodingsToSender(
|
|
3153
|
+
return this.parametersSetter.setEncodingsToSender(r, S);
|
|
3148
3154
|
}
|
|
3149
3155
|
}
|
|
3150
|
-
const
|
|
3151
|
-
class
|
|
3156
|
+
const An = (n) => n.find((e) => e.track?.kind === "video");
|
|
3157
|
+
class Rn {
|
|
3152
3158
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
3153
3159
|
findVideoSender(e) {
|
|
3154
|
-
return
|
|
3160
|
+
return An(e);
|
|
3155
3161
|
}
|
|
3156
3162
|
}
|
|
3157
3163
|
class Nn {
|
|
@@ -3167,7 +3173,7 @@ class Nn {
|
|
|
3167
3173
|
pollIntervalMs: e = 1e3,
|
|
3168
3174
|
maxPollIntervalMs: t
|
|
3169
3175
|
}) {
|
|
3170
|
-
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new
|
|
3176
|
+
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ee();
|
|
3171
3177
|
}
|
|
3172
3178
|
/**
|
|
3173
3179
|
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
@@ -3186,8 +3192,8 @@ class Nn {
|
|
|
3186
3192
|
attachSender(e, t) {
|
|
3187
3193
|
this.currentSender = e;
|
|
3188
3194
|
const s = e.replaceTrack.bind(e);
|
|
3189
|
-
this.originalReplaceTrack = s, e.replaceTrack = async (
|
|
3190
|
-
await s(
|
|
3195
|
+
this.originalReplaceTrack = s, e.replaceTrack = async (i) => {
|
|
3196
|
+
await s(i), this.attachTrack(t, i ?? void 0), t();
|
|
3191
3197
|
}, this.attachTrack(t, e.track);
|
|
3192
3198
|
}
|
|
3193
3199
|
detachSender() {
|
|
@@ -3196,8 +3202,8 @@ class Nn {
|
|
|
3196
3202
|
attachTrack(e, t) {
|
|
3197
3203
|
if (this.detachTrack(), !t)
|
|
3198
3204
|
return;
|
|
3199
|
-
const { width: s, height:
|
|
3200
|
-
this.lastWidth = s, this.lastHeight =
|
|
3205
|
+
const { width: s, height: i } = t.getSettings();
|
|
3206
|
+
this.lastWidth = s, this.lastHeight = i, this.currentPollIntervalMs = this.pollIntervalMs, this.schedulePoll(t, e);
|
|
3201
3207
|
}
|
|
3202
3208
|
/**
|
|
3203
3209
|
* Периодически опрашивает track с экспоненциальной адаптацией частоты.
|
|
@@ -3206,8 +3212,8 @@ class Nn {
|
|
|
3206
3212
|
*/
|
|
3207
3213
|
schedulePoll(e, t) {
|
|
3208
3214
|
const s = () => {
|
|
3209
|
-
const { width:
|
|
3210
|
-
|
|
3215
|
+
const { width: i, height: r } = e.getSettings();
|
|
3216
|
+
i !== this.lastWidth || r !== this.lastHeight ? (this.lastWidth = i, this.lastHeight = r, this.currentPollIntervalMs = this.pollIntervalMs, t()) : this.currentPollIntervalMs = Math.min(
|
|
3211
3217
|
this.currentPollIntervalMs * 2,
|
|
3212
3218
|
this.maxPollIntervalMs
|
|
3213
3219
|
), this.setTimeoutRequest.request(s, this.currentPollIntervalMs);
|
|
@@ -3218,7 +3224,7 @@ class Nn {
|
|
|
3218
3224
|
this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
|
|
3219
3225
|
}
|
|
3220
3226
|
}
|
|
3221
|
-
class
|
|
3227
|
+
class pn {
|
|
3222
3228
|
apiManager;
|
|
3223
3229
|
currentHandler;
|
|
3224
3230
|
constructor(e) {
|
|
@@ -3247,19 +3253,19 @@ class In {
|
|
|
3247
3253
|
trackMonitor;
|
|
3248
3254
|
constructor(e, t, {
|
|
3249
3255
|
ignoreForCodec: s,
|
|
3250
|
-
onSetParameters:
|
|
3251
|
-
pollIntervalMs:
|
|
3256
|
+
onSetParameters: i,
|
|
3257
|
+
pollIntervalMs: r
|
|
3252
3258
|
} = {}) {
|
|
3253
|
-
this.getConnection = t, this.eventHandler = new
|
|
3259
|
+
this.getConnection = t, this.eventHandler = new pn(e), this.parametersSetterWithQueue = new cn(i), this.senderBalancer = new En(
|
|
3254
3260
|
{
|
|
3255
|
-
senderFinder: new
|
|
3256
|
-
codecProvider: new
|
|
3261
|
+
senderFinder: new Rn(),
|
|
3262
|
+
codecProvider: new an(),
|
|
3257
3263
|
parametersSetter: this.parametersSetterWithQueue
|
|
3258
3264
|
},
|
|
3259
3265
|
{
|
|
3260
3266
|
ignoreForCodec: s
|
|
3261
3267
|
}
|
|
3262
|
-
), this.trackMonitor = new Nn({ pollIntervalMs:
|
|
3268
|
+
), this.trackMonitor = new Nn({ pollIntervalMs: r });
|
|
3263
3269
|
}
|
|
3264
3270
|
/**
|
|
3265
3271
|
* Подписывается на события управления главной камерой
|
|
@@ -3290,7 +3296,7 @@ class In {
|
|
|
3290
3296
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
3291
3297
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
3292
3298
|
this.balance().catch((s) => {
|
|
3293
|
-
|
|
3299
|
+
c("balance on track change: error", s);
|
|
3294
3300
|
});
|
|
3295
3301
|
}), t;
|
|
3296
3302
|
}
|
|
@@ -3300,17 +3306,17 @@ class In {
|
|
|
3300
3306
|
*/
|
|
3301
3307
|
handleMainCamControl = (e) => {
|
|
3302
3308
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
3303
|
-
|
|
3309
|
+
c("handleMainCamControl: error", t);
|
|
3304
3310
|
});
|
|
3305
3311
|
};
|
|
3306
3312
|
}
|
|
3307
|
-
const
|
|
3313
|
+
const me = [
|
|
3308
3314
|
"balancing-scheduled",
|
|
3309
3315
|
"balancing-started",
|
|
3310
3316
|
"balancing-stopped",
|
|
3311
3317
|
"parameters-updated"
|
|
3312
3318
|
];
|
|
3313
|
-
class
|
|
3319
|
+
class mn {
|
|
3314
3320
|
isBalancingActive = !1;
|
|
3315
3321
|
events;
|
|
3316
3322
|
callManager;
|
|
@@ -3318,13 +3324,13 @@ class pn {
|
|
|
3318
3324
|
videoSendingBalancer;
|
|
3319
3325
|
startBalancingTimer;
|
|
3320
3326
|
constructor(e, t, s = {}) {
|
|
3321
|
-
this.events = new U(
|
|
3327
|
+
this.events = new U(me), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new In(
|
|
3322
3328
|
t,
|
|
3323
3329
|
() => e.connection,
|
|
3324
3330
|
{
|
|
3325
3331
|
...s,
|
|
3326
|
-
onSetParameters: (
|
|
3327
|
-
this.events.trigger("parameters-updated",
|
|
3332
|
+
onSetParameters: (i) => {
|
|
3333
|
+
this.events.trigger("parameters-updated", i), s.onSetParameters?.(i);
|
|
3328
3334
|
}
|
|
3329
3335
|
}
|
|
3330
3336
|
), this.subscribe();
|
|
@@ -3380,7 +3386,7 @@ class pn {
|
|
|
3380
3386
|
scheduleBalancingStart() {
|
|
3381
3387
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
3382
3388
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
3383
|
-
|
|
3389
|
+
c("startBalancing: error", e);
|
|
3384
3390
|
});
|
|
3385
3391
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
3386
3392
|
}
|
|
@@ -3388,17 +3394,17 @@ class pn {
|
|
|
3388
3394
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
3389
3395
|
}
|
|
3390
3396
|
}
|
|
3391
|
-
const
|
|
3392
|
-
..._n,
|
|
3397
|
+
const _n = 1e6, Mn = Ce.map((n) => `auto-connect:${n}`), fn = ge.map((n) => `connection:${n}`), vn = re.map((n) => `call:${n}`), Pn = se.map((n) => `api:${n}`), On = Ee.map((n) => `incoming-call:${n}`), yn = le.map((n) => `presentation:${n}`), bn = Ae.map((n) => `stats:${n}`), Dn = me.map((n) => `video-balancer:${n}`), wn = [
|
|
3393
3398
|
...Mn,
|
|
3394
3399
|
...fn,
|
|
3395
3400
|
...vn,
|
|
3396
3401
|
...Pn,
|
|
3397
3402
|
...On,
|
|
3398
3403
|
...yn,
|
|
3404
|
+
...bn,
|
|
3399
3405
|
...Dn
|
|
3400
3406
|
];
|
|
3401
|
-
class
|
|
3407
|
+
class Qn {
|
|
3402
3408
|
events;
|
|
3403
3409
|
connectionManager;
|
|
3404
3410
|
connectionQueueManager;
|
|
@@ -3415,34 +3421,34 @@ class Gn {
|
|
|
3415
3421
|
constructor({ JsSIP: e }, {
|
|
3416
3422
|
preferredMimeTypesVideoCodecs: t,
|
|
3417
3423
|
excludeMimeTypesVideoCodecs: s,
|
|
3418
|
-
videoBalancerOptions:
|
|
3419
|
-
autoConnectorOptions:
|
|
3424
|
+
videoBalancerOptions: i,
|
|
3425
|
+
autoConnectorOptions: r
|
|
3420
3426
|
} = {}) {
|
|
3421
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new k(
|
|
3427
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new k(wn), this.connectionManager = new mt({ JsSIP: e }), this.connectionQueueManager = new _t({
|
|
3422
3428
|
connectionManager: this.connectionManager
|
|
3423
|
-
}), this.callManager = new
|
|
3429
|
+
}), this.callManager = new Xe(), this.apiManager = new ke({
|
|
3424
3430
|
connectionManager: this.connectionManager,
|
|
3425
3431
|
callManager: this.callManager
|
|
3426
|
-
}), this.incomingCallManager = new
|
|
3432
|
+
}), this.incomingCallManager = new qt(this.connectionManager), this.presentationManager = new ht({
|
|
3427
3433
|
callManager: this.callManager,
|
|
3428
|
-
maxBitrate:
|
|
3429
|
-
}), this.statsManager = new
|
|
3434
|
+
maxBitrate: _n
|
|
3435
|
+
}), this.statsManager = new Xt({
|
|
3430
3436
|
callManager: this.callManager,
|
|
3431
3437
|
apiManager: this.apiManager
|
|
3432
|
-
}), this.autoConnectorManager = new
|
|
3438
|
+
}), this.autoConnectorManager = new Ft(
|
|
3433
3439
|
{
|
|
3434
3440
|
connectionQueueManager: this.connectionQueueManager,
|
|
3435
3441
|
connectionManager: this.connectionManager,
|
|
3436
3442
|
callManager: this.callManager
|
|
3437
3443
|
},
|
|
3438
|
-
|
|
3439
|
-
), this.transceiverManager = new
|
|
3444
|
+
r
|
|
3445
|
+
), this.transceiverManager = new tn({
|
|
3440
3446
|
callManager: this.callManager,
|
|
3441
3447
|
apiManager: this.apiManager
|
|
3442
|
-
}), this.videoSendingBalancerManager = new
|
|
3448
|
+
}), this.videoSendingBalancerManager = new mn(
|
|
3443
3449
|
this.callManager,
|
|
3444
3450
|
this.apiManager,
|
|
3445
|
-
|
|
3451
|
+
i
|
|
3446
3452
|
), this.subscribe();
|
|
3447
3453
|
}
|
|
3448
3454
|
get requestedConnection() {
|
|
@@ -3549,7 +3555,7 @@ class Gn {
|
|
|
3549
3555
|
getRemoteStreams = () => this.callManager.getRemoteStreams();
|
|
3550
3556
|
replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
|
|
3551
3557
|
async startPresentation(e, t = {}) {
|
|
3552
|
-
const { isP2P: s, callLimit:
|
|
3558
|
+
const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...a } = t;
|
|
3553
3559
|
return this.presentationManager.startPresentation(
|
|
3554
3560
|
async () => {
|
|
3555
3561
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
@@ -3557,9 +3563,9 @@ class Gn {
|
|
|
3557
3563
|
e,
|
|
3558
3564
|
{
|
|
3559
3565
|
...a,
|
|
3560
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
3566
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(r)
|
|
3561
3567
|
},
|
|
3562
|
-
|
|
3568
|
+
i === void 0 ? void 0 : { callLimit: i }
|
|
3563
3569
|
);
|
|
3564
3570
|
}
|
|
3565
3571
|
async stopPresentation(e = {}) {
|
|
@@ -3569,15 +3575,15 @@ class Gn {
|
|
|
3569
3575
|
});
|
|
3570
3576
|
}
|
|
3571
3577
|
async updatePresentation(e, t = {}) {
|
|
3572
|
-
const { isP2P: s, onAddedTransceiver:
|
|
3578
|
+
const { isP2P: s, onAddedTransceiver: i, ...r } = t;
|
|
3573
3579
|
return this.presentationManager.updatePresentation(
|
|
3574
3580
|
async () => {
|
|
3575
3581
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
3576
3582
|
},
|
|
3577
3583
|
e,
|
|
3578
3584
|
{
|
|
3579
|
-
...
|
|
3580
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
3585
|
+
...r,
|
|
3586
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(i)
|
|
3581
3587
|
}
|
|
3582
3588
|
);
|
|
3583
3589
|
}
|
|
@@ -3624,7 +3630,7 @@ class Gn {
|
|
|
3624
3630
|
return this.apiManager.askPermissionToEnableCam(...e);
|
|
3625
3631
|
}
|
|
3626
3632
|
setCodecPreferences(e) {
|
|
3627
|
-
|
|
3633
|
+
en(e, {
|
|
3628
3634
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
3629
3635
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
3630
3636
|
});
|
|
@@ -3633,30 +3639,30 @@ class Gn {
|
|
|
3633
3639
|
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);
|
|
3634
3640
|
}
|
|
3635
3641
|
bridgeEvents = (e, t) => {
|
|
3636
|
-
t.events.eachTriggers((s,
|
|
3637
|
-
t.on(
|
|
3638
|
-
this.events.trigger(`${e}:${
|
|
3642
|
+
t.events.eachTriggers((s, i) => {
|
|
3643
|
+
t.on(i, (r) => {
|
|
3644
|
+
this.events.trigger(`${e}:${i}`, r);
|
|
3639
3645
|
});
|
|
3640
3646
|
});
|
|
3641
3647
|
};
|
|
3642
|
-
resolveHandleAddTransceiver = (e) => async (t, s,
|
|
3643
|
-
this.setCodecPreferences(t), await e?.(t, s,
|
|
3648
|
+
resolveHandleAddTransceiver = (e) => async (t, s, i) => {
|
|
3649
|
+
this.setCodecPreferences(t), await e?.(t, s, i);
|
|
3644
3650
|
};
|
|
3645
3651
|
}
|
|
3646
3652
|
export {
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3653
|
+
oe as E,
|
|
3654
|
+
$e as O,
|
|
3655
|
+
Qn as S,
|
|
3656
|
+
at as a,
|
|
3657
|
+
Fe as b,
|
|
3658
|
+
Gn as c,
|
|
3659
|
+
xn as d,
|
|
3654
3660
|
Wn as e,
|
|
3655
3661
|
A as f,
|
|
3656
|
-
|
|
3662
|
+
zt as g,
|
|
3657
3663
|
Nt as h,
|
|
3658
|
-
|
|
3659
|
-
|
|
3664
|
+
rn as i,
|
|
3665
|
+
c as l,
|
|
3660
3666
|
F as p,
|
|
3661
3667
|
he as s
|
|
3662
3668
|
};
|