sip-connector 18.0.0 → 19.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -29
- package/dist/@SipConnector-DNQcZdY9.cjs +1 -0
- package/dist/{@SipConnector-UTHCoMXw.js → @SipConnector-Wp8bjnnP.js} +832 -473
- package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +41 -0
- package/dist/AutoConnectorManager/AttemptsState.d.ts +21 -0
- package/dist/AutoConnectorManager/CheckTelephonyRequester.d.ts +19 -0
- package/dist/AutoConnectorManager/PingServerIfNotActiveCallRequester.d.ts +18 -0
- package/dist/AutoConnectorManager/PingServerRequester.d.ts +13 -0
- package/dist/AutoConnectorManager/RegistrationFailedOutOfCallSubscriber.d.ts +18 -0
- package/dist/AutoConnectorManager/eventNames.d.ts +18 -0
- package/dist/AutoConnectorManager/index.d.ts +3 -0
- package/dist/AutoConnectorManager/types.d.ts +22 -0
- package/dist/AutoConnectorManager/utils/errors.d.ts +2 -0
- package/dist/AutoConnectorManager/utils/index.d.ts +1 -0
- package/dist/CallManager/@CallManager.d.ts +3 -0
- package/dist/CallManager/eventNames.d.ts +6 -2
- package/dist/ConnectionManager/@ConnectionManager.d.ts +10 -1
- package/dist/ConnectionManager/eventNames.d.ts +6 -2
- package/dist/ConnectionManager/index.d.ts +1 -0
- package/dist/ConnectionManager/utils/errors.d.ts +2 -0
- package/dist/ConnectionManager/utils/index.d.ts +2 -0
- package/dist/ConnectionManager/utils/resolveParameters.d.ts +2 -0
- package/dist/ConnectionQueueManager/@ConnectionQueueManager.d.ts +1 -7
- package/dist/ConnectionQueueManager/index.d.ts +1 -0
- package/dist/SipConnector/@SipConnector.d.ts +8 -4
- package/dist/SipConnector/eventNames.d.ts +1 -1
- package/dist/SipConnectorFacade/@SipConnectorFacade.d.ts +16 -10
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +227 -213
- package/package.json +5 -5
- package/dist/@SipConnector-CFYT0HQB.cjs +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Events as
|
|
1
|
+
import { Events as U, TypedEvents as k } from "events-constructor";
|
|
2
2
|
import x from "debug";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { CancelableRequest as G, isCanceledError as _e } from "@krivega/cancelable-promise";
|
|
4
|
+
import { resolveRequesterByTimeout as Me, requesterByTimeoutsWithFailCalls as ve, DelayRequester as fe, hasCanceledError as Pe, SetTimeoutRequest as Z } from "@krivega/timeout-requester";
|
|
5
|
+
import { hasCanceledError as Oe, repeatedCallsAsync as ee } from "repeated-calls";
|
|
6
|
+
import { setup as De, createActor as ye } from "xstate";
|
|
7
|
+
import { createStackPromises as te, isPromiseIsNotActualError as be } from "stack-promises";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
const
|
|
11
|
-
x.enable(
|
|
12
|
-
},
|
|
13
|
-
x.enable(`-${
|
|
14
|
-
},
|
|
15
|
-
var
|
|
16
|
-
const
|
|
10
|
+
const Q = "sip-connector", d = x(Q), Hn = () => {
|
|
11
|
+
x.enable(Q);
|
|
12
|
+
}, xn = () => {
|
|
13
|
+
x.enable(`-${Q}`);
|
|
14
|
+
}, we = "Error decline with 603", Ue = 1006, Le = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Ue, Be = (n) => n.message === we;
|
|
15
|
+
var l = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(l || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), q = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(q || {}), f = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.RESTART = "application/vinteo.webrtc.restart", n))(f || {}), _ = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(_ || {}), v = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(v || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(W || {}), H = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(H || {}), Fe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Fe || {}), u = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n.RESTART = "restart", n))(u || {});
|
|
16
|
+
const ne = [
|
|
17
17
|
"participation:accepting-word-request",
|
|
18
18
|
"participation:cancelling-word-request",
|
|
19
19
|
"participant:move-request-to-stream",
|
|
@@ -43,8 +43,8 @@ const Z = [
|
|
|
43
43
|
"newDTMF",
|
|
44
44
|
"restart"
|
|
45
45
|
];
|
|
46
|
-
var
|
|
47
|
-
class
|
|
46
|
+
var p = /* @__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))(p || {});
|
|
47
|
+
class ke {
|
|
48
48
|
events;
|
|
49
49
|
connectionManager;
|
|
50
50
|
callManager;
|
|
@@ -52,13 +52,13 @@ class ve {
|
|
|
52
52
|
connectionManager: e,
|
|
53
53
|
callManager: t
|
|
54
54
|
}) {
|
|
55
|
-
this.connectionManager = e, this.callManager = t, this.events = new
|
|
55
|
+
this.connectionManager = e, this.callManager = t, this.events = new U(ne), this.subscribe();
|
|
56
56
|
}
|
|
57
57
|
async waitChannels() {
|
|
58
|
-
return this.wait(
|
|
58
|
+
return this.wait(u.CHANNELS);
|
|
59
59
|
}
|
|
60
60
|
async waitSyncMediaState() {
|
|
61
|
-
return this.wait(
|
|
61
|
+
return this.wait(u.ADMIN_FORCE_SYNC_MEDIA_STATE);
|
|
62
62
|
}
|
|
63
63
|
async sendDTMF(e) {
|
|
64
64
|
return new Promise((t, s) => {
|
|
@@ -77,19 +77,19 @@ class ve {
|
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
80
|
-
const s = this.getEstablishedRTCSessionProtected(), i = `${
|
|
80
|
+
const s = this.getEstablishedRTCSessionProtected(), i = `${l.INPUT_CHANNELS}: ${e}`, r = `${l.OUTPUT_CHANNELS}: ${t}`, a = [
|
|
81
81
|
i,
|
|
82
82
|
r
|
|
83
83
|
];
|
|
84
|
-
return s.sendInfo(
|
|
84
|
+
return s.sendInfo(_.CHANNELS, void 0, { extraHeaders: a });
|
|
85
85
|
}
|
|
86
86
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
87
|
-
const i = this.getEstablishedRTCSessionProtected(), r = `${
|
|
87
|
+
const i = this.getEstablishedRTCSessionProtected(), r = `${l.MEDIA_STATE}: currentstate`, a = `${l.MAIN_CAM_STATE}: ${Number(e)}`, o = `${l.MIC_STATE}: ${Number(t)}`, c = [
|
|
88
88
|
r,
|
|
89
89
|
a,
|
|
90
90
|
o
|
|
91
91
|
];
|
|
92
|
-
return i.sendInfo(
|
|
92
|
+
return i.sendInfo(_.MEDIA_STATE, void 0, {
|
|
93
93
|
noTerminateWhenError: !0,
|
|
94
94
|
...s,
|
|
95
95
|
extraHeaders: c
|
|
@@ -98,15 +98,15 @@ class ve {
|
|
|
98
98
|
async sendStats({
|
|
99
99
|
availableIncomingBitrate: e
|
|
100
100
|
}) {
|
|
101
|
-
const t = this.getEstablishedRTCSessionProtected(), i = [`${
|
|
102
|
-
return t.sendInfo(
|
|
101
|
+
const t = this.getEstablishedRTCSessionProtected(), i = [`${l.AVAILABLE_INCOMING_BITRATE}: ${e}`];
|
|
102
|
+
return t.sendInfo(_.STATS, void 0, {
|
|
103
103
|
noTerminateWhenError: !0,
|
|
104
104
|
extraHeaders: i
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
async sendRefusalToTurnOn(e, t = {}) {
|
|
108
|
-
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${
|
|
109
|
-
return s.sendInfo(
|
|
108
|
+
const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${l.MEDIA_TYPE}: ${a}`];
|
|
109
|
+
return s.sendInfo(_.REFUSAL, void 0, {
|
|
110
110
|
noTerminateWhenError: !0,
|
|
111
111
|
...t,
|
|
112
112
|
extraHeaders: c
|
|
@@ -119,38 +119,38 @@ class ve {
|
|
|
119
119
|
return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
|
|
120
120
|
}
|
|
121
121
|
async sendMustStopPresentationP2P() {
|
|
122
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
123
|
-
extraHeaders: [
|
|
122
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
|
|
123
|
+
extraHeaders: [l.MUST_STOP_PRESENTATION_P2P]
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
async sendStoppedPresentationP2P() {
|
|
127
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
128
|
-
extraHeaders: [
|
|
127
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
|
|
128
|
+
extraHeaders: [l.STOP_PRESENTATION_P2P]
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
async sendStoppedPresentation() {
|
|
132
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
133
|
-
extraHeaders: [
|
|
132
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
|
|
133
|
+
extraHeaders: [l.STOP_PRESENTATION]
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
async askPermissionToStartPresentationP2P() {
|
|
137
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
138
|
-
extraHeaders: [
|
|
137
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
|
|
138
|
+
extraHeaders: [l.START_PRESENTATION_P2P]
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
async askPermissionToStartPresentation() {
|
|
142
|
-
await this.getEstablishedRTCSessionProtected().sendInfo(
|
|
143
|
-
extraHeaders: [
|
|
142
|
+
await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
|
|
143
|
+
extraHeaders: [l.START_PRESENTATION]
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
async askPermissionToEnableCam(e = {}) {
|
|
147
|
-
const t = this.getEstablishedRTCSessionProtected(), s = [
|
|
148
|
-
return t.sendInfo(
|
|
147
|
+
const t = this.getEstablishedRTCSessionProtected(), s = [l.ENABLE_MAIN_CAM];
|
|
148
|
+
return t.sendInfo(_.MAIN_CAM, void 0, {
|
|
149
149
|
noTerminateWhenError: !0,
|
|
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
|
}
|
|
@@ -189,110 +189,110 @@ class ve {
|
|
|
189
189
|
};
|
|
190
190
|
maybeHandleNotify = (e) => {
|
|
191
191
|
try {
|
|
192
|
-
const t = e.getHeader(
|
|
192
|
+
const t = e.getHeader(l.NOTIFY);
|
|
193
193
|
if (t) {
|
|
194
194
|
const s = JSON.parse(t);
|
|
195
195
|
this.handleNotify(s);
|
|
196
196
|
}
|
|
197
197
|
} catch (t) {
|
|
198
|
-
|
|
198
|
+
d("error parse notify", t);
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
handleNotify = (e) => {
|
|
202
202
|
switch (e.cmd) {
|
|
203
|
-
case
|
|
203
|
+
case p.CHANNELS: {
|
|
204
204
|
const t = e;
|
|
205
205
|
this.triggerChannelsNotify(t);
|
|
206
206
|
break;
|
|
207
207
|
}
|
|
208
|
-
case
|
|
208
|
+
case p.WEBCAST_STARTED: {
|
|
209
209
|
const t = e;
|
|
210
210
|
this.triggerWebcastStartedNotify(t);
|
|
211
211
|
break;
|
|
212
212
|
}
|
|
213
|
-
case
|
|
213
|
+
case p.WEBCAST_STOPPED: {
|
|
214
214
|
const t = e;
|
|
215
215
|
this.triggerWebcastStoppedNotify(t);
|
|
216
216
|
break;
|
|
217
217
|
}
|
|
218
|
-
case
|
|
218
|
+
case p.ADDED_TO_LIST_MODERATORS: {
|
|
219
219
|
const t = e;
|
|
220
220
|
this.triggerAddedToListModeratorsNotify(t);
|
|
221
221
|
break;
|
|
222
222
|
}
|
|
223
|
-
case
|
|
223
|
+
case p.REMOVED_FROM_LIST_MODERATORS: {
|
|
224
224
|
const t = e;
|
|
225
225
|
this.triggerRemovedFromListModeratorsNotify(t);
|
|
226
226
|
break;
|
|
227
227
|
}
|
|
228
|
-
case
|
|
228
|
+
case p.ACCEPTING_WORD_REQUEST: {
|
|
229
229
|
const t = e;
|
|
230
230
|
this.triggerParticipationAcceptingWordRequest(t);
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
|
-
case
|
|
233
|
+
case p.CANCELLING_WORD_REQUEST: {
|
|
234
234
|
const t = e;
|
|
235
235
|
this.triggerParticipationCancellingWordRequest(t);
|
|
236
236
|
break;
|
|
237
237
|
}
|
|
238
|
-
case
|
|
238
|
+
case p.MOVE_REQUEST_TO_STREAM: {
|
|
239
239
|
const t = e;
|
|
240
240
|
this.triggerParticipantMoveRequestToStream(t);
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
|
-
case
|
|
243
|
+
case p.ACCOUNT_CHANGED: {
|
|
244
244
|
this.triggerAccountChangedNotify();
|
|
245
245
|
break;
|
|
246
246
|
}
|
|
247
|
-
case
|
|
247
|
+
case p.ACCOUNT_DELETED: {
|
|
248
248
|
this.triggerAccountDeletedNotify();
|
|
249
249
|
break;
|
|
250
250
|
}
|
|
251
|
-
case
|
|
251
|
+
case p.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
|
|
252
252
|
const t = e;
|
|
253
253
|
this.triggerConferenceParticipantTokenIssued(t);
|
|
254
254
|
break;
|
|
255
255
|
}
|
|
256
256
|
default:
|
|
257
|
-
|
|
257
|
+
d("unknown cmd", e);
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
handleNewInfo = (e) => {
|
|
261
261
|
const { originator: t } = e;
|
|
262
262
|
if (t !== "remote")
|
|
263
263
|
return;
|
|
264
|
-
const { request: s } = e, i = s, r = i.getHeader(
|
|
264
|
+
const { request: s } = e, i = s, r = i.getHeader(l.CONTENT_TYPE);
|
|
265
265
|
if (r !== void 0)
|
|
266
266
|
switch (r) {
|
|
267
|
-
case
|
|
267
|
+
case f.ENTER_ROOM: {
|
|
268
268
|
this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
|
|
269
269
|
break;
|
|
270
270
|
}
|
|
271
|
-
case
|
|
271
|
+
case f.NOTIFY: {
|
|
272
272
|
this.maybeHandleNotify(i);
|
|
273
273
|
break;
|
|
274
274
|
}
|
|
275
|
-
case
|
|
275
|
+
case f.SHARE_STATE: {
|
|
276
276
|
this.triggerShareState(i);
|
|
277
277
|
break;
|
|
278
278
|
}
|
|
279
|
-
case
|
|
279
|
+
case f.MAIN_CAM: {
|
|
280
280
|
this.triggerMainCamControl(i);
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
|
-
case
|
|
283
|
+
case f.MIC: {
|
|
284
284
|
this.triggerMicControl(i);
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
|
-
case
|
|
287
|
+
case f.USE_LICENSE: {
|
|
288
288
|
this.triggerUseLicense(i);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
|
-
case
|
|
291
|
+
case f.PARTICIPANT_STATE: {
|
|
292
292
|
this.maybeTriggerParticipantMoveRequest(i);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
|
-
case
|
|
295
|
+
case f.RESTART: {
|
|
296
296
|
this.triggerRestart(i);
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
@@ -303,7 +303,7 @@ class ve {
|
|
|
303
303
|
inputChannels: t,
|
|
304
304
|
outputChannels: s
|
|
305
305
|
};
|
|
306
|
-
this.events.trigger(
|
|
306
|
+
this.events.trigger(u.CHANNELS_NOTIFY, i);
|
|
307
307
|
};
|
|
308
308
|
triggerWebcastStartedNotify = ({
|
|
309
309
|
body: { conference: e, type: t }
|
|
@@ -312,7 +312,7 @@ class ve {
|
|
|
312
312
|
conference: e,
|
|
313
313
|
type: t
|
|
314
314
|
};
|
|
315
|
-
this.events.trigger(
|
|
315
|
+
this.events.trigger(u.WEBCAST_STARTED, s);
|
|
316
316
|
};
|
|
317
317
|
triggerWebcastStoppedNotify = ({
|
|
318
318
|
body: { conference: e, type: t }
|
|
@@ -321,7 +321,7 @@ class ve {
|
|
|
321
321
|
conference: e,
|
|
322
322
|
type: t
|
|
323
323
|
};
|
|
324
|
-
this.events.trigger(
|
|
324
|
+
this.events.trigger(u.WEBCAST_STOPPED, s);
|
|
325
325
|
};
|
|
326
326
|
triggerAddedToListModeratorsNotify = ({
|
|
327
327
|
conference: e
|
|
@@ -330,7 +330,7 @@ class ve {
|
|
|
330
330
|
conference: e
|
|
331
331
|
};
|
|
332
332
|
this.events.trigger(
|
|
333
|
-
|
|
333
|
+
u.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
|
|
334
334
|
t
|
|
335
335
|
);
|
|
336
336
|
};
|
|
@@ -341,7 +341,7 @@ class ve {
|
|
|
341
341
|
conference: e
|
|
342
342
|
};
|
|
343
343
|
this.events.trigger(
|
|
344
|
-
|
|
344
|
+
u.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
|
|
345
345
|
t
|
|
346
346
|
);
|
|
347
347
|
};
|
|
@@ -351,7 +351,7 @@ class ve {
|
|
|
351
351
|
const t = {
|
|
352
352
|
conference: e
|
|
353
353
|
};
|
|
354
|
-
this.events.trigger(
|
|
354
|
+
this.events.trigger(u.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
|
|
355
355
|
};
|
|
356
356
|
triggerParticipationCancellingWordRequest = ({
|
|
357
357
|
body: { conference: e }
|
|
@@ -359,7 +359,7 @@ class ve {
|
|
|
359
359
|
const t = {
|
|
360
360
|
conference: e
|
|
361
361
|
};
|
|
362
|
-
this.events.trigger(
|
|
362
|
+
this.events.trigger(u.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
|
|
363
363
|
};
|
|
364
364
|
triggerParticipantMoveRequestToStream = ({
|
|
365
365
|
body: { conference: e }
|
|
@@ -367,13 +367,13 @@ class ve {
|
|
|
367
367
|
const t = {
|
|
368
368
|
conference: e
|
|
369
369
|
};
|
|
370
|
-
this.events.trigger(
|
|
370
|
+
this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
|
|
371
371
|
};
|
|
372
372
|
triggerAccountChangedNotify = () => {
|
|
373
|
-
this.events.trigger(
|
|
373
|
+
this.events.trigger(u.ACCOUNT_CHANGED, void 0);
|
|
374
374
|
};
|
|
375
375
|
triggerAccountDeletedNotify = () => {
|
|
376
|
-
this.events.trigger(
|
|
376
|
+
this.events.trigger(u.ACCOUNT_DELETED, void 0);
|
|
377
377
|
};
|
|
378
378
|
triggerConferenceParticipantTokenIssued = ({
|
|
379
379
|
body: { conference: e, participant: t, jwt: s }
|
|
@@ -384,84 +384,84 @@ class ve {
|
|
|
384
384
|
jwt: s
|
|
385
385
|
};
|
|
386
386
|
this.events.trigger(
|
|
387
|
-
|
|
387
|
+
u.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
|
|
388
388
|
i
|
|
389
389
|
);
|
|
390
390
|
};
|
|
391
391
|
maybeTriggerChannels = (e) => {
|
|
392
|
-
const t = e.getHeader(
|
|
392
|
+
const t = e.getHeader(l.INPUT_CHANNELS), s = e.getHeader(l.OUTPUT_CHANNELS);
|
|
393
393
|
if (t && s) {
|
|
394
394
|
const i = {
|
|
395
395
|
inputChannels: t,
|
|
396
396
|
outputChannels: s
|
|
397
397
|
};
|
|
398
|
-
this.events.trigger(
|
|
398
|
+
this.events.trigger(u.CHANNELS, i);
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
triggerEnterRoom = (e) => {
|
|
402
|
-
const t = e.getHeader(
|
|
403
|
-
this.events.trigger(
|
|
402
|
+
const t = e.getHeader(l.CONTENT_ENTER_ROOM), s = e.getHeader(l.PARTICIPANT_NAME);
|
|
403
|
+
this.events.trigger(u.ENTER_ROOM, { room: t, participantName: s });
|
|
404
404
|
};
|
|
405
405
|
triggerShareState = (e) => {
|
|
406
|
-
const t = e.getHeader(
|
|
406
|
+
const t = e.getHeader(l.CONTENT_SHARE_STATE);
|
|
407
407
|
if (t !== void 0)
|
|
408
408
|
switch (t) {
|
|
409
|
-
case
|
|
410
|
-
this.events.trigger(
|
|
409
|
+
case B.AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
410
|
+
this.events.trigger(u.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
411
411
|
break;
|
|
412
412
|
}
|
|
413
|
-
case
|
|
414
|
-
this.events.trigger(
|
|
413
|
+
case B.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
414
|
+
this.events.trigger(u.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
|
-
case
|
|
418
|
-
this.events.trigger(
|
|
417
|
+
case B.MUST_STOP_PRESENTATION: {
|
|
418
|
+
this.events.trigger(u.MUST_STOP_PRESENTATION, void 0);
|
|
419
419
|
break;
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
};
|
|
423
423
|
maybeTriggerParticipantMoveRequest = (e) => {
|
|
424
|
-
const t = e.getHeader(
|
|
425
|
-
t ===
|
|
424
|
+
const t = e.getHeader(l.CONTENT_PARTICIPANT_STATE);
|
|
425
|
+
t === q.SPECTATOR && this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === q.PARTICIPANT && this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
|
|
426
426
|
};
|
|
427
427
|
triggerMainCamControl = (e) => {
|
|
428
|
-
const t = e.getHeader(
|
|
429
|
-
if (t ===
|
|
430
|
-
this.events.trigger(
|
|
428
|
+
const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC), i = s === H.ADMIN_SYNC_FORCED;
|
|
429
|
+
if (t === v.ADMIN_START_MAIN_CAM) {
|
|
430
|
+
this.events.trigger(u.ADMIN_START_MAIN_CAM, { isSyncForced: i });
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
|
-
if (t ===
|
|
434
|
-
this.events.trigger(
|
|
433
|
+
if (t === v.ADMIN_STOP_MAIN_CAM) {
|
|
434
|
+
this.events.trigger(u.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
|
|
435
435
|
return;
|
|
436
436
|
}
|
|
437
|
-
(t ===
|
|
438
|
-
const r = e.getHeader(
|
|
439
|
-
this.events.trigger(
|
|
437
|
+
(t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(u.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
|
|
438
|
+
const r = e.getHeader(l.MAIN_CAM_RESOLUTION);
|
|
439
|
+
this.events.trigger(u.MAIN_CAM_CONTROL, {
|
|
440
440
|
mainCam: t,
|
|
441
441
|
resolutionMainCam: r
|
|
442
442
|
});
|
|
443
443
|
};
|
|
444
444
|
triggerMicControl = (e) => {
|
|
445
|
-
const t = e.getHeader(
|
|
446
|
-
t ===
|
|
445
|
+
const t = e.getHeader(l.MIC), i = e.getHeader(l.MEDIA_SYNC) === H.ADMIN_SYNC_FORCED;
|
|
446
|
+
t === W.ADMIN_START_MIC ? this.events.trigger(u.ADMIN_START_MIC, { isSyncForced: i }) : t === W.ADMIN_STOP_MIC && this.events.trigger(u.ADMIN_STOP_MIC, { isSyncForced: i });
|
|
447
447
|
};
|
|
448
448
|
triggerUseLicense = (e) => {
|
|
449
|
-
const t = e.getHeader(
|
|
450
|
-
this.events.trigger(
|
|
449
|
+
const t = e.getHeader(l.CONTENT_USE_LICENSE);
|
|
450
|
+
this.events.trigger(u.USE_LICENSE, t);
|
|
451
451
|
};
|
|
452
452
|
triggerRestart = (e) => {
|
|
453
453
|
const t = e.getHeader(
|
|
454
|
-
|
|
454
|
+
l.TRACKS_DIRECTION
|
|
455
455
|
), s = Number(
|
|
456
|
-
e.getHeader(
|
|
456
|
+
e.getHeader(l.AUDIO_TRACK_COUNT)
|
|
457
457
|
), i = Number(
|
|
458
|
-
e.getHeader(
|
|
458
|
+
e.getHeader(l.VIDEO_TRACK_COUNT)
|
|
459
459
|
), r = { tracksDirection: t, audioTrackCount: s, videoTrackCount: i };
|
|
460
|
-
this.events.trigger(
|
|
460
|
+
this.events.trigger(u.RESTART, r);
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
|
-
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))(N || {}),
|
|
464
|
-
const
|
|
463
|
+
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 || {}), $e = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($e || {});
|
|
464
|
+
const se = [
|
|
465
465
|
"peerconnection",
|
|
466
466
|
"connecting",
|
|
467
467
|
"sending",
|
|
@@ -488,18 +488,19 @@ const ee = [
|
|
|
488
488
|
"peerconnection:createanswerfailed",
|
|
489
489
|
"peerconnection:setlocaldescriptionfailed",
|
|
490
490
|
"peerconnection:setremotedescriptionfailed"
|
|
491
|
-
],
|
|
491
|
+
], Ve = [
|
|
492
492
|
"peerconnection:confirmed",
|
|
493
493
|
"peerconnection:ontrack",
|
|
494
|
-
"ended:fromserver"
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
...
|
|
498
|
-
|
|
494
|
+
"ended:fromserver",
|
|
495
|
+
"call-status-changed"
|
|
496
|
+
], ie = [
|
|
497
|
+
...se,
|
|
498
|
+
...Ve
|
|
499
|
+
], qe = (n, e) => {
|
|
499
500
|
n.getVideoTracks().forEach((s) => {
|
|
500
501
|
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
501
502
|
});
|
|
502
|
-
},
|
|
503
|
+
}, F = (n, {
|
|
503
504
|
directionVideo: e,
|
|
504
505
|
directionAudio: t,
|
|
505
506
|
contentHint: s
|
|
@@ -507,16 +508,16 @@ const ee = [
|
|
|
507
508
|
if (!n || e === "recvonly" && t === "recvonly")
|
|
508
509
|
return;
|
|
509
510
|
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
|
|
510
|
-
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" &&
|
|
511
|
+
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && qe(o, s), o;
|
|
511
512
|
};
|
|
512
|
-
function
|
|
513
|
+
function We(n) {
|
|
513
514
|
return (e) => `sip:${e}@${n}`;
|
|
514
515
|
}
|
|
515
|
-
const
|
|
516
|
+
const He = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, re = (n) => n.trim().replaceAll(" ", "_"), xe = He(1e5, 99999999), Ge = (n) => n.some((t) => {
|
|
516
517
|
const { kind: s } = t;
|
|
517
518
|
return s === "video";
|
|
518
519
|
});
|
|
519
|
-
class
|
|
520
|
+
class Qe {
|
|
520
521
|
isPendingCall = !1;
|
|
521
522
|
isPendingAnswer = !1;
|
|
522
523
|
rtcSession;
|
|
@@ -527,8 +528,8 @@ class Le {
|
|
|
527
528
|
this.events = e;
|
|
528
529
|
}
|
|
529
530
|
}
|
|
530
|
-
var
|
|
531
|
-
class
|
|
531
|
+
var ae = /* @__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))(ae || {});
|
|
532
|
+
class Ye {
|
|
532
533
|
remoteStreams = {};
|
|
533
534
|
reset() {
|
|
534
535
|
this.remoteStreams = {};
|
|
@@ -557,8 +558,8 @@ class Be {
|
|
|
557
558
|
return e.map((t) => this.generateAudioStream(t));
|
|
558
559
|
}
|
|
559
560
|
}
|
|
560
|
-
class
|
|
561
|
-
remoteStreamsManager = new
|
|
561
|
+
class ze extends Qe {
|
|
562
|
+
remoteStreamsManager = new Ye();
|
|
562
563
|
disposers = /* @__PURE__ */ new Set();
|
|
563
564
|
constructor(e) {
|
|
564
565
|
super(e), e.on(N.FAILED, this.handleEnded), e.on(N.ENDED, this.handleEnded);
|
|
@@ -582,28 +583,28 @@ class ke extends Le {
|
|
|
582
583
|
ontrack: a,
|
|
583
584
|
iceServers: o,
|
|
584
585
|
directionVideo: c,
|
|
585
|
-
directionAudio:
|
|
586
|
-
contentHint:
|
|
587
|
-
offerToReceiveAudio:
|
|
588
|
-
offerToReceiveVideo:
|
|
589
|
-
degradationPreference:
|
|
586
|
+
directionAudio: h,
|
|
587
|
+
contentHint: T,
|
|
588
|
+
offerToReceiveAudio: S = !0,
|
|
589
|
+
offerToReceiveVideo: g = !0,
|
|
590
|
+
degradationPreference: C,
|
|
590
591
|
sendEncodings: m,
|
|
591
592
|
onAddedTransceiver: I
|
|
592
|
-
}) => (this.isPendingCall = !0, new Promise((R,
|
|
593
|
-
this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch((
|
|
594
|
-
|
|
593
|
+
}) => (this.isPendingCall = !0, new Promise((R, y) => {
|
|
594
|
+
this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch(($) => {
|
|
595
|
+
y($);
|
|
595
596
|
}), this.rtcSession = e.call(t(s), {
|
|
596
|
-
mediaStream:
|
|
597
|
+
mediaStream: F(i, {
|
|
597
598
|
directionVideo: c,
|
|
598
|
-
directionAudio:
|
|
599
|
-
contentHint:
|
|
599
|
+
directionAudio: h,
|
|
600
|
+
contentHint: T
|
|
600
601
|
}),
|
|
601
602
|
pcConfig: {
|
|
602
603
|
iceServers: o
|
|
603
604
|
},
|
|
604
605
|
rtcOfferConstraints: {
|
|
605
|
-
offerToReceiveAudio:
|
|
606
|
-
offerToReceiveVideo:
|
|
606
|
+
offerToReceiveAudio: S,
|
|
607
|
+
offerToReceiveVideo: g
|
|
607
608
|
},
|
|
608
609
|
// необходимо передавать в методе call, чтобы подписаться на события peerconnection,
|
|
609
610
|
// так как в методе call создается RTCSession
|
|
@@ -611,8 +612,8 @@ class ke extends Le {
|
|
|
611
612
|
eventHandlers: this.events.triggers,
|
|
612
613
|
extraHeaders: r,
|
|
613
614
|
directionVideo: c,
|
|
614
|
-
directionAudio:
|
|
615
|
-
degradationPreference:
|
|
615
|
+
directionAudio: h,
|
|
616
|
+
degradationPreference: C,
|
|
616
617
|
sendEncodings: m,
|
|
617
618
|
onAddedTransceiver: I
|
|
618
619
|
});
|
|
@@ -623,7 +624,7 @@ class ke extends Le {
|
|
|
623
624
|
const { rtcSession: e } = this;
|
|
624
625
|
if (e && !e.isEnded())
|
|
625
626
|
return e.terminateAsync({
|
|
626
|
-
cause:
|
|
627
|
+
cause: ae.CANCELED
|
|
627
628
|
}).finally(() => {
|
|
628
629
|
this.reset();
|
|
629
630
|
});
|
|
@@ -637,35 +638,35 @@ class ke extends Le {
|
|
|
637
638
|
directionVideo: a,
|
|
638
639
|
directionAudio: o,
|
|
639
640
|
offerToReceiveAudio: c,
|
|
640
|
-
offerToReceiveVideo:
|
|
641
|
-
contentHint:
|
|
642
|
-
degradationPreference:
|
|
643
|
-
sendEncodings:
|
|
644
|
-
onAddedTransceiver:
|
|
641
|
+
offerToReceiveVideo: h,
|
|
642
|
+
contentHint: T,
|
|
643
|
+
degradationPreference: S,
|
|
644
|
+
sendEncodings: g,
|
|
645
|
+
onAddedTransceiver: C
|
|
645
646
|
}) => (this.isPendingAnswer = !0, new Promise((m, I) => {
|
|
646
647
|
try {
|
|
647
648
|
const R = e();
|
|
648
|
-
this.rtcSession = R, this.subscribeToSessionEvents(R), this.callConfiguration.answer = !0, this.callConfiguration.number = R.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(m).catch((
|
|
649
|
-
I(
|
|
649
|
+
this.rtcSession = R, this.subscribeToSessionEvents(R), this.callConfiguration.answer = !0, this.callConfiguration.number = R.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(m).catch((y) => {
|
|
650
|
+
I(y);
|
|
650
651
|
}), R.answer({
|
|
651
652
|
pcConfig: {
|
|
652
653
|
iceServers: r
|
|
653
654
|
},
|
|
654
655
|
rtcOfferConstraints: {
|
|
655
656
|
offerToReceiveAudio: c,
|
|
656
|
-
offerToReceiveVideo:
|
|
657
|
+
offerToReceiveVideo: h
|
|
657
658
|
},
|
|
658
|
-
mediaStream:
|
|
659
|
+
mediaStream: F(t, {
|
|
659
660
|
directionVideo: a,
|
|
660
661
|
directionAudio: o,
|
|
661
|
-
contentHint:
|
|
662
|
+
contentHint: T
|
|
662
663
|
}),
|
|
663
664
|
extraHeaders: i,
|
|
664
665
|
directionVideo: a,
|
|
665
666
|
directionAudio: o,
|
|
666
|
-
degradationPreference:
|
|
667
|
-
sendEncodings:
|
|
668
|
-
onAddedTransceiver:
|
|
667
|
+
degradationPreference: S,
|
|
668
|
+
sendEncodings: g,
|
|
669
|
+
onAddedTransceiver: C
|
|
669
670
|
});
|
|
670
671
|
} catch (R) {
|
|
671
672
|
I(R);
|
|
@@ -683,12 +684,12 @@ class ke extends Le {
|
|
|
683
684
|
if (!this.connection)
|
|
684
685
|
return;
|
|
685
686
|
const t = this.connection.getReceivers().map(({ track: s }) => s);
|
|
686
|
-
return
|
|
687
|
+
return Ge(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
|
|
687
688
|
}
|
|
688
689
|
async replaceMediaStream(e, t) {
|
|
689
690
|
if (!this.rtcSession)
|
|
690
691
|
throw new Error("No rtcSession established");
|
|
691
|
-
const { contentHint: s } = t ?? {}, i =
|
|
692
|
+
const { contentHint: s } = t ?? {}, i = F(e, { contentHint: s });
|
|
692
693
|
if (i === void 0)
|
|
693
694
|
throw new Error("No preparedMediaStream");
|
|
694
695
|
return this.rtcSession.replaceMediaStream(i, t);
|
|
@@ -707,33 +708,33 @@ class ke extends Le {
|
|
|
707
708
|
ontrack: e
|
|
708
709
|
}) => new Promise((t, s) => {
|
|
709
710
|
const i = () => {
|
|
710
|
-
this.events.on(N.PEER_CONNECTION,
|
|
711
|
+
this.events.on(N.PEER_CONNECTION, T), this.events.on(N.CONFIRMED, S);
|
|
711
712
|
}, r = () => {
|
|
712
|
-
this.events.off(N.PEER_CONNECTION,
|
|
713
|
+
this.events.off(N.PEER_CONNECTION, T), this.events.off(N.CONFIRMED, S);
|
|
713
714
|
}, a = () => {
|
|
714
715
|
this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
|
|
715
716
|
}, o = () => {
|
|
716
717
|
this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
|
|
717
|
-
}, c = (
|
|
718
|
-
r(), o(), s(
|
|
718
|
+
}, c = (g) => {
|
|
719
|
+
r(), o(), s(g);
|
|
719
720
|
};
|
|
720
|
-
let
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
const
|
|
721
|
+
let h;
|
|
722
|
+
const T = ({ peerconnection: g }) => {
|
|
723
|
+
h = g;
|
|
724
|
+
const C = (m) => {
|
|
724
725
|
this.events.trigger(N.PEER_CONNECTION_ONTRACK, m), e && e(m);
|
|
725
726
|
};
|
|
726
|
-
|
|
727
|
-
|
|
727
|
+
g.addEventListener("track", C), this.disposers.add(() => {
|
|
728
|
+
g.removeEventListener("track", C);
|
|
728
729
|
});
|
|
729
|
-
},
|
|
730
|
-
|
|
730
|
+
}, S = () => {
|
|
731
|
+
h !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, h), r(), o(), t(h);
|
|
731
732
|
};
|
|
732
733
|
i(), a();
|
|
733
734
|
});
|
|
734
735
|
subscribeToSessionEvents(e) {
|
|
735
736
|
this.events.eachTriggers((t, s) => {
|
|
736
|
-
const i =
|
|
737
|
+
const i = se.find((r) => r === s);
|
|
737
738
|
i && (e.on(i, t), this.disposers.add(() => {
|
|
738
739
|
e.off(i, t);
|
|
739
740
|
}));
|
|
@@ -752,11 +753,11 @@ class ke extends Le {
|
|
|
752
753
|
delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
|
|
753
754
|
};
|
|
754
755
|
}
|
|
755
|
-
class
|
|
756
|
+
class Xe {
|
|
756
757
|
events;
|
|
757
758
|
strategy;
|
|
758
759
|
constructor(e) {
|
|
759
|
-
this.events = new
|
|
760
|
+
this.events = new k(ie), this.strategy = e ?? new ze(this.events), this.subscribeCallStatusChange();
|
|
760
761
|
}
|
|
761
762
|
get requested() {
|
|
762
763
|
return this.strategy.requested;
|
|
@@ -773,6 +774,9 @@ class Fe {
|
|
|
773
774
|
on(e, t) {
|
|
774
775
|
return this.events.on(e, t);
|
|
775
776
|
}
|
|
777
|
+
onRace(e, t) {
|
|
778
|
+
return this.events.onRace(e, t);
|
|
779
|
+
}
|
|
776
780
|
once(e, t) {
|
|
777
781
|
return this.events.once(e, t);
|
|
778
782
|
}
|
|
@@ -797,40 +801,51 @@ class Fe {
|
|
|
797
801
|
addTransceiver = async (...e) => this.strategy.addTransceiver(...e);
|
|
798
802
|
replaceMediaStream = async (...e) => this.strategy.replaceMediaStream(...e);
|
|
799
803
|
restartIce = async (e) => this.strategy.restartIce(e);
|
|
804
|
+
subscribeCallStatusChange() {
|
|
805
|
+
let { isCallActive: e } = this;
|
|
806
|
+
const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = N;
|
|
807
|
+
this.onRace([t, s, i, r], () => {
|
|
808
|
+
e = this.maybeTriggerCallStatus(e);
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
maybeTriggerCallStatus(e) {
|
|
812
|
+
const t = this.isCallActive;
|
|
813
|
+
return t !== e && this.events.trigger(N.CALL_STATUS_CHANGED, { isCallActive: t }), t;
|
|
814
|
+
}
|
|
800
815
|
}
|
|
801
|
-
const
|
|
816
|
+
const Je = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ke = (n, e) => {
|
|
802
817
|
n.encodings ??= [];
|
|
803
818
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
804
819
|
n.encodings.push({});
|
|
805
820
|
return n;
|
|
806
|
-
},
|
|
807
|
-
if (
|
|
821
|
+
}, oe = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, je = oe(), Ze = (n, e) => {
|
|
822
|
+
if (je(n, e))
|
|
808
823
|
return n;
|
|
809
|
-
},
|
|
810
|
-
const t = n.maxBitrate, s =
|
|
824
|
+
}, et = (n, e) => {
|
|
825
|
+
const t = n.maxBitrate, s = Ze(e, t);
|
|
811
826
|
return s !== void 0 && (n.maxBitrate = s), n;
|
|
812
|
-
},
|
|
813
|
-
|
|
814
|
-
),
|
|
815
|
-
const t = n === void 0 ? void 0 : Math.max(n,
|
|
816
|
-
if (t !== void 0 &&
|
|
827
|
+
}, ce = 1, tt = oe(
|
|
828
|
+
ce
|
|
829
|
+
), nt = (n, e) => {
|
|
830
|
+
const t = n === void 0 ? void 0 : Math.max(n, ce);
|
|
831
|
+
if (t !== void 0 && tt(
|
|
817
832
|
t,
|
|
818
833
|
e
|
|
819
834
|
))
|
|
820
835
|
return t;
|
|
821
|
-
},
|
|
822
|
-
const t = n.scaleResolutionDownBy, s =
|
|
836
|
+
}, st = (n, e) => {
|
|
837
|
+
const t = n.scaleResolutionDownBy, s = nt(
|
|
823
838
|
e,
|
|
824
839
|
t
|
|
825
840
|
);
|
|
826
841
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
827
|
-
},
|
|
842
|
+
}, it = (n, e) => {
|
|
828
843
|
const t = e.encodings?.length ?? 0;
|
|
829
|
-
return
|
|
844
|
+
return Ke(n, t), n.encodings.forEach((s, i) => {
|
|
830
845
|
const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
|
|
831
|
-
|
|
846
|
+
et(s, a), st(s, o);
|
|
832
847
|
}), n;
|
|
833
|
-
},
|
|
848
|
+
}, rt = (n, e) => {
|
|
834
849
|
if (n.codecs?.length !== e.codecs?.length)
|
|
835
850
|
return !0;
|
|
836
851
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -847,15 +862,15 @@ const $e = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ve
|
|
|
847
862
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
848
863
|
return !0;
|
|
849
864
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
850
|
-
},
|
|
865
|
+
}, at = async (n, e) => {
|
|
851
866
|
const t = n.getParameters(), s = JSON.parse(
|
|
852
867
|
JSON.stringify(t)
|
|
853
868
|
);
|
|
854
|
-
|
|
855
|
-
const i =
|
|
869
|
+
it(t, e), Je(t, e);
|
|
870
|
+
const i = rt(s, t);
|
|
856
871
|
return i && await n.setParameters(t), { parameters: t, isChanged: i };
|
|
857
|
-
},
|
|
858
|
-
const { isChanged: s, parameters: i } = await
|
|
872
|
+
}, de = async (n, e, t) => {
|
|
873
|
+
const { isChanged: s, parameters: i } = await at(n, {
|
|
859
874
|
encodings: [
|
|
860
875
|
{
|
|
861
876
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -864,20 +879,20 @@ const $e = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ve
|
|
|
864
879
|
]
|
|
865
880
|
});
|
|
866
881
|
return s && t && t(i), { isChanged: s, parameters: i };
|
|
867
|
-
},
|
|
868
|
-
const s =
|
|
882
|
+
}, ot = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ct = async (n, e, t) => {
|
|
883
|
+
const s = ot(n, e);
|
|
869
884
|
if (s)
|
|
870
|
-
return
|
|
885
|
+
return de(s, { maxBitrate: t });
|
|
871
886
|
};
|
|
872
|
-
var
|
|
873
|
-
const
|
|
887
|
+
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 || {});
|
|
888
|
+
const he = [
|
|
874
889
|
"presentation:start",
|
|
875
890
|
"presentation:started",
|
|
876
891
|
"presentation:end",
|
|
877
892
|
"presentation:ended",
|
|
878
893
|
"presentation:failed"
|
|
879
|
-
],
|
|
880
|
-
class
|
|
894
|
+
], dt = 1, Gn = (n) => Oe(n);
|
|
895
|
+
class ht {
|
|
881
896
|
events;
|
|
882
897
|
promisePendingStartPresentation;
|
|
883
898
|
promisePendingStopPresentation;
|
|
@@ -889,7 +904,7 @@ class Ze {
|
|
|
889
904
|
callManager: e,
|
|
890
905
|
maxBitrate: t
|
|
891
906
|
}) {
|
|
892
|
-
this.callManager = e, this.maxBitrate = t, this.events = new
|
|
907
|
+
this.callManager = e, this.maxBitrate = t, this.events = new U(he), this.subscribe();
|
|
893
908
|
}
|
|
894
909
|
get isPendingPresentation() {
|
|
895
910
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
@@ -924,8 +939,8 @@ class Ze {
|
|
|
924
939
|
});
|
|
925
940
|
const i = this.callManager.getEstablishedRTCSession();
|
|
926
941
|
return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
|
|
927
|
-
throw this.events.trigger(
|
|
928
|
-
}) : t && this.events.trigger(
|
|
942
|
+
throw this.events.trigger(P.FAILED_PRESENTATION, r), r;
|
|
943
|
+
}) : t && this.events.trigger(P.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
929
944
|
this.resetPresentation();
|
|
930
945
|
});
|
|
931
946
|
}
|
|
@@ -968,15 +983,15 @@ class Ze {
|
|
|
968
983
|
}
|
|
969
984
|
subscribe() {
|
|
970
985
|
this.callManager.on("presentation:start", (e) => {
|
|
971
|
-
this.events.trigger(
|
|
986
|
+
this.events.trigger(P.START_PRESENTATION, e);
|
|
972
987
|
}), this.callManager.on("presentation:started", (e) => {
|
|
973
|
-
this.events.trigger(
|
|
988
|
+
this.events.trigger(P.STARTED_PRESENTATION, e);
|
|
974
989
|
}), this.callManager.on("presentation:end", (e) => {
|
|
975
|
-
this.events.trigger(
|
|
990
|
+
this.events.trigger(P.END_PRESENTATION, e);
|
|
976
991
|
}), this.callManager.on("presentation:ended", (e) => {
|
|
977
|
-
this.events.trigger(
|
|
992
|
+
this.events.trigger(P.ENDED_PRESENTATION, e);
|
|
978
993
|
}), this.callManager.on("presentation:failed", (e) => {
|
|
979
|
-
this.events.trigger(
|
|
994
|
+
this.events.trigger(P.FAILED_PRESENTATION, e);
|
|
980
995
|
}), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
|
|
981
996
|
}
|
|
982
997
|
async sendPresentationWithDuplicatedCalls(e, {
|
|
@@ -984,7 +999,7 @@ class Ze {
|
|
|
984
999
|
stream: s,
|
|
985
1000
|
presentationOptions: i,
|
|
986
1001
|
options: r = {
|
|
987
|
-
callLimit:
|
|
1002
|
+
callLimit: dt
|
|
988
1003
|
}
|
|
989
1004
|
}) {
|
|
990
1005
|
const a = async () => this.sendPresentation(
|
|
@@ -993,7 +1008,7 @@ class Ze {
|
|
|
993
1008
|
s,
|
|
994
1009
|
i
|
|
995
1010
|
), o = () => !!this.streamPresentationCurrent;
|
|
996
|
-
return this.cancelableSendPresentationWithRepeatedCalls =
|
|
1011
|
+
return this.cancelableSendPresentationWithRepeatedCalls = ee({
|
|
997
1012
|
targetFunction: a,
|
|
998
1013
|
isComplete: o,
|
|
999
1014
|
isRejectAsValid: !0,
|
|
@@ -1008,18 +1023,18 @@ class Ze {
|
|
|
1008
1023
|
sendEncodings: o,
|
|
1009
1024
|
onAddedTransceiver: c
|
|
1010
1025
|
}) {
|
|
1011
|
-
const
|
|
1012
|
-
if (
|
|
1026
|
+
const h = F(s, { contentHint: r });
|
|
1027
|
+
if (h === void 0)
|
|
1013
1028
|
throw new Error("No streamPresentationTarget");
|
|
1014
|
-
this.streamPresentationCurrent =
|
|
1015
|
-
const
|
|
1029
|
+
this.streamPresentationCurrent = h;
|
|
1030
|
+
const T = e().then(async () => t.startPresentation(h, i, {
|
|
1016
1031
|
degradationPreference: a,
|
|
1017
1032
|
sendEncodings: o,
|
|
1018
1033
|
onAddedTransceiver: c
|
|
1019
|
-
})).then(this.setMaxBitrate).then(() => s).catch((
|
|
1020
|
-
throw this.removeStreamPresentationCurrent(), this.events.trigger(
|
|
1034
|
+
})).then(this.setMaxBitrate).then(() => s).catch((S) => {
|
|
1035
|
+
throw this.removeStreamPresentationCurrent(), this.events.trigger(P.FAILED_PRESENTATION, S), S;
|
|
1021
1036
|
});
|
|
1022
|
-
return this.promisePendingStartPresentation =
|
|
1037
|
+
return this.promisePendingStartPresentation = T, T.finally(() => {
|
|
1023
1038
|
this.promisePendingStartPresentation = void 0;
|
|
1024
1039
|
});
|
|
1025
1040
|
}
|
|
@@ -1028,7 +1043,7 @@ class Ze {
|
|
|
1028
1043
|
if (!e || !t || s === void 0)
|
|
1029
1044
|
return;
|
|
1030
1045
|
const i = e.getSenders();
|
|
1031
|
-
await
|
|
1046
|
+
await ct(i, t, s);
|
|
1032
1047
|
};
|
|
1033
1048
|
getRtcSessionProtected = () => {
|
|
1034
1049
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1049,7 +1064,7 @@ class Ze {
|
|
|
1049
1064
|
delete this.streamPresentationCurrent;
|
|
1050
1065
|
}
|
|
1051
1066
|
}
|
|
1052
|
-
class
|
|
1067
|
+
class lt {
|
|
1053
1068
|
data = {};
|
|
1054
1069
|
getUa;
|
|
1055
1070
|
constructor(e) {
|
|
@@ -1122,8 +1137,8 @@ class et {
|
|
|
1122
1137
|
return this.data.register === !0;
|
|
1123
1138
|
}
|
|
1124
1139
|
}
|
|
1125
|
-
var A = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n))(A || {});
|
|
1126
|
-
const
|
|
1140
|
+
var A = /* @__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))(A || {});
|
|
1141
|
+
const le = [
|
|
1127
1142
|
"connecting",
|
|
1128
1143
|
"connected",
|
|
1129
1144
|
"disconnected",
|
|
@@ -1133,8 +1148,13 @@ const ce = [
|
|
|
1133
1148
|
"registrationFailed",
|
|
1134
1149
|
"newMessage",
|
|
1135
1150
|
"sipEvent"
|
|
1136
|
-
],
|
|
1137
|
-
|
|
1151
|
+
], gt = [
|
|
1152
|
+
"disconnecting",
|
|
1153
|
+
"connect-started",
|
|
1154
|
+
"connect-succeeded",
|
|
1155
|
+
"connect-failed"
|
|
1156
|
+
], ge = [...le, ...gt], ut = 3;
|
|
1157
|
+
class Tt {
|
|
1138
1158
|
cancelableConnectWithRepeatedCalls;
|
|
1139
1159
|
JsSIP;
|
|
1140
1160
|
events;
|
|
@@ -1160,11 +1180,12 @@ class nt {
|
|
|
1160
1180
|
}
|
|
1161
1181
|
let r = !1;
|
|
1162
1182
|
const a = this.getConnectionConfiguration();
|
|
1163
|
-
e !== void 0 && e !== a.displayName && (r = i.set("display_name",
|
|
1183
|
+
e !== void 0 && e !== a.displayName && (r = i.set("display_name", re(e)), this.updateConnectionConfiguration("displayName", e));
|
|
1164
1184
|
const o = r;
|
|
1165
1185
|
o ? t(o) : s(new Error("nothing changed"));
|
|
1166
1186
|
});
|
|
1167
1187
|
disconnect = async () => {
|
|
1188
|
+
this.events.trigger(A.DISCONNECTING, void 0);
|
|
1168
1189
|
const e = new Promise((s) => {
|
|
1169
1190
|
this.events.once(A.DISCONNECTED, () => {
|
|
1170
1191
|
s();
|
|
@@ -1177,12 +1198,12 @@ class nt {
|
|
|
1177
1198
|
cancelRequests() {
|
|
1178
1199
|
this.cancelConnectWithRepeatedCalls();
|
|
1179
1200
|
}
|
|
1180
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
1201
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = ut } = {}) => {
|
|
1181
1202
|
const s = async () => this.connectInner(e), i = (r) => {
|
|
1182
|
-
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e),
|
|
1183
|
-
return c ||
|
|
1203
|
+
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), h = r != null && !Le(r);
|
|
1204
|
+
return c || h;
|
|
1184
1205
|
};
|
|
1185
|
-
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls =
|
|
1206
|
+
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ee({
|
|
1186
1207
|
targetFunction: s,
|
|
1187
1208
|
isComplete: i,
|
|
1188
1209
|
callLimit: t,
|
|
@@ -1208,16 +1229,16 @@ class nt {
|
|
|
1208
1229
|
sessionTimers: a,
|
|
1209
1230
|
registerExpires: o,
|
|
1210
1231
|
connectionRecoveryMinInterval: c,
|
|
1211
|
-
connectionRecoveryMaxInterval:
|
|
1212
|
-
userAgent:
|
|
1213
|
-
displayName:
|
|
1214
|
-
register:
|
|
1215
|
-
extraHeaders:
|
|
1232
|
+
connectionRecoveryMaxInterval: h,
|
|
1233
|
+
userAgent: T,
|
|
1234
|
+
displayName: S = "",
|
|
1235
|
+
register: g = !1,
|
|
1236
|
+
extraHeaders: C = []
|
|
1216
1237
|
}) => {
|
|
1217
1238
|
this.stateMachine.startInitUa(), this.setConnectionConfiguration({
|
|
1218
1239
|
sipServerUrl: s,
|
|
1219
|
-
displayName:
|
|
1220
|
-
register:
|
|
1240
|
+
displayName: S,
|
|
1241
|
+
register: g,
|
|
1221
1242
|
user: e,
|
|
1222
1243
|
password: t
|
|
1223
1244
|
}), this.getUa() && await this.disconnect();
|
|
@@ -1227,15 +1248,15 @@ class nt {
|
|
|
1227
1248
|
password: t,
|
|
1228
1249
|
sipServerUrl: s,
|
|
1229
1250
|
sipWebSocketServerURL: i,
|
|
1230
|
-
displayName:
|
|
1231
|
-
register:
|
|
1251
|
+
displayName: S,
|
|
1252
|
+
register: g,
|
|
1232
1253
|
sessionTimers: a,
|
|
1233
1254
|
registerExpires: o,
|
|
1234
1255
|
connectionRecoveryMinInterval: c,
|
|
1235
|
-
connectionRecoveryMaxInterval:
|
|
1236
|
-
userAgent:
|
|
1256
|
+
connectionRecoveryMaxInterval: h,
|
|
1257
|
+
userAgent: T,
|
|
1237
1258
|
remoteAddress: r,
|
|
1238
|
-
extraHeaders:
|
|
1259
|
+
extraHeaders: C
|
|
1239
1260
|
},
|
|
1240
1261
|
this.events
|
|
1241
1262
|
);
|
|
@@ -1248,15 +1269,15 @@ class nt {
|
|
|
1248
1269
|
return;
|
|
1249
1270
|
}
|
|
1250
1271
|
let i;
|
|
1251
|
-
i = ((c,
|
|
1272
|
+
i = ((c, h) => {
|
|
1252
1273
|
if (this.getConnectionConfiguration().register === !0)
|
|
1253
|
-
return this.registrationManager.subscribeToStartEvents(c,
|
|
1254
|
-
const
|
|
1255
|
-
return this.events.on(
|
|
1256
|
-
this.events.on(
|
|
1274
|
+
return this.registrationManager.subscribeToStartEvents(c, h);
|
|
1275
|
+
const S = A.CONNECTED, g = [A.DISCONNECTED];
|
|
1276
|
+
return this.events.on(S, c), g.forEach((C) => {
|
|
1277
|
+
this.events.on(C, h);
|
|
1257
1278
|
}), () => {
|
|
1258
|
-
this.events.off(
|
|
1259
|
-
this.events.off(
|
|
1279
|
+
this.events.off(S, c), g.forEach((C) => {
|
|
1280
|
+
this.events.off(C, h);
|
|
1260
1281
|
});
|
|
1261
1282
|
};
|
|
1262
1283
|
})(() => {
|
|
@@ -1269,18 +1290,18 @@ class nt {
|
|
|
1269
1290
|
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
1270
1291
|
}
|
|
1271
1292
|
}
|
|
1272
|
-
var
|
|
1273
|
-
const
|
|
1293
|
+
var ue = /* @__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))(ue || {});
|
|
1294
|
+
const St = De({
|
|
1274
1295
|
types: {
|
|
1275
1296
|
context: {},
|
|
1276
1297
|
events: {}
|
|
1277
1298
|
},
|
|
1278
1299
|
actions: {
|
|
1279
1300
|
logTransition: (n, e) => {
|
|
1280
|
-
|
|
1301
|
+
d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1281
1302
|
},
|
|
1282
1303
|
logStateChange: (n, e) => {
|
|
1283
|
-
|
|
1304
|
+
d("ConnectionStateMachine state changed", e.state);
|
|
1284
1305
|
}
|
|
1285
1306
|
}
|
|
1286
1307
|
}).createMachine({
|
|
@@ -1584,14 +1605,14 @@ const st = Ae({
|
|
|
1584
1605
|
}
|
|
1585
1606
|
}
|
|
1586
1607
|
});
|
|
1587
|
-
class
|
|
1608
|
+
class Ct {
|
|
1588
1609
|
actor;
|
|
1589
1610
|
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
1590
1611
|
events;
|
|
1591
1612
|
unsubscribeFromEvents;
|
|
1592
1613
|
actorSubscription;
|
|
1593
1614
|
constructor(e) {
|
|
1594
|
-
this.events = e, this.actor =
|
|
1615
|
+
this.events = e, this.actor = ye(St), this.actorSubscription = this.actor.subscribe((t) => {
|
|
1595
1616
|
const s = t.value;
|
|
1596
1617
|
this.stateChangeListeners.forEach((i) => {
|
|
1597
1618
|
i(s);
|
|
@@ -1677,7 +1698,7 @@ class it {
|
|
|
1677
1698
|
return this.actor.getSnapshot().can({ type: e });
|
|
1678
1699
|
}
|
|
1679
1700
|
getValidEvents() {
|
|
1680
|
-
return Object.values(
|
|
1701
|
+
return Object.values(ue).filter((e) => this.canTransition(e));
|
|
1681
1702
|
}
|
|
1682
1703
|
hasState(e) {
|
|
1683
1704
|
return this.actor.getSnapshot().matches(e);
|
|
@@ -1685,7 +1706,7 @@ class it {
|
|
|
1685
1706
|
sendEvent(e) {
|
|
1686
1707
|
const t = this.actor.getSnapshot(), s = { type: e };
|
|
1687
1708
|
if (!t.can(s)) {
|
|
1688
|
-
|
|
1709
|
+
d(
|
|
1689
1710
|
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1690
1711
|
);
|
|
1691
1712
|
return;
|
|
@@ -1746,7 +1767,7 @@ class it {
|
|
|
1746
1767
|
};
|
|
1747
1768
|
}
|
|
1748
1769
|
}
|
|
1749
|
-
class
|
|
1770
|
+
class Et {
|
|
1750
1771
|
events;
|
|
1751
1772
|
getUaProtected;
|
|
1752
1773
|
constructor(e) {
|
|
@@ -1768,7 +1789,7 @@ class rt {
|
|
|
1768
1789
|
try {
|
|
1769
1790
|
await this.unregister();
|
|
1770
1791
|
} catch (e) {
|
|
1771
|
-
|
|
1792
|
+
d("tryRegister", e);
|
|
1772
1793
|
}
|
|
1773
1794
|
return this.register();
|
|
1774
1795
|
}
|
|
@@ -1783,7 +1804,7 @@ class rt {
|
|
|
1783
1804
|
};
|
|
1784
1805
|
}
|
|
1785
1806
|
}
|
|
1786
|
-
class
|
|
1807
|
+
class At {
|
|
1787
1808
|
uaFactory;
|
|
1788
1809
|
getUaProtected;
|
|
1789
1810
|
constructor(e) {
|
|
@@ -1829,30 +1850,30 @@ class at {
|
|
|
1829
1850
|
extraHeaders: a
|
|
1830
1851
|
}) {
|
|
1831
1852
|
return new Promise((o, c) => {
|
|
1832
|
-
const { configuration:
|
|
1853
|
+
const { configuration: h } = this.uaFactory.createConfiguration({
|
|
1833
1854
|
sipWebSocketServerURL: i,
|
|
1834
1855
|
displayName: t,
|
|
1835
1856
|
userAgent: e,
|
|
1836
1857
|
sipServerUrl: s
|
|
1837
|
-
}),
|
|
1838
|
-
const
|
|
1839
|
-
c(
|
|
1858
|
+
}), T = this.uaFactory.createUA({ ...h, remoteAddress: r, extraHeaders: a }), S = () => {
|
|
1859
|
+
const C = new Error("Telephony is not available");
|
|
1860
|
+
c(C);
|
|
1840
1861
|
};
|
|
1841
|
-
|
|
1842
|
-
const
|
|
1843
|
-
|
|
1862
|
+
T.once(A.DISCONNECTED, S);
|
|
1863
|
+
const g = () => {
|
|
1864
|
+
T.removeAllListeners(), T.once(A.DISCONNECTED, () => {
|
|
1844
1865
|
o();
|
|
1845
|
-
}),
|
|
1866
|
+
}), T.stop();
|
|
1846
1867
|
};
|
|
1847
|
-
|
|
1868
|
+
T.once(A.CONNECTED, g), T.start();
|
|
1848
1869
|
});
|
|
1849
1870
|
}
|
|
1850
1871
|
}
|
|
1851
|
-
const
|
|
1872
|
+
const Nt = (n) => {
|
|
1852
1873
|
const e = [];
|
|
1853
1874
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
1854
1875
|
};
|
|
1855
|
-
class
|
|
1876
|
+
class D {
|
|
1856
1877
|
JsSIP;
|
|
1857
1878
|
constructor(e) {
|
|
1858
1879
|
this.JsSIP = e;
|
|
@@ -1877,10 +1898,10 @@ class O {
|
|
|
1877
1898
|
throw new Error("user is required for authorized connection");
|
|
1878
1899
|
}
|
|
1879
1900
|
static resolveAuthorizationUser(e, t) {
|
|
1880
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
1901
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${xe()}`;
|
|
1881
1902
|
}
|
|
1882
1903
|
static buildExtraHeaders(e, t) {
|
|
1883
|
-
const s = e !== void 0 && e !== "" ?
|
|
1904
|
+
const s = e !== void 0 && e !== "" ? Nt(e) : [];
|
|
1884
1905
|
return t === void 0 ? s : [...s, ...t];
|
|
1885
1906
|
}
|
|
1886
1907
|
createConfiguration({
|
|
@@ -1893,40 +1914,40 @@ class O {
|
|
|
1893
1914
|
sessionTimers: o = !1,
|
|
1894
1915
|
registerExpires: c = 300,
|
|
1895
1916
|
// 5 minutes in sec
|
|
1896
|
-
connectionRecoveryMinInterval:
|
|
1897
|
-
connectionRecoveryMaxInterval:
|
|
1898
|
-
userAgent:
|
|
1917
|
+
connectionRecoveryMinInterval: h = 2,
|
|
1918
|
+
connectionRecoveryMaxInterval: T = 6,
|
|
1919
|
+
userAgent: S
|
|
1899
1920
|
}) {
|
|
1900
|
-
|
|
1921
|
+
D.validateConfiguration({
|
|
1901
1922
|
register: a,
|
|
1902
1923
|
password: t,
|
|
1903
1924
|
user: e,
|
|
1904
1925
|
sipServerUrl: r,
|
|
1905
1926
|
sipWebSocketServerURL: s
|
|
1906
1927
|
});
|
|
1907
|
-
const
|
|
1928
|
+
const g = D.resolveAuthorizationUser(a, e), C = We(r), m = C(g), I = new this.JsSIP.WebSocketInterface(s);
|
|
1908
1929
|
return {
|
|
1909
1930
|
configuration: {
|
|
1910
1931
|
password: t,
|
|
1911
1932
|
register: a,
|
|
1912
1933
|
uri: m,
|
|
1913
|
-
display_name:
|
|
1914
|
-
user_agent:
|
|
1934
|
+
display_name: re(i),
|
|
1935
|
+
user_agent: S,
|
|
1915
1936
|
sdpSemantics: "unified-plan",
|
|
1916
1937
|
sockets: [I],
|
|
1917
1938
|
session_timers: o,
|
|
1918
1939
|
register_expires: c,
|
|
1919
|
-
connection_recovery_min_interval:
|
|
1920
|
-
connection_recovery_max_interval:
|
|
1940
|
+
connection_recovery_min_interval: h,
|
|
1941
|
+
connection_recovery_max_interval: T
|
|
1921
1942
|
},
|
|
1922
1943
|
helpers: {
|
|
1923
1944
|
socket: I,
|
|
1924
|
-
getSipServerUrl:
|
|
1945
|
+
getSipServerUrl: C
|
|
1925
1946
|
}
|
|
1926
1947
|
};
|
|
1927
1948
|
}
|
|
1928
1949
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
1929
|
-
const i = new this.JsSIP.UA(s), r =
|
|
1950
|
+
const i = new this.JsSIP.UA(s), r = D.buildExtraHeaders(e, t);
|
|
1930
1951
|
return r.length > 0 && i.registrator().setExtraHeaders(r), i;
|
|
1931
1952
|
}
|
|
1932
1953
|
/**
|
|
@@ -1939,12 +1960,13 @@ class O {
|
|
|
1939
1960
|
extraHeaders: e.extraHeaders
|
|
1940
1961
|
});
|
|
1941
1962
|
return t.eachTriggers((a, o) => {
|
|
1942
|
-
const c =
|
|
1963
|
+
const c = le.find((h) => h === o);
|
|
1943
1964
|
c && r.on(c, a);
|
|
1944
1965
|
}), { ua: r, helpers: i };
|
|
1945
1966
|
}
|
|
1946
1967
|
}
|
|
1947
|
-
|
|
1968
|
+
const Te = "Not ready for connection", Rt = (n) => n instanceof Error && n.message === Te, It = () => new Error(Te), pt = async (n) => typeof n == "function" ? n() : n;
|
|
1969
|
+
class mt {
|
|
1948
1970
|
events;
|
|
1949
1971
|
ua;
|
|
1950
1972
|
socket;
|
|
@@ -1956,15 +1978,15 @@ class ct {
|
|
|
1956
1978
|
configurationManager;
|
|
1957
1979
|
JsSIP;
|
|
1958
1980
|
constructor({ JsSIP: e }) {
|
|
1959
|
-
this.JsSIP = e, this.events = new
|
|
1981
|
+
this.JsSIP = e, this.events = new U(ge), this.uaFactory = new D(e), this.registrationManager = new Et({
|
|
1960
1982
|
events: this.events,
|
|
1961
1983
|
getUaProtected: this.getUaProtected
|
|
1962
|
-
}), this.stateMachine = new
|
|
1984
|
+
}), this.stateMachine = new Ct(this.events), this.configurationManager = new lt({
|
|
1963
1985
|
getUa: this.getUa
|
|
1964
|
-
}), this.sipOperations = new
|
|
1986
|
+
}), this.sipOperations = new At({
|
|
1965
1987
|
uaFactory: this.uaFactory,
|
|
1966
1988
|
getUaProtected: this.getUaProtected
|
|
1967
|
-
}), this.connectionFlow = new
|
|
1989
|
+
}), this.connectionFlow = new Tt({
|
|
1968
1990
|
JsSIP: this.JsSIP,
|
|
1969
1991
|
events: this.events,
|
|
1970
1992
|
uaFactory: this.uaFactory,
|
|
@@ -1998,18 +2020,29 @@ class ct {
|
|
|
1998
2020
|
get isPendingInitUa() {
|
|
1999
2021
|
return this.stateMachine.isPendingInitUa;
|
|
2000
2022
|
}
|
|
2023
|
+
get isDisconnected() {
|
|
2024
|
+
return this.stateMachine.isDisconnected;
|
|
2025
|
+
}
|
|
2026
|
+
get isFailed() {
|
|
2027
|
+
return this.stateMachine.isFailed;
|
|
2028
|
+
}
|
|
2001
2029
|
get connectionState() {
|
|
2002
2030
|
return this.stateMachine.state;
|
|
2003
2031
|
}
|
|
2004
2032
|
get isRegistered() {
|
|
2005
|
-
return
|
|
2033
|
+
return D.isRegisteredUA(this.ua);
|
|
2006
2034
|
}
|
|
2007
2035
|
get isRegisterConfig() {
|
|
2008
2036
|
return this.configurationManager.isRegister();
|
|
2009
2037
|
}
|
|
2010
|
-
connect = async (e, t) => this.
|
|
2038
|
+
connect = async (e, t) => this.disconnect().catch((s) => {
|
|
2039
|
+
d("connect: disconnect error", s);
|
|
2040
|
+
}).then(async () => this.connectWithProcessError(e, t));
|
|
2011
2041
|
set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
|
|
2012
|
-
disconnect = async () =>
|
|
2042
|
+
disconnect = async () => {
|
|
2043
|
+
if (this.isConfigured())
|
|
2044
|
+
return this.connectionFlow.disconnect();
|
|
2045
|
+
};
|
|
2013
2046
|
async register() {
|
|
2014
2047
|
return this.registrationManager.register();
|
|
2015
2048
|
}
|
|
@@ -2054,10 +2087,26 @@ class ct {
|
|
|
2054
2087
|
return this.ua;
|
|
2055
2088
|
};
|
|
2056
2089
|
getUa = () => this.ua;
|
|
2090
|
+
connectWithProcessError = async (e, t) => {
|
|
2091
|
+
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
2092
|
+
throw It();
|
|
2093
|
+
return this.processConnect(e, t).catch(async (i) => {
|
|
2094
|
+
const r = i;
|
|
2095
|
+
return this.disconnect().then(() => {
|
|
2096
|
+
throw r;
|
|
2097
|
+
}).catch(() => {
|
|
2098
|
+
throw r;
|
|
2099
|
+
});
|
|
2100
|
+
});
|
|
2101
|
+
};
|
|
2102
|
+
processConnect = async (e, t) => (this.events.trigger(A.CONNECT_STARTED, {}), pt(e).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(A.CONNECT_SUCCEEDED, { ua: s }), s)).catch((s) => {
|
|
2103
|
+
const i = s ?? new Error("Failed to connect to server");
|
|
2104
|
+
throw this.events.trigger(A.CONNECT_FAILED, i), i;
|
|
2105
|
+
}));
|
|
2057
2106
|
}
|
|
2058
|
-
class
|
|
2107
|
+
class _t {
|
|
2059
2108
|
connectionManager;
|
|
2060
|
-
stackPromises =
|
|
2109
|
+
stackPromises = te({
|
|
2061
2110
|
noRunIsNotActual: !0
|
|
2062
2111
|
});
|
|
2063
2112
|
constructor({ connectionManager: e }) {
|
|
@@ -2065,27 +2114,318 @@ class dt {
|
|
|
2065
2114
|
}
|
|
2066
2115
|
connect = async (...e) => this.stackPromises.run(async () => this.connectionManager.connect(...e));
|
|
2067
2116
|
disconnect = async () => this.stackPromises.run(async () => this.connectionManager.disconnect());
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
checkTelephony = async (...e) => this.stackPromises.run(async () => this.connectionManager.checkTelephony(...e));
|
|
2072
|
-
sendOptions = async (...e) => this.stackPromises.run(async () => this.connectionManager.sendOptions(...e));
|
|
2073
|
-
ping = async (...e) => this.stackPromises.run(async () => this.connectionManager.ping(...e));
|
|
2074
|
-
set = async (...e) => this.stackPromises.run(async () => this.connectionManager.set(...e));
|
|
2117
|
+
stop() {
|
|
2118
|
+
this.stackPromises.stop();
|
|
2119
|
+
}
|
|
2075
2120
|
}
|
|
2076
|
-
var
|
|
2077
|
-
const
|
|
2121
|
+
var O = /* @__PURE__ */ ((n) => (n.BEFORE_ATTEMPT = "before-attempt", n.SUCCEEDED_ATTEMPT = "succeeded-attempt", n.FAILED_ATTEMPT = "failed-attempt", n.CANCELLED_ATTEMPT = "cancelled-attempt", n.CHANGED_ATTEMPT_STATUS = "changed-attempt-status", n))(O || {});
|
|
2122
|
+
const Se = [
|
|
2123
|
+
"before-attempt",
|
|
2124
|
+
"succeeded-attempt",
|
|
2125
|
+
"failed-attempt",
|
|
2126
|
+
"cancelled-attempt",
|
|
2127
|
+
"changed-attempt-status"
|
|
2128
|
+
], z = 0, Mt = 30;
|
|
2129
|
+
class vt {
|
|
2130
|
+
events;
|
|
2131
|
+
countInner = z;
|
|
2132
|
+
initialCount = z;
|
|
2133
|
+
limitInner = Mt;
|
|
2134
|
+
isInProgress = !1;
|
|
2135
|
+
constructor({ events: e }) {
|
|
2136
|
+
this.events = e;
|
|
2137
|
+
}
|
|
2138
|
+
get count() {
|
|
2139
|
+
return this.countInner;
|
|
2140
|
+
}
|
|
2141
|
+
get limit() {
|
|
2142
|
+
return this.limitInner;
|
|
2143
|
+
}
|
|
2144
|
+
get isAttemptInProgress() {
|
|
2145
|
+
return this.isInProgress;
|
|
2146
|
+
}
|
|
2147
|
+
hasLimitReached() {
|
|
2148
|
+
return this.countInner >= this.limitInner;
|
|
2149
|
+
}
|
|
2150
|
+
startAttempt() {
|
|
2151
|
+
this.isInProgress || (this.isInProgress = !0, this.emitStatusChange());
|
|
2152
|
+
}
|
|
2153
|
+
finishAttempt() {
|
|
2154
|
+
this.isInProgress && (this.isInProgress = !1, this.emitStatusChange());
|
|
2155
|
+
}
|
|
2156
|
+
increment() {
|
|
2157
|
+
this.count < this.limit && (this.countInner += 1);
|
|
2158
|
+
}
|
|
2159
|
+
reset() {
|
|
2160
|
+
this.countInner = this.initialCount, this.finishAttempt();
|
|
2161
|
+
}
|
|
2162
|
+
emitStatusChange() {
|
|
2163
|
+
this.events.trigger(O.CHANGED_ATTEMPT_STATUS, { isInProgress: this.isInProgress });
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
class ft {
|
|
2167
|
+
connectionManager;
|
|
2168
|
+
interval;
|
|
2169
|
+
checkTelephonyByTimeout = void 0;
|
|
2170
|
+
cancelableBeforeRequest = void 0;
|
|
2171
|
+
constructor({
|
|
2172
|
+
connectionManager: e,
|
|
2173
|
+
interval: t
|
|
2174
|
+
}) {
|
|
2175
|
+
this.connectionManager = e, this.interval = t;
|
|
2176
|
+
}
|
|
2177
|
+
start({
|
|
2178
|
+
onBeforeRequest: e,
|
|
2179
|
+
onSuccessRequest: t,
|
|
2180
|
+
onFailRequest: s
|
|
2181
|
+
}) {
|
|
2182
|
+
this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Me({
|
|
2183
|
+
isDontStopOnFail: !0,
|
|
2184
|
+
requestInterval: this.interval,
|
|
2185
|
+
request: async () => {
|
|
2186
|
+
if (!this.cancelableBeforeRequest)
|
|
2187
|
+
throw new Error("cancelableBeforeRequest is not defined");
|
|
2188
|
+
const i = await this.cancelableBeforeRequest.request();
|
|
2189
|
+
return this.connectionManager.checkTelephony(i);
|
|
2190
|
+
}
|
|
2191
|
+
}), this.checkTelephonyByTimeout.start(void 0, {
|
|
2192
|
+
onFailRequest: s,
|
|
2193
|
+
onSuccessRequest: () => {
|
|
2194
|
+
this.stop(), t();
|
|
2195
|
+
}
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
stop() {
|
|
2199
|
+
this.checkTelephonyByTimeout?.stop(), this.checkTelephonyByTimeout = void 0, this.cancelableBeforeRequest?.cancelRequest(), this.cancelableBeforeRequest = void 0;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
const Pt = 15e3, Ot = 2;
|
|
2203
|
+
class Dt {
|
|
2204
|
+
connectionManager;
|
|
2205
|
+
pingServerByTimeoutWithFailCalls;
|
|
2206
|
+
constructor({ connectionManager: e }) {
|
|
2207
|
+
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = ve(Ot, {
|
|
2208
|
+
whenPossibleRequest: async () => {
|
|
2209
|
+
},
|
|
2210
|
+
requestInterval: Pt,
|
|
2211
|
+
request: async () => (d("ping"), this.connectionManager.ping().then(() => {
|
|
2212
|
+
d("ping success");
|
|
2213
|
+
}))
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
start({ onFailRequest: e }) {
|
|
2217
|
+
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(d);
|
|
2218
|
+
}
|
|
2219
|
+
stop() {
|
|
2220
|
+
this.pingServerByTimeoutWithFailCalls.stop();
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
class yt {
|
|
2224
|
+
callManager;
|
|
2225
|
+
pingServerRequester;
|
|
2226
|
+
disposeCallStatusChange;
|
|
2227
|
+
constructor({
|
|
2228
|
+
connectionManager: e,
|
|
2229
|
+
callManager: t
|
|
2230
|
+
}) {
|
|
2231
|
+
this.callManager = t, this.pingServerRequester = new Dt({
|
|
2232
|
+
connectionManager: e
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
start({ onFailRequest: e }) {
|
|
2236
|
+
d("start"), this.disposeCallStatusChange = this.callManager.on("call-status-changed", () => {
|
|
2237
|
+
this.handleCallStatusChange({ onFailRequest: e });
|
|
2238
|
+
}), this.handleCallStatusChange({ onFailRequest: e });
|
|
2239
|
+
}
|
|
2240
|
+
stop() {
|
|
2241
|
+
d("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
|
|
2242
|
+
}
|
|
2243
|
+
unsubscribeCallStatusChange() {
|
|
2244
|
+
this.disposeCallStatusChange?.(), this.disposeCallStatusChange = void 0;
|
|
2245
|
+
}
|
|
2246
|
+
handleCallStatusChange({ onFailRequest: e }) {
|
|
2247
|
+
this.callManager.isCallActive ? this.pingServerRequester.stop() : this.pingServerRequester.start({ onFailRequest: e });
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
class bt {
|
|
2251
|
+
connectionManager;
|
|
2252
|
+
callManager;
|
|
2253
|
+
isRegistrationFailed = !1;
|
|
2254
|
+
disposers = [];
|
|
2255
|
+
constructor({
|
|
2256
|
+
connectionManager: e,
|
|
2257
|
+
callManager: t
|
|
2258
|
+
}) {
|
|
2259
|
+
this.connectionManager = e, this.callManager = t;
|
|
2260
|
+
}
|
|
2261
|
+
subscribe(e) {
|
|
2262
|
+
this.unsubscribe(), this.disposers.push(
|
|
2263
|
+
this.connectionManager.on("registrationFailed", () => {
|
|
2264
|
+
this.setIsRegistrationFailed();
|
|
2265
|
+
})
|
|
2266
|
+
), this.disposers.push(
|
|
2267
|
+
this.callManager.on("call-status-changed", ({ isCallActive: t }) => {
|
|
2268
|
+
!t && this.isRegistrationFailed && e();
|
|
2269
|
+
})
|
|
2270
|
+
);
|
|
2271
|
+
}
|
|
2272
|
+
unsubscribe() {
|
|
2273
|
+
this.disposers.forEach((e) => {
|
|
2274
|
+
e();
|
|
2275
|
+
}), this.disposers = [], this.resetIsRegistrationFailed();
|
|
2276
|
+
}
|
|
2277
|
+
setIsRegistrationFailed() {
|
|
2278
|
+
this.isRegistrationFailed = !0;
|
|
2279
|
+
}
|
|
2280
|
+
resetIsRegistrationFailed() {
|
|
2281
|
+
this.isRegistrationFailed = !1;
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
const Ce = "Parameters are missing", wt = (n) => n instanceof Error && n.message === Ce, Qn = () => new Error(Ce), Ut = 3e3, Lt = 15e3, Bt = async () => {
|
|
2285
|
+
};
|
|
2286
|
+
class Ft {
|
|
2287
|
+
events;
|
|
2288
|
+
connectionManager;
|
|
2289
|
+
connectionQueueManager;
|
|
2290
|
+
checkTelephonyRequester;
|
|
2291
|
+
pingServerIfNotActiveCallRequester;
|
|
2292
|
+
registrationFailedOutOfCallSubscriber;
|
|
2293
|
+
attemptsState;
|
|
2294
|
+
delayBetweenAttempts;
|
|
2295
|
+
cancelableRequestBeforeRetry;
|
|
2296
|
+
onBeforeRetry;
|
|
2297
|
+
constructor({
|
|
2298
|
+
connectionQueueManager: e,
|
|
2299
|
+
connectionManager: t,
|
|
2300
|
+
callManager: s
|
|
2301
|
+
}, i) {
|
|
2302
|
+
const r = i?.onBeforeRetry ?? Bt;
|
|
2303
|
+
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.events = new k(Se), this.checkTelephonyRequester = new ft({
|
|
2304
|
+
connectionManager: t,
|
|
2305
|
+
interval: i?.checkTelephonyRequestInterval ?? Lt
|
|
2306
|
+
}), this.pingServerIfNotActiveCallRequester = new yt({
|
|
2307
|
+
connectionManager: t,
|
|
2308
|
+
callManager: s
|
|
2309
|
+
}), this.registrationFailedOutOfCallSubscriber = new bt({
|
|
2310
|
+
connectionManager: t,
|
|
2311
|
+
callManager: s
|
|
2312
|
+
}), this.attemptsState = new vt({
|
|
2313
|
+
events: this.events
|
|
2314
|
+
}), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new fe(
|
|
2315
|
+
i?.timeoutBetweenAttempts ?? Ut
|
|
2316
|
+
);
|
|
2317
|
+
}
|
|
2318
|
+
start(e) {
|
|
2319
|
+
d("auto connector start"), this.stop(), this.connect(e).catch((t) => {
|
|
2320
|
+
d("auto connector failed to connect:", t);
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
stop() {
|
|
2324
|
+
d("auto connector stop"), this.stopAttempts(), this.stopConnectTriggers(), this.connectionQueueManager.disconnect().catch((e) => {
|
|
2325
|
+
d("auto connector disconnect: error", e);
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
on(e, t) {
|
|
2329
|
+
return this.events.on(e, t);
|
|
2330
|
+
}
|
|
2331
|
+
once(e, t) {
|
|
2332
|
+
return this.events.once(e, t);
|
|
2333
|
+
}
|
|
2334
|
+
onceRace(e, t) {
|
|
2335
|
+
return this.events.onceRace(e, t);
|
|
2336
|
+
}
|
|
2337
|
+
async wait(e) {
|
|
2338
|
+
return this.events.wait(e);
|
|
2339
|
+
}
|
|
2340
|
+
off(e, t) {
|
|
2341
|
+
this.events.off(e, t);
|
|
2342
|
+
}
|
|
2343
|
+
stopAttempts() {
|
|
2344
|
+
this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
|
|
2345
|
+
}
|
|
2346
|
+
stopConnectTriggers() {
|
|
2347
|
+
d("stopConnectTriggers"), this.pingServerIfNotActiveCallRequester.stop(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
|
|
2348
|
+
}
|
|
2349
|
+
runCheckTelephony(e) {
|
|
2350
|
+
d("runCheckTelephony"), this.checkTelephonyRequester.start({
|
|
2351
|
+
onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
|
|
2352
|
+
onSuccessRequest: () => {
|
|
2353
|
+
d("runCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
|
|
2354
|
+
},
|
|
2355
|
+
onFailRequest: (t) => {
|
|
2356
|
+
d("runCheckTelephony: onFailRequest", t.message);
|
|
2357
|
+
}
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
async connect(e) {
|
|
2361
|
+
if (d("connect: attempts.count", this.attemptsState.count), this.events.trigger(O.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
|
|
2362
|
+
d("connect: isLimitReached!"), this.handleLimitReached(e);
|
|
2363
|
+
return;
|
|
2364
|
+
}
|
|
2365
|
+
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.processConnect(e);
|
|
2366
|
+
}
|
|
2367
|
+
async processConnect(e) {
|
|
2368
|
+
try {
|
|
2369
|
+
await this.connectionQueueManager.connect(e.getParameters, e.options), d("processConnect success"), this.handleSucceededAttempt(e);
|
|
2370
|
+
} catch (t) {
|
|
2371
|
+
if (Rt(t)) {
|
|
2372
|
+
this.handleSucceededAttempt(e);
|
|
2373
|
+
return;
|
|
2374
|
+
}
|
|
2375
|
+
if (wt(t)) {
|
|
2376
|
+
d("processConnect: parameters not exist error", t);
|
|
2377
|
+
return;
|
|
2378
|
+
}
|
|
2379
|
+
if (be(t)) {
|
|
2380
|
+
d("processConnect: not actual error", t), this.events.trigger(O.CANCELLED_ATTEMPT, t);
|
|
2381
|
+
return;
|
|
2382
|
+
}
|
|
2383
|
+
d("processConnect: error", t), this.reconnect(e);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
handleLimitReached(e) {
|
|
2387
|
+
this.attemptsState.finishAttempt(), this.events.trigger(O.FAILED_ATTEMPT, new Error("Limit reached")), this.runCheckTelephony(e);
|
|
2388
|
+
}
|
|
2389
|
+
handleSucceededAttempt(e) {
|
|
2390
|
+
d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(O.SUCCEEDED_ATTEMPT, {});
|
|
2391
|
+
}
|
|
2392
|
+
subscribeToConnectTriggers(e) {
|
|
2393
|
+
this.pingServerIfNotActiveCallRequester.start({
|
|
2394
|
+
onFailRequest: () => {
|
|
2395
|
+
d("pingServer onFailRequest"), this.start(e);
|
|
2396
|
+
}
|
|
2397
|
+
}), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2398
|
+
d("registrationFailedOutOfCallListener callback"), this.start(e);
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2401
|
+
connectIfDisconnected(e) {
|
|
2402
|
+
const t = this.hasFailedOrDisconnectedConnection();
|
|
2403
|
+
d("connectIfDisconnected: isFailedOrDisconnected", t), t ? this.start(e) : (this.stopConnectTriggers(), this.events.trigger(O.SUCCEEDED_ATTEMPT, {}));
|
|
2404
|
+
}
|
|
2405
|
+
reconnect(e) {
|
|
2406
|
+
d("reconnect"), this.delayBetweenAttempts.request().then(async () => (d("reconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (d("reconnect: onBeforeRetry success"), this.connect(e))).catch((t) => {
|
|
2407
|
+
const s = t instanceof Error ? t : new Error("Failed to reconnect");
|
|
2408
|
+
_e(t) || Pe(t) ? this.events.trigger(O.CANCELLED_ATTEMPT, s) : this.events.trigger(O.FAILED_ATTEMPT, s), d("reconnect: error", t);
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
hasFailedOrDisconnectedConnection() {
|
|
2412
|
+
const { isFailed: e, isDisconnected: t } = this.connectionManager;
|
|
2413
|
+
return e || t;
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
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 || {});
|
|
2417
|
+
const Ee = [
|
|
2078
2418
|
"incomingCall",
|
|
2079
2419
|
"declinedIncomingCall",
|
|
2080
2420
|
"terminatedIncomingCall",
|
|
2081
2421
|
"failedIncomingCall"
|
|
2082
|
-
],
|
|
2083
|
-
class
|
|
2422
|
+
], kt = 486, $t = 487;
|
|
2423
|
+
class Vt {
|
|
2084
2424
|
events;
|
|
2085
2425
|
incomingRTCSession;
|
|
2086
2426
|
connectionManager;
|
|
2087
2427
|
constructor(e) {
|
|
2088
|
-
this.connectionManager = e, this.events = new
|
|
2428
|
+
this.connectionManager = e, this.events = new U(Ee), this.start();
|
|
2089
2429
|
}
|
|
2090
2430
|
get remoteCallerData() {
|
|
2091
2431
|
return {
|
|
@@ -2115,19 +2455,19 @@ class gt {
|
|
|
2115
2455
|
return this.removeIncomingSession(), e;
|
|
2116
2456
|
};
|
|
2117
2457
|
async declineToIncomingCall({
|
|
2118
|
-
statusCode: e =
|
|
2458
|
+
statusCode: e = $t
|
|
2119
2459
|
} = {}) {
|
|
2120
2460
|
return new Promise((t, s) => {
|
|
2121
2461
|
try {
|
|
2122
2462
|
const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
|
|
2123
|
-
this.removeIncomingSession(), this.events.trigger(
|
|
2463
|
+
this.removeIncomingSession(), this.events.trigger(w.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
|
|
2124
2464
|
} catch (i) {
|
|
2125
2465
|
s(i);
|
|
2126
2466
|
}
|
|
2127
2467
|
});
|
|
2128
2468
|
}
|
|
2129
2469
|
async busyIncomingCall() {
|
|
2130
|
-
return this.declineToIncomingCall({ statusCode:
|
|
2470
|
+
return this.declineToIncomingCall({ statusCode: kt });
|
|
2131
2471
|
}
|
|
2132
2472
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
2133
2473
|
on(e, t) {
|
|
@@ -2164,19 +2504,19 @@ class gt {
|
|
|
2164
2504
|
this.incomingRTCSession = e;
|
|
2165
2505
|
const t = this.remoteCallerData;
|
|
2166
2506
|
e.on("failed", (s) => {
|
|
2167
|
-
this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(
|
|
2168
|
-
}), this.events.trigger(
|
|
2507
|
+
this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(w.TERMINATED_INCOMING_CALL, t) : this.events.trigger(w.FAILED_INCOMING_CALL, t);
|
|
2508
|
+
}), this.events.trigger(w.INCOMING_CALL, t);
|
|
2169
2509
|
}
|
|
2170
2510
|
removeIncomingSession() {
|
|
2171
2511
|
delete this.incomingRTCSession;
|
|
2172
2512
|
}
|
|
2173
2513
|
}
|
|
2174
|
-
const
|
|
2175
|
-
var
|
|
2176
|
-
const
|
|
2514
|
+
const b = 1e3;
|
|
2515
|
+
var E = /* @__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))(E || {});
|
|
2516
|
+
const Ae = ["collected"], X = () => "performance" in window ? performance.now() : Date.now(), L = (n) => [...n.keys()].reduce((e, t) => {
|
|
2177
2517
|
const s = n.get(t);
|
|
2178
2518
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2179
|
-
}, {}),
|
|
2519
|
+
}, {}), qt = (n) => {
|
|
2180
2520
|
if (!n)
|
|
2181
2521
|
return {
|
|
2182
2522
|
outboundRtp: void 0,
|
|
@@ -2184,14 +2524,14 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
|
|
|
2184
2524
|
mediaSource: void 0,
|
|
2185
2525
|
remoteInboundRtp: void 0
|
|
2186
2526
|
};
|
|
2187
|
-
const e =
|
|
2527
|
+
const e = L(n);
|
|
2188
2528
|
return {
|
|
2189
|
-
outboundRtp: e[
|
|
2190
|
-
codec: e[
|
|
2191
|
-
mediaSource: e[
|
|
2192
|
-
remoteInboundRtp: e[
|
|
2529
|
+
outboundRtp: e[E.OUTBOUND_RTP],
|
|
2530
|
+
codec: e[E.CODEC],
|
|
2531
|
+
mediaSource: e[E.MEDIA_SOURCE],
|
|
2532
|
+
remoteInboundRtp: e[E.REMOTE_INBOUND_RTP]
|
|
2193
2533
|
};
|
|
2194
|
-
},
|
|
2534
|
+
}, J = (n) => {
|
|
2195
2535
|
if (!n)
|
|
2196
2536
|
return {
|
|
2197
2537
|
outboundRtp: void 0,
|
|
@@ -2199,14 +2539,14 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
|
|
|
2199
2539
|
mediaSource: void 0,
|
|
2200
2540
|
remoteInboundRtp: void 0
|
|
2201
2541
|
};
|
|
2202
|
-
const e =
|
|
2542
|
+
const e = L(n);
|
|
2203
2543
|
return {
|
|
2204
|
-
outboundRtp: e[
|
|
2205
|
-
codec: e[
|
|
2206
|
-
mediaSource: e[
|
|
2207
|
-
remoteInboundRtp: e[
|
|
2544
|
+
outboundRtp: e[E.OUTBOUND_RTP],
|
|
2545
|
+
codec: e[E.CODEC],
|
|
2546
|
+
mediaSource: e[E.MEDIA_SOURCE],
|
|
2547
|
+
remoteInboundRtp: e[E.REMOTE_INBOUND_RTP]
|
|
2208
2548
|
};
|
|
2209
|
-
},
|
|
2549
|
+
}, K = ({
|
|
2210
2550
|
videoReceiversStats: n,
|
|
2211
2551
|
synchronizationSourcesVideo: e
|
|
2212
2552
|
}) => {
|
|
@@ -2216,13 +2556,13 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
|
|
|
2216
2556
|
codec: void 0,
|
|
2217
2557
|
synchronizationSources: e
|
|
2218
2558
|
};
|
|
2219
|
-
const t =
|
|
2559
|
+
const t = L(n);
|
|
2220
2560
|
return {
|
|
2221
|
-
inboundRtp: t[
|
|
2222
|
-
codec: t[
|
|
2561
|
+
inboundRtp: t[E.INBOUND_RTP],
|
|
2562
|
+
codec: t[E.CODEC],
|
|
2223
2563
|
synchronizationSources: e
|
|
2224
2564
|
};
|
|
2225
|
-
},
|
|
2565
|
+
}, Wt = ({
|
|
2226
2566
|
audioReceiverStats: n,
|
|
2227
2567
|
synchronizationSourcesAudio: e
|
|
2228
2568
|
}) => {
|
|
@@ -2233,14 +2573,14 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
|
|
|
2233
2573
|
remoteOutboundRtp: void 0,
|
|
2234
2574
|
synchronizationSources: e
|
|
2235
2575
|
};
|
|
2236
|
-
const t =
|
|
2576
|
+
const t = L(n);
|
|
2237
2577
|
return {
|
|
2238
|
-
inboundRtp: t[
|
|
2239
|
-
codec: t[
|
|
2240
|
-
remoteOutboundRtp: t[
|
|
2578
|
+
inboundRtp: t[E.INBOUND_RTP],
|
|
2579
|
+
codec: t[E.CODEC],
|
|
2580
|
+
remoteOutboundRtp: t[E.REMOTE_OUTBOUND_RTP],
|
|
2241
2581
|
synchronizationSources: e
|
|
2242
2582
|
};
|
|
2243
|
-
},
|
|
2583
|
+
}, Ne = (n) => {
|
|
2244
2584
|
if (!n)
|
|
2245
2585
|
return {
|
|
2246
2586
|
candidatePair: void 0,
|
|
@@ -2249,47 +2589,47 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
|
|
|
2249
2589
|
remoteCandidate: void 0,
|
|
2250
2590
|
transport: void 0
|
|
2251
2591
|
};
|
|
2252
|
-
const e =
|
|
2592
|
+
const e = L(n);
|
|
2253
2593
|
return {
|
|
2254
|
-
candidatePair: e[
|
|
2255
|
-
certificate: e[
|
|
2256
|
-
localCandidate: e[
|
|
2257
|
-
remoteCandidate: e[
|
|
2258
|
-
transport: e[
|
|
2594
|
+
candidatePair: e[E.CANDIDATE_PAIR],
|
|
2595
|
+
certificate: e[E.CERTIFICATE],
|
|
2596
|
+
localCandidate: e[E.LOCAL_CANDIDATE],
|
|
2597
|
+
remoteCandidate: e[E.REMOTE_CANDIDATE],
|
|
2598
|
+
transport: e[E.TRANSPORT]
|
|
2259
2599
|
};
|
|
2260
|
-
},
|
|
2600
|
+
}, Ht = ({
|
|
2261
2601
|
audioSenderStats: n,
|
|
2262
2602
|
videoSenderFirstStats: e,
|
|
2263
2603
|
videoSenderSecondStats: t
|
|
2264
2604
|
}) => ({
|
|
2265
|
-
video:
|
|
2266
|
-
secondVideo:
|
|
2267
|
-
audio:
|
|
2268
|
-
additional:
|
|
2605
|
+
video: J(e),
|
|
2606
|
+
secondVideo: J(t),
|
|
2607
|
+
audio: qt(n),
|
|
2608
|
+
additional: Ne(
|
|
2269
2609
|
n ?? e ?? t
|
|
2270
2610
|
)
|
|
2271
|
-
}),
|
|
2611
|
+
}), xt = ({
|
|
2272
2612
|
audioReceiverStats: n,
|
|
2273
2613
|
videoReceiverFirstStats: e,
|
|
2274
2614
|
videoReceiverSecondStats: t,
|
|
2275
2615
|
synchronizationSources: s
|
|
2276
2616
|
}) => ({
|
|
2277
|
-
video:
|
|
2617
|
+
video: K({
|
|
2278
2618
|
videoReceiversStats: e,
|
|
2279
2619
|
synchronizationSourcesVideo: s.video
|
|
2280
2620
|
}),
|
|
2281
|
-
secondVideo:
|
|
2621
|
+
secondVideo: K({
|
|
2282
2622
|
videoReceiversStats: t,
|
|
2283
2623
|
synchronizationSourcesVideo: s.video
|
|
2284
2624
|
}),
|
|
2285
|
-
audio:
|
|
2625
|
+
audio: Wt({
|
|
2286
2626
|
audioReceiverStats: n,
|
|
2287
2627
|
synchronizationSourcesAudio: s.audio
|
|
2288
2628
|
}),
|
|
2289
|
-
additional:
|
|
2629
|
+
additional: Ne(
|
|
2290
2630
|
n ?? e ?? t
|
|
2291
2631
|
)
|
|
2292
|
-
}),
|
|
2632
|
+
}), Gt = ({
|
|
2293
2633
|
audioSenderStats: n,
|
|
2294
2634
|
videoSenderFirstStats: e,
|
|
2295
2635
|
videoSenderSecondStats: t,
|
|
@@ -2298,11 +2638,11 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
|
|
|
2298
2638
|
videoReceiverSecondStats: r,
|
|
2299
2639
|
synchronizationSources: a
|
|
2300
2640
|
}) => {
|
|
2301
|
-
const o =
|
|
2641
|
+
const o = Ht({
|
|
2302
2642
|
audioSenderStats: n,
|
|
2303
2643
|
videoSenderFirstStats: e,
|
|
2304
2644
|
videoSenderSecondStats: t
|
|
2305
|
-
}), c =
|
|
2645
|
+
}), c = xt({
|
|
2306
2646
|
audioReceiverStats: s,
|
|
2307
2647
|
videoReceiverFirstStats: i,
|
|
2308
2648
|
videoReceiverSecondStats: r,
|
|
@@ -2312,16 +2652,16 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
|
|
|
2312
2652
|
outbound: o,
|
|
2313
2653
|
inbound: c
|
|
2314
2654
|
};
|
|
2315
|
-
},
|
|
2316
|
-
const e = "audio", t = "video", s = n.getSenders(), i = s.find((
|
|
2655
|
+
}, Qt = async (n) => {
|
|
2656
|
+
const e = "audio", t = "video", s = n.getSenders(), i = s.find((g) => g.track?.kind === e), r = s.filter((g) => g.track?.kind === t), a = n.getReceivers(), o = a.find((g) => g.track.kind === e), c = a.filter((g) => g.track.kind === t), h = {
|
|
2317
2657
|
trackIdentifier: o?.track.id,
|
|
2318
2658
|
item: o?.getSynchronizationSources()[0]
|
|
2319
|
-
},
|
|
2659
|
+
}, T = {
|
|
2320
2660
|
trackIdentifier: c[0]?.track.id,
|
|
2321
2661
|
item: c[0]?.getSynchronizationSources()[0]
|
|
2322
|
-
},
|
|
2323
|
-
audio:
|
|
2324
|
-
video:
|
|
2662
|
+
}, S = {
|
|
2663
|
+
audio: h,
|
|
2664
|
+
video: T
|
|
2325
2665
|
};
|
|
2326
2666
|
return Promise.all([
|
|
2327
2667
|
i?.getStats() ?? Promise.resolve(void 0),
|
|
@@ -2330,41 +2670,41 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
|
|
|
2330
2670
|
o?.getStats() ?? Promise.resolve(void 0),
|
|
2331
2671
|
c[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2332
2672
|
c[1]?.getStats() ?? Promise.resolve(void 0)
|
|
2333
|
-
]).then((
|
|
2673
|
+
]).then((g) => {
|
|
2334
2674
|
const [
|
|
2335
|
-
|
|
2675
|
+
C,
|
|
2336
2676
|
m,
|
|
2337
2677
|
I,
|
|
2338
2678
|
R,
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
] =
|
|
2679
|
+
y,
|
|
2680
|
+
$
|
|
2681
|
+
] = g;
|
|
2342
2682
|
return {
|
|
2343
|
-
synchronizationSources:
|
|
2344
|
-
audioSenderStats:
|
|
2683
|
+
synchronizationSources: S,
|
|
2684
|
+
audioSenderStats: C,
|
|
2345
2685
|
videoSenderFirstStats: m,
|
|
2346
2686
|
videoSenderSecondStats: I,
|
|
2347
2687
|
audioReceiverStats: R,
|
|
2348
|
-
videoReceiverFirstStats:
|
|
2349
|
-
videoReceiverSecondStats:
|
|
2688
|
+
videoReceiverFirstStats: y,
|
|
2689
|
+
videoReceiverSecondStats: $
|
|
2350
2690
|
};
|
|
2351
2691
|
});
|
|
2352
|
-
},
|
|
2353
|
-
|
|
2692
|
+
}, Yt = (n) => {
|
|
2693
|
+
d(String(n));
|
|
2354
2694
|
};
|
|
2355
|
-
class
|
|
2695
|
+
class zt {
|
|
2356
2696
|
events;
|
|
2357
2697
|
setTimeoutRequest;
|
|
2358
|
-
requesterAllStatistics = new
|
|
2698
|
+
requesterAllStatistics = new G(Qt);
|
|
2359
2699
|
constructor() {
|
|
2360
|
-
this.events = new
|
|
2700
|
+
this.events = new k(Ae), this.setTimeoutRequest = new Z();
|
|
2361
2701
|
}
|
|
2362
2702
|
get requested() {
|
|
2363
2703
|
return this.setTimeoutRequest.requested;
|
|
2364
2704
|
}
|
|
2365
2705
|
start(e, {
|
|
2366
|
-
interval: t =
|
|
2367
|
-
onError: s =
|
|
2706
|
+
interval: t = b,
|
|
2707
|
+
onError: s = Yt
|
|
2368
2708
|
} = {}) {
|
|
2369
2709
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
2370
2710
|
this.collectStatistics(e, {
|
|
@@ -2393,12 +2733,12 @@ class Rt {
|
|
|
2393
2733
|
collectStatistics = (e, {
|
|
2394
2734
|
onError: t
|
|
2395
2735
|
}) => {
|
|
2396
|
-
const s =
|
|
2736
|
+
const s = X();
|
|
2397
2737
|
this.requesterAllStatistics.request(e).then((i) => {
|
|
2398
|
-
this.events.trigger("collected",
|
|
2399
|
-
const a =
|
|
2400
|
-
let o =
|
|
2401
|
-
a > 48 ? o =
|
|
2738
|
+
this.events.trigger("collected", Gt(i));
|
|
2739
|
+
const a = X() - s;
|
|
2740
|
+
let o = b;
|
|
2741
|
+
a > 48 ? o = b * 4 : a > 32 ? o = b * 3 : a > 16 && (o = b * 2), this.start(e, {
|
|
2402
2742
|
onError: t,
|
|
2403
2743
|
interval: o
|
|
2404
2744
|
});
|
|
@@ -2407,7 +2747,7 @@ class Rt {
|
|
|
2407
2747
|
});
|
|
2408
2748
|
};
|
|
2409
2749
|
}
|
|
2410
|
-
class
|
|
2750
|
+
class Xt {
|
|
2411
2751
|
availableIncomingBitrate;
|
|
2412
2752
|
statsPeerConnection;
|
|
2413
2753
|
callManager;
|
|
@@ -2417,7 +2757,7 @@ class It {
|
|
|
2417
2757
|
callManager: e,
|
|
2418
2758
|
apiManager: t
|
|
2419
2759
|
}) {
|
|
2420
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
2760
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new zt(), this.subscribe();
|
|
2421
2761
|
}
|
|
2422
2762
|
get events() {
|
|
2423
2763
|
return this.statsPeerConnection.events;
|
|
@@ -2455,30 +2795,30 @@ class It {
|
|
|
2455
2795
|
};
|
|
2456
2796
|
maybeSendStats() {
|
|
2457
2797
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
2458
|
-
|
|
2798
|
+
d("Failed to send stats", e);
|
|
2459
2799
|
});
|
|
2460
2800
|
}
|
|
2461
2801
|
}
|
|
2462
|
-
const
|
|
2802
|
+
const Jt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), Kt = (n) => {
|
|
2463
2803
|
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
|
|
2464
|
-
return
|
|
2465
|
-
},
|
|
2804
|
+
return Jt(s, i);
|
|
2805
|
+
}, jt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
2466
2806
|
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;
|
|
2467
2807
|
return a - o;
|
|
2468
|
-
}),
|
|
2808
|
+
}), Zt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), en = (n, {
|
|
2469
2809
|
preferredMimeTypesVideoCodecs: e,
|
|
2470
2810
|
excludeMimeTypesVideoCodecs: t
|
|
2471
2811
|
}) => {
|
|
2472
2812
|
try {
|
|
2473
2813
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
2474
|
-
const s =
|
|
2814
|
+
const s = Kt("video"), i = Zt(s, t), r = jt(i, e);
|
|
2475
2815
|
n.setCodecPreferences(r);
|
|
2476
2816
|
}
|
|
2477
2817
|
} catch (s) {
|
|
2478
|
-
|
|
2818
|
+
d("setCodecPreferences error", s);
|
|
2479
2819
|
}
|
|
2480
2820
|
};
|
|
2481
|
-
class
|
|
2821
|
+
class tn {
|
|
2482
2822
|
/**
|
|
2483
2823
|
* Хранилище основных transceiver'ов
|
|
2484
2824
|
*/
|
|
@@ -2557,10 +2897,10 @@ class vt {
|
|
|
2557
2897
|
*/
|
|
2558
2898
|
handleRestart = (e) => {
|
|
2559
2899
|
this.updateTransceivers(e).catch((t) => {
|
|
2560
|
-
|
|
2900
|
+
d("Failed to update transceivers", t);
|
|
2561
2901
|
}).finally(() => {
|
|
2562
2902
|
this.callManager.restartIce().catch((t) => {
|
|
2563
|
-
|
|
2903
|
+
d("Failed to restart ICE", t);
|
|
2564
2904
|
});
|
|
2565
2905
|
});
|
|
2566
2906
|
};
|
|
@@ -2572,7 +2912,7 @@ class vt {
|
|
|
2572
2912
|
t === 2 && (this.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
|
|
2573
2913
|
direction: "recvonly"
|
|
2574
2914
|
}).catch((r) => {
|
|
2575
|
-
|
|
2915
|
+
d("Failed to add presentation video transceiver", r);
|
|
2576
2916
|
}));
|
|
2577
2917
|
};
|
|
2578
2918
|
subscribe() {
|
|
@@ -2585,15 +2925,15 @@ class vt {
|
|
|
2585
2925
|
this.clear();
|
|
2586
2926
|
};
|
|
2587
2927
|
}
|
|
2588
|
-
const
|
|
2589
|
-
class
|
|
2928
|
+
const nn = (n) => [...n.keys()].map((e) => n.get(e)), sn = (n, e) => nn(n).find((t) => t?.type === e), rn = async (n) => n.getStats().then((e) => sn(e, "codec")?.mimeType);
|
|
2929
|
+
class an {
|
|
2590
2930
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2591
2931
|
async getCodecFromSender(e) {
|
|
2592
|
-
return await
|
|
2932
|
+
return await rn(e) ?? "";
|
|
2593
2933
|
}
|
|
2594
2934
|
}
|
|
2595
|
-
class
|
|
2596
|
-
stackPromises =
|
|
2935
|
+
class on {
|
|
2936
|
+
stackPromises = te({
|
|
2597
2937
|
noRunIsNotActual: !0
|
|
2598
2938
|
});
|
|
2599
2939
|
/**
|
|
@@ -2613,34 +2953,34 @@ class bt {
|
|
|
2613
2953
|
*/
|
|
2614
2954
|
async run() {
|
|
2615
2955
|
return this.stackPromises().catch((e) => {
|
|
2616
|
-
|
|
2956
|
+
d("TaskQueue: error", e);
|
|
2617
2957
|
});
|
|
2618
2958
|
}
|
|
2619
2959
|
}
|
|
2620
|
-
class
|
|
2960
|
+
class cn {
|
|
2621
2961
|
taskQueue;
|
|
2622
2962
|
onSetParameters;
|
|
2623
2963
|
constructor(e) {
|
|
2624
|
-
this.onSetParameters = e, this.taskQueue = new
|
|
2964
|
+
this.onSetParameters = e, this.taskQueue = new on();
|
|
2625
2965
|
}
|
|
2626
2966
|
async setEncodingsToSender(e, t) {
|
|
2627
|
-
return this.taskQueue.add(async () =>
|
|
2967
|
+
return this.taskQueue.add(async () => de(e, t, this.onSetParameters));
|
|
2628
2968
|
}
|
|
2629
2969
|
stop() {
|
|
2630
2970
|
this.taskQueue.stop();
|
|
2631
2971
|
}
|
|
2632
2972
|
}
|
|
2633
|
-
const
|
|
2634
|
-
const t =
|
|
2635
|
-
return
|
|
2636
|
-
},
|
|
2973
|
+
const Re = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), dn = 1e6, M = (n) => n * dn, Ie = M(0.06), pe = M(4), hn = (n) => n <= 64 ? Ie : n <= 128 ? M(0.12) : n <= 256 ? M(0.25) : n <= 384 ? M(0.32) : n <= 426 ? M(0.38) : n <= 640 ? M(0.5) : n <= 848 ? M(0.7) : n <= 1280 ? M(1) : n <= 1920 ? M(2) : pe, ln = "av1", gn = (n) => Re(n, ln), un = 0.6, Y = (n, e) => gn(e) ? n * un : n, Tn = (n) => Y(Ie, n), Sn = (n) => Y(pe, n), j = (n, e) => {
|
|
2974
|
+
const t = hn(n);
|
|
2975
|
+
return Y(t, e);
|
|
2976
|
+
}, V = 1, Cn = ({
|
|
2637
2977
|
videoTrack: n,
|
|
2638
2978
|
targetSize: e
|
|
2639
2979
|
}) => {
|
|
2640
|
-
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ?
|
|
2641
|
-
return Math.max(r, a,
|
|
2980
|
+
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? V : s / e.width, a = i === void 0 ? V : i / e.height;
|
|
2981
|
+
return Math.max(r, a, V);
|
|
2642
2982
|
};
|
|
2643
|
-
class
|
|
2983
|
+
class En {
|
|
2644
2984
|
ignoreForCodec;
|
|
2645
2985
|
senderFinder;
|
|
2646
2986
|
codecProvider;
|
|
@@ -2673,7 +3013,7 @@ class Ht {
|
|
|
2673
3013
|
if (!i?.track)
|
|
2674
3014
|
return { ...this.resultNoChanged, sender: i };
|
|
2675
3015
|
const r = await this.codecProvider.getCodecFromSender(i);
|
|
2676
|
-
if (
|
|
3016
|
+
if (Re(r, this.ignoreForCodec))
|
|
2677
3017
|
return { ...this.resultNoChanged, sender: i };
|
|
2678
3018
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
2679
3019
|
return this.processSender(
|
|
@@ -2693,14 +3033,14 @@ class Ht {
|
|
|
2693
3033
|
async processSender(e, t) {
|
|
2694
3034
|
const { mainCam: s, resolutionMainCam: i } = e;
|
|
2695
3035
|
switch (s) {
|
|
2696
|
-
case
|
|
3036
|
+
case v.PAUSE_MAIN_CAM:
|
|
2697
3037
|
return this.downgradeResolutionSender(t);
|
|
2698
|
-
case
|
|
3038
|
+
case v.RESUME_MAIN_CAM:
|
|
2699
3039
|
return this.setBitrateByTrackResolution(t);
|
|
2700
|
-
case
|
|
3040
|
+
case v.MAX_MAIN_CAM_RESOLUTION:
|
|
2701
3041
|
return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
|
|
2702
|
-
case
|
|
2703
|
-
case
|
|
3042
|
+
case v.ADMIN_STOP_MAIN_CAM:
|
|
3043
|
+
case v.ADMIN_START_MAIN_CAM:
|
|
2704
3044
|
case void 0:
|
|
2705
3045
|
return this.setBitrateByTrackResolution(t);
|
|
2706
3046
|
default:
|
|
@@ -2715,7 +3055,7 @@ class Ht {
|
|
|
2715
3055
|
async downgradeResolutionSender(e) {
|
|
2716
3056
|
const { sender: t, codec: s } = e, i = {
|
|
2717
3057
|
scaleResolutionDownBy: 200,
|
|
2718
|
-
maxBitrate:
|
|
3058
|
+
maxBitrate: Tn(s)
|
|
2719
3059
|
};
|
|
2720
3060
|
return this.parametersSetter.setEncodingsToSender(t, i);
|
|
2721
3061
|
}
|
|
@@ -2725,7 +3065,7 @@ class Ht {
|
|
|
2725
3065
|
* @returns Promise с результатом
|
|
2726
3066
|
*/
|
|
2727
3067
|
async setBitrateByTrackResolution(e) {
|
|
2728
|
-
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ?
|
|
3068
|
+
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Sn(i) : j(a, i);
|
|
2729
3069
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
2730
3070
|
scaleResolutionDownBy: 1,
|
|
2731
3071
|
maxBitrate: o
|
|
@@ -2741,24 +3081,24 @@ class Ht {
|
|
|
2741
3081
|
const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
|
|
2742
3082
|
width: Number(s),
|
|
2743
3083
|
height: Number(i)
|
|
2744
|
-
},
|
|
3084
|
+
}, h = Cn({
|
|
2745
3085
|
videoTrack: a,
|
|
2746
3086
|
targetSize: c
|
|
2747
|
-
}),
|
|
2748
|
-
scaleResolutionDownBy:
|
|
2749
|
-
maxBitrate:
|
|
3087
|
+
}), T = j(c.width, o), S = {
|
|
3088
|
+
scaleResolutionDownBy: h,
|
|
3089
|
+
maxBitrate: T
|
|
2750
3090
|
};
|
|
2751
|
-
return this.parametersSetter.setEncodingsToSender(r,
|
|
3091
|
+
return this.parametersSetter.setEncodingsToSender(r, S);
|
|
2752
3092
|
}
|
|
2753
3093
|
}
|
|
2754
|
-
const
|
|
2755
|
-
class
|
|
3094
|
+
const An = (n) => n.find((e) => e.track?.kind === "video");
|
|
3095
|
+
class Nn {
|
|
2756
3096
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2757
3097
|
findVideoSender(e) {
|
|
2758
|
-
return
|
|
3098
|
+
return An(e);
|
|
2759
3099
|
}
|
|
2760
3100
|
}
|
|
2761
|
-
class
|
|
3101
|
+
class Rn {
|
|
2762
3102
|
currentSender;
|
|
2763
3103
|
originalReplaceTrack;
|
|
2764
3104
|
lastWidth;
|
|
@@ -2771,7 +3111,7 @@ class Gt {
|
|
|
2771
3111
|
pollIntervalMs: e = 1e3,
|
|
2772
3112
|
maxPollIntervalMs: t
|
|
2773
3113
|
}) {
|
|
2774
|
-
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new
|
|
3114
|
+
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new Z();
|
|
2775
3115
|
}
|
|
2776
3116
|
/**
|
|
2777
3117
|
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
@@ -2822,7 +3162,7 @@ class Gt {
|
|
|
2822
3162
|
this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
|
|
2823
3163
|
}
|
|
2824
3164
|
}
|
|
2825
|
-
class
|
|
3165
|
+
class In {
|
|
2826
3166
|
apiManager;
|
|
2827
3167
|
currentHandler;
|
|
2828
3168
|
constructor(e) {
|
|
@@ -2842,7 +3182,7 @@ class Qt {
|
|
|
2842
3182
|
this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
2843
3183
|
}
|
|
2844
3184
|
}
|
|
2845
|
-
class
|
|
3185
|
+
class pn {
|
|
2846
3186
|
eventHandler;
|
|
2847
3187
|
senderBalancer;
|
|
2848
3188
|
parametersSetterWithQueue;
|
|
@@ -2854,16 +3194,16 @@ class Yt {
|
|
|
2854
3194
|
onSetParameters: i,
|
|
2855
3195
|
pollIntervalMs: r
|
|
2856
3196
|
} = {}) {
|
|
2857
|
-
this.getConnection = t, this.eventHandler = new
|
|
3197
|
+
this.getConnection = t, this.eventHandler = new In(e), this.parametersSetterWithQueue = new cn(i), this.senderBalancer = new En(
|
|
2858
3198
|
{
|
|
2859
|
-
senderFinder: new
|
|
2860
|
-
codecProvider: new
|
|
3199
|
+
senderFinder: new Nn(),
|
|
3200
|
+
codecProvider: new an(),
|
|
2861
3201
|
parametersSetter: this.parametersSetterWithQueue
|
|
2862
3202
|
},
|
|
2863
3203
|
{
|
|
2864
3204
|
ignoreForCodec: s
|
|
2865
3205
|
}
|
|
2866
|
-
), this.trackMonitor = new
|
|
3206
|
+
), this.trackMonitor = new Rn({ pollIntervalMs: r });
|
|
2867
3207
|
}
|
|
2868
3208
|
/**
|
|
2869
3209
|
* Подписывается на события управления главной камерой
|
|
@@ -2894,7 +3234,7 @@ class Yt {
|
|
|
2894
3234
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
2895
3235
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
2896
3236
|
this.balance().catch((s) => {
|
|
2897
|
-
|
|
3237
|
+
d("balance on track change: error", s);
|
|
2898
3238
|
});
|
|
2899
3239
|
}), t;
|
|
2900
3240
|
}
|
|
@@ -2904,17 +3244,17 @@ class Yt {
|
|
|
2904
3244
|
*/
|
|
2905
3245
|
handleMainCamControl = (e) => {
|
|
2906
3246
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
2907
|
-
|
|
3247
|
+
d("handleMainCamControl: error", t);
|
|
2908
3248
|
});
|
|
2909
3249
|
};
|
|
2910
3250
|
}
|
|
2911
|
-
const
|
|
3251
|
+
const me = [
|
|
2912
3252
|
"balancing-scheduled",
|
|
2913
3253
|
"balancing-started",
|
|
2914
3254
|
"balancing-stopped",
|
|
2915
3255
|
"parameters-updated"
|
|
2916
3256
|
];
|
|
2917
|
-
class
|
|
3257
|
+
class mn {
|
|
2918
3258
|
isBalancingActive = !1;
|
|
2919
3259
|
events;
|
|
2920
3260
|
callManager;
|
|
@@ -2922,7 +3262,7 @@ class zt {
|
|
|
2922
3262
|
videoSendingBalancer;
|
|
2923
3263
|
startBalancingTimer;
|
|
2924
3264
|
constructor(e, t, s = {}) {
|
|
2925
|
-
this.events = new
|
|
3265
|
+
this.events = new k(me), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new pn(
|
|
2926
3266
|
t,
|
|
2927
3267
|
() => e.connection,
|
|
2928
3268
|
{
|
|
@@ -2984,7 +3324,7 @@ class zt {
|
|
|
2984
3324
|
scheduleBalancingStart() {
|
|
2985
3325
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
2986
3326
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
2987
|
-
|
|
3327
|
+
d("startBalancing: error", e);
|
|
2988
3328
|
});
|
|
2989
3329
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
2990
3330
|
}
|
|
@@ -2992,20 +3332,22 @@ class zt {
|
|
|
2992
3332
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
2993
3333
|
}
|
|
2994
3334
|
}
|
|
2995
|
-
const
|
|
2996
|
-
...
|
|
2997
|
-
...
|
|
2998
|
-
...
|
|
2999
|
-
...
|
|
3000
|
-
...
|
|
3001
|
-
...
|
|
3002
|
-
...
|
|
3335
|
+
const _n = 1e6, Mn = Se.map((n) => `auto-connect:${n}`), vn = ge.map((n) => `connection:${n}`), fn = ie.map((n) => `call:${n}`), Pn = ne.map((n) => `api:${n}`), On = Ee.map((n) => `incoming-call:${n}`), Dn = he.map((n) => `presentation:${n}`), yn = Ae.map((n) => `stats:${n}`), bn = me.map((n) => `video-balancer:${n}`), wn = [
|
|
3336
|
+
...Mn,
|
|
3337
|
+
...vn,
|
|
3338
|
+
...fn,
|
|
3339
|
+
...Pn,
|
|
3340
|
+
...On,
|
|
3341
|
+
...Dn,
|
|
3342
|
+
...yn,
|
|
3343
|
+
...bn
|
|
3003
3344
|
];
|
|
3004
|
-
class
|
|
3345
|
+
class Yn {
|
|
3005
3346
|
events;
|
|
3006
3347
|
connectionManager;
|
|
3007
3348
|
connectionQueueManager;
|
|
3008
3349
|
callManager;
|
|
3350
|
+
autoConnectorManager;
|
|
3009
3351
|
apiManager;
|
|
3010
3352
|
incomingCallManager;
|
|
3011
3353
|
presentationManager;
|
|
@@ -3017,23 +3359,31 @@ class En {
|
|
|
3017
3359
|
constructor({ JsSIP: e }, {
|
|
3018
3360
|
preferredMimeTypesVideoCodecs: t,
|
|
3019
3361
|
excludeMimeTypesVideoCodecs: s,
|
|
3020
|
-
videoBalancerOptions: i
|
|
3362
|
+
videoBalancerOptions: i,
|
|
3363
|
+
autoConnectorOptions: r
|
|
3021
3364
|
} = {}) {
|
|
3022
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new
|
|
3365
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new U(wn), this.connectionManager = new mt({ JsSIP: e }), this.connectionQueueManager = new _t({
|
|
3023
3366
|
connectionManager: this.connectionManager
|
|
3024
|
-
}), this.callManager = new
|
|
3367
|
+
}), this.callManager = new Xe(), this.apiManager = new ke({
|
|
3025
3368
|
connectionManager: this.connectionManager,
|
|
3026
3369
|
callManager: this.callManager
|
|
3027
|
-
}), this.incomingCallManager = new
|
|
3370
|
+
}), this.incomingCallManager = new Vt(this.connectionManager), this.presentationManager = new ht({
|
|
3028
3371
|
callManager: this.callManager,
|
|
3029
|
-
maxBitrate:
|
|
3030
|
-
}), this.statsManager = new
|
|
3372
|
+
maxBitrate: _n
|
|
3373
|
+
}), this.statsManager = new Xt({
|
|
3031
3374
|
callManager: this.callManager,
|
|
3032
3375
|
apiManager: this.apiManager
|
|
3033
|
-
}), this.
|
|
3376
|
+
}), this.autoConnectorManager = new Ft(
|
|
3377
|
+
{
|
|
3378
|
+
connectionQueueManager: this.connectionQueueManager,
|
|
3379
|
+
connectionManager: this.connectionManager,
|
|
3380
|
+
callManager: this.callManager
|
|
3381
|
+
},
|
|
3382
|
+
r
|
|
3383
|
+
), this.transceiverManager = new tn({
|
|
3034
3384
|
callManager: this.callManager,
|
|
3035
3385
|
apiManager: this.apiManager
|
|
3036
|
-
}), this.videoSendingBalancerManager = new
|
|
3386
|
+
}), this.videoSendingBalancerManager = new mn(
|
|
3037
3387
|
this.callManager,
|
|
3038
3388
|
this.apiManager,
|
|
3039
3389
|
i
|
|
@@ -3098,17 +3448,23 @@ class En {
|
|
|
3098
3448
|
this.events.off(e, t);
|
|
3099
3449
|
}
|
|
3100
3450
|
connect = async (...e) => this.connectionQueueManager.connect(...e);
|
|
3101
|
-
set = async (...e) => this.connectionQueueManager.set(...e);
|
|
3102
3451
|
disconnect = async () => this.connectionQueueManager.disconnect();
|
|
3103
|
-
register = async () => this.
|
|
3104
|
-
unregister = async () => this.
|
|
3105
|
-
tryRegister = async () => this.
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3452
|
+
register = async () => this.connectionManager.register();
|
|
3453
|
+
unregister = async () => this.connectionManager.unregister();
|
|
3454
|
+
tryRegister = async () => this.connectionManager.tryRegister();
|
|
3455
|
+
set = async (...e) => this.connectionManager.set(...e);
|
|
3456
|
+
sendOptions = async (e, t, s) => this.connectionManager.sendOptions(e, t, s);
|
|
3457
|
+
ping = async (e, t) => this.connectionManager.ping(e, t);
|
|
3458
|
+
checkTelephony = async (e) => this.connectionManager.checkTelephony(e);
|
|
3109
3459
|
isConfigured = () => this.connectionManager.isConfigured();
|
|
3110
3460
|
getConnectionConfiguration = () => this.connectionManager.getConnectionConfiguration();
|
|
3111
3461
|
getSipServerUrl = (e) => this.connectionManager.getSipServerUrl(e);
|
|
3462
|
+
startAutoConnect = (...e) => {
|
|
3463
|
+
this.autoConnectorManager.start(...e);
|
|
3464
|
+
};
|
|
3465
|
+
stopAutoConnect = () => {
|
|
3466
|
+
this.autoConnectorManager.stop();
|
|
3467
|
+
};
|
|
3112
3468
|
call = async (e) => {
|
|
3113
3469
|
const { onAddedTransceiver: t, ...s } = e;
|
|
3114
3470
|
return this.callManager.startCall(
|
|
@@ -3212,13 +3568,13 @@ class En {
|
|
|
3212
3568
|
return this.apiManager.askPermissionToEnableCam(...e);
|
|
3213
3569
|
}
|
|
3214
3570
|
setCodecPreferences(e) {
|
|
3215
|
-
|
|
3571
|
+
en(e, {
|
|
3216
3572
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
3217
3573
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
3218
3574
|
});
|
|
3219
3575
|
}
|
|
3220
3576
|
subscribe() {
|
|
3221
|
-
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);
|
|
3577
|
+
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);
|
|
3222
3578
|
}
|
|
3223
3579
|
bridgeEvents = (e, t) => {
|
|
3224
3580
|
t.events.eachTriggers((s, i) => {
|
|
@@ -3232,18 +3588,21 @@ class En {
|
|
|
3232
3588
|
};
|
|
3233
3589
|
}
|
|
3234
3590
|
export {
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3591
|
+
ae as E,
|
|
3592
|
+
$e as O,
|
|
3593
|
+
Yn as S,
|
|
3594
|
+
at as a,
|
|
3595
|
+
Fe as b,
|
|
3596
|
+
Gn as c,
|
|
3597
|
+
xn as d,
|
|
3598
|
+
Hn as e,
|
|
3599
|
+
E as f,
|
|
3600
|
+
zt as g,
|
|
3601
|
+
Rt as h,
|
|
3602
|
+
rn as i,
|
|
3603
|
+
Qn as j,
|
|
3604
|
+
d as l,
|
|
3605
|
+
F as p,
|
|
3606
|
+
pt as r,
|
|
3607
|
+
de as s
|
|
3249
3608
|
};
|