sip-connector 19.9.0 → 19.9.2
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-OcfQjQBi.cjs +1 -0
- package/dist/{@SipConnector-BpypVXj0.js → @SipConnector-YrnmsDaG.js} +415 -358
- package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +3 -0
- package/dist/AutoConnectorManager/NotActiveCallSubscriber.d.ts +15 -0
- package/dist/AutoConnectorManager/PingServerIfNotActiveCallRequester.d.ts +1 -3
- package/dist/AutoConnectorManager/RegistrationFailedOutOfCallSubscriber.d.ts +1 -1
- package/dist/SipConnector/@SipConnector.d.ts +2 -0
- package/dist/SipConnector/eventNames.d.ts +7 -2
- 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-CR3DyIpB.cjs +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { TypedEvents as O } from "events-constructor";
|
|
2
2
|
import H from "debug";
|
|
3
|
-
import { CancelableRequest as x, isCanceledError as
|
|
4
|
-
import { resolveRequesterByTimeout as
|
|
5
|
-
import { hasCanceledError as
|
|
6
|
-
import { setup as
|
|
7
|
-
import { createStackPromises as
|
|
3
|
+
import { CancelableRequest as x, 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 be, createActor as De } from "xstate";
|
|
7
|
+
import { createStackPromises as ne, isPromiseIsNotActualError as ye } from "stack-promises";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
const G = "sip-connector",
|
|
10
|
+
const G = "sip-connector", c = H(G), Vn = () => {
|
|
11
11
|
H.enable(G);
|
|
12
|
-
},
|
|
12
|
+
}, Hn = () => {
|
|
13
13
|
H.enable(`-${G}`);
|
|
14
|
-
},
|
|
15
|
-
var u = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(u || {}), L = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(L || {}), q = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(q || {}),
|
|
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 u = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(u || {}), L = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(L || {}), q = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(q || {}), b = /* @__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))(b || {}), 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))(p || {}), 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 || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(W || {}), V = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(V || {}), 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_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n))(g || {});
|
|
16
|
+
const se = [
|
|
17
17
|
"participation:accepting-word-request",
|
|
18
18
|
"participation:cancelling-word-request",
|
|
19
19
|
"participant:move-request-to-stream",
|
|
@@ -44,7 +44,7 @@ const ne = [
|
|
|
44
44
|
"newDTMF"
|
|
45
45
|
];
|
|
46
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
|
|
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 O(
|
|
55
|
+
this.connectionManager = e, this.callManager = t, this.events = new O(se), this.subscribe();
|
|
56
56
|
}
|
|
57
57
|
async waitChannels() {
|
|
58
58
|
return this.wait(g.CHANNELS);
|
|
@@ -84,7 +84,7 @@ class Fe {
|
|
|
84
84
|
return s.sendInfo(p.CHANNELS, void 0, { extraHeaders: a });
|
|
85
85
|
}
|
|
86
86
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
87
|
-
const i = this.getEstablishedRTCSessionProtected(), r = `${u.MEDIA_STATE}: currentstate`, a = `${u.MAIN_CAM_STATE}: ${Number(e)}`, o = `${u.MIC_STATE}: ${Number(t)}`,
|
|
87
|
+
const i = this.getEstablishedRTCSessionProtected(), r = `${u.MEDIA_STATE}: currentstate`, a = `${u.MAIN_CAM_STATE}: ${Number(e)}`, o = `${u.MIC_STATE}: ${Number(t)}`, h = [
|
|
88
88
|
r,
|
|
89
89
|
a,
|
|
90
90
|
o
|
|
@@ -92,7 +92,7 @@ class Fe {
|
|
|
92
92
|
return i.sendInfo(p.MEDIA_STATE, void 0, {
|
|
93
93
|
noTerminateWhenError: !0,
|
|
94
94
|
...s,
|
|
95
|
-
extraHeaders:
|
|
95
|
+
extraHeaders: h
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
async sendStats({
|
|
@@ -105,11 +105,11 @@ class Fe {
|
|
|
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, h = [`${u.MEDIA_TYPE}: ${a}`];
|
|
109
109
|
return s.sendInfo(p.REFUSAL, void 0, {
|
|
110
110
|
noTerminateWhenError: !0,
|
|
111
111
|
...t,
|
|
112
|
-
extraHeaders:
|
|
112
|
+
extraHeaders: h
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
async sendRefusalToTurnOnMic(e = {}) {
|
|
@@ -150,7 +150,7 @@ class Fe {
|
|
|
150
150
|
...e,
|
|
151
151
|
extraHeaders: s
|
|
152
152
|
}).catch((i) => {
|
|
153
|
-
if (
|
|
153
|
+
if (Be(i))
|
|
154
154
|
throw i;
|
|
155
155
|
});
|
|
156
156
|
}
|
|
@@ -191,7 +191,7 @@ class Fe {
|
|
|
191
191
|
this.handleNotify(s);
|
|
192
192
|
}
|
|
193
193
|
} catch (t) {
|
|
194
|
-
|
|
194
|
+
c("error parse notify", t);
|
|
195
195
|
}
|
|
196
196
|
};
|
|
197
197
|
handleNotify = (e) => {
|
|
@@ -250,7 +250,7 @@ class Fe {
|
|
|
250
250
|
break;
|
|
251
251
|
}
|
|
252
252
|
default:
|
|
253
|
-
|
|
253
|
+
c("unknown cmd", e);
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
256
|
handleNewInfo = (e) => {
|
|
@@ -260,31 +260,31 @@ class Fe {
|
|
|
260
260
|
const { request: s } = e, i = s, r = i.getHeader(u.CONTENT_TYPE);
|
|
261
261
|
if (r !== void 0)
|
|
262
262
|
switch (r) {
|
|
263
|
-
case
|
|
263
|
+
case b.ENTER_ROOM: {
|
|
264
264
|
this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
|
|
265
265
|
break;
|
|
266
266
|
}
|
|
267
|
-
case
|
|
267
|
+
case b.NOTIFY: {
|
|
268
268
|
this.maybeHandleNotify(i);
|
|
269
269
|
break;
|
|
270
270
|
}
|
|
271
|
-
case
|
|
271
|
+
case b.SHARE_STATE: {
|
|
272
272
|
this.triggerShareState(i);
|
|
273
273
|
break;
|
|
274
274
|
}
|
|
275
|
-
case
|
|
275
|
+
case b.MAIN_CAM: {
|
|
276
276
|
this.triggerMainCamControl(i);
|
|
277
277
|
break;
|
|
278
278
|
}
|
|
279
|
-
case
|
|
279
|
+
case b.MIC: {
|
|
280
280
|
this.triggerMicControl(i);
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
|
-
case
|
|
283
|
+
case b.USE_LICENSE: {
|
|
284
284
|
this.triggerUseLicense(i);
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
|
-
case
|
|
287
|
+
case b.PARTICIPANT_STATE: {
|
|
288
288
|
this.maybeTriggerParticipantMoveRequest(i);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
@@ -420,15 +420,15 @@ class Fe {
|
|
|
420
420
|
};
|
|
421
421
|
triggerMainCamControl = (e) => {
|
|
422
422
|
const t = e.getHeader(u.MAIN_CAM), s = e.getHeader(u.MEDIA_SYNC), i = s === V.ADMIN_SYNC_FORCED;
|
|
423
|
-
if (t ===
|
|
423
|
+
if (t === v.ADMIN_START_MAIN_CAM) {
|
|
424
424
|
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
|
|
425
425
|
return;
|
|
426
426
|
}
|
|
427
|
-
if (t ===
|
|
427
|
+
if (t === v.ADMIN_STOP_MAIN_CAM) {
|
|
428
428
|
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
|
|
429
429
|
return;
|
|
430
430
|
}
|
|
431
|
-
(t ===
|
|
431
|
+
(t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
|
|
432
432
|
const r = e.getHeader(u.MAIN_CAM_RESOLUTION);
|
|
433
433
|
this.events.trigger(g.MAIN_CAM_CONTROL, {
|
|
434
434
|
mainCam: t,
|
|
@@ -444,15 +444,15 @@ class Fe {
|
|
|
444
444
|
this.events.trigger(g.USE_LICENSE, t);
|
|
445
445
|
};
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function $e(n) {
|
|
448
448
|
return (e) => `sip:${e}@${n}`;
|
|
449
449
|
}
|
|
450
|
-
const
|
|
450
|
+
const qe = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, ie = (n) => n.trim().replaceAll(" ", "_"), We = qe(1e5, 99999999), Ve = (n) => n.some((t) => {
|
|
451
451
|
const { kind: s } = t;
|
|
452
452
|
return s === "video";
|
|
453
453
|
});
|
|
454
|
-
var N = /* @__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))(N || {}),
|
|
455
|
-
const
|
|
454
|
+
var N = /* @__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))(N || {}), He = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(He || {});
|
|
455
|
+
const re = [
|
|
456
456
|
"peerconnection",
|
|
457
457
|
"connecting",
|
|
458
458
|
"sending",
|
|
@@ -479,15 +479,15 @@ const ie = [
|
|
|
479
479
|
"peerconnection:createanswerfailed",
|
|
480
480
|
"peerconnection:setlocaldescriptionfailed",
|
|
481
481
|
"peerconnection:setremotedescriptionfailed"
|
|
482
|
-
],
|
|
482
|
+
], xe = [
|
|
483
483
|
"peerconnection:confirmed",
|
|
484
484
|
"peerconnection:ontrack",
|
|
485
485
|
"ended:fromserver",
|
|
486
486
|
"call-status-changed"
|
|
487
|
-
],
|
|
488
|
-
...
|
|
489
|
-
...
|
|
490
|
-
],
|
|
487
|
+
], ae = [
|
|
488
|
+
...re,
|
|
489
|
+
...xe
|
|
490
|
+
], Ge = (n, e) => {
|
|
491
491
|
n.getVideoTracks().forEach((s) => {
|
|
492
492
|
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
493
493
|
});
|
|
@@ -499,10 +499,10 @@ const ie = [
|
|
|
499
499
|
if (!n || e === "recvonly" && t === "recvonly")
|
|
500
500
|
return;
|
|
501
501
|
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
|
|
502
|
-
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" &&
|
|
502
|
+
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Ge(o, s), o;
|
|
503
503
|
};
|
|
504
|
-
var
|
|
505
|
-
class
|
|
504
|
+
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 || {});
|
|
505
|
+
class Qe {
|
|
506
506
|
events;
|
|
507
507
|
rtcSession;
|
|
508
508
|
disposers = /* @__PURE__ */ new Set();
|
|
@@ -523,7 +523,7 @@ class Ge {
|
|
|
523
523
|
extraHeaders: r = [],
|
|
524
524
|
ontrack: a,
|
|
525
525
|
iceServers: o,
|
|
526
|
-
directionVideo:
|
|
526
|
+
directionVideo: h,
|
|
527
527
|
directionAudio: d,
|
|
528
528
|
contentHint: T,
|
|
529
529
|
offerToReceiveAudio: S = !0,
|
|
@@ -536,7 +536,7 @@ class Ge {
|
|
|
536
536
|
F(k);
|
|
537
537
|
}), this.rtcSession = e.call(t(s), {
|
|
538
538
|
mediaStream: B(i, {
|
|
539
|
-
directionVideo:
|
|
539
|
+
directionVideo: h,
|
|
540
540
|
directionAudio: d,
|
|
541
541
|
contentHint: T
|
|
542
542
|
}),
|
|
@@ -552,7 +552,7 @@ class Ge {
|
|
|
552
552
|
// и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
|
|
553
553
|
eventHandlers: this.events.triggers,
|
|
554
554
|
extraHeaders: r,
|
|
555
|
-
directionVideo:
|
|
555
|
+
directionVideo: h,
|
|
556
556
|
directionAudio: d,
|
|
557
557
|
degradationPreference: E,
|
|
558
558
|
sendEncodings: m,
|
|
@@ -563,7 +563,7 @@ class Ge {
|
|
|
563
563
|
const { rtcSession: e } = this;
|
|
564
564
|
if (e && !e.isEnded())
|
|
565
565
|
return e.terminateAsync({
|
|
566
|
-
cause:
|
|
566
|
+
cause: oe.CANCELED
|
|
567
567
|
}).finally(() => {
|
|
568
568
|
this.reset();
|
|
569
569
|
});
|
|
@@ -576,7 +576,7 @@ class Ge {
|
|
|
576
576
|
iceServers: r,
|
|
577
577
|
directionVideo: a,
|
|
578
578
|
directionAudio: o,
|
|
579
|
-
offerToReceiveAudio:
|
|
579
|
+
offerToReceiveAudio: h,
|
|
580
580
|
offerToReceiveVideo: d,
|
|
581
581
|
contentHint: T,
|
|
582
582
|
degradationPreference: S,
|
|
@@ -591,7 +591,7 @@ class Ge {
|
|
|
591
591
|
iceServers: r
|
|
592
592
|
},
|
|
593
593
|
rtcOfferConstraints: {
|
|
594
|
-
offerToReceiveAudio:
|
|
594
|
+
offerToReceiveAudio: h,
|
|
595
595
|
offerToReceiveVideo: d
|
|
596
596
|
},
|
|
597
597
|
mediaStream: B(t, {
|
|
@@ -634,10 +634,10 @@ class Ge {
|
|
|
634
634
|
}, r = () => {
|
|
635
635
|
this.events.off(N.PEER_CONNECTION, T), this.events.off(N.CONFIRMED, S);
|
|
636
636
|
}, a = () => {
|
|
637
|
-
this.events.on(N.FAILED,
|
|
637
|
+
this.events.on(N.FAILED, h), this.events.on(N.ENDED, h);
|
|
638
638
|
}, o = () => {
|
|
639
|
-
this.events.off(N.FAILED,
|
|
640
|
-
},
|
|
639
|
+
this.events.off(N.FAILED, h), this.events.off(N.ENDED, h);
|
|
640
|
+
}, h = (l) => {
|
|
641
641
|
r(), o(), s(l);
|
|
642
642
|
};
|
|
643
643
|
let d;
|
|
@@ -656,7 +656,7 @@ class Ge {
|
|
|
656
656
|
});
|
|
657
657
|
subscribeToSessionEvents(e) {
|
|
658
658
|
this.events.eachTriggers((t, s) => {
|
|
659
|
-
const i =
|
|
659
|
+
const i = re.find((r) => r === s);
|
|
660
660
|
i && (e.on(i, t), this.disposers.add(() => {
|
|
661
661
|
e.off(i, t);
|
|
662
662
|
}));
|
|
@@ -675,7 +675,7 @@ class Ge {
|
|
|
675
675
|
delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
|
|
676
676
|
};
|
|
677
677
|
}
|
|
678
|
-
class
|
|
678
|
+
class Ye {
|
|
679
679
|
remoteStreams = {};
|
|
680
680
|
reset() {
|
|
681
681
|
this.remoteStreams = {};
|
|
@@ -696,25 +696,25 @@ class Qe {
|
|
|
696
696
|
const r = s, a = e[i - 1];
|
|
697
697
|
let o;
|
|
698
698
|
a?.kind === "audio" && (o = a);
|
|
699
|
-
const
|
|
700
|
-
t.push(
|
|
699
|
+
const h = this.generateStream(r, o);
|
|
700
|
+
t.push(h);
|
|
701
701
|
}), t;
|
|
702
702
|
}
|
|
703
703
|
generateAudioStreams(e) {
|
|
704
704
|
return e.map((t) => this.generateAudioStream(t));
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
|
-
class
|
|
707
|
+
class ze {
|
|
708
708
|
events;
|
|
709
709
|
isPendingCall = !1;
|
|
710
710
|
isPendingAnswer = !1;
|
|
711
711
|
rtcSession;
|
|
712
712
|
remoteStreams = {};
|
|
713
713
|
callConfiguration = {};
|
|
714
|
-
remoteStreamsManager = new
|
|
714
|
+
remoteStreamsManager = new Ye();
|
|
715
715
|
mcuSession;
|
|
716
716
|
constructor() {
|
|
717
|
-
this.events = new O(
|
|
717
|
+
this.events = new O(ae), this.mcuSession = new Qe(this.events, { onReset: this.reset }), this.subscribeCallStatusChange();
|
|
718
718
|
}
|
|
719
719
|
get requested() {
|
|
720
720
|
return this.isPendingCall || this.isPendingAnswer;
|
|
@@ -763,7 +763,7 @@ class Ye {
|
|
|
763
763
|
getRemoteStreams() {
|
|
764
764
|
const e = this.mcuSession.getRemoteTracks();
|
|
765
765
|
if (e)
|
|
766
|
-
return
|
|
766
|
+
return Ve(e) ? this.remoteStreamsManager.generateStreams(e) : this.remoteStreamsManager.generateAudioStreams(e);
|
|
767
767
|
}
|
|
768
768
|
async replaceMediaStream(e, t) {
|
|
769
769
|
return this.mcuSession.replaceMediaStream(e, t);
|
|
@@ -786,39 +786,39 @@ class Ye {
|
|
|
786
786
|
return t !== e && this.events.trigger(N.CALL_STATUS_CHANGED, { isCallActive: t }), t;
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
|
-
const
|
|
789
|
+
const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je = (n, e) => {
|
|
790
790
|
n.encodings ??= [];
|
|
791
791
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
792
792
|
n.encodings.push({});
|
|
793
793
|
return n;
|
|
794
|
-
},
|
|
795
|
-
if (
|
|
794
|
+
}, ce = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Ke = ce(), je = (n, e) => {
|
|
795
|
+
if (Ke(n, e))
|
|
796
796
|
return n;
|
|
797
|
-
},
|
|
798
|
-
const t = n.maxBitrate, s =
|
|
797
|
+
}, Ze = (n, e) => {
|
|
798
|
+
const t = n.maxBitrate, s = je(e, t);
|
|
799
799
|
return s !== void 0 && (n.maxBitrate = s), n;
|
|
800
|
-
},
|
|
801
|
-
|
|
802
|
-
),
|
|
803
|
-
const t = n === void 0 ? void 0 : Math.max(n,
|
|
804
|
-
if (t !== void 0 &&
|
|
800
|
+
}, he = 1, et = ce(
|
|
801
|
+
he
|
|
802
|
+
), tt = (n, e) => {
|
|
803
|
+
const t = n === void 0 ? void 0 : Math.max(n, he);
|
|
804
|
+
if (t !== void 0 && et(
|
|
805
805
|
t,
|
|
806
806
|
e
|
|
807
807
|
))
|
|
808
808
|
return t;
|
|
809
|
-
},
|
|
810
|
-
const t = n.scaleResolutionDownBy, s =
|
|
809
|
+
}, nt = (n, e) => {
|
|
810
|
+
const t = n.scaleResolutionDownBy, s = tt(
|
|
811
811
|
e,
|
|
812
812
|
t
|
|
813
813
|
);
|
|
814
814
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
815
|
-
},
|
|
815
|
+
}, st = (n, e) => {
|
|
816
816
|
const t = e.encodings?.length ?? 0;
|
|
817
|
-
return
|
|
817
|
+
return Je(n, t), n.encodings.forEach((s, i) => {
|
|
818
818
|
const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
|
|
819
|
-
|
|
819
|
+
Ze(s, a), nt(s, o);
|
|
820
820
|
}), n;
|
|
821
|
-
},
|
|
821
|
+
}, it = (n, e) => {
|
|
822
822
|
if (n.codecs?.length !== e.codecs?.length)
|
|
823
823
|
return !0;
|
|
824
824
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -835,15 +835,15 @@ const ze = (n, e) => (n.degradationPreference = e.degradationPreference, n), Xe
|
|
|
835
835
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
836
836
|
return !0;
|
|
837
837
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
838
|
-
},
|
|
838
|
+
}, rt = async (n, e) => {
|
|
839
839
|
const t = n.getParameters(), s = JSON.parse(
|
|
840
840
|
JSON.stringify(t)
|
|
841
841
|
);
|
|
842
|
-
|
|
843
|
-
const i =
|
|
842
|
+
st(t, e), Xe(t, e);
|
|
843
|
+
const i = it(s, t);
|
|
844
844
|
return i && await n.setParameters(t), { parameters: t, isChanged: i };
|
|
845
|
-
},
|
|
846
|
-
const { isChanged: s, parameters: i } = await
|
|
845
|
+
}, de = async (n, e, t) => {
|
|
846
|
+
const { isChanged: s, parameters: i } = await rt(n, {
|
|
847
847
|
encodings: [
|
|
848
848
|
{
|
|
849
849
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -852,20 +852,20 @@ const ze = (n, e) => (n.degradationPreference = e.degradationPreference, n), Xe
|
|
|
852
852
|
]
|
|
853
853
|
});
|
|
854
854
|
return s && t && t(i), { isChanged: s, parameters: i };
|
|
855
|
-
},
|
|
856
|
-
const s =
|
|
855
|
+
}, at = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ot = async (n, e, t) => {
|
|
856
|
+
const s = at(n, e);
|
|
857
857
|
if (s)
|
|
858
|
-
return
|
|
858
|
+
return de(s, { maxBitrate: t });
|
|
859
859
|
};
|
|
860
|
-
var
|
|
861
|
-
const
|
|
860
|
+
var P = /* @__PURE__ */ ((n) => (n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n))(P || {});
|
|
861
|
+
const le = [
|
|
862
862
|
"presentation:start",
|
|
863
863
|
"presentation:started",
|
|
864
864
|
"presentation:end",
|
|
865
865
|
"presentation:ended",
|
|
866
866
|
"presentation:failed"
|
|
867
|
-
],
|
|
868
|
-
class
|
|
867
|
+
], ct = 1, xn = (n) => Oe(n);
|
|
868
|
+
class ht {
|
|
869
869
|
events;
|
|
870
870
|
promisePendingStartPresentation;
|
|
871
871
|
promisePendingStopPresentation;
|
|
@@ -877,7 +877,7 @@ class ct {
|
|
|
877
877
|
callManager: e,
|
|
878
878
|
maxBitrate: t
|
|
879
879
|
}) {
|
|
880
|
-
this.callManager = e, this.maxBitrate = t, this.events = new O(
|
|
880
|
+
this.callManager = e, this.maxBitrate = t, this.events = new O(le), this.subscribe();
|
|
881
881
|
}
|
|
882
882
|
get isPendingPresentation() {
|
|
883
883
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
@@ -889,11 +889,11 @@ class ct {
|
|
|
889
889
|
sendEncodings: r,
|
|
890
890
|
onAddedTransceiver: a
|
|
891
891
|
} = {}, o) {
|
|
892
|
-
const
|
|
892
|
+
const h = this.getRtcSessionProtected();
|
|
893
893
|
if (this.streamPresentationCurrent)
|
|
894
894
|
throw new Error("Presentation is already started");
|
|
895
895
|
return this.sendPresentationWithDuplicatedCalls(e, {
|
|
896
|
-
rtcSession:
|
|
896
|
+
rtcSession: h,
|
|
897
897
|
stream: t,
|
|
898
898
|
presentationOptions: {
|
|
899
899
|
isNeedReinvite: s,
|
|
@@ -913,8 +913,8 @@ class ct {
|
|
|
913
913
|
const i = this.callManager.getEstablishedRTCSession();
|
|
914
914
|
return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
|
|
915
915
|
const a = r instanceof Error ? r : new Error(String(r));
|
|
916
|
-
throw this.events.trigger(
|
|
917
|
-
}) : t && this.events.trigger(
|
|
916
|
+
throw this.events.trigger(P.FAILED_PRESENTATION, a), r;
|
|
917
|
+
}) : t && this.events.trigger(P.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
918
918
|
this.resetPresentation();
|
|
919
919
|
});
|
|
920
920
|
}
|
|
@@ -953,15 +953,15 @@ class ct {
|
|
|
953
953
|
}
|
|
954
954
|
subscribe() {
|
|
955
955
|
this.callManager.on("presentation:start", (e) => {
|
|
956
|
-
this.events.trigger(
|
|
956
|
+
this.events.trigger(P.START_PRESENTATION, e);
|
|
957
957
|
}), this.callManager.on("presentation:started", (e) => {
|
|
958
|
-
this.events.trigger(
|
|
958
|
+
this.events.trigger(P.STARTED_PRESENTATION, e);
|
|
959
959
|
}), this.callManager.on("presentation:end", (e) => {
|
|
960
|
-
this.events.trigger(
|
|
960
|
+
this.events.trigger(P.END_PRESENTATION, e);
|
|
961
961
|
}), this.callManager.on("presentation:ended", (e) => {
|
|
962
|
-
this.events.trigger(
|
|
962
|
+
this.events.trigger(P.ENDED_PRESENTATION, e);
|
|
963
963
|
}), this.callManager.on("presentation:failed", (e) => {
|
|
964
|
-
this.events.trigger(
|
|
964
|
+
this.events.trigger(P.FAILED_PRESENTATION, e);
|
|
965
965
|
}), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
|
|
966
966
|
}
|
|
967
967
|
async sendPresentationWithDuplicatedCalls(e, {
|
|
@@ -969,7 +969,7 @@ class ct {
|
|
|
969
969
|
stream: s,
|
|
970
970
|
presentationOptions: i,
|
|
971
971
|
options: r = {
|
|
972
|
-
callLimit:
|
|
972
|
+
callLimit: ct
|
|
973
973
|
}
|
|
974
974
|
}) {
|
|
975
975
|
const a = async () => this.sendPresentation(
|
|
@@ -978,12 +978,12 @@ class ct {
|
|
|
978
978
|
s,
|
|
979
979
|
i
|
|
980
980
|
), o = () => !!this.streamPresentationCurrent;
|
|
981
|
-
return this.cancelableSendPresentationWithRepeatedCalls =
|
|
981
|
+
return this.cancelableSendPresentationWithRepeatedCalls = te({
|
|
982
982
|
targetFunction: a,
|
|
983
983
|
isComplete: o,
|
|
984
984
|
isRejectAsValid: !0,
|
|
985
985
|
...r
|
|
986
|
-
}), this.cancelableSendPresentationWithRepeatedCalls.then((
|
|
986
|
+
}), this.cancelableSendPresentationWithRepeatedCalls.then((h) => h);
|
|
987
987
|
}
|
|
988
988
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
989
989
|
async sendPresentation(e, t, s, {
|
|
@@ -991,7 +991,7 @@ class ct {
|
|
|
991
991
|
contentHint: r = "detail",
|
|
992
992
|
degradationPreference: a,
|
|
993
993
|
sendEncodings: o,
|
|
994
|
-
onAddedTransceiver:
|
|
994
|
+
onAddedTransceiver: h
|
|
995
995
|
}) {
|
|
996
996
|
const d = B(s, { contentHint: r });
|
|
997
997
|
if (d === void 0)
|
|
@@ -1000,11 +1000,11 @@ class ct {
|
|
|
1000
1000
|
const T = e().then(async () => t.startPresentation(d, i, {
|
|
1001
1001
|
degradationPreference: a,
|
|
1002
1002
|
sendEncodings: o,
|
|
1003
|
-
onAddedTransceiver:
|
|
1003
|
+
onAddedTransceiver: h
|
|
1004
1004
|
})).then(this.setMaxBitrate).then(() => s).catch((S) => {
|
|
1005
1005
|
this.removeStreamPresentationCurrent();
|
|
1006
1006
|
const l = S instanceof Error ? S : new Error(String(S));
|
|
1007
|
-
throw this.events.trigger(
|
|
1007
|
+
throw this.events.trigger(P.FAILED_PRESENTATION, l), S;
|
|
1008
1008
|
});
|
|
1009
1009
|
return this.promisePendingStartPresentation = T, T.finally(() => {
|
|
1010
1010
|
this.promisePendingStartPresentation = void 0;
|
|
@@ -1015,7 +1015,7 @@ class ct {
|
|
|
1015
1015
|
if (!e || !t || s === void 0)
|
|
1016
1016
|
return;
|
|
1017
1017
|
const i = e.getSenders();
|
|
1018
|
-
await
|
|
1018
|
+
await ot(i, t, s);
|
|
1019
1019
|
};
|
|
1020
1020
|
getRtcSessionProtected = () => {
|
|
1021
1021
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1036,7 +1036,7 @@ class ct {
|
|
|
1036
1036
|
delete this.streamPresentationCurrent;
|
|
1037
1037
|
}
|
|
1038
1038
|
}
|
|
1039
|
-
class
|
|
1039
|
+
class dt {
|
|
1040
1040
|
data;
|
|
1041
1041
|
getUa;
|
|
1042
1042
|
constructor(e) {
|
|
@@ -1117,7 +1117,7 @@ class ht {
|
|
|
1117
1117
|
}
|
|
1118
1118
|
}
|
|
1119
1119
|
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.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(C || {});
|
|
1120
|
-
const
|
|
1120
|
+
const ue = [
|
|
1121
1121
|
"connecting",
|
|
1122
1122
|
"connected",
|
|
1123
1123
|
"disconnected",
|
|
@@ -1127,7 +1127,7 @@ const le = [
|
|
|
1127
1127
|
"registrationFailed",
|
|
1128
1128
|
"newMessage",
|
|
1129
1129
|
"sipEvent"
|
|
1130
|
-
],
|
|
1130
|
+
], lt = [
|
|
1131
1131
|
"disconnecting",
|
|
1132
1132
|
"connect-started",
|
|
1133
1133
|
"connect-succeeded",
|
|
@@ -1135,8 +1135,8 @@ const le = [
|
|
|
1135
1135
|
"connect-parameters-resolve-success",
|
|
1136
1136
|
"connect-parameters-resolve-failed",
|
|
1137
1137
|
"connected-with-configuration"
|
|
1138
|
-
],
|
|
1139
|
-
class
|
|
1138
|
+
], ge = [...ue, ...lt], ut = 3;
|
|
1139
|
+
class gt {
|
|
1140
1140
|
cancelableConnectWithRepeatedCalls;
|
|
1141
1141
|
JsSIP;
|
|
1142
1142
|
events;
|
|
@@ -1162,7 +1162,7 @@ class ut {
|
|
|
1162
1162
|
}
|
|
1163
1163
|
let r = !1;
|
|
1164
1164
|
const a = this.getConnectionConfiguration();
|
|
1165
|
-
e !== void 0 && e !== a?.displayName && (r = i.set("display_name",
|
|
1165
|
+
e !== void 0 && e !== a?.displayName && (r = i.set("display_name", ie(e)), this.updateConnectionConfiguration("displayName", e));
|
|
1166
1166
|
const o = r;
|
|
1167
1167
|
o ? t(o) : s(new Error("nothing changed"));
|
|
1168
1168
|
});
|
|
@@ -1180,12 +1180,12 @@ class ut {
|
|
|
1180
1180
|
cancelRequests() {
|
|
1181
1181
|
this.cancelConnectWithRepeatedCalls();
|
|
1182
1182
|
}
|
|
1183
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
1183
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = ut } = {}) => {
|
|
1184
1184
|
const s = async () => this.connectInner(e), i = (r) => {
|
|
1185
|
-
const
|
|
1186
|
-
return
|
|
1185
|
+
const h = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !Le(r);
|
|
1186
|
+
return h || d;
|
|
1187
1187
|
};
|
|
1188
|
-
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls =
|
|
1188
|
+
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = te({
|
|
1189
1189
|
targetFunction: s,
|
|
1190
1190
|
isComplete: i,
|
|
1191
1191
|
callLimit: t,
|
|
@@ -1218,7 +1218,7 @@ class ut {
|
|
|
1218
1218
|
remoteAddress: r,
|
|
1219
1219
|
sessionTimers: a,
|
|
1220
1220
|
registerExpires: o,
|
|
1221
|
-
connectionRecoveryMinInterval:
|
|
1221
|
+
connectionRecoveryMinInterval: h,
|
|
1222
1222
|
connectionRecoveryMaxInterval: d,
|
|
1223
1223
|
userAgent: T,
|
|
1224
1224
|
displayName: S = "",
|
|
@@ -1242,7 +1242,7 @@ class ut {
|
|
|
1242
1242
|
register: l,
|
|
1243
1243
|
sessionTimers: a,
|
|
1244
1244
|
registerExpires: o,
|
|
1245
|
-
connectionRecoveryMinInterval:
|
|
1245
|
+
connectionRecoveryMinInterval: h,
|
|
1246
1246
|
connectionRecoveryMaxInterval: d,
|
|
1247
1247
|
userAgent: T,
|
|
1248
1248
|
remoteAddress: r,
|
|
@@ -1259,21 +1259,21 @@ class ut {
|
|
|
1259
1259
|
return;
|
|
1260
1260
|
}
|
|
1261
1261
|
let i;
|
|
1262
|
-
i = ((
|
|
1262
|
+
i = ((h, d) => {
|
|
1263
1263
|
if (this.getConnectionConfiguration()?.register === !0)
|
|
1264
|
-
return this.registrationManager.subscribeToStartEvents(
|
|
1264
|
+
return this.registrationManager.subscribeToStartEvents(h, d);
|
|
1265
1265
|
const S = C.CONNECTED, l = [C.DISCONNECTED];
|
|
1266
|
-
return this.events.on(S,
|
|
1266
|
+
return this.events.on(S, h), l.forEach((E) => {
|
|
1267
1267
|
this.events.on(E, d);
|
|
1268
1268
|
}), () => {
|
|
1269
|
-
this.events.off(S,
|
|
1269
|
+
this.events.off(S, h), l.forEach((E) => {
|
|
1270
1270
|
this.events.off(E, d);
|
|
1271
1271
|
});
|
|
1272
1272
|
};
|
|
1273
1273
|
})(() => {
|
|
1274
1274
|
i?.(), e(s);
|
|
1275
|
-
}, (
|
|
1276
|
-
i?.(), t(
|
|
1275
|
+
}, (h) => {
|
|
1276
|
+
i?.(), t(h);
|
|
1277
1277
|
}), s.start();
|
|
1278
1278
|
});
|
|
1279
1279
|
cancelConnectWithRepeatedCalls() {
|
|
@@ -1289,18 +1289,18 @@ class ut {
|
|
|
1289
1289
|
});
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
|
-
var
|
|
1293
|
-
const
|
|
1292
|
+
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 || {});
|
|
1293
|
+
const Tt = be({
|
|
1294
1294
|
types: {
|
|
1295
1295
|
context: {},
|
|
1296
1296
|
events: {}
|
|
1297
1297
|
},
|
|
1298
1298
|
actions: {
|
|
1299
1299
|
logTransition: (n, e) => {
|
|
1300
|
-
|
|
1300
|
+
c(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1301
1301
|
},
|
|
1302
1302
|
logStateChange: (n, e) => {
|
|
1303
|
-
|
|
1303
|
+
c("ConnectionStateMachine state changed", e.state);
|
|
1304
1304
|
}
|
|
1305
1305
|
}
|
|
1306
1306
|
}).createMachine({
|
|
@@ -1604,14 +1604,14 @@ const gt = Oe({
|
|
|
1604
1604
|
}
|
|
1605
1605
|
}
|
|
1606
1606
|
});
|
|
1607
|
-
class
|
|
1607
|
+
class St {
|
|
1608
1608
|
actor;
|
|
1609
1609
|
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
1610
1610
|
events;
|
|
1611
1611
|
unsubscribeFromEvents;
|
|
1612
1612
|
actorSubscription;
|
|
1613
1613
|
constructor(e) {
|
|
1614
|
-
this.events = e, this.actor = De(
|
|
1614
|
+
this.events = e, this.actor = De(Tt), this.actorSubscription = this.actor.subscribe((t) => {
|
|
1615
1615
|
const s = t.value;
|
|
1616
1616
|
this.stateChangeListeners.forEach((i) => {
|
|
1617
1617
|
i(s);
|
|
@@ -1697,7 +1697,7 @@ class Tt {
|
|
|
1697
1697
|
return this.actor.getSnapshot().can({ type: e });
|
|
1698
1698
|
}
|
|
1699
1699
|
getValidEvents() {
|
|
1700
|
-
return Object.values(
|
|
1700
|
+
return Object.values(Te).filter((e) => this.canTransition(e));
|
|
1701
1701
|
}
|
|
1702
1702
|
hasState(e) {
|
|
1703
1703
|
return this.actor.getSnapshot().matches(e);
|
|
@@ -1705,7 +1705,7 @@ class Tt {
|
|
|
1705
1705
|
sendEvent(e) {
|
|
1706
1706
|
const t = this.actor.getSnapshot(), s = { type: e };
|
|
1707
1707
|
if (!t.can(s)) {
|
|
1708
|
-
|
|
1708
|
+
c(
|
|
1709
1709
|
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1710
1710
|
);
|
|
1711
1711
|
return;
|
|
@@ -1766,7 +1766,7 @@ class Tt {
|
|
|
1766
1766
|
};
|
|
1767
1767
|
}
|
|
1768
1768
|
}
|
|
1769
|
-
class
|
|
1769
|
+
class Ct {
|
|
1770
1770
|
events;
|
|
1771
1771
|
getUaProtected;
|
|
1772
1772
|
constructor(e) {
|
|
@@ -1788,7 +1788,7 @@ class St {
|
|
|
1788
1788
|
try {
|
|
1789
1789
|
await this.unregister();
|
|
1790
1790
|
} catch (e) {
|
|
1791
|
-
|
|
1791
|
+
c("tryRegister", e);
|
|
1792
1792
|
}
|
|
1793
1793
|
return this.register();
|
|
1794
1794
|
}
|
|
@@ -1803,7 +1803,7 @@ class St {
|
|
|
1803
1803
|
};
|
|
1804
1804
|
}
|
|
1805
1805
|
}
|
|
1806
|
-
class
|
|
1806
|
+
class Et {
|
|
1807
1807
|
uaFactory;
|
|
1808
1808
|
getUaProtected;
|
|
1809
1809
|
constructor(e) {
|
|
@@ -1848,7 +1848,7 @@ class Ct {
|
|
|
1848
1848
|
remoteAddress: r,
|
|
1849
1849
|
extraHeaders: a
|
|
1850
1850
|
}) {
|
|
1851
|
-
return new Promise((o,
|
|
1851
|
+
return new Promise((o, h) => {
|
|
1852
1852
|
const { configuration: d } = this.uaFactory.createConfiguration({
|
|
1853
1853
|
sipWebSocketServerURL: i,
|
|
1854
1854
|
displayName: t,
|
|
@@ -1856,7 +1856,7 @@ class Ct {
|
|
|
1856
1856
|
sipServerUrl: s
|
|
1857
1857
|
}), T = this.uaFactory.createUA({ ...d, remoteAddress: r, extraHeaders: a }), S = () => {
|
|
1858
1858
|
const E = new Error("Telephony is not available");
|
|
1859
|
-
|
|
1859
|
+
h(E);
|
|
1860
1860
|
};
|
|
1861
1861
|
T.once(C.DISCONNECTED, S);
|
|
1862
1862
|
const l = () => {
|
|
@@ -1868,11 +1868,11 @@ class Ct {
|
|
|
1868
1868
|
});
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
|
-
const
|
|
1871
|
+
const At = (n) => {
|
|
1872
1872
|
const e = [];
|
|
1873
1873
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
1874
1874
|
};
|
|
1875
|
-
class
|
|
1875
|
+
class D {
|
|
1876
1876
|
JsSIP;
|
|
1877
1877
|
constructor(e) {
|
|
1878
1878
|
this.JsSIP = e;
|
|
@@ -1897,10 +1897,10 @@ class b {
|
|
|
1897
1897
|
throw new Error("user is required for authorized connection");
|
|
1898
1898
|
}
|
|
1899
1899
|
static resolveAuthorizationUser(e, t) {
|
|
1900
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
1900
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${We()}`;
|
|
1901
1901
|
}
|
|
1902
1902
|
static buildExtraHeaders(e, t) {
|
|
1903
|
-
const s = e !== void 0 && e !== "" ?
|
|
1903
|
+
const s = e !== void 0 && e !== "" ? At(e) : [];
|
|
1904
1904
|
return t === void 0 ? s : [...s, ...t];
|
|
1905
1905
|
}
|
|
1906
1906
|
createConfiguration({
|
|
@@ -1911,31 +1911,31 @@ class b {
|
|
|
1911
1911
|
sipServerUrl: r,
|
|
1912
1912
|
register: a = !1,
|
|
1913
1913
|
sessionTimers: o = !1,
|
|
1914
|
-
registerExpires:
|
|
1914
|
+
registerExpires: h = 300,
|
|
1915
1915
|
// 5 minutes in sec
|
|
1916
1916
|
connectionRecoveryMinInterval: d = 2,
|
|
1917
1917
|
connectionRecoveryMaxInterval: T = 6,
|
|
1918
1918
|
userAgent: S
|
|
1919
1919
|
}) {
|
|
1920
|
-
|
|
1920
|
+
D.validateParametersConnection({
|
|
1921
1921
|
register: a,
|
|
1922
1922
|
password: t,
|
|
1923
1923
|
user: e,
|
|
1924
1924
|
sipServerUrl: r,
|
|
1925
1925
|
sipWebSocketServerURL: s
|
|
1926
1926
|
});
|
|
1927
|
-
const l =
|
|
1927
|
+
const l = D.resolveAuthorizationUser(a, e), E = $e(r), m = E(l), R = new this.JsSIP.WebSocketInterface(s);
|
|
1928
1928
|
return {
|
|
1929
1929
|
configuration: {
|
|
1930
1930
|
password: t,
|
|
1931
1931
|
register: a,
|
|
1932
1932
|
uri: m,
|
|
1933
|
-
display_name:
|
|
1933
|
+
display_name: ie(i),
|
|
1934
1934
|
user_agent: S,
|
|
1935
1935
|
sdpSemantics: "unified-plan",
|
|
1936
1936
|
sockets: [R],
|
|
1937
1937
|
session_timers: o,
|
|
1938
|
-
register_expires:
|
|
1938
|
+
register_expires: h,
|
|
1939
1939
|
connection_recovery_min_interval: d,
|
|
1940
1940
|
connection_recovery_max_interval: T
|
|
1941
1941
|
},
|
|
@@ -1946,7 +1946,7 @@ class b {
|
|
|
1946
1946
|
};
|
|
1947
1947
|
}
|
|
1948
1948
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
1949
|
-
const i = new this.JsSIP.UA(s), r =
|
|
1949
|
+
const i = new this.JsSIP.UA(s), r = D.buildExtraHeaders(e, t);
|
|
1950
1950
|
return r.length > 0 && i.registrator().setExtraHeaders(r), i;
|
|
1951
1951
|
}
|
|
1952
1952
|
/**
|
|
@@ -1959,13 +1959,13 @@ class b {
|
|
|
1959
1959
|
extraHeaders: e.extraHeaders
|
|
1960
1960
|
});
|
|
1961
1961
|
return t.eachTriggers((a, o) => {
|
|
1962
|
-
const
|
|
1963
|
-
|
|
1962
|
+
const h = ue.find((d) => d === o);
|
|
1963
|
+
h && r.on(h, a);
|
|
1964
1964
|
}), { ua: r, helpers: i };
|
|
1965
1965
|
}
|
|
1966
1966
|
}
|
|
1967
|
-
const
|
|
1968
|
-
class
|
|
1967
|
+
const Se = "Not ready for connection", Nt = (n) => n instanceof Error && n.message === Se, Rt = () => new Error(Se), It = async (n) => typeof n == "function" ? n() : n;
|
|
1968
|
+
class mt {
|
|
1969
1969
|
events;
|
|
1970
1970
|
ua;
|
|
1971
1971
|
socket;
|
|
@@ -1977,15 +1977,15 @@ class It {
|
|
|
1977
1977
|
configurationManager;
|
|
1978
1978
|
JsSIP;
|
|
1979
1979
|
constructor({ JsSIP: e }) {
|
|
1980
|
-
this.JsSIP = e, this.events = new O(
|
|
1980
|
+
this.JsSIP = e, this.events = new O(ge), this.uaFactory = new D(e), this.registrationManager = new Ct({
|
|
1981
1981
|
events: this.events,
|
|
1982
1982
|
getUaProtected: this.getUaProtected
|
|
1983
|
-
}), this.stateMachine = new
|
|
1983
|
+
}), this.stateMachine = new St(this.events), this.configurationManager = new dt({
|
|
1984
1984
|
getUa: this.getUa
|
|
1985
|
-
}), this.sipOperations = new
|
|
1985
|
+
}), this.sipOperations = new Et({
|
|
1986
1986
|
uaFactory: this.uaFactory,
|
|
1987
1987
|
getUaProtected: this.getUaProtected
|
|
1988
|
-
}), this.connectionFlow = new
|
|
1988
|
+
}), this.connectionFlow = new gt({
|
|
1989
1989
|
JsSIP: this.JsSIP,
|
|
1990
1990
|
events: this.events,
|
|
1991
1991
|
uaFactory: this.uaFactory,
|
|
@@ -2032,13 +2032,13 @@ class It {
|
|
|
2032
2032
|
return this.stateMachine.state;
|
|
2033
2033
|
}
|
|
2034
2034
|
get isRegistered() {
|
|
2035
|
-
return
|
|
2035
|
+
return D.isRegisteredUA(this.ua);
|
|
2036
2036
|
}
|
|
2037
2037
|
get isRegisterConfig() {
|
|
2038
2038
|
return this.configurationManager.isRegister();
|
|
2039
2039
|
}
|
|
2040
2040
|
connect = async (e, t) => this.disconnect().catch((s) => {
|
|
2041
|
-
|
|
2041
|
+
c("connect: disconnect error", s);
|
|
2042
2042
|
}).then(async () => this.connectWithProcessError(e, t));
|
|
2043
2043
|
set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
|
|
2044
2044
|
disconnect = async () => {
|
|
@@ -2087,7 +2087,7 @@ class It {
|
|
|
2087
2087
|
getUa = () => this.ua;
|
|
2088
2088
|
connectWithProcessError = async (e, t) => {
|
|
2089
2089
|
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
2090
|
-
throw
|
|
2090
|
+
throw Rt();
|
|
2091
2091
|
return this.processConnect(e, t).catch(async (i) => {
|
|
2092
2092
|
const r = i;
|
|
2093
2093
|
return this.disconnect().then(() => {
|
|
@@ -2097,7 +2097,7 @@ class It {
|
|
|
2097
2097
|
});
|
|
2098
2098
|
});
|
|
2099
2099
|
};
|
|
2100
|
-
processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}),
|
|
2100
|
+
processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), It(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
|
|
2101
2101
|
throw this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
|
|
2102
2102
|
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
|
|
2103
2103
|
...s
|
|
@@ -2106,9 +2106,9 @@ class It {
|
|
|
2106
2106
|
throw this.events.trigger(C.CONNECT_FAILED, i), i;
|
|
2107
2107
|
}));
|
|
2108
2108
|
}
|
|
2109
|
-
class
|
|
2109
|
+
class pt {
|
|
2110
2110
|
connectionManager;
|
|
2111
|
-
stackPromises =
|
|
2111
|
+
stackPromises = ne({
|
|
2112
2112
|
noRunIsNotActual: !0
|
|
2113
2113
|
});
|
|
2114
2114
|
constructor({ connectionManager: e }) {
|
|
@@ -2120,11 +2120,11 @@ class mt {
|
|
|
2120
2120
|
this.stackPromises.stop();
|
|
2121
2121
|
}
|
|
2122
2122
|
}
|
|
2123
|
-
const
|
|
2124
|
-
class
|
|
2125
|
-
countInner =
|
|
2126
|
-
initialCount =
|
|
2127
|
-
limitInner =
|
|
2123
|
+
const z = 0, _t = 30;
|
|
2124
|
+
class Mt {
|
|
2125
|
+
countInner = z;
|
|
2126
|
+
initialCount = z;
|
|
2127
|
+
limitInner = _t;
|
|
2128
2128
|
isInProgress = !1;
|
|
2129
2129
|
onStatusChange;
|
|
2130
2130
|
constructor({
|
|
@@ -2157,7 +2157,7 @@ class _t {
|
|
|
2157
2157
|
this.countInner = this.initialCount, this.finishAttempt();
|
|
2158
2158
|
}
|
|
2159
2159
|
}
|
|
2160
|
-
class
|
|
2160
|
+
class ft {
|
|
2161
2161
|
connectionManager;
|
|
2162
2162
|
interval;
|
|
2163
2163
|
checkTelephonyByTimeout = void 0;
|
|
@@ -2173,7 +2173,7 @@ class Mt {
|
|
|
2173
2173
|
onSuccessRequest: t,
|
|
2174
2174
|
onFailRequest: s
|
|
2175
2175
|
}) {
|
|
2176
|
-
this.stop(), this.cancelableBeforeRequest = new x(e), this.checkTelephonyByTimeout =
|
|
2176
|
+
this.stop(), this.cancelableBeforeRequest = new x(e), this.checkTelephonyByTimeout = Me({
|
|
2177
2177
|
isDontStopOnFail: !0,
|
|
2178
2178
|
requestInterval: this.interval,
|
|
2179
2179
|
request: async () => {
|
|
@@ -2194,7 +2194,7 @@ class Mt {
|
|
|
2194
2194
|
}
|
|
2195
2195
|
}
|
|
2196
2196
|
var _ = /* @__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))(_ || {});
|
|
2197
|
-
const
|
|
2197
|
+
const Ce = [
|
|
2198
2198
|
"before-attempt",
|
|
2199
2199
|
"success",
|
|
2200
2200
|
"failed-all-attempts",
|
|
@@ -2202,75 +2202,104 @@ const Se = [
|
|
|
2202
2202
|
"changed-attempt-status",
|
|
2203
2203
|
"stop-attempts-by-error",
|
|
2204
2204
|
"limit-reached-attempts"
|
|
2205
|
-
]
|
|
2206
|
-
class
|
|
2205
|
+
];
|
|
2206
|
+
class Q {
|
|
2207
|
+
callManager;
|
|
2208
|
+
disposers = [];
|
|
2209
|
+
constructor({ callManager: e }) {
|
|
2210
|
+
this.callManager = e;
|
|
2211
|
+
}
|
|
2212
|
+
subscribe(e) {
|
|
2213
|
+
this.unsubscribe(), this.disposers.push(
|
|
2214
|
+
this.callManager.on("call-status-changed", () => {
|
|
2215
|
+
this.handleCallStatusChange(e);
|
|
2216
|
+
})
|
|
2217
|
+
), this.handleCallStatusChange(e);
|
|
2218
|
+
}
|
|
2219
|
+
unsubscribe() {
|
|
2220
|
+
this.disposers.forEach((e) => {
|
|
2221
|
+
e();
|
|
2222
|
+
}), this.disposers = [];
|
|
2223
|
+
}
|
|
2224
|
+
handleCallStatusChange({
|
|
2225
|
+
onActive: e,
|
|
2226
|
+
onInactive: t
|
|
2227
|
+
}) {
|
|
2228
|
+
this.callManager.isCallActive ? e?.() : t();
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
const vt = 15e3, Pt = 2;
|
|
2232
|
+
class Ot {
|
|
2207
2233
|
connectionManager;
|
|
2208
2234
|
pingServerByTimeoutWithFailCalls;
|
|
2209
2235
|
constructor({ connectionManager: e }) {
|
|
2210
|
-
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls =
|
|
2236
|
+
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = fe(Pt, {
|
|
2211
2237
|
whenPossibleRequest: async () => {
|
|
2212
2238
|
},
|
|
2213
|
-
requestInterval:
|
|
2214
|
-
request: async () => (
|
|
2215
|
-
|
|
2239
|
+
requestInterval: vt,
|
|
2240
|
+
request: async () => (c("ping"), this.connectionManager.ping().then(() => {
|
|
2241
|
+
c("ping success");
|
|
2216
2242
|
}))
|
|
2217
2243
|
});
|
|
2218
2244
|
}
|
|
2219
2245
|
start({ onFailRequest: e }) {
|
|
2220
|
-
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(
|
|
2246
|
+
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(c);
|
|
2221
2247
|
}
|
|
2222
2248
|
stop() {
|
|
2223
2249
|
this.pingServerByTimeoutWithFailCalls.stop();
|
|
2224
2250
|
}
|
|
2225
2251
|
}
|
|
2226
|
-
class
|
|
2227
|
-
callManager;
|
|
2252
|
+
class bt {
|
|
2228
2253
|
pingServerRequester;
|
|
2229
|
-
|
|
2254
|
+
notActiveCallSubscriber;
|
|
2230
2255
|
constructor({
|
|
2231
2256
|
connectionManager: e,
|
|
2232
2257
|
callManager: t
|
|
2233
2258
|
}) {
|
|
2234
|
-
this.
|
|
2259
|
+
this.pingServerRequester = new Ot({
|
|
2235
2260
|
connectionManager: e
|
|
2236
|
-
});
|
|
2261
|
+
}), this.notActiveCallSubscriber = new Q({ callManager: t });
|
|
2237
2262
|
}
|
|
2238
2263
|
start({ onFailRequest: e }) {
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2264
|
+
c("start"), this.notActiveCallSubscriber.subscribe({
|
|
2265
|
+
onActive: () => {
|
|
2266
|
+
this.pingServerRequester.stop();
|
|
2267
|
+
},
|
|
2268
|
+
onInactive: () => {
|
|
2269
|
+
this.pingServerRequester.start({ onFailRequest: e });
|
|
2270
|
+
}
|
|
2271
|
+
});
|
|
2242
2272
|
}
|
|
2243
2273
|
stop() {
|
|
2244
|
-
|
|
2274
|
+
c("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
|
|
2245
2275
|
}
|
|
2246
2276
|
unsubscribeCallStatusChange() {
|
|
2247
|
-
this.
|
|
2248
|
-
}
|
|
2249
|
-
handleCallStatusChange({ onFailRequest: e }) {
|
|
2250
|
-
this.callManager.isCallActive ? this.pingServerRequester.stop() : this.pingServerRequester.start({ onFailRequest: e });
|
|
2277
|
+
this.notActiveCallSubscriber.unsubscribe();
|
|
2251
2278
|
}
|
|
2252
2279
|
}
|
|
2253
2280
|
class Dt {
|
|
2254
2281
|
connectionManager;
|
|
2255
|
-
callManager;
|
|
2256
2282
|
isRegistrationFailed = !1;
|
|
2257
2283
|
disposers = [];
|
|
2284
|
+
notActiveCallSubscriber;
|
|
2258
2285
|
constructor({
|
|
2259
2286
|
connectionManager: e,
|
|
2260
2287
|
callManager: t
|
|
2261
2288
|
}) {
|
|
2262
|
-
this.connectionManager = e, this.
|
|
2289
|
+
this.connectionManager = e, this.notActiveCallSubscriber = new Q({ callManager: t });
|
|
2263
2290
|
}
|
|
2264
2291
|
subscribe(e) {
|
|
2265
2292
|
this.unsubscribe(), this.disposers.push(
|
|
2266
2293
|
this.connectionManager.on("registrationFailed", () => {
|
|
2267
2294
|
this.setIsRegistrationFailed();
|
|
2268
2295
|
})
|
|
2269
|
-
), this.
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
}
|
|
2273
|
-
)
|
|
2296
|
+
), this.notActiveCallSubscriber.subscribe({
|
|
2297
|
+
onInactive: () => {
|
|
2298
|
+
this.isRegistrationFailed && e();
|
|
2299
|
+
}
|
|
2300
|
+
}), this.disposers.push(() => {
|
|
2301
|
+
this.notActiveCallSubscriber.unsubscribe();
|
|
2302
|
+
});
|
|
2274
2303
|
}
|
|
2275
2304
|
unsubscribe() {
|
|
2276
2305
|
this.disposers.forEach((e) => {
|
|
@@ -2284,12 +2313,12 @@ class Dt {
|
|
|
2284
2313
|
this.isRegistrationFailed = !1;
|
|
2285
2314
|
}
|
|
2286
2315
|
}
|
|
2287
|
-
const
|
|
2316
|
+
const yt = 3e3, wt = 15e3, X = {
|
|
2288
2317
|
LIMIT_REACHED: "Limit reached",
|
|
2289
2318
|
FAILED_TO_RECONNECT: "Failed to reconnect"
|
|
2290
|
-
},
|
|
2291
|
-
},
|
|
2292
|
-
class
|
|
2319
|
+
}, Ut = async () => {
|
|
2320
|
+
}, Lt = (n) => !0;
|
|
2321
|
+
class Bt {
|
|
2293
2322
|
events;
|
|
2294
2323
|
connectionManager;
|
|
2295
2324
|
connectionQueueManager;
|
|
@@ -2303,33 +2332,34 @@ class Lt {
|
|
|
2303
2332
|
canRetryOnError;
|
|
2304
2333
|
networkInterfacesSubscriber;
|
|
2305
2334
|
resumeFromSleepModeSubscriber;
|
|
2335
|
+
notActiveCallSubscriber;
|
|
2306
2336
|
constructor({
|
|
2307
2337
|
connectionQueueManager: e,
|
|
2308
2338
|
connectionManager: t,
|
|
2309
2339
|
callManager: s
|
|
2310
2340
|
}, i) {
|
|
2311
|
-
const r = i?.onBeforeRetry ??
|
|
2312
|
-
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = new O(
|
|
2341
|
+
const r = i?.onBeforeRetry ?? Ut, a = i?.canRetryOnError ?? Lt;
|
|
2342
|
+
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = new O(Ce), this.checkTelephonyRequester = new ft({
|
|
2313
2343
|
connectionManager: t,
|
|
2314
|
-
interval: i?.checkTelephonyRequestInterval ??
|
|
2315
|
-
}), this.pingServerIfNotActiveCallRequester = new
|
|
2344
|
+
interval: i?.checkTelephonyRequestInterval ?? wt
|
|
2345
|
+
}), this.pingServerIfNotActiveCallRequester = new bt({
|
|
2316
2346
|
connectionManager: t,
|
|
2317
2347
|
callManager: s
|
|
2318
2348
|
}), this.registrationFailedOutOfCallSubscriber = new Dt({
|
|
2319
2349
|
connectionManager: t,
|
|
2320
2350
|
callManager: s
|
|
2321
|
-
}), this.attemptsState = new
|
|
2351
|
+
}), this.attemptsState = new Mt({
|
|
2322
2352
|
onStatusChange: this.emitStatusChange
|
|
2323
|
-
}), this.cancelableRequestBeforeRetry = new x(r), this.delayBetweenAttempts = new
|
|
2324
|
-
i?.timeoutBetweenAttempts ??
|
|
2325
|
-
);
|
|
2353
|
+
}), this.cancelableRequestBeforeRetry = new x(r), this.delayBetweenAttempts = new ve(
|
|
2354
|
+
i?.timeoutBetweenAttempts ?? yt
|
|
2355
|
+
), this.notActiveCallSubscriber = new Q({ callManager: s });
|
|
2326
2356
|
}
|
|
2327
2357
|
start(e) {
|
|
2328
|
-
|
|
2358
|
+
c("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
|
|
2329
2359
|
}
|
|
2330
2360
|
stop() {
|
|
2331
|
-
|
|
2332
|
-
|
|
2361
|
+
c("auto connector stop"), this.unsubscribeFromNotActiveCall(), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow().catch((e) => {
|
|
2362
|
+
c("auto connector stop from stop method: error", e);
|
|
2333
2363
|
});
|
|
2334
2364
|
}
|
|
2335
2365
|
on(e, t) {
|
|
@@ -2348,78 +2378,91 @@ class Lt {
|
|
|
2348
2378
|
this.events.off(e, t);
|
|
2349
2379
|
}
|
|
2350
2380
|
restartConnectionAttempts(e) {
|
|
2351
|
-
|
|
2352
|
-
|
|
2381
|
+
c("auto connector restart connection attempts"), this.stopConnectionFlow().then(async () => this.attemptConnection(e)).catch((t) => {
|
|
2382
|
+
c("auto connector failed to restart connection attempts:", t);
|
|
2353
2383
|
});
|
|
2354
2384
|
}
|
|
2355
2385
|
async stopConnectionFlow() {
|
|
2356
|
-
|
|
2386
|
+
c("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), await this.connectionQueueManager.disconnect();
|
|
2357
2387
|
}
|
|
2358
2388
|
stopAttempts() {
|
|
2359
2389
|
this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
|
|
2360
2390
|
}
|
|
2361
2391
|
stopConnectTriggers() {
|
|
2362
|
-
|
|
2392
|
+
c("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
|
|
2363
2393
|
}
|
|
2364
2394
|
startCheckTelephony(e) {
|
|
2365
|
-
|
|
2395
|
+
c("startCheckTelephony"), this.checkTelephonyRequester.start({
|
|
2366
2396
|
onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
|
|
2367
2397
|
onSuccessRequest: () => {
|
|
2368
|
-
|
|
2398
|
+
c("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
|
|
2369
2399
|
},
|
|
2370
2400
|
onFailRequest: (t) => {
|
|
2371
|
-
|
|
2401
|
+
c("startCheckTelephony: onFailRequest", t.message);
|
|
2372
2402
|
}
|
|
2373
2403
|
});
|
|
2374
2404
|
}
|
|
2375
2405
|
async attemptConnection(e) {
|
|
2376
|
-
if (
|
|
2377
|
-
|
|
2406
|
+
if (c("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(_.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
|
|
2407
|
+
c("attemptConnection: limit reached"), this.handleLimitReached(e);
|
|
2378
2408
|
return;
|
|
2379
2409
|
}
|
|
2380
2410
|
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.executeConnectionAttempt(e);
|
|
2381
2411
|
}
|
|
2382
2412
|
async executeConnectionAttempt(e) {
|
|
2383
2413
|
try {
|
|
2384
|
-
await this.connectionQueueManager.connect(e.getParameters, e.options),
|
|
2414
|
+
await this.connectionQueueManager.connect(e.getParameters, e.options), c("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
|
|
2385
2415
|
} catch (t) {
|
|
2386
2416
|
this.handleConnectionError(t, e);
|
|
2387
2417
|
}
|
|
2388
2418
|
}
|
|
2389
2419
|
handleConnectionError(e, t) {
|
|
2390
|
-
if (
|
|
2420
|
+
if (Nt(e)) {
|
|
2391
2421
|
this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
|
|
2392
2422
|
return;
|
|
2393
2423
|
}
|
|
2394
2424
|
if (!this.canRetryOnError(e)) {
|
|
2395
|
-
|
|
2425
|
+
c("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
|
|
2396
2426
|
return;
|
|
2397
2427
|
}
|
|
2398
|
-
if (
|
|
2399
|
-
|
|
2428
|
+
if (ye(e)) {
|
|
2429
|
+
c("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(_.CANCELLED_ATTEMPTS, e);
|
|
2400
2430
|
return;
|
|
2401
2431
|
}
|
|
2402
|
-
|
|
2432
|
+
c("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
|
|
2403
2433
|
}
|
|
2404
2434
|
handleLimitReached(e) {
|
|
2405
|
-
this.attemptsState.finishAttempt(), this.events.trigger(_.LIMIT_REACHED_ATTEMPTS, new Error(
|
|
2435
|
+
this.attemptsState.finishAttempt(), this.events.trigger(_.LIMIT_REACHED_ATTEMPTS, new Error(X.LIMIT_REACHED)), this.startCheckTelephony(e);
|
|
2406
2436
|
}
|
|
2407
2437
|
handleSucceededAttempt(e) {
|
|
2408
|
-
|
|
2438
|
+
c("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(_.SUCCESS);
|
|
2409
2439
|
}
|
|
2410
2440
|
subscribeToConnectTriggers(e) {
|
|
2411
2441
|
this.startPingRequester(e), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2412
|
-
|
|
2442
|
+
c("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
|
|
2413
2443
|
});
|
|
2414
2444
|
}
|
|
2445
|
+
subscribeToNotActiveCall(e) {
|
|
2446
|
+
this.notActiveCallSubscriber.subscribe({
|
|
2447
|
+
onActive: () => {
|
|
2448
|
+
c("subscribeToNotActiveCall onActive"), this.unsubscribeFromHardwareTriggers();
|
|
2449
|
+
},
|
|
2450
|
+
onInactive: () => {
|
|
2451
|
+
c("subscribeToNotActiveCall onInactive"), this.subscribeToHardwareTriggers(e);
|
|
2452
|
+
}
|
|
2453
|
+
});
|
|
2454
|
+
}
|
|
2455
|
+
unsubscribeFromNotActiveCall() {
|
|
2456
|
+
this.notActiveCallSubscriber.unsubscribe();
|
|
2457
|
+
}
|
|
2415
2458
|
subscribeToHardwareTriggers(e) {
|
|
2416
|
-
this.unsubscribeFromHardwareTriggers(),
|
|
2459
|
+
this.unsubscribeFromHardwareTriggers(), c("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
|
|
2417
2460
|
onChange: () => {
|
|
2418
|
-
|
|
2461
|
+
c("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
|
|
2419
2462
|
},
|
|
2420
2463
|
onUnavailable: () => {
|
|
2421
|
-
|
|
2422
|
-
|
|
2464
|
+
c("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow().catch((t) => {
|
|
2465
|
+
c(
|
|
2423
2466
|
"auto connector stop from networkInterfacesSubscriber onUnavailable: error",
|
|
2424
2467
|
t
|
|
2425
2468
|
);
|
|
@@ -2427,12 +2470,12 @@ class Lt {
|
|
|
2427
2470
|
}
|
|
2428
2471
|
}), this.resumeFromSleepModeSubscriber?.subscribe({
|
|
2429
2472
|
onResume: () => {
|
|
2430
|
-
|
|
2473
|
+
c("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
|
|
2431
2474
|
}
|
|
2432
2475
|
});
|
|
2433
2476
|
}
|
|
2434
2477
|
unsubscribeFromHardwareTriggers() {
|
|
2435
|
-
|
|
2478
|
+
c("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
|
|
2436
2479
|
}
|
|
2437
2480
|
stopPingRequester() {
|
|
2438
2481
|
this.pingServerIfNotActiveCallRequester.stop();
|
|
@@ -2440,18 +2483,18 @@ class Lt {
|
|
|
2440
2483
|
startPingRequester(e) {
|
|
2441
2484
|
this.pingServerIfNotActiveCallRequester.start({
|
|
2442
2485
|
onFailRequest: () => {
|
|
2443
|
-
|
|
2486
|
+
c("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
|
|
2444
2487
|
}
|
|
2445
2488
|
});
|
|
2446
2489
|
}
|
|
2447
2490
|
connectIfDisconnected(e) {
|
|
2448
2491
|
const t = this.isConnectionUnavailable();
|
|
2449
|
-
|
|
2492
|
+
c("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(_.SUCCESS));
|
|
2450
2493
|
}
|
|
2451
2494
|
scheduleReconnect(e) {
|
|
2452
|
-
|
|
2453
|
-
const s = t instanceof Error ? t : new Error(
|
|
2454
|
-
this.attemptsState.finishAttempt(),
|
|
2495
|
+
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) => {
|
|
2496
|
+
const s = t instanceof Error ? t : new Error(X.FAILED_TO_RECONNECT);
|
|
2497
|
+
this.attemptsState.finishAttempt(), _e(t) || Pe(t) ? this.events.trigger(_.CANCELLED_ATTEMPTS, s) : this.events.trigger(_.FAILED_ALL_ATTEMPTS, s), c("scheduleReconnect: error", t);
|
|
2455
2498
|
});
|
|
2456
2499
|
}
|
|
2457
2500
|
isConnectionUnavailable() {
|
|
@@ -2463,18 +2506,18 @@ class Lt {
|
|
|
2463
2506
|
};
|
|
2464
2507
|
}
|
|
2465
2508
|
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 || {});
|
|
2466
|
-
const
|
|
2509
|
+
const Ee = [
|
|
2467
2510
|
"incomingCall",
|
|
2468
2511
|
"declinedIncomingCall",
|
|
2469
2512
|
"terminatedIncomingCall",
|
|
2470
2513
|
"failedIncomingCall"
|
|
2471
|
-
],
|
|
2472
|
-
class
|
|
2514
|
+
], Ft = 486, kt = 487;
|
|
2515
|
+
class $t {
|
|
2473
2516
|
events;
|
|
2474
2517
|
incomingRTCSession;
|
|
2475
2518
|
connectionManager;
|
|
2476
2519
|
constructor(e) {
|
|
2477
|
-
this.connectionManager = e, this.events = new O(
|
|
2520
|
+
this.connectionManager = e, this.events = new O(Ee), this.start();
|
|
2478
2521
|
}
|
|
2479
2522
|
get remoteCallerData() {
|
|
2480
2523
|
return {
|
|
@@ -2504,7 +2547,7 @@ class kt {
|
|
|
2504
2547
|
return this.removeIncomingSession(), e;
|
|
2505
2548
|
};
|
|
2506
2549
|
async declineToIncomingCall({
|
|
2507
|
-
statusCode: e =
|
|
2550
|
+
statusCode: e = kt
|
|
2508
2551
|
} = {}) {
|
|
2509
2552
|
return new Promise((t, s) => {
|
|
2510
2553
|
try {
|
|
@@ -2516,7 +2559,7 @@ class kt {
|
|
|
2516
2559
|
});
|
|
2517
2560
|
}
|
|
2518
2561
|
async busyIncomingCall() {
|
|
2519
|
-
return this.declineToIncomingCall({ statusCode:
|
|
2562
|
+
return this.declineToIncomingCall({ statusCode: Ft });
|
|
2520
2563
|
}
|
|
2521
2564
|
on(e, t) {
|
|
2522
2565
|
return this.events.on(e, t);
|
|
@@ -2558,10 +2601,10 @@ class kt {
|
|
|
2558
2601
|
}
|
|
2559
2602
|
const y = 1e3;
|
|
2560
2603
|
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 || {});
|
|
2561
|
-
const
|
|
2604
|
+
const Ae = ["collected"], J = () => "performance" in window ? performance.now() : Date.now(), U = (n) => [...n.keys()].reduce((e, t) => {
|
|
2562
2605
|
const s = n.get(t);
|
|
2563
2606
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2564
|
-
}, {}),
|
|
2607
|
+
}, {}), qt = (n) => {
|
|
2565
2608
|
if (!n)
|
|
2566
2609
|
return {
|
|
2567
2610
|
outboundRtp: void 0,
|
|
@@ -2576,7 +2619,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2576
2619
|
mediaSource: e[A.MEDIA_SOURCE],
|
|
2577
2620
|
remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
|
|
2578
2621
|
};
|
|
2579
|
-
},
|
|
2622
|
+
}, K = (n) => {
|
|
2580
2623
|
if (!n)
|
|
2581
2624
|
return {
|
|
2582
2625
|
outboundRtp: void 0,
|
|
@@ -2591,7 +2634,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2591
2634
|
mediaSource: e[A.MEDIA_SOURCE],
|
|
2592
2635
|
remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
|
|
2593
2636
|
};
|
|
2594
|
-
},
|
|
2637
|
+
}, j = ({
|
|
2595
2638
|
videoReceiversStats: n,
|
|
2596
2639
|
synchronizationSourcesVideo: e
|
|
2597
2640
|
}) => {
|
|
@@ -2607,7 +2650,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2607
2650
|
codec: t[A.CODEC],
|
|
2608
2651
|
synchronizationSources: e
|
|
2609
2652
|
};
|
|
2610
|
-
},
|
|
2653
|
+
}, Wt = ({
|
|
2611
2654
|
audioReceiverStats: n,
|
|
2612
2655
|
synchronizationSourcesAudio: e
|
|
2613
2656
|
}) => {
|
|
@@ -2625,7 +2668,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2625
2668
|
remoteOutboundRtp: t[A.REMOTE_OUTBOUND_RTP],
|
|
2626
2669
|
synchronizationSources: e
|
|
2627
2670
|
};
|
|
2628
|
-
},
|
|
2671
|
+
}, Ne = (n) => {
|
|
2629
2672
|
if (!n)
|
|
2630
2673
|
return {
|
|
2631
2674
|
candidatePair: void 0,
|
|
@@ -2642,39 +2685,39 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2642
2685
|
remoteCandidate: e[A.REMOTE_CANDIDATE],
|
|
2643
2686
|
transport: e[A.TRANSPORT]
|
|
2644
2687
|
};
|
|
2645
|
-
},
|
|
2688
|
+
}, Vt = ({
|
|
2646
2689
|
audioSenderStats: n,
|
|
2647
2690
|
videoSenderFirstStats: e,
|
|
2648
2691
|
videoSenderSecondStats: t
|
|
2649
2692
|
}) => ({
|
|
2650
|
-
video:
|
|
2651
|
-
secondVideo:
|
|
2652
|
-
audio:
|
|
2653
|
-
additional:
|
|
2693
|
+
video: K(e),
|
|
2694
|
+
secondVideo: K(t),
|
|
2695
|
+
audio: qt(n),
|
|
2696
|
+
additional: Ne(
|
|
2654
2697
|
n ?? e ?? t
|
|
2655
2698
|
)
|
|
2656
|
-
}),
|
|
2699
|
+
}), Ht = ({
|
|
2657
2700
|
audioReceiverStats: n,
|
|
2658
2701
|
videoReceiverFirstStats: e,
|
|
2659
2702
|
videoReceiverSecondStats: t,
|
|
2660
2703
|
synchronizationSources: s
|
|
2661
2704
|
}) => ({
|
|
2662
|
-
video:
|
|
2705
|
+
video: j({
|
|
2663
2706
|
videoReceiversStats: e,
|
|
2664
2707
|
synchronizationSourcesVideo: s.video
|
|
2665
2708
|
}),
|
|
2666
|
-
secondVideo:
|
|
2709
|
+
secondVideo: j({
|
|
2667
2710
|
videoReceiversStats: t,
|
|
2668
2711
|
synchronizationSourcesVideo: s.video
|
|
2669
2712
|
}),
|
|
2670
|
-
audio:
|
|
2713
|
+
audio: Wt({
|
|
2671
2714
|
audioReceiverStats: n,
|
|
2672
2715
|
synchronizationSourcesAudio: s.audio
|
|
2673
2716
|
}),
|
|
2674
|
-
additional:
|
|
2717
|
+
additional: Ne(
|
|
2675
2718
|
n ?? e ?? t
|
|
2676
2719
|
)
|
|
2677
|
-
}),
|
|
2720
|
+
}), xt = ({
|
|
2678
2721
|
audioSenderStats: n,
|
|
2679
2722
|
videoSenderFirstStats: e,
|
|
2680
2723
|
videoSenderSecondStats: t,
|
|
@@ -2683,11 +2726,11 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2683
2726
|
videoReceiverSecondStats: r,
|
|
2684
2727
|
synchronizationSources: a
|
|
2685
2728
|
}) => {
|
|
2686
|
-
const o =
|
|
2729
|
+
const o = Vt({
|
|
2687
2730
|
audioSenderStats: n,
|
|
2688
2731
|
videoSenderFirstStats: e,
|
|
2689
2732
|
videoSenderSecondStats: t
|
|
2690
|
-
}),
|
|
2733
|
+
}), h = Ht({
|
|
2691
2734
|
audioReceiverStats: s,
|
|
2692
2735
|
videoReceiverFirstStats: i,
|
|
2693
2736
|
videoReceiverSecondStats: r,
|
|
@@ -2695,15 +2738,15 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2695
2738
|
});
|
|
2696
2739
|
return {
|
|
2697
2740
|
outbound: o,
|
|
2698
|
-
inbound:
|
|
2741
|
+
inbound: h
|
|
2699
2742
|
};
|
|
2700
|
-
},
|
|
2701
|
-
const e = "audio", t = "video", s = n.getSenders(), i = s.find((l) => l.track?.kind === e), r = s.filter((l) => l.track?.kind === t), a = n.getReceivers(), o = a.find((l) => l.track.kind === e),
|
|
2743
|
+
}, Gt = async (n) => {
|
|
2744
|
+
const e = "audio", t = "video", s = n.getSenders(), i = s.find((l) => l.track?.kind === e), r = s.filter((l) => l.track?.kind === t), a = n.getReceivers(), o = a.find((l) => l.track.kind === e), h = a.filter((l) => l.track.kind === t), d = {
|
|
2702
2745
|
trackIdentifier: o?.track.id,
|
|
2703
2746
|
item: o?.getSynchronizationSources()[0]
|
|
2704
2747
|
}, T = {
|
|
2705
|
-
trackIdentifier:
|
|
2706
|
-
item:
|
|
2748
|
+
trackIdentifier: h[0]?.track.id,
|
|
2749
|
+
item: h[0]?.getSynchronizationSources()[0]
|
|
2707
2750
|
}, S = {
|
|
2708
2751
|
audio: d,
|
|
2709
2752
|
video: T
|
|
@@ -2713,8 +2756,8 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2713
2756
|
r[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2714
2757
|
r[1]?.getStats() ?? Promise.resolve(void 0),
|
|
2715
2758
|
o?.getStats() ?? Promise.resolve(void 0),
|
|
2716
|
-
|
|
2717
|
-
|
|
2759
|
+
h[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2760
|
+
h[1]?.getStats() ?? Promise.resolve(void 0)
|
|
2718
2761
|
]).then((l) => {
|
|
2719
2762
|
const [
|
|
2720
2763
|
E,
|
|
@@ -2734,22 +2777,22 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2734
2777
|
videoReceiverSecondStats: k
|
|
2735
2778
|
};
|
|
2736
2779
|
});
|
|
2737
|
-
},
|
|
2738
|
-
|
|
2780
|
+
}, Qt = (n) => {
|
|
2781
|
+
c(String(n));
|
|
2739
2782
|
};
|
|
2740
|
-
class
|
|
2783
|
+
class Yt {
|
|
2741
2784
|
events;
|
|
2742
2785
|
setTimeoutRequest;
|
|
2743
|
-
requesterAllStatistics = new x(
|
|
2786
|
+
requesterAllStatistics = new x(Gt);
|
|
2744
2787
|
constructor() {
|
|
2745
|
-
this.events = new O(
|
|
2788
|
+
this.events = new O(Ae), this.setTimeoutRequest = new ee();
|
|
2746
2789
|
}
|
|
2747
2790
|
get requested() {
|
|
2748
2791
|
return this.setTimeoutRequest.requested;
|
|
2749
2792
|
}
|
|
2750
2793
|
start(e, {
|
|
2751
2794
|
interval: t = y,
|
|
2752
|
-
onError: s =
|
|
2795
|
+
onError: s = Qt
|
|
2753
2796
|
} = {}) {
|
|
2754
2797
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
2755
2798
|
this.collectStatistics(e, {
|
|
@@ -2778,10 +2821,10 @@ class Qt {
|
|
|
2778
2821
|
collectStatistics = (e, {
|
|
2779
2822
|
onError: t
|
|
2780
2823
|
}) => {
|
|
2781
|
-
const s =
|
|
2824
|
+
const s = J();
|
|
2782
2825
|
this.requesterAllStatistics.request(e).then((i) => {
|
|
2783
|
-
this.events.trigger("collected",
|
|
2784
|
-
const a =
|
|
2826
|
+
this.events.trigger("collected", xt(i));
|
|
2827
|
+
const a = J() - s;
|
|
2785
2828
|
let o = y;
|
|
2786
2829
|
a > 48 ? o = y * 4 : a > 32 ? o = y * 3 : a > 16 && (o = y * 2), this.start(e, {
|
|
2787
2830
|
onError: t,
|
|
@@ -2792,7 +2835,7 @@ class Qt {
|
|
|
2792
2835
|
});
|
|
2793
2836
|
};
|
|
2794
2837
|
}
|
|
2795
|
-
class
|
|
2838
|
+
class zt {
|
|
2796
2839
|
availableIncomingBitrate;
|
|
2797
2840
|
statsPeerConnection;
|
|
2798
2841
|
callManager;
|
|
@@ -2802,7 +2845,7 @@ class Yt {
|
|
|
2802
2845
|
callManager: e,
|
|
2803
2846
|
apiManager: t
|
|
2804
2847
|
}) {
|
|
2805
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
2848
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Yt(), this.subscribe();
|
|
2806
2849
|
}
|
|
2807
2850
|
get events() {
|
|
2808
2851
|
return this.statsPeerConnection.events;
|
|
@@ -2840,37 +2883,37 @@ class Yt {
|
|
|
2840
2883
|
};
|
|
2841
2884
|
maybeSendStats() {
|
|
2842
2885
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
2843
|
-
|
|
2886
|
+
c("Failed to send stats", e);
|
|
2844
2887
|
});
|
|
2845
2888
|
}
|
|
2846
2889
|
}
|
|
2847
|
-
const
|
|
2890
|
+
const Xt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), Jt = (n) => {
|
|
2848
2891
|
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
|
|
2849
|
-
return
|
|
2850
|
-
},
|
|
2892
|
+
return Xt(s, i);
|
|
2893
|
+
}, Kt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
2851
2894
|
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;
|
|
2852
2895
|
return a - o;
|
|
2853
|
-
}),
|
|
2896
|
+
}), jt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Zt = (n, {
|
|
2854
2897
|
preferredMimeTypesVideoCodecs: e,
|
|
2855
2898
|
excludeMimeTypesVideoCodecs: t
|
|
2856
2899
|
}) => {
|
|
2857
2900
|
try {
|
|
2858
2901
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
2859
|
-
const s =
|
|
2902
|
+
const s = Jt("video"), i = jt(s, t), r = Kt(i, e);
|
|
2860
2903
|
n.setCodecPreferences(r);
|
|
2861
2904
|
}
|
|
2862
2905
|
} catch (s) {
|
|
2863
|
-
|
|
2906
|
+
c("setCodecPreferences error", s);
|
|
2864
2907
|
}
|
|
2865
|
-
},
|
|
2866
|
-
class
|
|
2908
|
+
}, en = (n) => [...n.keys()].map((e) => n.get(e)), tn = (n, e) => en(n).find((t) => t?.type === e), nn = async (n) => n.getStats().then((e) => tn(e, "codec")?.mimeType);
|
|
2909
|
+
class sn {
|
|
2867
2910
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2868
2911
|
async getCodecFromSender(e) {
|
|
2869
|
-
return await
|
|
2912
|
+
return await nn(e) ?? "";
|
|
2870
2913
|
}
|
|
2871
2914
|
}
|
|
2872
|
-
class
|
|
2873
|
-
stackPromises =
|
|
2915
|
+
class rn {
|
|
2916
|
+
stackPromises = ne({
|
|
2874
2917
|
noRunIsNotActual: !0
|
|
2875
2918
|
});
|
|
2876
2919
|
/**
|
|
@@ -2890,34 +2933,34 @@ class sn {
|
|
|
2890
2933
|
*/
|
|
2891
2934
|
async run() {
|
|
2892
2935
|
return this.stackPromises().catch((e) => {
|
|
2893
|
-
|
|
2936
|
+
c("TaskQueue: error", e);
|
|
2894
2937
|
});
|
|
2895
2938
|
}
|
|
2896
2939
|
}
|
|
2897
|
-
class
|
|
2940
|
+
class an {
|
|
2898
2941
|
taskQueue;
|
|
2899
2942
|
onSetParameters;
|
|
2900
2943
|
constructor(e) {
|
|
2901
|
-
this.onSetParameters = e, this.taskQueue = new
|
|
2944
|
+
this.onSetParameters = e, this.taskQueue = new rn();
|
|
2902
2945
|
}
|
|
2903
2946
|
async setEncodingsToSender(e, t) {
|
|
2904
|
-
return this.taskQueue.add(async () =>
|
|
2947
|
+
return this.taskQueue.add(async () => de(e, t, this.onSetParameters));
|
|
2905
2948
|
}
|
|
2906
2949
|
stop() {
|
|
2907
2950
|
this.taskQueue.stop();
|
|
2908
2951
|
}
|
|
2909
2952
|
}
|
|
2910
|
-
const
|
|
2911
|
-
const t =
|
|
2912
|
-
return
|
|
2913
|
-
}, $ = 1,
|
|
2953
|
+
const Re = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), on = 1e6, f = (n) => n * on, Ie = f(0.06), me = f(4), cn = (n) => n <= 64 ? Ie : 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) : me, hn = "av1", dn = (n) => Re(n, hn), ln = 0.6, Y = (n, e) => dn(e) ? n * ln : n, un = (n) => Y(Ie, n), gn = (n) => Y(me, n), Z = (n, e) => {
|
|
2954
|
+
const t = cn(n);
|
|
2955
|
+
return Y(t, e);
|
|
2956
|
+
}, $ = 1, Tn = ({
|
|
2914
2957
|
videoTrack: n,
|
|
2915
2958
|
targetSize: e
|
|
2916
2959
|
}) => {
|
|
2917
2960
|
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? $ : s / e.width, a = i === void 0 ? $ : i / e.height;
|
|
2918
2961
|
return Math.max(r, a, $);
|
|
2919
2962
|
};
|
|
2920
|
-
class
|
|
2963
|
+
class Sn {
|
|
2921
2964
|
ignoreForCodec;
|
|
2922
2965
|
senderFinder;
|
|
2923
2966
|
codecProvider;
|
|
@@ -2950,7 +2993,7 @@ class Tn {
|
|
|
2950
2993
|
if (!i?.track)
|
|
2951
2994
|
return { ...this.resultNoChanged, sender: i };
|
|
2952
2995
|
const r = await this.codecProvider.getCodecFromSender(i);
|
|
2953
|
-
if (
|
|
2996
|
+
if (Re(r, this.ignoreForCodec))
|
|
2954
2997
|
return { ...this.resultNoChanged, sender: i };
|
|
2955
2998
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
2956
2999
|
return this.processSender(
|
|
@@ -2960,7 +3003,7 @@ class Tn {
|
|
|
2960
3003
|
codec: r,
|
|
2961
3004
|
videoTrack: i.track
|
|
2962
3005
|
}
|
|
2963
|
-
).then((
|
|
3006
|
+
).then((h) => ({ ...h, sender: i }));
|
|
2964
3007
|
}
|
|
2965
3008
|
/**
|
|
2966
3009
|
* Обрабатывает отправитель в зависимости от команды управления
|
|
@@ -2970,14 +3013,14 @@ class Tn {
|
|
|
2970
3013
|
async processSender(e, t) {
|
|
2971
3014
|
const { mainCam: s, resolutionMainCam: i } = e;
|
|
2972
3015
|
switch (s) {
|
|
2973
|
-
case
|
|
3016
|
+
case v.PAUSE_MAIN_CAM:
|
|
2974
3017
|
return this.downgradeResolutionSender(t);
|
|
2975
|
-
case
|
|
3018
|
+
case v.RESUME_MAIN_CAM:
|
|
2976
3019
|
return this.setBitrateByTrackResolution(t);
|
|
2977
|
-
case
|
|
3020
|
+
case v.MAX_MAIN_CAM_RESOLUTION:
|
|
2978
3021
|
return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
|
|
2979
|
-
case
|
|
2980
|
-
case
|
|
3022
|
+
case v.ADMIN_STOP_MAIN_CAM:
|
|
3023
|
+
case v.ADMIN_START_MAIN_CAM:
|
|
2981
3024
|
case void 0:
|
|
2982
3025
|
return this.setBitrateByTrackResolution(t);
|
|
2983
3026
|
default:
|
|
@@ -2992,7 +3035,7 @@ class Tn {
|
|
|
2992
3035
|
async downgradeResolutionSender(e) {
|
|
2993
3036
|
const { sender: t, codec: s } = e, i = {
|
|
2994
3037
|
scaleResolutionDownBy: 200,
|
|
2995
|
-
maxBitrate:
|
|
3038
|
+
maxBitrate: un(s)
|
|
2996
3039
|
};
|
|
2997
3040
|
return this.parametersSetter.setEncodingsToSender(t, i);
|
|
2998
3041
|
}
|
|
@@ -3002,7 +3045,7 @@ class Tn {
|
|
|
3002
3045
|
* @returns Promise с результатом
|
|
3003
3046
|
*/
|
|
3004
3047
|
async setBitrateByTrackResolution(e) {
|
|
3005
|
-
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ?
|
|
3048
|
+
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? gn(i) : Z(a, i);
|
|
3006
3049
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
3007
3050
|
scaleResolutionDownBy: 1,
|
|
3008
3051
|
maxBitrate: o
|
|
@@ -3015,27 +3058,27 @@ class Tn {
|
|
|
3015
3058
|
* @returns Promise с результатом
|
|
3016
3059
|
*/
|
|
3017
3060
|
async setResolutionSender(e, t) {
|
|
3018
|
-
const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t,
|
|
3061
|
+
const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, h = {
|
|
3019
3062
|
width: Number(s),
|
|
3020
3063
|
height: Number(i)
|
|
3021
|
-
}, d =
|
|
3064
|
+
}, d = Tn({
|
|
3022
3065
|
videoTrack: a,
|
|
3023
|
-
targetSize:
|
|
3024
|
-
}), T =
|
|
3066
|
+
targetSize: h
|
|
3067
|
+
}), T = Z(h.width, o), S = {
|
|
3025
3068
|
scaleResolutionDownBy: d,
|
|
3026
3069
|
maxBitrate: T
|
|
3027
3070
|
};
|
|
3028
3071
|
return this.parametersSetter.setEncodingsToSender(r, S);
|
|
3029
3072
|
}
|
|
3030
3073
|
}
|
|
3031
|
-
const
|
|
3032
|
-
class
|
|
3074
|
+
const Cn = (n) => n.find((e) => e.track?.kind === "video");
|
|
3075
|
+
class En {
|
|
3033
3076
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
3034
3077
|
findVideoSender(e) {
|
|
3035
|
-
return
|
|
3078
|
+
return Cn(e);
|
|
3036
3079
|
}
|
|
3037
3080
|
}
|
|
3038
|
-
class
|
|
3081
|
+
class An {
|
|
3039
3082
|
currentSender;
|
|
3040
3083
|
originalReplaceTrack;
|
|
3041
3084
|
lastWidth;
|
|
@@ -3048,7 +3091,7 @@ class En {
|
|
|
3048
3091
|
pollIntervalMs: e = 1e3,
|
|
3049
3092
|
maxPollIntervalMs: t
|
|
3050
3093
|
}) {
|
|
3051
|
-
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new
|
|
3094
|
+
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ee();
|
|
3052
3095
|
}
|
|
3053
3096
|
/**
|
|
3054
3097
|
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
@@ -3099,7 +3142,7 @@ class En {
|
|
|
3099
3142
|
this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
|
|
3100
3143
|
}
|
|
3101
3144
|
}
|
|
3102
|
-
class
|
|
3145
|
+
class Nn {
|
|
3103
3146
|
apiManager;
|
|
3104
3147
|
currentHandler;
|
|
3105
3148
|
constructor(e) {
|
|
@@ -3119,7 +3162,7 @@ class An {
|
|
|
3119
3162
|
this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
3120
3163
|
}
|
|
3121
3164
|
}
|
|
3122
|
-
class
|
|
3165
|
+
class Rn {
|
|
3123
3166
|
eventHandler;
|
|
3124
3167
|
senderBalancer;
|
|
3125
3168
|
parametersSetterWithQueue;
|
|
@@ -3131,16 +3174,16 @@ class Nn {
|
|
|
3131
3174
|
onSetParameters: i,
|
|
3132
3175
|
pollIntervalMs: r
|
|
3133
3176
|
} = {}) {
|
|
3134
|
-
this.getConnection = t, this.eventHandler = new
|
|
3177
|
+
this.getConnection = t, this.eventHandler = new Nn(e), this.parametersSetterWithQueue = new an(i), this.senderBalancer = new Sn(
|
|
3135
3178
|
{
|
|
3136
|
-
senderFinder: new
|
|
3137
|
-
codecProvider: new
|
|
3179
|
+
senderFinder: new En(),
|
|
3180
|
+
codecProvider: new sn(),
|
|
3138
3181
|
parametersSetter: this.parametersSetterWithQueue
|
|
3139
3182
|
},
|
|
3140
3183
|
{
|
|
3141
3184
|
ignoreForCodec: s
|
|
3142
3185
|
}
|
|
3143
|
-
), this.trackMonitor = new
|
|
3186
|
+
), this.trackMonitor = new An({ pollIntervalMs: r });
|
|
3144
3187
|
}
|
|
3145
3188
|
/**
|
|
3146
3189
|
* Подписывается на события управления главной камерой
|
|
@@ -3171,7 +3214,7 @@ class Nn {
|
|
|
3171
3214
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
3172
3215
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
3173
3216
|
this.balance().catch((s) => {
|
|
3174
|
-
|
|
3217
|
+
c("balance on track change: error", s);
|
|
3175
3218
|
});
|
|
3176
3219
|
}), t;
|
|
3177
3220
|
}
|
|
@@ -3181,17 +3224,17 @@ class Nn {
|
|
|
3181
3224
|
*/
|
|
3182
3225
|
handleMainCamControl = (e) => {
|
|
3183
3226
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
3184
|
-
|
|
3227
|
+
c("handleMainCamControl: error", t);
|
|
3185
3228
|
});
|
|
3186
3229
|
};
|
|
3187
3230
|
}
|
|
3188
|
-
const
|
|
3231
|
+
const pe = [
|
|
3189
3232
|
"balancing-scheduled",
|
|
3190
3233
|
"balancing-started",
|
|
3191
3234
|
"balancing-stopped",
|
|
3192
3235
|
"parameters-updated"
|
|
3193
3236
|
];
|
|
3194
|
-
class
|
|
3237
|
+
class In {
|
|
3195
3238
|
isBalancingActive = !1;
|
|
3196
3239
|
events;
|
|
3197
3240
|
callManager;
|
|
@@ -3199,7 +3242,7 @@ class Rn {
|
|
|
3199
3242
|
videoSendingBalancer;
|
|
3200
3243
|
startBalancingTimer;
|
|
3201
3244
|
constructor(e, t, s = {}) {
|
|
3202
|
-
this.events = new O(
|
|
3245
|
+
this.events = new O(pe), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new Rn(
|
|
3203
3246
|
t,
|
|
3204
3247
|
() => e.connection,
|
|
3205
3248
|
{
|
|
@@ -3261,7 +3304,7 @@ class Rn {
|
|
|
3261
3304
|
scheduleBalancingStart() {
|
|
3262
3305
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
3263
3306
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
3264
|
-
|
|
3307
|
+
c("startBalancing: error", e);
|
|
3265
3308
|
});
|
|
3266
3309
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
3267
3310
|
}
|
|
@@ -3269,17 +3312,21 @@ class Rn {
|
|
|
3269
3312
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
3270
3313
|
}
|
|
3271
3314
|
}
|
|
3272
|
-
const
|
|
3273
|
-
|
|
3315
|
+
const mn = 1e6, pn = Ce.map((n) => `auto-connect:${n}`), _n = ge.map((n) => `connection:${n}`), Mn = ae.map((n) => `call:${n}`), fn = se.map((n) => `api:${n}`), vn = Ee.map((n) => `incoming-call:${n}`), Pn = le.map((n) => `presentation:${n}`), On = Ae.map((n) => `stats:${n}`), bn = pe.map((n) => `video-balancer:${n}`), Dn = [
|
|
3316
|
+
"disconnected-from-out-of-call",
|
|
3317
|
+
"connected-with-configuration-from-out-of-call"
|
|
3318
|
+
], yn = [
|
|
3274
3319
|
...pn,
|
|
3275
3320
|
..._n,
|
|
3276
3321
|
...Mn,
|
|
3277
3322
|
...fn,
|
|
3278
|
-
...Pn,
|
|
3279
3323
|
...vn,
|
|
3280
|
-
...
|
|
3324
|
+
...Pn,
|
|
3325
|
+
...On,
|
|
3326
|
+
...bn,
|
|
3327
|
+
...Dn
|
|
3281
3328
|
];
|
|
3282
|
-
class
|
|
3329
|
+
class Gn {
|
|
3283
3330
|
events;
|
|
3284
3331
|
connectionManager;
|
|
3285
3332
|
connectionQueueManager;
|
|
@@ -3298,25 +3345,25 @@ class Hn {
|
|
|
3298
3345
|
videoBalancerOptions: i,
|
|
3299
3346
|
autoConnectorOptions: r
|
|
3300
3347
|
} = {}) {
|
|
3301
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new O(
|
|
3348
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new O(yn), this.connectionManager = new mt({ JsSIP: e }), this.connectionQueueManager = new pt({
|
|
3302
3349
|
connectionManager: this.connectionManager
|
|
3303
|
-
}), this.callManager = new
|
|
3350
|
+
}), this.callManager = new ze(), this.apiManager = new ke({
|
|
3304
3351
|
connectionManager: this.connectionManager,
|
|
3305
3352
|
callManager: this.callManager
|
|
3306
|
-
}), this.incomingCallManager = new
|
|
3353
|
+
}), this.incomingCallManager = new $t(this.connectionManager), this.presentationManager = new ht({
|
|
3307
3354
|
callManager: this.callManager,
|
|
3308
|
-
maxBitrate:
|
|
3309
|
-
}), this.statsManager = new
|
|
3355
|
+
maxBitrate: mn
|
|
3356
|
+
}), this.statsManager = new zt({
|
|
3310
3357
|
callManager: this.callManager,
|
|
3311
3358
|
apiManager: this.apiManager
|
|
3312
|
-
}), this.autoConnectorManager = new
|
|
3359
|
+
}), this.autoConnectorManager = new Bt(
|
|
3313
3360
|
{
|
|
3314
3361
|
connectionQueueManager: this.connectionQueueManager,
|
|
3315
3362
|
connectionManager: this.connectionManager,
|
|
3316
3363
|
callManager: this.callManager
|
|
3317
3364
|
},
|
|
3318
3365
|
r
|
|
3319
|
-
), this.videoSendingBalancerManager = new
|
|
3366
|
+
), this.videoSendingBalancerManager = new In(
|
|
3320
3367
|
this.callManager,
|
|
3321
3368
|
this.apiManager,
|
|
3322
3369
|
i
|
|
@@ -3493,14 +3540,24 @@ class Hn {
|
|
|
3493
3540
|
async askPermissionToEnableCam(...e) {
|
|
3494
3541
|
return this.apiManager.askPermissionToEnableCam(...e);
|
|
3495
3542
|
}
|
|
3543
|
+
subscribeDisconnectedFromOutOfCall() {
|
|
3544
|
+
this.connectionManager.on("disconnected", () => {
|
|
3545
|
+
this.isCallActive || this.events.trigger("disconnected-from-out-of-call", {});
|
|
3546
|
+
});
|
|
3547
|
+
}
|
|
3548
|
+
subscribeConnectedWithConfigurationFromOutOfCall() {
|
|
3549
|
+
this.connectionManager.on("connected-with-configuration", (e) => {
|
|
3550
|
+
this.isCallActive || this.events.trigger("connected-with-configuration-from-out-of-call", e);
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3496
3553
|
setCodecPreferences(e) {
|
|
3497
|
-
|
|
3554
|
+
Zt(e, {
|
|
3498
3555
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
3499
3556
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
3500
3557
|
});
|
|
3501
3558
|
}
|
|
3502
3559
|
subscribe() {
|
|
3503
|
-
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);
|
|
3560
|
+
this.bridgeEvents("auto-connect", this.autoConnectorManager), this.bridgeEvents("connection", this.connectionManager), this.bridgeEvents("call", this.callManager), this.bridgeEvents("api", this.apiManager), this.bridgeEvents("incoming-call", this.incomingCallManager), this.bridgeEvents("presentation", this.presentationManager), this.bridgeEvents("stats", this.statsManager), this.bridgeEvents("video-balancer", this.videoSendingBalancerManager), this.subscribeDisconnectedFromOutOfCall(), this.subscribeConnectedWithConfigurationFromOutOfCall();
|
|
3504
3561
|
}
|
|
3505
3562
|
bridgeEvents = (e, t) => {
|
|
3506
3563
|
t.events.eachTriggers((s, i) => {
|
|
@@ -3514,19 +3571,19 @@ class Hn {
|
|
|
3514
3571
|
};
|
|
3515
3572
|
}
|
|
3516
3573
|
export {
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3574
|
+
oe as E,
|
|
3575
|
+
He as O,
|
|
3576
|
+
Gn as S,
|
|
3577
|
+
rt as a,
|
|
3578
|
+
Fe as b,
|
|
3579
|
+
xn as c,
|
|
3580
|
+
Hn as d,
|
|
3581
|
+
Vn as e,
|
|
3525
3582
|
A as f,
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3583
|
+
Yt as g,
|
|
3584
|
+
Nt as h,
|
|
3585
|
+
nn as i,
|
|
3586
|
+
c as l,
|
|
3530
3587
|
B as p,
|
|
3531
|
-
|
|
3588
|
+
de as s
|
|
3532
3589
|
};
|