sip-connector 19.5.0 → 19.7.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/dist/@SipConnector-CMDm0Voo.cjs +1 -0
- package/dist/{@SipConnector-CM9pBA-c.js → @SipConnector-DXMX6l2G.js} +451 -408
- package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +8 -0
- package/dist/AutoConnectorManager/types.d.ts +15 -0
- package/dist/ConnectionManager/@ConnectionManager.d.ts +1 -1
- package/dist/ConnectionManager/ConfigurationManager.d.ts +4 -4
- package/dist/ConnectionManager/ConnectionFlow.d.ts +5 -5
- package/dist/ConnectionManager/UAFactory.d.ts +1 -1
- package/dist/SipConnector/@SipConnector.d.ts +1 -1
- package/dist/StatsPeerConnection/types.d.ts +6 -32
- package/dist/__fixtures__/index.d.ts +3 -0
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +40 -37
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/tools/__fixtures__/connectToServer.d.ts +5 -0
- package/dist/tools/__fixtures__/processRequest.d.ts +1 -1
- package/dist/tools/__tests-utils__/parseObject.d.ts +1 -3
- package/package.json +9 -9
- package/dist/@SipConnector-kXwCLeH0.cjs +0 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Events as k, TypedEvents as U } from "events-constructor";
|
|
2
2
|
import x from "debug";
|
|
3
3
|
import { CancelableRequest as G, isCanceledError as me } from "@krivega/cancelable-promise";
|
|
4
|
-
import { resolveRequesterByTimeout as _e, requesterByTimeoutsWithFailCalls as Me, DelayRequester as
|
|
4
|
+
import { resolveRequesterByTimeout as _e, requesterByTimeoutsWithFailCalls as Me, DelayRequester as fe, hasCanceledError as ve, SetTimeoutRequest as Z } from "@krivega/timeout-requester";
|
|
5
5
|
import { hasCanceledError as Pe, repeatedCallsAsync as ee } from "repeated-calls";
|
|
6
6
|
import { setup as Oe, createActor as ye } from "xstate";
|
|
7
7
|
import { createStackPromises as te, isPromiseIsNotActualError as De } from "stack-promises";
|
|
8
8
|
import "ua-parser-js";
|
|
9
9
|
import "sequent-promises";
|
|
10
|
-
const Q = "sip-connector",
|
|
10
|
+
const Q = "sip-connector", h = x(Q), Wn = () => {
|
|
11
11
|
x.enable(Q);
|
|
12
12
|
}, Hn = () => {
|
|
13
13
|
x.enable(`-${Q}`);
|
|
14
14
|
}, be = "Error decline with 603", we = 1006, Ue = (n) => typeof n == "object" && n !== null && "code" in n && n.code === we, Le = (n) => n.message === be;
|
|
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 || {}),
|
|
15
|
+
var l = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(l || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), V = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(V || {}), P = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.RESTART = "application/vinteo.webrtc.restart", n))(P || {}), _ = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(_ || {}), v = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(v || {}), 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 || {}), Be = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Be || {}), g = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n.RESTART = "restart", n))(g || {});
|
|
16
16
|
const ne = [
|
|
17
17
|
"participation:accepting-word-request",
|
|
18
18
|
"participation:cancelling-word-request",
|
|
@@ -55,41 +55,41 @@ class Fe {
|
|
|
55
55
|
this.connectionManager = e, this.callManager = t, this.events = new k(ne), this.subscribe();
|
|
56
56
|
}
|
|
57
57
|
async waitChannels() {
|
|
58
|
-
return this.wait(
|
|
58
|
+
return this.wait(g.CHANNELS);
|
|
59
59
|
}
|
|
60
60
|
async waitSyncMediaState() {
|
|
61
|
-
return this.wait(
|
|
61
|
+
return this.wait(g.ADMIN_FORCE_SYNC_MEDIA_STATE);
|
|
62
62
|
}
|
|
63
63
|
async sendDTMF(e) {
|
|
64
64
|
return new Promise((t, s) => {
|
|
65
|
-
let
|
|
65
|
+
let r;
|
|
66
66
|
try {
|
|
67
|
-
|
|
68
|
-
} catch (
|
|
69
|
-
s(
|
|
67
|
+
r = this.getEstablishedRTCSessionProtected();
|
|
68
|
+
} catch (i) {
|
|
69
|
+
s(i);
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}),
|
|
71
|
+
r && (this.callManager.once("newDTMF", ({ originator: i }) => {
|
|
72
|
+
i === "local" && t();
|
|
73
|
+
}), r.sendDTMF(e, {
|
|
74
74
|
duration: 120,
|
|
75
75
|
interToneGap: 600
|
|
76
76
|
}));
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
async sendChannels({ inputChannels: e, outputChannels: t }) {
|
|
80
|
-
const s = this.getEstablishedRTCSessionProtected(),
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const s = this.getEstablishedRTCSessionProtected(), r = `${l.INPUT_CHANNELS}: ${e}`, i = `${l.OUTPUT_CHANNELS}: ${t}`, a = [
|
|
81
|
+
r,
|
|
82
|
+
i
|
|
83
83
|
];
|
|
84
84
|
return s.sendInfo(_.CHANNELS, void 0, { extraHeaders: a });
|
|
85
85
|
}
|
|
86
86
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const r = this.getEstablishedRTCSessionProtected(), i = `${l.MEDIA_STATE}: currentstate`, a = `${l.MAIN_CAM_STATE}: ${Number(e)}`, o = `${l.MIC_STATE}: ${Number(t)}`, c = [
|
|
88
|
+
i,
|
|
89
89
|
a,
|
|
90
90
|
o
|
|
91
91
|
];
|
|
92
|
-
return
|
|
92
|
+
return r.sendInfo(_.MEDIA_STATE, void 0, {
|
|
93
93
|
noTerminateWhenError: !0,
|
|
94
94
|
...s,
|
|
95
95
|
extraHeaders: c
|
|
@@ -98,10 +98,10 @@ class Fe {
|
|
|
98
98
|
async sendStats({
|
|
99
99
|
availableIncomingBitrate: e
|
|
100
100
|
}) {
|
|
101
|
-
const t = this.getEstablishedRTCSessionProtected(),
|
|
101
|
+
const t = this.getEstablishedRTCSessionProtected(), r = [`${l.AVAILABLE_INCOMING_BITRATE}: ${e}`];
|
|
102
102
|
return t.sendInfo(_.STATS, void 0, {
|
|
103
103
|
noTerminateWhenError: !0,
|
|
104
|
-
extraHeaders:
|
|
104
|
+
extraHeaders: r
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
async sendRefusalToTurnOn(e, t = {}) {
|
|
@@ -149,9 +149,9 @@ class Fe {
|
|
|
149
149
|
noTerminateWhenError: !0,
|
|
150
150
|
...e,
|
|
151
151
|
extraHeaders: s
|
|
152
|
-
}).catch((
|
|
153
|
-
if (Le(
|
|
154
|
-
throw
|
|
152
|
+
}).catch((r) => {
|
|
153
|
+
if (Le(r))
|
|
154
|
+
throw r;
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
@@ -195,7 +195,7 @@ class Fe {
|
|
|
195
195
|
this.handleNotify(s);
|
|
196
196
|
}
|
|
197
197
|
} catch (t) {
|
|
198
|
-
|
|
198
|
+
h("error parse notify", t);
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
handleNotify = (e) => {
|
|
@@ -254,56 +254,56 @@ class Fe {
|
|
|
254
254
|
break;
|
|
255
255
|
}
|
|
256
256
|
default:
|
|
257
|
-
|
|
257
|
+
h("unknown cmd", e);
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
handleNewInfo = (e) => {
|
|
261
261
|
const { originator: t } = e;
|
|
262
262
|
if (t !== "remote")
|
|
263
263
|
return;
|
|
264
|
-
const { request: s } = e,
|
|
265
|
-
if (
|
|
266
|
-
switch (
|
|
264
|
+
const { request: s } = e, r = s, i = r.getHeader(l.CONTENT_TYPE);
|
|
265
|
+
if (i !== void 0)
|
|
266
|
+
switch (i) {
|
|
267
267
|
case P.ENTER_ROOM: {
|
|
268
|
-
this.triggerEnterRoom(
|
|
268
|
+
this.triggerEnterRoom(r), this.maybeTriggerChannels(r);
|
|
269
269
|
break;
|
|
270
270
|
}
|
|
271
271
|
case P.NOTIFY: {
|
|
272
|
-
this.maybeHandleNotify(
|
|
272
|
+
this.maybeHandleNotify(r);
|
|
273
273
|
break;
|
|
274
274
|
}
|
|
275
275
|
case P.SHARE_STATE: {
|
|
276
|
-
this.triggerShareState(
|
|
276
|
+
this.triggerShareState(r);
|
|
277
277
|
break;
|
|
278
278
|
}
|
|
279
279
|
case P.MAIN_CAM: {
|
|
280
|
-
this.triggerMainCamControl(
|
|
280
|
+
this.triggerMainCamControl(r);
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
283
|
case P.MIC: {
|
|
284
|
-
this.triggerMicControl(
|
|
284
|
+
this.triggerMicControl(r);
|
|
285
285
|
break;
|
|
286
286
|
}
|
|
287
287
|
case P.USE_LICENSE: {
|
|
288
|
-
this.triggerUseLicense(
|
|
288
|
+
this.triggerUseLicense(r);
|
|
289
289
|
break;
|
|
290
290
|
}
|
|
291
291
|
case P.PARTICIPANT_STATE: {
|
|
292
|
-
this.maybeTriggerParticipantMoveRequest(
|
|
292
|
+
this.maybeTriggerParticipantMoveRequest(r);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
case P.RESTART: {
|
|
296
|
-
this.triggerRestart(
|
|
296
|
+
this.triggerRestart(r);
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
301
|
triggerChannelsNotify = (e) => {
|
|
302
|
-
const t = e.input, s = e.output,
|
|
302
|
+
const t = e.input, s = e.output, r = {
|
|
303
303
|
inputChannels: t,
|
|
304
304
|
outputChannels: s
|
|
305
305
|
};
|
|
306
|
-
this.events.trigger(
|
|
306
|
+
this.events.trigger(g.CHANNELS_NOTIFY, r);
|
|
307
307
|
};
|
|
308
308
|
triggerWebcastStartedNotify = ({
|
|
309
309
|
body: { conference: e, type: t }
|
|
@@ -312,7 +312,7 @@ class Fe {
|
|
|
312
312
|
conference: e,
|
|
313
313
|
type: t
|
|
314
314
|
};
|
|
315
|
-
this.events.trigger(
|
|
315
|
+
this.events.trigger(g.WEBCAST_STARTED, s);
|
|
316
316
|
};
|
|
317
317
|
triggerWebcastStoppedNotify = ({
|
|
318
318
|
body: { conference: e, type: t }
|
|
@@ -321,7 +321,7 @@ class Fe {
|
|
|
321
321
|
conference: e,
|
|
322
322
|
type: t
|
|
323
323
|
};
|
|
324
|
-
this.events.trigger(
|
|
324
|
+
this.events.trigger(g.WEBCAST_STOPPED, s);
|
|
325
325
|
};
|
|
326
326
|
triggerAddedToListModeratorsNotify = ({
|
|
327
327
|
conference: e
|
|
@@ -330,7 +330,7 @@ class Fe {
|
|
|
330
330
|
conference: e
|
|
331
331
|
};
|
|
332
332
|
this.events.trigger(
|
|
333
|
-
|
|
333
|
+
g.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
|
|
334
334
|
t
|
|
335
335
|
);
|
|
336
336
|
};
|
|
@@ -341,7 +341,7 @@ class Fe {
|
|
|
341
341
|
conference: e
|
|
342
342
|
};
|
|
343
343
|
this.events.trigger(
|
|
344
|
-
|
|
344
|
+
g.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
|
|
345
345
|
t
|
|
346
346
|
);
|
|
347
347
|
};
|
|
@@ -351,7 +351,7 @@ class Fe {
|
|
|
351
351
|
const t = {
|
|
352
352
|
conference: e
|
|
353
353
|
};
|
|
354
|
-
this.events.trigger(
|
|
354
|
+
this.events.trigger(g.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
|
|
355
355
|
};
|
|
356
356
|
triggerParticipationCancellingWordRequest = ({
|
|
357
357
|
body: { conference: e }
|
|
@@ -359,7 +359,7 @@ class Fe {
|
|
|
359
359
|
const t = {
|
|
360
360
|
conference: e
|
|
361
361
|
};
|
|
362
|
-
this.events.trigger(
|
|
362
|
+
this.events.trigger(g.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
|
|
363
363
|
};
|
|
364
364
|
triggerParticipantMoveRequestToStream = ({
|
|
365
365
|
body: { conference: e }
|
|
@@ -367,97 +367,97 @@ class Fe {
|
|
|
367
367
|
const t = {
|
|
368
368
|
conference: e
|
|
369
369
|
};
|
|
370
|
-
this.events.trigger(
|
|
370
|
+
this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
|
|
371
371
|
};
|
|
372
372
|
triggerAccountChangedNotify = () => {
|
|
373
|
-
this.events.trigger(
|
|
373
|
+
this.events.trigger(g.ACCOUNT_CHANGED, void 0);
|
|
374
374
|
};
|
|
375
375
|
triggerAccountDeletedNotify = () => {
|
|
376
|
-
this.events.trigger(
|
|
376
|
+
this.events.trigger(g.ACCOUNT_DELETED, void 0);
|
|
377
377
|
};
|
|
378
378
|
triggerConferenceParticipantTokenIssued = ({
|
|
379
379
|
body: { conference: e, participant: t, jwt: s }
|
|
380
380
|
}) => {
|
|
381
|
-
const
|
|
381
|
+
const r = {
|
|
382
382
|
conference: e,
|
|
383
383
|
participant: t,
|
|
384
384
|
jwt: s
|
|
385
385
|
};
|
|
386
386
|
this.events.trigger(
|
|
387
|
-
|
|
388
|
-
|
|
387
|
+
g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
|
|
388
|
+
r
|
|
389
389
|
);
|
|
390
390
|
};
|
|
391
391
|
maybeTriggerChannels = (e) => {
|
|
392
392
|
const t = e.getHeader(l.INPUT_CHANNELS), s = e.getHeader(l.OUTPUT_CHANNELS);
|
|
393
393
|
if (t && s) {
|
|
394
|
-
const
|
|
394
|
+
const r = {
|
|
395
395
|
inputChannels: t,
|
|
396
396
|
outputChannels: s
|
|
397
397
|
};
|
|
398
|
-
this.events.trigger(
|
|
398
|
+
this.events.trigger(g.CHANNELS, r);
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
triggerEnterRoom = (e) => {
|
|
402
402
|
const t = e.getHeader(l.CONTENT_ENTER_ROOM), s = e.getHeader(l.PARTICIPANT_NAME);
|
|
403
|
-
this.events.trigger(
|
|
403
|
+
this.events.trigger(g.ENTER_ROOM, { room: t, participantName: s });
|
|
404
404
|
};
|
|
405
405
|
triggerShareState = (e) => {
|
|
406
406
|
const t = e.getHeader(l.CONTENT_SHARE_STATE);
|
|
407
407
|
if (t !== void 0)
|
|
408
408
|
switch (t) {
|
|
409
409
|
case B.AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
410
|
-
this.events.trigger(
|
|
410
|
+
this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
411
411
|
break;
|
|
412
412
|
}
|
|
413
413
|
case B.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
|
|
414
|
-
this.events.trigger(
|
|
414
|
+
this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
417
|
case B.MUST_STOP_PRESENTATION: {
|
|
418
|
-
this.events.trigger(
|
|
418
|
+
this.events.trigger(g.MUST_STOP_PRESENTATION, void 0);
|
|
419
419
|
break;
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
};
|
|
423
423
|
maybeTriggerParticipantMoveRequest = (e) => {
|
|
424
424
|
const t = e.getHeader(l.CONTENT_PARTICIPANT_STATE);
|
|
425
|
-
t ===
|
|
425
|
+
t === V.SPECTATOR && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === V.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
|
|
426
426
|
};
|
|
427
427
|
triggerMainCamControl = (e) => {
|
|
428
|
-
const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC),
|
|
429
|
-
if (t ===
|
|
430
|
-
this.events.trigger(
|
|
428
|
+
const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC), r = s === H.ADMIN_SYNC_FORCED;
|
|
429
|
+
if (t === v.ADMIN_START_MAIN_CAM) {
|
|
430
|
+
this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: r });
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
|
-
if (t ===
|
|
434
|
-
this.events.trigger(
|
|
433
|
+
if (t === v.ADMIN_STOP_MAIN_CAM) {
|
|
434
|
+
this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: r });
|
|
435
435
|
return;
|
|
436
436
|
}
|
|
437
|
-
(t ===
|
|
438
|
-
const
|
|
439
|
-
this.events.trigger(
|
|
437
|
+
(t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: r });
|
|
438
|
+
const i = e.getHeader(l.MAIN_CAM_RESOLUTION);
|
|
439
|
+
this.events.trigger(g.MAIN_CAM_CONTROL, {
|
|
440
440
|
mainCam: t,
|
|
441
|
-
resolutionMainCam:
|
|
441
|
+
resolutionMainCam: i
|
|
442
442
|
});
|
|
443
443
|
};
|
|
444
444
|
triggerMicControl = (e) => {
|
|
445
|
-
const t = e.getHeader(l.MIC),
|
|
446
|
-
t === W.ADMIN_START_MIC ? this.events.trigger(
|
|
445
|
+
const t = e.getHeader(l.MIC), r = e.getHeader(l.MEDIA_SYNC) === H.ADMIN_SYNC_FORCED;
|
|
446
|
+
t === W.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: r }) : t === W.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: r });
|
|
447
447
|
};
|
|
448
448
|
triggerUseLicense = (e) => {
|
|
449
449
|
const t = e.getHeader(l.CONTENT_USE_LICENSE);
|
|
450
|
-
this.events.trigger(
|
|
450
|
+
this.events.trigger(g.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
456
|
e.getHeader(l.AUDIO_TRACK_COUNT)
|
|
457
|
-
),
|
|
457
|
+
), r = Number(
|
|
458
458
|
e.getHeader(l.VIDEO_TRACK_COUNT)
|
|
459
|
-
),
|
|
460
|
-
this.events.trigger(
|
|
459
|
+
), i = { tracksDirection: t, audioTrackCount: s, videoTrackCount: r };
|
|
460
|
+
this.events.trigger(g.RESTART, i);
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
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 || {}), ke = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(ke || {});
|
|
@@ -493,10 +493,10 @@ const se = [
|
|
|
493
493
|
"peerconnection:ontrack",
|
|
494
494
|
"ended:fromserver",
|
|
495
495
|
"call-status-changed"
|
|
496
|
-
],
|
|
496
|
+
], re = [
|
|
497
497
|
...se,
|
|
498
498
|
...$e
|
|
499
|
-
],
|
|
499
|
+
], qe = (n, e) => {
|
|
500
500
|
n.getVideoTracks().forEach((s) => {
|
|
501
501
|
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
502
502
|
});
|
|
@@ -507,13 +507,13 @@ const se = [
|
|
|
507
507
|
} = {}) => {
|
|
508
508
|
if (!n || e === "recvonly" && t === "recvonly")
|
|
509
509
|
return;
|
|
510
|
-
const
|
|
511
|
-
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" &&
|
|
510
|
+
const r = t === "recvonly" ? [] : n.getAudioTracks(), i = e === "recvonly" ? [] : n.getVideoTracks(), a = [...r, ...i], o = new MediaStream(a);
|
|
511
|
+
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && qe(o, s), o;
|
|
512
512
|
};
|
|
513
|
-
function
|
|
513
|
+
function Ve(n) {
|
|
514
514
|
return (e) => `sip:${e}@${n}`;
|
|
515
515
|
}
|
|
516
|
-
const We = (n, e) => () => Math.floor(Math.random() * (e - n)) + n,
|
|
516
|
+
const We = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, ie = (n) => n.trim().replaceAll(" ", "_"), He = We(1e5, 99999999), xe = (n) => n.some((t) => {
|
|
517
517
|
const { kind: s } = t;
|
|
518
518
|
return s === "video";
|
|
519
519
|
});
|
|
@@ -535,8 +535,8 @@ class Qe {
|
|
|
535
535
|
this.remoteStreams = {};
|
|
536
536
|
}
|
|
537
537
|
generateStream(e, t) {
|
|
538
|
-
const { id: s } = e,
|
|
539
|
-
return t &&
|
|
538
|
+
const { id: s } = e, r = this.remoteStreams[s] ?? new MediaStream();
|
|
539
|
+
return t && r.addTrack(t), r.addTrack(e), this.remoteStreams[s] = r, r;
|
|
540
540
|
}
|
|
541
541
|
generateAudioStream(e) {
|
|
542
542
|
const { id: t } = e, s = this.remoteStreams[t] ?? new MediaStream();
|
|
@@ -544,13 +544,13 @@ class Qe {
|
|
|
544
544
|
}
|
|
545
545
|
generateStreams(e) {
|
|
546
546
|
const t = [];
|
|
547
|
-
return e.forEach((s,
|
|
547
|
+
return e.forEach((s, r) => {
|
|
548
548
|
if (s.kind === "audio")
|
|
549
549
|
return;
|
|
550
|
-
const
|
|
550
|
+
const i = s, a = e[r - 1];
|
|
551
551
|
let o;
|
|
552
552
|
a?.kind === "audio" && (o = a);
|
|
553
|
-
const c = this.generateStream(
|
|
553
|
+
const c = this.generateStream(i, o);
|
|
554
554
|
t.push(c);
|
|
555
555
|
}), t;
|
|
556
556
|
}
|
|
@@ -578,15 +578,15 @@ class Ye extends Ge {
|
|
|
578
578
|
}
|
|
579
579
|
startCall = async (e, t, {
|
|
580
580
|
number: s,
|
|
581
|
-
mediaStream:
|
|
582
|
-
extraHeaders:
|
|
581
|
+
mediaStream: r,
|
|
582
|
+
extraHeaders: i = [],
|
|
583
583
|
ontrack: a,
|
|
584
584
|
iceServers: o,
|
|
585
585
|
directionVideo: c,
|
|
586
|
-
directionAudio:
|
|
586
|
+
directionAudio: d,
|
|
587
587
|
contentHint: T,
|
|
588
588
|
offerToReceiveAudio: S = !0,
|
|
589
|
-
offerToReceiveVideo:
|
|
589
|
+
offerToReceiveVideo: u = !0,
|
|
590
590
|
degradationPreference: E,
|
|
591
591
|
sendEncodings: m,
|
|
592
592
|
onAddedTransceiver: I
|
|
@@ -594,9 +594,9 @@ class Ye extends Ge {
|
|
|
594
594
|
this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch(($) => {
|
|
595
595
|
D($);
|
|
596
596
|
}), this.rtcSession = e.call(t(s), {
|
|
597
|
-
mediaStream: F(
|
|
597
|
+
mediaStream: F(r, {
|
|
598
598
|
directionVideo: c,
|
|
599
|
-
directionAudio:
|
|
599
|
+
directionAudio: d,
|
|
600
600
|
contentHint: T
|
|
601
601
|
}),
|
|
602
602
|
pcConfig: {
|
|
@@ -604,15 +604,15 @@ class Ye extends Ge {
|
|
|
604
604
|
},
|
|
605
605
|
rtcOfferConstraints: {
|
|
606
606
|
offerToReceiveAudio: S,
|
|
607
|
-
offerToReceiveVideo:
|
|
607
|
+
offerToReceiveVideo: u
|
|
608
608
|
},
|
|
609
609
|
// необходимо передавать в методе call, чтобы подписаться на события peerconnection,
|
|
610
610
|
// так как в методе call создается RTCSession
|
|
611
611
|
// и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
|
|
612
612
|
eventHandlers: this.events.triggers,
|
|
613
|
-
extraHeaders:
|
|
613
|
+
extraHeaders: i,
|
|
614
614
|
directionVideo: c,
|
|
615
|
-
directionAudio:
|
|
615
|
+
directionAudio: d,
|
|
616
616
|
degradationPreference: E,
|
|
617
617
|
sendEncodings: m,
|
|
618
618
|
onAddedTransceiver: I
|
|
@@ -633,15 +633,15 @@ class Ye extends Ge {
|
|
|
633
633
|
answerToIncomingCall = async (e, {
|
|
634
634
|
mediaStream: t,
|
|
635
635
|
ontrack: s,
|
|
636
|
-
extraHeaders:
|
|
637
|
-
iceServers:
|
|
636
|
+
extraHeaders: r = [],
|
|
637
|
+
iceServers: i,
|
|
638
638
|
directionVideo: a,
|
|
639
639
|
directionAudio: o,
|
|
640
640
|
offerToReceiveAudio: c,
|
|
641
|
-
offerToReceiveVideo:
|
|
641
|
+
offerToReceiveVideo: d,
|
|
642
642
|
contentHint: T,
|
|
643
643
|
degradationPreference: S,
|
|
644
|
-
sendEncodings:
|
|
644
|
+
sendEncodings: u,
|
|
645
645
|
onAddedTransceiver: E
|
|
646
646
|
}) => (this.isPendingAnswer = !0, new Promise((m, I) => {
|
|
647
647
|
try {
|
|
@@ -650,22 +650,22 @@ class Ye extends Ge {
|
|
|
650
650
|
I(D);
|
|
651
651
|
}), R.answer({
|
|
652
652
|
pcConfig: {
|
|
653
|
-
iceServers:
|
|
653
|
+
iceServers: i
|
|
654
654
|
},
|
|
655
655
|
rtcOfferConstraints: {
|
|
656
656
|
offerToReceiveAudio: c,
|
|
657
|
-
offerToReceiveVideo:
|
|
657
|
+
offerToReceiveVideo: d
|
|
658
658
|
},
|
|
659
659
|
mediaStream: F(t, {
|
|
660
660
|
directionVideo: a,
|
|
661
661
|
directionAudio: o,
|
|
662
662
|
contentHint: T
|
|
663
663
|
}),
|
|
664
|
-
extraHeaders:
|
|
664
|
+
extraHeaders: r,
|
|
665
665
|
directionVideo: a,
|
|
666
666
|
directionAudio: o,
|
|
667
667
|
degradationPreference: S,
|
|
668
|
-
sendEncodings:
|
|
668
|
+
sendEncodings: u,
|
|
669
669
|
onAddedTransceiver: E
|
|
670
670
|
});
|
|
671
671
|
} catch (R) {
|
|
@@ -689,10 +689,10 @@ class Ye extends Ge {
|
|
|
689
689
|
async replaceMediaStream(e, t) {
|
|
690
690
|
if (!this.rtcSession)
|
|
691
691
|
throw new Error("No rtcSession established");
|
|
692
|
-
const { contentHint: s } = t ?? {},
|
|
693
|
-
if (
|
|
692
|
+
const { contentHint: s } = t ?? {}, r = F(e, { contentHint: s });
|
|
693
|
+
if (r === void 0)
|
|
694
694
|
throw new Error("No preparedMediaStream");
|
|
695
|
-
return this.rtcSession.replaceMediaStream(
|
|
695
|
+
return this.rtcSession.replaceMediaStream(r, t);
|
|
696
696
|
}
|
|
697
697
|
async restartIce(e) {
|
|
698
698
|
if (!this.rtcSession)
|
|
@@ -707,36 +707,36 @@ class Ye extends Ge {
|
|
|
707
707
|
handleCall = async ({
|
|
708
708
|
ontrack: e
|
|
709
709
|
}) => new Promise((t, s) => {
|
|
710
|
-
const
|
|
710
|
+
const r = () => {
|
|
711
711
|
this.events.on(N.PEER_CONNECTION, T), this.events.on(N.CONFIRMED, S);
|
|
712
|
-
},
|
|
712
|
+
}, i = () => {
|
|
713
713
|
this.events.off(N.PEER_CONNECTION, T), this.events.off(N.CONFIRMED, S);
|
|
714
714
|
}, a = () => {
|
|
715
715
|
this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
|
|
716
716
|
}, o = () => {
|
|
717
717
|
this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
|
|
718
|
-
}, c = (
|
|
719
|
-
|
|
718
|
+
}, c = (u) => {
|
|
719
|
+
i(), o(), s(u);
|
|
720
720
|
};
|
|
721
|
-
let
|
|
722
|
-
const T = ({ peerconnection:
|
|
723
|
-
|
|
721
|
+
let d;
|
|
722
|
+
const T = ({ peerconnection: u }) => {
|
|
723
|
+
d = u;
|
|
724
724
|
const E = (m) => {
|
|
725
725
|
this.events.trigger(N.PEER_CONNECTION_ONTRACK, m), e && e(m);
|
|
726
726
|
};
|
|
727
|
-
|
|
728
|
-
|
|
727
|
+
u.addEventListener("track", E), this.disposers.add(() => {
|
|
728
|
+
u.removeEventListener("track", E);
|
|
729
729
|
});
|
|
730
730
|
}, S = () => {
|
|
731
|
-
|
|
731
|
+
d !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, d), i(), o(), t(d);
|
|
732
732
|
};
|
|
733
|
-
|
|
733
|
+
r(), a();
|
|
734
734
|
});
|
|
735
735
|
subscribeToSessionEvents(e) {
|
|
736
736
|
this.events.eachTriggers((t, s) => {
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
e.off(
|
|
737
|
+
const r = se.find((i) => i === s);
|
|
738
|
+
r && (e.on(r, t), this.disposers.add(() => {
|
|
739
|
+
e.off(r, t);
|
|
740
740
|
}));
|
|
741
741
|
});
|
|
742
742
|
}
|
|
@@ -757,7 +757,7 @@ class ze {
|
|
|
757
757
|
events;
|
|
758
758
|
strategy;
|
|
759
759
|
constructor(e) {
|
|
760
|
-
this.events = new U(
|
|
760
|
+
this.events = new U(re), this.strategy = e ?? new Ye(this.events), this.subscribeCallStatusChange();
|
|
761
761
|
}
|
|
762
762
|
get requested() {
|
|
763
763
|
return this.strategy.requested;
|
|
@@ -803,8 +803,8 @@ class ze {
|
|
|
803
803
|
restartIce = async (e) => this.strategy.restartIce(e);
|
|
804
804
|
subscribeCallStatusChange() {
|
|
805
805
|
let { isCallActive: e } = this;
|
|
806
|
-
const { ACCEPTED: t, CONFIRMED: s, ENDED:
|
|
807
|
-
this.onRace([t, s,
|
|
806
|
+
const { ACCEPTED: t, CONFIRMED: s, ENDED: r, FAILED: i } = N;
|
|
807
|
+
this.onRace([t, s, r, i], () => {
|
|
808
808
|
e = this.maybeTriggerCallStatus(e);
|
|
809
809
|
});
|
|
810
810
|
}
|
|
@@ -841,11 +841,11 @@ const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je
|
|
|
841
841
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
842
842
|
}, st = (n, e) => {
|
|
843
843
|
const t = e.encodings?.length ?? 0;
|
|
844
|
-
return Je(n, t), n.encodings.forEach((s,
|
|
845
|
-
const
|
|
844
|
+
return Je(n, t), n.encodings.forEach((s, r) => {
|
|
845
|
+
const i = (e?.encodings ?? [])[r], a = i?.maxBitrate, o = i?.scaleResolutionDownBy;
|
|
846
846
|
Ze(s, a), nt(s, o);
|
|
847
847
|
}), n;
|
|
848
|
-
},
|
|
848
|
+
}, rt = (n, e) => {
|
|
849
849
|
if (n.codecs?.length !== e.codecs?.length)
|
|
850
850
|
return !0;
|
|
851
851
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -862,15 +862,15 @@ const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je
|
|
|
862
862
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
863
863
|
return !0;
|
|
864
864
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
865
|
-
},
|
|
865
|
+
}, it = async (n, e) => {
|
|
866
866
|
const t = n.getParameters(), s = JSON.parse(
|
|
867
867
|
JSON.stringify(t)
|
|
868
868
|
);
|
|
869
869
|
st(t, e), Xe(t, e);
|
|
870
|
-
const
|
|
871
|
-
return
|
|
872
|
-
},
|
|
873
|
-
const { isChanged: s, parameters:
|
|
870
|
+
const r = rt(s, t);
|
|
871
|
+
return r && await n.setParameters(t), { parameters: t, isChanged: r };
|
|
872
|
+
}, he = async (n, e, t) => {
|
|
873
|
+
const { isChanged: s, parameters: r } = await it(n, {
|
|
874
874
|
encodings: [
|
|
875
875
|
{
|
|
876
876
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -878,21 +878,21 @@ const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je
|
|
|
878
878
|
}
|
|
879
879
|
]
|
|
880
880
|
});
|
|
881
|
-
return s && t && t(
|
|
881
|
+
return s && t && t(r), { isChanged: s, parameters: r };
|
|
882
882
|
}, at = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ot = async (n, e, t) => {
|
|
883
883
|
const s = at(n, e);
|
|
884
884
|
if (s)
|
|
885
|
-
return
|
|
885
|
+
return he(s, { maxBitrate: t });
|
|
886
886
|
};
|
|
887
887
|
var O = /* @__PURE__ */ ((n) => (n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n))(O || {});
|
|
888
|
-
const
|
|
888
|
+
const de = [
|
|
889
889
|
"presentation:start",
|
|
890
890
|
"presentation:started",
|
|
891
891
|
"presentation:end",
|
|
892
892
|
"presentation:ended",
|
|
893
893
|
"presentation:failed"
|
|
894
894
|
], ct = 1, xn = (n) => Pe(n);
|
|
895
|
-
class
|
|
895
|
+
class ht {
|
|
896
896
|
events;
|
|
897
897
|
promisePendingStartPresentation;
|
|
898
898
|
promisePendingStopPresentation;
|
|
@@ -904,7 +904,7 @@ class dt {
|
|
|
904
904
|
callManager: e,
|
|
905
905
|
maxBitrate: t
|
|
906
906
|
}) {
|
|
907
|
-
this.callManager = e, this.maxBitrate = t, this.events = new k(
|
|
907
|
+
this.callManager = e, this.maxBitrate = t, this.events = new k(de), this.subscribe();
|
|
908
908
|
}
|
|
909
909
|
get isPendingPresentation() {
|
|
910
910
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
@@ -912,8 +912,8 @@ class dt {
|
|
|
912
912
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
913
913
|
async startPresentation(e, t, {
|
|
914
914
|
isNeedReinvite: s,
|
|
915
|
-
contentHint:
|
|
916
|
-
sendEncodings:
|
|
915
|
+
contentHint: r,
|
|
916
|
+
sendEncodings: i,
|
|
917
917
|
onAddedTransceiver: a
|
|
918
918
|
} = {}, o) {
|
|
919
919
|
const c = this.getRtcSessionProtected();
|
|
@@ -924,8 +924,8 @@ class dt {
|
|
|
924
924
|
stream: t,
|
|
925
925
|
presentationOptions: {
|
|
926
926
|
isNeedReinvite: s,
|
|
927
|
-
contentHint:
|
|
928
|
-
sendEncodings:
|
|
927
|
+
contentHint: r,
|
|
928
|
+
sendEncodings: i,
|
|
929
929
|
onAddedTransceiver: a
|
|
930
930
|
},
|
|
931
931
|
options: o
|
|
@@ -937,17 +937,17 @@ class dt {
|
|
|
937
937
|
let s = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
|
|
938
938
|
this.promisePendingStartPresentation && await this.promisePendingStartPresentation.catch(() => {
|
|
939
939
|
});
|
|
940
|
-
const
|
|
941
|
-
return
|
|
942
|
-
throw this.events.trigger(O.FAILED_PRESENTATION,
|
|
940
|
+
const r = this.callManager.getEstablishedRTCSession();
|
|
941
|
+
return r && t ? s = e().then(async () => r.stopPresentation(t)).catch((i) => {
|
|
942
|
+
throw this.events.trigger(O.FAILED_PRESENTATION, i), i;
|
|
943
943
|
}) : t && this.events.trigger(O.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
944
944
|
this.resetPresentation();
|
|
945
945
|
});
|
|
946
946
|
}
|
|
947
947
|
async updatePresentation(e, t, {
|
|
948
948
|
contentHint: s,
|
|
949
|
-
sendEncodings:
|
|
950
|
-
onAddedTransceiver:
|
|
949
|
+
sendEncodings: r,
|
|
950
|
+
onAddedTransceiver: i
|
|
951
951
|
} = {}) {
|
|
952
952
|
const a = this.getRtcSessionProtected();
|
|
953
953
|
if (!this.streamPresentationCurrent)
|
|
@@ -955,8 +955,8 @@ class dt {
|
|
|
955
955
|
return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, a, t, {
|
|
956
956
|
contentHint: s,
|
|
957
957
|
isNeedReinvite: !1,
|
|
958
|
-
sendEncodings:
|
|
959
|
-
onAddedTransceiver:
|
|
958
|
+
sendEncodings: r,
|
|
959
|
+
onAddedTransceiver: i
|
|
960
960
|
}).then(async (o) => (await this.setMaxBitrate(), o));
|
|
961
961
|
}
|
|
962
962
|
cancelSendPresentationWithRepeatedCalls() {
|
|
@@ -997,8 +997,8 @@ class dt {
|
|
|
997
997
|
async sendPresentationWithDuplicatedCalls(e, {
|
|
998
998
|
rtcSession: t,
|
|
999
999
|
stream: s,
|
|
1000
|
-
presentationOptions:
|
|
1001
|
-
options:
|
|
1000
|
+
presentationOptions: r,
|
|
1001
|
+
options: i = {
|
|
1002
1002
|
callLimit: ct
|
|
1003
1003
|
}
|
|
1004
1004
|
}) {
|
|
@@ -1006,28 +1006,28 @@ class dt {
|
|
|
1006
1006
|
e,
|
|
1007
1007
|
t,
|
|
1008
1008
|
s,
|
|
1009
|
-
|
|
1009
|
+
r
|
|
1010
1010
|
), o = () => !!this.streamPresentationCurrent;
|
|
1011
1011
|
return this.cancelableSendPresentationWithRepeatedCalls = ee({
|
|
1012
1012
|
targetFunction: a,
|
|
1013
1013
|
isComplete: o,
|
|
1014
1014
|
isRejectAsValid: !0,
|
|
1015
|
-
...
|
|
1015
|
+
...i
|
|
1016
1016
|
}), this.cancelableSendPresentationWithRepeatedCalls.then((c) => c);
|
|
1017
1017
|
}
|
|
1018
1018
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
1019
1019
|
async sendPresentation(e, t, s, {
|
|
1020
|
-
isNeedReinvite:
|
|
1021
|
-
contentHint:
|
|
1020
|
+
isNeedReinvite: r = !0,
|
|
1021
|
+
contentHint: i = "detail",
|
|
1022
1022
|
degradationPreference: a,
|
|
1023
1023
|
sendEncodings: o,
|
|
1024
1024
|
onAddedTransceiver: c
|
|
1025
1025
|
}) {
|
|
1026
|
-
const
|
|
1027
|
-
if (
|
|
1026
|
+
const d = F(s, { contentHint: i });
|
|
1027
|
+
if (d === void 0)
|
|
1028
1028
|
throw new Error("No streamPresentationTarget");
|
|
1029
|
-
this.streamPresentationCurrent =
|
|
1030
|
-
const T = e().then(async () => t.startPresentation(
|
|
1029
|
+
this.streamPresentationCurrent = d;
|
|
1030
|
+
const T = e().then(async () => t.startPresentation(d, r, {
|
|
1031
1031
|
degradationPreference: a,
|
|
1032
1032
|
sendEncodings: o,
|
|
1033
1033
|
onAddedTransceiver: c
|
|
@@ -1042,8 +1042,8 @@ class dt {
|
|
|
1042
1042
|
const { connection: e } = this.callManager, { streamPresentationCurrent: t } = this, { maxBitrate: s } = this;
|
|
1043
1043
|
if (!e || !t || s === void 0)
|
|
1044
1044
|
return;
|
|
1045
|
-
const
|
|
1046
|
-
await ot(
|
|
1045
|
+
const r = e.getSenders();
|
|
1046
|
+
await ot(r, t, s);
|
|
1047
1047
|
};
|
|
1048
1048
|
getRtcSessionProtected = () => {
|
|
1049
1049
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -1064,8 +1064,8 @@ class dt {
|
|
|
1064
1064
|
delete this.streamPresentationCurrent;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
|
-
class
|
|
1068
|
-
data
|
|
1067
|
+
class dt {
|
|
1068
|
+
data;
|
|
1069
1069
|
getUa;
|
|
1070
1070
|
constructor(e) {
|
|
1071
1071
|
this.getUa = e.getUa;
|
|
@@ -1080,61 +1080,68 @@ class ht {
|
|
|
1080
1080
|
* Получает текущую конфигурацию подключения
|
|
1081
1081
|
*/
|
|
1082
1082
|
get() {
|
|
1083
|
-
|
|
1083
|
+
if (this.data !== void 0)
|
|
1084
|
+
return { ...this.data };
|
|
1084
1085
|
}
|
|
1085
1086
|
/**
|
|
1086
1087
|
* Устанавливает конфигурацию подключения
|
|
1087
1088
|
*/
|
|
1088
1089
|
set(e) {
|
|
1090
|
+
if (e === void 0) {
|
|
1091
|
+
this.data = void 0;
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1089
1094
|
this.data = { ...e };
|
|
1090
1095
|
}
|
|
1091
1096
|
/**
|
|
1092
1097
|
* Обновляет конфигурацию подключения
|
|
1093
1098
|
*/
|
|
1094
1099
|
update(e, t) {
|
|
1100
|
+
if (this.data === void 0)
|
|
1101
|
+
throw new Error("data is not exist");
|
|
1095
1102
|
this.data[e] = t;
|
|
1096
1103
|
}
|
|
1097
1104
|
/**
|
|
1098
1105
|
* Очищает конфигурацию
|
|
1099
1106
|
*/
|
|
1100
1107
|
clear() {
|
|
1101
|
-
this.data =
|
|
1108
|
+
this.data = void 0;
|
|
1102
1109
|
}
|
|
1103
1110
|
/**
|
|
1104
1111
|
* Проверяет, включена ли регистрация в конфигурации
|
|
1105
1112
|
*/
|
|
1106
1113
|
isRegister() {
|
|
1107
|
-
return this.data
|
|
1114
|
+
return this.data?.register === !0;
|
|
1108
1115
|
}
|
|
1109
1116
|
/**
|
|
1110
1117
|
* Получает SIP сервер URL из конфигурации
|
|
1111
1118
|
*/
|
|
1112
1119
|
getSipServerUrl() {
|
|
1113
|
-
return this.data
|
|
1120
|
+
return this.data?.sipServerUrl;
|
|
1114
1121
|
}
|
|
1115
1122
|
/**
|
|
1116
1123
|
* Получает display name из конфигурации
|
|
1117
1124
|
*/
|
|
1118
1125
|
getDisplayName() {
|
|
1119
|
-
return this.data
|
|
1126
|
+
return this.data?.displayName;
|
|
1120
1127
|
}
|
|
1121
1128
|
/**
|
|
1122
1129
|
* Получает пользователя из конфигурации
|
|
1123
1130
|
*/
|
|
1124
1131
|
getUser() {
|
|
1125
|
-
return this.data
|
|
1132
|
+
return this.data?.user;
|
|
1126
1133
|
}
|
|
1127
1134
|
/**
|
|
1128
1135
|
* Получает пароль из конфигурации
|
|
1129
1136
|
*/
|
|
1130
1137
|
getPassword() {
|
|
1131
|
-
return this.data
|
|
1138
|
+
return this.data?.password;
|
|
1132
1139
|
}
|
|
1133
1140
|
/**
|
|
1134
1141
|
* Проверяет, включена ли регистрация
|
|
1135
1142
|
*/
|
|
1136
1143
|
isRegisterEnabled() {
|
|
1137
|
-
return this.data
|
|
1144
|
+
return this.data?.register === !0;
|
|
1138
1145
|
}
|
|
1139
1146
|
}
|
|
1140
1147
|
var C = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n))(C || {});
|
|
@@ -1155,8 +1162,8 @@ const le = [
|
|
|
1155
1162
|
"connect-failed",
|
|
1156
1163
|
"connect-parameters-resolve-success",
|
|
1157
1164
|
"connect-parameters-resolve-failed"
|
|
1158
|
-
],
|
|
1159
|
-
class
|
|
1165
|
+
], ue = [...le, ...lt], ut = 3;
|
|
1166
|
+
class gt {
|
|
1160
1167
|
cancelableConnectWithRepeatedCalls;
|
|
1161
1168
|
JsSIP;
|
|
1162
1169
|
events;
|
|
@@ -1175,15 +1182,15 @@ class ut {
|
|
|
1175
1182
|
}
|
|
1176
1183
|
connect = async (e, t) => (this.cancelRequests(), this.connectWithDuplicatedCalls(e, t));
|
|
1177
1184
|
set = async ({ displayName: e }) => new Promise((t, s) => {
|
|
1178
|
-
const
|
|
1179
|
-
if (!
|
|
1185
|
+
const r = this.getUa();
|
|
1186
|
+
if (!r) {
|
|
1180
1187
|
s(new Error("this.ua is not initialized"));
|
|
1181
1188
|
return;
|
|
1182
1189
|
}
|
|
1183
|
-
let
|
|
1190
|
+
let i = !1;
|
|
1184
1191
|
const a = this.getConnectionConfiguration();
|
|
1185
|
-
e !== void 0 && e !== a
|
|
1186
|
-
const o =
|
|
1192
|
+
e !== void 0 && e !== a?.displayName && (i = r.set("display_name", ie(e)), this.updateConnectionConfiguration("displayName", e));
|
|
1193
|
+
const o = i;
|
|
1187
1194
|
o ? t(o) : s(new Error("nothing changed"));
|
|
1188
1195
|
});
|
|
1189
1196
|
disconnect = async () => {
|
|
@@ -1200,50 +1207,55 @@ class ut {
|
|
|
1200
1207
|
cancelRequests() {
|
|
1201
1208
|
this.cancelConnectWithRepeatedCalls();
|
|
1202
1209
|
}
|
|
1203
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
1204
|
-
const s = async () => this.connectInner(e),
|
|
1205
|
-
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e),
|
|
1206
|
-
return c ||
|
|
1210
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = ut } = {}) => {
|
|
1211
|
+
const s = async () => this.connectInner(e), r = (i) => {
|
|
1212
|
+
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = i != null && !Ue(i);
|
|
1213
|
+
return c || d;
|
|
1207
1214
|
};
|
|
1208
1215
|
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ee({
|
|
1209
1216
|
targetFunction: s,
|
|
1210
|
-
isComplete:
|
|
1217
|
+
isComplete: r,
|
|
1211
1218
|
callLimit: t,
|
|
1212
1219
|
isRejectAsValid: !0,
|
|
1213
1220
|
isCheckBeforeCall: !1
|
|
1214
|
-
}), this.cancelableConnectWithRepeatedCalls.then((
|
|
1215
|
-
if ("ua" in
|
|
1216
|
-
return
|
|
1217
|
-
throw
|
|
1221
|
+
}), this.cancelableConnectWithRepeatedCalls.then((i) => {
|
|
1222
|
+
if ("ua" in i && i.ua instanceof this.JsSIP.UA)
|
|
1223
|
+
return i;
|
|
1224
|
+
throw i;
|
|
1218
1225
|
});
|
|
1219
1226
|
};
|
|
1220
1227
|
hasEqualConnectionConfiguration(e) {
|
|
1221
|
-
const { configuration: t } = this.uaFactory.createConfiguration(e),
|
|
1222
|
-
return
|
|
1228
|
+
const { configuration: t } = this.uaFactory.createConfiguration(e), r = this.getUa()?.configuration;
|
|
1229
|
+
return r ? r.password === t.password && r.register === t.register && r.uri.toString() === t.uri && r.display_name === t.display_name && r.user_agent === t.user_agent && r.sockets === t.sockets && r.session_timers === t.session_timers && r.register_expires === t.register_expires && r.connection_recovery_min_interval === t.connection_recovery_min_interval && r.connection_recovery_max_interval === t.connection_recovery_max_interval : !1;
|
|
1223
1230
|
}
|
|
1224
|
-
connectInner = async (e) => this.initUa(e).then(async () => this.start()).then((t) =>
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1231
|
+
connectInner = async (e) => this.initUa(e).then(async () => this.start()).then((t) => {
|
|
1232
|
+
const s = this.getConnectionConfiguration();
|
|
1233
|
+
if (s === void 0)
|
|
1234
|
+
throw new Error("connectionConfiguration has not defined");
|
|
1235
|
+
return {
|
|
1236
|
+
...s,
|
|
1237
|
+
ua: t
|
|
1238
|
+
};
|
|
1239
|
+
});
|
|
1228
1240
|
initUa = async ({
|
|
1229
1241
|
user: e,
|
|
1230
1242
|
password: t,
|
|
1231
1243
|
sipServerUrl: s,
|
|
1232
|
-
sipWebSocketServerURL:
|
|
1233
|
-
remoteAddress:
|
|
1244
|
+
sipWebSocketServerURL: r,
|
|
1245
|
+
remoteAddress: i,
|
|
1234
1246
|
sessionTimers: a,
|
|
1235
1247
|
registerExpires: o,
|
|
1236
1248
|
connectionRecoveryMinInterval: c,
|
|
1237
|
-
connectionRecoveryMaxInterval:
|
|
1249
|
+
connectionRecoveryMaxInterval: d,
|
|
1238
1250
|
userAgent: T,
|
|
1239
1251
|
displayName: S = "",
|
|
1240
|
-
register:
|
|
1252
|
+
register: u = !1,
|
|
1241
1253
|
extraHeaders: E = []
|
|
1242
1254
|
}) => {
|
|
1243
1255
|
this.stateMachine.startInitUa(), this.setConnectionConfiguration({
|
|
1244
1256
|
sipServerUrl: s,
|
|
1245
1257
|
displayName: S,
|
|
1246
|
-
register:
|
|
1258
|
+
register: u,
|
|
1247
1259
|
user: e,
|
|
1248
1260
|
password: t
|
|
1249
1261
|
}), this.getUa() && await this.disconnect();
|
|
@@ -1252,15 +1264,15 @@ class ut {
|
|
|
1252
1264
|
user: e,
|
|
1253
1265
|
password: t,
|
|
1254
1266
|
sipServerUrl: s,
|
|
1255
|
-
sipWebSocketServerURL:
|
|
1267
|
+
sipWebSocketServerURL: r,
|
|
1256
1268
|
displayName: S,
|
|
1257
|
-
register:
|
|
1269
|
+
register: u,
|
|
1258
1270
|
sessionTimers: a,
|
|
1259
1271
|
registerExpires: o,
|
|
1260
1272
|
connectionRecoveryMinInterval: c,
|
|
1261
|
-
connectionRecoveryMaxInterval:
|
|
1273
|
+
connectionRecoveryMaxInterval: d,
|
|
1262
1274
|
userAgent: T,
|
|
1263
|
-
remoteAddress:
|
|
1275
|
+
remoteAddress: i,
|
|
1264
1276
|
extraHeaders: E
|
|
1265
1277
|
},
|
|
1266
1278
|
this.events
|
|
@@ -1273,29 +1285,29 @@ class ut {
|
|
|
1273
1285
|
t(new Error("this.ua is not initialized"));
|
|
1274
1286
|
return;
|
|
1275
1287
|
}
|
|
1276
|
-
let
|
|
1277
|
-
|
|
1278
|
-
if (this.getConnectionConfiguration()
|
|
1279
|
-
return this.registrationManager.subscribeToStartEvents(c,
|
|
1280
|
-
const S = C.CONNECTED,
|
|
1281
|
-
return this.events.on(S, c),
|
|
1282
|
-
this.events.on(E,
|
|
1288
|
+
let r;
|
|
1289
|
+
r = ((c, d) => {
|
|
1290
|
+
if (this.getConnectionConfiguration()?.register === !0)
|
|
1291
|
+
return this.registrationManager.subscribeToStartEvents(c, d);
|
|
1292
|
+
const S = C.CONNECTED, u = [C.DISCONNECTED];
|
|
1293
|
+
return this.events.on(S, c), u.forEach((E) => {
|
|
1294
|
+
this.events.on(E, d);
|
|
1283
1295
|
}), () => {
|
|
1284
|
-
this.events.off(S, c),
|
|
1285
|
-
this.events.off(E,
|
|
1296
|
+
this.events.off(S, c), u.forEach((E) => {
|
|
1297
|
+
this.events.off(E, d);
|
|
1286
1298
|
});
|
|
1287
1299
|
};
|
|
1288
1300
|
})(() => {
|
|
1289
|
-
|
|
1301
|
+
r?.(), e(s);
|
|
1290
1302
|
}, (c) => {
|
|
1291
|
-
|
|
1303
|
+
r?.(), t(c);
|
|
1292
1304
|
}), s.start();
|
|
1293
1305
|
});
|
|
1294
1306
|
cancelConnectWithRepeatedCalls() {
|
|
1295
1307
|
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
1296
1308
|
}
|
|
1297
1309
|
}
|
|
1298
|
-
var
|
|
1310
|
+
var ge = /* @__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))(ge || {});
|
|
1299
1311
|
const Tt = Oe({
|
|
1300
1312
|
types: {
|
|
1301
1313
|
context: {},
|
|
@@ -1303,10 +1315,10 @@ const Tt = Oe({
|
|
|
1303
1315
|
},
|
|
1304
1316
|
actions: {
|
|
1305
1317
|
logTransition: (n, e) => {
|
|
1306
|
-
|
|
1318
|
+
h(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1307
1319
|
},
|
|
1308
1320
|
logStateChange: (n, e) => {
|
|
1309
|
-
|
|
1321
|
+
h("ConnectionStateMachine state changed", e.state);
|
|
1310
1322
|
}
|
|
1311
1323
|
}
|
|
1312
1324
|
}).createMachine({
|
|
@@ -1619,8 +1631,8 @@ class St {
|
|
|
1619
1631
|
constructor(e) {
|
|
1620
1632
|
this.events = e, this.actor = ye(Tt), this.actorSubscription = this.actor.subscribe((t) => {
|
|
1621
1633
|
const s = t.value;
|
|
1622
|
-
this.stateChangeListeners.forEach((
|
|
1623
|
-
|
|
1634
|
+
this.stateChangeListeners.forEach((r) => {
|
|
1635
|
+
r(s);
|
|
1624
1636
|
});
|
|
1625
1637
|
}), this.actor.start(), this.subscribeToEvents();
|
|
1626
1638
|
}
|
|
@@ -1703,7 +1715,7 @@ class St {
|
|
|
1703
1715
|
return this.actor.getSnapshot().can({ type: e });
|
|
1704
1716
|
}
|
|
1705
1717
|
getValidEvents() {
|
|
1706
|
-
return Object.values(
|
|
1718
|
+
return Object.values(ge).filter((e) => this.canTransition(e));
|
|
1707
1719
|
}
|
|
1708
1720
|
hasState(e) {
|
|
1709
1721
|
return this.actor.getSnapshot().matches(e);
|
|
@@ -1711,7 +1723,7 @@ class St {
|
|
|
1711
1723
|
sendEvent(e) {
|
|
1712
1724
|
const t = this.actor.getSnapshot(), s = { type: e };
|
|
1713
1725
|
if (!t.can(s)) {
|
|
1714
|
-
|
|
1726
|
+
h(
|
|
1715
1727
|
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1716
1728
|
);
|
|
1717
1729
|
return;
|
|
@@ -1794,17 +1806,17 @@ class Ct {
|
|
|
1794
1806
|
try {
|
|
1795
1807
|
await this.unregister();
|
|
1796
1808
|
} catch (e) {
|
|
1797
|
-
|
|
1809
|
+
h("tryRegister", e);
|
|
1798
1810
|
}
|
|
1799
1811
|
return this.register();
|
|
1800
1812
|
}
|
|
1801
1813
|
subscribeToStartEvents(e, t) {
|
|
1802
|
-
const s = C.REGISTERED,
|
|
1803
|
-
return this.events.on(s, e),
|
|
1804
|
-
this.events.on(
|
|
1814
|
+
const s = C.REGISTERED, r = [C.REGISTRATION_FAILED, C.DISCONNECTED];
|
|
1815
|
+
return this.events.on(s, e), r.forEach((i) => {
|
|
1816
|
+
this.events.on(i, t);
|
|
1805
1817
|
}), () => {
|
|
1806
|
-
this.events.off(s, e),
|
|
1807
|
-
this.events.off(
|
|
1818
|
+
this.events.off(s, e), r.forEach((i) => {
|
|
1819
|
+
this.events.off(i, t);
|
|
1808
1820
|
});
|
|
1809
1821
|
};
|
|
1810
1822
|
}
|
|
@@ -1819,14 +1831,14 @@ class Et {
|
|
|
1819
1831
|
* Отправляет SIP OPTIONS запрос к указанному адресу
|
|
1820
1832
|
*/
|
|
1821
1833
|
async sendOptions(e, t, s) {
|
|
1822
|
-
const
|
|
1823
|
-
return new Promise((
|
|
1834
|
+
const r = this.getUaProtected();
|
|
1835
|
+
return new Promise((i, a) => {
|
|
1824
1836
|
try {
|
|
1825
|
-
|
|
1837
|
+
r.sendOptions(e, t, {
|
|
1826
1838
|
extraHeaders: s,
|
|
1827
1839
|
eventHandlers: {
|
|
1828
1840
|
succeeded: () => {
|
|
1829
|
-
|
|
1841
|
+
i();
|
|
1830
1842
|
},
|
|
1831
1843
|
failed: a
|
|
1832
1844
|
}
|
|
@@ -1840,8 +1852,8 @@ class Et {
|
|
|
1840
1852
|
* Отправляет SIP OPTIONS запрос к собственному URI (ping)
|
|
1841
1853
|
*/
|
|
1842
1854
|
async ping(e, t) {
|
|
1843
|
-
const
|
|
1844
|
-
return this.sendOptions(
|
|
1855
|
+
const r = this.getUaProtected().configuration.uri;
|
|
1856
|
+
return this.sendOptions(r, e, t);
|
|
1845
1857
|
}
|
|
1846
1858
|
/**
|
|
1847
1859
|
* Проверяет доступность телефонии, создавая временное соединение
|
|
@@ -1850,27 +1862,27 @@ class Et {
|
|
|
1850
1862
|
userAgent: e,
|
|
1851
1863
|
displayName: t,
|
|
1852
1864
|
sipServerUrl: s,
|
|
1853
|
-
sipWebSocketServerURL:
|
|
1854
|
-
remoteAddress:
|
|
1865
|
+
sipWebSocketServerURL: r,
|
|
1866
|
+
remoteAddress: i,
|
|
1855
1867
|
extraHeaders: a
|
|
1856
1868
|
}) {
|
|
1857
1869
|
return new Promise((o, c) => {
|
|
1858
|
-
const { configuration:
|
|
1859
|
-
sipWebSocketServerURL:
|
|
1870
|
+
const { configuration: d } = this.uaFactory.createConfiguration({
|
|
1871
|
+
sipWebSocketServerURL: r,
|
|
1860
1872
|
displayName: t,
|
|
1861
1873
|
userAgent: e,
|
|
1862
1874
|
sipServerUrl: s
|
|
1863
|
-
}), T = this.uaFactory.createUA({ ...
|
|
1875
|
+
}), T = this.uaFactory.createUA({ ...d, remoteAddress: i, extraHeaders: a }), S = () => {
|
|
1864
1876
|
const E = new Error("Telephony is not available");
|
|
1865
1877
|
c(E);
|
|
1866
1878
|
};
|
|
1867
1879
|
T.once(C.DISCONNECTED, S);
|
|
1868
|
-
const
|
|
1880
|
+
const u = () => {
|
|
1869
1881
|
T.removeAllListeners(), T.once(C.DISCONNECTED, () => {
|
|
1870
1882
|
o();
|
|
1871
1883
|
}), T.stop();
|
|
1872
1884
|
};
|
|
1873
|
-
T.once(C.CONNECTED,
|
|
1885
|
+
T.once(C.CONNECTED, u), T.start();
|
|
1874
1886
|
});
|
|
1875
1887
|
}
|
|
1876
1888
|
}
|
|
@@ -1890,12 +1902,12 @@ class y {
|
|
|
1890
1902
|
register: e,
|
|
1891
1903
|
password: t,
|
|
1892
1904
|
user: s,
|
|
1893
|
-
sipServerUrl:
|
|
1894
|
-
sipWebSocketServerURL:
|
|
1905
|
+
sipServerUrl: r,
|
|
1906
|
+
sipWebSocketServerURL: i
|
|
1895
1907
|
}) {
|
|
1896
|
-
if (!i)
|
|
1897
|
-
throw new Error("sipServerUrl is required");
|
|
1898
1908
|
if (!r)
|
|
1909
|
+
throw new Error("sipServerUrl is required");
|
|
1910
|
+
if (!i)
|
|
1899
1911
|
throw new Error("sipWebSocketServerURL is required");
|
|
1900
1912
|
if (e && (t === void 0 || t === ""))
|
|
1901
1913
|
throw new Error("password is required for authorized connection");
|
|
@@ -1913,13 +1925,13 @@ class y {
|
|
|
1913
1925
|
user: e,
|
|
1914
1926
|
password: t,
|
|
1915
1927
|
sipWebSocketServerURL: s,
|
|
1916
|
-
displayName:
|
|
1917
|
-
sipServerUrl:
|
|
1928
|
+
displayName: r = "",
|
|
1929
|
+
sipServerUrl: i,
|
|
1918
1930
|
register: a = !1,
|
|
1919
1931
|
sessionTimers: o = !1,
|
|
1920
1932
|
registerExpires: c = 300,
|
|
1921
1933
|
// 5 minutes in sec
|
|
1922
|
-
connectionRecoveryMinInterval:
|
|
1934
|
+
connectionRecoveryMinInterval: d = 2,
|
|
1923
1935
|
connectionRecoveryMaxInterval: T = 6,
|
|
1924
1936
|
userAgent: S
|
|
1925
1937
|
}) {
|
|
@@ -1927,22 +1939,22 @@ class y {
|
|
|
1927
1939
|
register: a,
|
|
1928
1940
|
password: t,
|
|
1929
1941
|
user: e,
|
|
1930
|
-
sipServerUrl:
|
|
1942
|
+
sipServerUrl: i,
|
|
1931
1943
|
sipWebSocketServerURL: s
|
|
1932
1944
|
});
|
|
1933
|
-
const
|
|
1945
|
+
const u = y.resolveAuthorizationUser(a, e), E = Ve(i), m = E(u), I = new this.JsSIP.WebSocketInterface(s);
|
|
1934
1946
|
return {
|
|
1935
1947
|
configuration: {
|
|
1936
1948
|
password: t,
|
|
1937
1949
|
register: a,
|
|
1938
1950
|
uri: m,
|
|
1939
|
-
display_name:
|
|
1951
|
+
display_name: ie(r),
|
|
1940
1952
|
user_agent: S,
|
|
1941
1953
|
sdpSemantics: "unified-plan",
|
|
1942
1954
|
sockets: [I],
|
|
1943
1955
|
session_timers: o,
|
|
1944
1956
|
register_expires: c,
|
|
1945
|
-
connection_recovery_min_interval:
|
|
1957
|
+
connection_recovery_min_interval: d,
|
|
1946
1958
|
connection_recovery_max_interval: T
|
|
1947
1959
|
},
|
|
1948
1960
|
helpers: {
|
|
@@ -1952,22 +1964,22 @@ class y {
|
|
|
1952
1964
|
};
|
|
1953
1965
|
}
|
|
1954
1966
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
1955
|
-
const
|
|
1956
|
-
return
|
|
1967
|
+
const r = new this.JsSIP.UA(s), i = y.buildExtraHeaders(e, t);
|
|
1968
|
+
return i.length > 0 && r.registrator().setExtraHeaders(i), r;
|
|
1957
1969
|
}
|
|
1958
1970
|
/**
|
|
1959
1971
|
* Создает UA с полным жизненным циклом - конфигурация + создание + настройка событий
|
|
1960
1972
|
*/
|
|
1961
1973
|
createUAWithConfiguration(e, t) {
|
|
1962
|
-
const { configuration: s, helpers:
|
|
1974
|
+
const { configuration: s, helpers: r } = this.createConfiguration(e), i = this.createUA({
|
|
1963
1975
|
...s,
|
|
1964
1976
|
remoteAddress: e.remoteAddress,
|
|
1965
1977
|
extraHeaders: e.extraHeaders
|
|
1966
1978
|
});
|
|
1967
1979
|
return t.eachTriggers((a, o) => {
|
|
1968
|
-
const c = le.find((
|
|
1969
|
-
c &&
|
|
1970
|
-
}), { ua:
|
|
1980
|
+
const c = le.find((d) => d === o);
|
|
1981
|
+
c && i.on(c, a);
|
|
1982
|
+
}), { ua: i, helpers: r };
|
|
1971
1983
|
}
|
|
1972
1984
|
}
|
|
1973
1985
|
const Te = "Not ready for connection", Nt = (n) => n instanceof Error && n.message === Te, Rt = () => new Error(Te), It = async (n) => typeof n == "function" ? n() : n;
|
|
@@ -1983,15 +1995,15 @@ class pt {
|
|
|
1983
1995
|
configurationManager;
|
|
1984
1996
|
JsSIP;
|
|
1985
1997
|
constructor({ JsSIP: e }) {
|
|
1986
|
-
this.JsSIP = e, this.events = new U(
|
|
1998
|
+
this.JsSIP = e, this.events = new U(ue), this.uaFactory = new y(e), this.registrationManager = new Ct({
|
|
1987
1999
|
events: this.events,
|
|
1988
2000
|
getUaProtected: this.getUaProtected
|
|
1989
|
-
}), this.stateMachine = new St(this.events), this.configurationManager = new
|
|
2001
|
+
}), this.stateMachine = new St(this.events), this.configurationManager = new dt({
|
|
1990
2002
|
getUa: this.getUa
|
|
1991
2003
|
}), this.sipOperations = new Et({
|
|
1992
2004
|
uaFactory: this.uaFactory,
|
|
1993
2005
|
getUaProtected: this.getUaProtected
|
|
1994
|
-
}), this.connectionFlow = new
|
|
2006
|
+
}), this.connectionFlow = new gt({
|
|
1995
2007
|
JsSIP: this.JsSIP,
|
|
1996
2008
|
events: this.events,
|
|
1997
2009
|
uaFactory: this.uaFactory,
|
|
@@ -2044,7 +2056,7 @@ class pt {
|
|
|
2044
2056
|
return this.configurationManager.isRegister();
|
|
2045
2057
|
}
|
|
2046
2058
|
connect = async (e, t) => this.disconnect().catch((s) => {
|
|
2047
|
-
|
|
2059
|
+
h("connect: disconnect error", s);
|
|
2048
2060
|
}).then(async () => this.connectWithProcessError(e, t));
|
|
2049
2061
|
set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
|
|
2050
2062
|
disconnect = async () => {
|
|
@@ -2094,12 +2106,12 @@ class pt {
|
|
|
2094
2106
|
connectWithProcessError = async (e, t) => {
|
|
2095
2107
|
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
2096
2108
|
throw Rt();
|
|
2097
|
-
return this.processConnect(e, t).catch(async (
|
|
2098
|
-
const
|
|
2109
|
+
return this.processConnect(e, t).catch(async (r) => {
|
|
2110
|
+
const i = r;
|
|
2099
2111
|
return this.disconnect().then(() => {
|
|
2100
|
-
throw
|
|
2112
|
+
throw i;
|
|
2101
2113
|
}).catch(() => {
|
|
2102
|
-
throw
|
|
2114
|
+
throw i;
|
|
2103
2115
|
});
|
|
2104
2116
|
});
|
|
2105
2117
|
};
|
|
@@ -2108,8 +2120,8 @@ class pt {
|
|
|
2108
2120
|
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
|
|
2109
2121
|
...s
|
|
2110
2122
|
}), s)).catch((s) => {
|
|
2111
|
-
const
|
|
2112
|
-
throw this.events.trigger(C.CONNECT_FAILED,
|
|
2123
|
+
const r = s ?? new Error("Failed to connect to server");
|
|
2124
|
+
throw this.events.trigger(C.CONNECT_FAILED, r), r;
|
|
2113
2125
|
}));
|
|
2114
2126
|
}
|
|
2115
2127
|
class mt {
|
|
@@ -2163,7 +2175,7 @@ class Mt {
|
|
|
2163
2175
|
this.countInner = this.initialCount, this.finishAttempt();
|
|
2164
2176
|
}
|
|
2165
2177
|
}
|
|
2166
|
-
class
|
|
2178
|
+
class ft {
|
|
2167
2179
|
connectionManager;
|
|
2168
2180
|
interval;
|
|
2169
2181
|
checkTelephonyByTimeout = void 0;
|
|
@@ -2185,8 +2197,8 @@ class vt {
|
|
|
2185
2197
|
request: async () => {
|
|
2186
2198
|
if (!this.cancelableBeforeRequest)
|
|
2187
2199
|
throw new Error("cancelableBeforeRequest is not defined");
|
|
2188
|
-
const
|
|
2189
|
-
return this.connectionManager.checkTelephony(
|
|
2200
|
+
const r = await this.cancelableBeforeRequest.request();
|
|
2201
|
+
return this.connectionManager.checkTelephony(r);
|
|
2190
2202
|
}
|
|
2191
2203
|
}), this.checkTelephonyByTimeout.start(void 0, {
|
|
2192
2204
|
onFailRequest: s,
|
|
@@ -2208,7 +2220,7 @@ const Se = [
|
|
|
2208
2220
|
"changed-attempt-status",
|
|
2209
2221
|
"stop-attempts-by-error",
|
|
2210
2222
|
"limit-reached-attempts"
|
|
2211
|
-
],
|
|
2223
|
+
], vt = 15e3, Pt = 2;
|
|
2212
2224
|
class Ot {
|
|
2213
2225
|
connectionManager;
|
|
2214
2226
|
pingServerByTimeoutWithFailCalls;
|
|
@@ -2216,14 +2228,14 @@ class Ot {
|
|
|
2216
2228
|
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Me(Pt, {
|
|
2217
2229
|
whenPossibleRequest: async () => {
|
|
2218
2230
|
},
|
|
2219
|
-
requestInterval:
|
|
2220
|
-
request: async () => (
|
|
2221
|
-
|
|
2231
|
+
requestInterval: vt,
|
|
2232
|
+
request: async () => (h("ping"), this.connectionManager.ping().then(() => {
|
|
2233
|
+
h("ping success");
|
|
2222
2234
|
}))
|
|
2223
2235
|
});
|
|
2224
2236
|
}
|
|
2225
2237
|
start({ onFailRequest: e }) {
|
|
2226
|
-
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(
|
|
2238
|
+
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(h);
|
|
2227
2239
|
}
|
|
2228
2240
|
stop() {
|
|
2229
2241
|
this.pingServerByTimeoutWithFailCalls.stop();
|
|
@@ -2242,12 +2254,12 @@ class yt {
|
|
|
2242
2254
|
});
|
|
2243
2255
|
}
|
|
2244
2256
|
start({ onFailRequest: e }) {
|
|
2245
|
-
|
|
2257
|
+
h("start"), this.disposeCallStatusChange = this.callManager.on("call-status-changed", () => {
|
|
2246
2258
|
this.handleCallStatusChange({ onFailRequest: e });
|
|
2247
2259
|
}), this.handleCallStatusChange({ onFailRequest: e });
|
|
2248
2260
|
}
|
|
2249
2261
|
stop() {
|
|
2250
|
-
|
|
2262
|
+
h("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
|
|
2251
2263
|
}
|
|
2252
2264
|
unsubscribeCallStatusChange() {
|
|
2253
2265
|
this.disposeCallStatusChange?.(), this.disposeCallStatusChange = void 0;
|
|
@@ -2304,15 +2316,17 @@ class Bt {
|
|
|
2304
2316
|
cancelableRequestBeforeRetry;
|
|
2305
2317
|
onBeforeRetry;
|
|
2306
2318
|
canRetryOnError;
|
|
2319
|
+
networkInterfacesSubscriber;
|
|
2320
|
+
resumeFromSleepModeSubscriber;
|
|
2307
2321
|
constructor({
|
|
2308
2322
|
connectionQueueManager: e,
|
|
2309
2323
|
connectionManager: t,
|
|
2310
2324
|
callManager: s
|
|
2311
|
-
},
|
|
2312
|
-
const
|
|
2313
|
-
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry =
|
|
2325
|
+
}, r) {
|
|
2326
|
+
const i = r?.onBeforeRetry ?? Ut, a = r?.canRetryOnError ?? Lt;
|
|
2327
|
+
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = i, this.canRetryOnError = a, this.networkInterfacesSubscriber = r?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = r?.resumeFromSleepModeSubscriber, this.events = new U(Se), this.checkTelephonyRequester = new ft({
|
|
2314
2328
|
connectionManager: t,
|
|
2315
|
-
interval:
|
|
2329
|
+
interval: r?.checkTelephonyRequestInterval ?? wt
|
|
2316
2330
|
}), this.pingServerIfNotActiveCallRequester = new yt({
|
|
2317
2331
|
connectionManager: t,
|
|
2318
2332
|
callManager: s
|
|
@@ -2321,19 +2335,17 @@ class Bt {
|
|
|
2321
2335
|
callManager: s
|
|
2322
2336
|
}), this.attemptsState = new Mt({
|
|
2323
2337
|
onStatusChange: this.emitStatusChange
|
|
2324
|
-
}), this.cancelableRequestBeforeRetry = new G(
|
|
2325
|
-
|
|
2338
|
+
}), this.cancelableRequestBeforeRetry = new G(i), this.delayBetweenAttempts = new fe(
|
|
2339
|
+
r?.timeoutBetweenAttempts ?? bt
|
|
2326
2340
|
);
|
|
2327
2341
|
}
|
|
2328
2342
|
start(e) {
|
|
2329
|
-
|
|
2330
|
-
|
|
2343
|
+
h("auto connector start"), this.stop(), this.connect(e).catch((t) => {
|
|
2344
|
+
h("auto connector failed to connect:", t);
|
|
2331
2345
|
});
|
|
2332
2346
|
}
|
|
2333
2347
|
stop() {
|
|
2334
|
-
|
|
2335
|
-
d("auto connector disconnect: error", e);
|
|
2336
|
-
});
|
|
2348
|
+
h("auto connector stop"), this.unsubscribeFromNetworkInterfaces(), this.shutdown();
|
|
2337
2349
|
}
|
|
2338
2350
|
on(e, t) {
|
|
2339
2351
|
return this.events.on(e, t);
|
|
@@ -2350,72 +2362,103 @@ class Bt {
|
|
|
2350
2362
|
off(e, t) {
|
|
2351
2363
|
this.events.off(e, t);
|
|
2352
2364
|
}
|
|
2365
|
+
shutdown() {
|
|
2366
|
+
h("shutdown"), this.stopAttempts(), this.stopConnectTriggers(), this.connectionQueueManager.disconnect().catch((e) => {
|
|
2367
|
+
h("auto connector disconnect: error", e);
|
|
2368
|
+
});
|
|
2369
|
+
}
|
|
2353
2370
|
stopAttempts() {
|
|
2354
2371
|
this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
|
|
2355
2372
|
}
|
|
2356
2373
|
stopConnectTriggers() {
|
|
2357
|
-
|
|
2374
|
+
h("stopConnectTriggers"), this.stopPingServerIfNotActiveCallRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
|
|
2358
2375
|
}
|
|
2359
2376
|
runCheckTelephony(e) {
|
|
2360
|
-
|
|
2377
|
+
h("runCheckTelephony"), this.checkTelephonyRequester.start({
|
|
2361
2378
|
onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
|
|
2362
2379
|
onSuccessRequest: () => {
|
|
2363
|
-
|
|
2380
|
+
h("runCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
|
|
2364
2381
|
},
|
|
2365
2382
|
onFailRequest: (t) => {
|
|
2366
|
-
|
|
2383
|
+
h("runCheckTelephony: onFailRequest", t.message);
|
|
2367
2384
|
}
|
|
2368
2385
|
});
|
|
2369
2386
|
}
|
|
2370
2387
|
async connect(e) {
|
|
2371
|
-
if (
|
|
2372
|
-
|
|
2388
|
+
if (h("connect: attempts.count", this.attemptsState.count), this.events.trigger(M.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
|
|
2389
|
+
h("connect: isLimitReached!"), this.handleLimitReached(e);
|
|
2373
2390
|
return;
|
|
2374
2391
|
}
|
|
2375
2392
|
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.processConnect(e);
|
|
2376
2393
|
}
|
|
2377
2394
|
async processConnect(e) {
|
|
2378
2395
|
try {
|
|
2379
|
-
await this.connectionQueueManager.connect(e.getParameters, e.options),
|
|
2396
|
+
await this.connectionQueueManager.connect(e.getParameters, e.options), h("processConnect success"), this.handleSucceededAttempt(e);
|
|
2380
2397
|
} catch (t) {
|
|
2381
2398
|
if (Nt(t)) {
|
|
2382
2399
|
this.attemptsState.finishAttempt(), this.handleSucceededAttempt(e);
|
|
2383
2400
|
return;
|
|
2384
2401
|
}
|
|
2385
2402
|
if (!this.canRetryOnError(t)) {
|
|
2386
|
-
|
|
2403
|
+
h("processConnect: error does not allow retry", t), this.attemptsState.finishAttempt(), this.events.trigger(M.STOP_ATTEMPTS_BY_ERROR, t);
|
|
2387
2404
|
return;
|
|
2388
2405
|
}
|
|
2389
2406
|
if (De(t)) {
|
|
2390
|
-
|
|
2407
|
+
h("processConnect: not actual error", t), this.attemptsState.finishAttempt(), this.events.trigger(M.CANCELLED_ATTEMPTS, t);
|
|
2391
2408
|
return;
|
|
2392
2409
|
}
|
|
2393
|
-
|
|
2410
|
+
h("processConnect: error", t), this.reconnect(e);
|
|
2394
2411
|
}
|
|
2395
2412
|
}
|
|
2396
2413
|
handleLimitReached(e) {
|
|
2397
2414
|
this.attemptsState.finishAttempt(), this.events.trigger(M.LIMIT_REACHED_ATTEMPTS, new Error("Limit reached")), this.runCheckTelephony(e);
|
|
2398
2415
|
}
|
|
2399
2416
|
handleSucceededAttempt(e) {
|
|
2400
|
-
|
|
2417
|
+
h("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.subscribeToNetworkInterfaces(e), this.events.trigger(M.SUCCESS);
|
|
2401
2418
|
}
|
|
2402
2419
|
subscribeToConnectTriggers(e) {
|
|
2420
|
+
this.startPingServerIfNotActiveCallRequester(e), this.resumeFromSleepModeSubscriber?.subscribe({
|
|
2421
|
+
onResume: () => {
|
|
2422
|
+
h("resumeFromSleepModeSubscriber onResume"), this.restartPingServerIfNotActiveCallRequester(e);
|
|
2423
|
+
}
|
|
2424
|
+
}), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2425
|
+
h("registrationFailedOutOfCallListener callback"), this.start(e);
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
subscribeToNetworkInterfaces(e) {
|
|
2429
|
+
this.unsubscribeFromNetworkInterfaces(), this.networkInterfacesSubscriber?.subscribe({
|
|
2430
|
+
onChange: () => {
|
|
2431
|
+
h("networkInterfacesSubscriber onChange"), this.restartPingServerIfNotActiveCallRequester(e);
|
|
2432
|
+
},
|
|
2433
|
+
onUnavailable: () => {
|
|
2434
|
+
h("networkInterfacesSubscriber onUnavailable"), this.shutdown();
|
|
2435
|
+
}
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
unsubscribeFromNetworkInterfaces() {
|
|
2439
|
+
this.networkInterfacesSubscriber?.unsubscribe();
|
|
2440
|
+
}
|
|
2441
|
+
restartPingServerIfNotActiveCallRequester(e) {
|
|
2442
|
+
this.stopPingServerIfNotActiveCallRequester(), this.startPingServerIfNotActiveCallRequester(e);
|
|
2443
|
+
}
|
|
2444
|
+
stopPingServerIfNotActiveCallRequester() {
|
|
2445
|
+
this.pingServerIfNotActiveCallRequester.stop();
|
|
2446
|
+
}
|
|
2447
|
+
startPingServerIfNotActiveCallRequester(e) {
|
|
2403
2448
|
this.pingServerIfNotActiveCallRequester.start({
|
|
2404
2449
|
onFailRequest: () => {
|
|
2405
|
-
|
|
2450
|
+
h("pingServer onFailRequest"), this.start(e);
|
|
2406
2451
|
}
|
|
2407
|
-
}), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2408
|
-
d("registrationFailedOutOfCallListener callback"), this.start(e);
|
|
2409
2452
|
});
|
|
2410
2453
|
}
|
|
2411
2454
|
connectIfDisconnected(e) {
|
|
2412
2455
|
const t = this.hasFailedOrDisconnectedConnection();
|
|
2413
|
-
|
|
2456
|
+
h("connectIfDisconnected: isFailedOrDisconnected", t), t ? this.start(e) : (this.stopConnectTriggers(), this.events.trigger(M.SUCCESS));
|
|
2414
2457
|
}
|
|
2415
2458
|
reconnect(e) {
|
|
2416
|
-
|
|
2459
|
+
h("reconnect"), this.delayBetweenAttempts.request().then(async () => (h("reconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (h("reconnect: onBeforeRetry success"), this.connect(e))).catch((t) => {
|
|
2417
2460
|
const s = t instanceof Error ? t : new Error("Failed to reconnect");
|
|
2418
|
-
this.attemptsState.finishAttempt(), me(t) ||
|
|
2461
|
+
this.attemptsState.finishAttempt(), me(t) || ve(t) ? this.events.trigger(M.CANCELLED_ATTEMPTS, s) : this.events.trigger(M.FAILED_ALL_ATTEMPTS, s), h("reconnect: error", t);
|
|
2419
2462
|
});
|
|
2420
2463
|
}
|
|
2421
2464
|
hasFailedOrDisconnectedConnection() {
|
|
@@ -2472,10 +2515,10 @@ class $t {
|
|
|
2472
2515
|
} = {}) {
|
|
2473
2516
|
return new Promise((t, s) => {
|
|
2474
2517
|
try {
|
|
2475
|
-
const
|
|
2476
|
-
this.removeIncomingSession(), this.events.trigger(w.DECLINED_INCOMING_CALL,
|
|
2477
|
-
} catch (
|
|
2478
|
-
s(
|
|
2518
|
+
const r = this.getIncomingRTCSession(), i = this.remoteCallerData;
|
|
2519
|
+
this.removeIncomingSession(), this.events.trigger(w.DECLINED_INCOMING_CALL, i), r.terminate({ status_code: e }), t();
|
|
2520
|
+
} catch (r) {
|
|
2521
|
+
s(r);
|
|
2479
2522
|
}
|
|
2480
2523
|
});
|
|
2481
2524
|
}
|
|
@@ -2529,7 +2572,7 @@ var A = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUN
|
|
|
2529
2572
|
const Ee = ["collected"], X = () => "performance" in window ? performance.now() : Date.now(), L = (n) => [...n.keys()].reduce((e, t) => {
|
|
2530
2573
|
const s = n.get(t);
|
|
2531
2574
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2532
|
-
}, {}),
|
|
2575
|
+
}, {}), qt = (n) => {
|
|
2533
2576
|
if (!n)
|
|
2534
2577
|
return {
|
|
2535
2578
|
outboundRtp: void 0,
|
|
@@ -2575,7 +2618,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2575
2618
|
codec: t[A.CODEC],
|
|
2576
2619
|
synchronizationSources: e
|
|
2577
2620
|
};
|
|
2578
|
-
},
|
|
2621
|
+
}, Vt = ({
|
|
2579
2622
|
audioReceiverStats: n,
|
|
2580
2623
|
synchronizationSourcesAudio: e
|
|
2581
2624
|
}) => {
|
|
@@ -2617,7 +2660,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2617
2660
|
}) => ({
|
|
2618
2661
|
video: J(e),
|
|
2619
2662
|
secondVideo: J(t),
|
|
2620
|
-
audio:
|
|
2663
|
+
audio: qt(n),
|
|
2621
2664
|
additional: Ae(
|
|
2622
2665
|
n ?? e ?? t
|
|
2623
2666
|
)
|
|
@@ -2635,7 +2678,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2635
2678
|
videoReceiversStats: t,
|
|
2636
2679
|
synchronizationSourcesVideo: s.video
|
|
2637
2680
|
}),
|
|
2638
|
-
audio:
|
|
2681
|
+
audio: Vt({
|
|
2639
2682
|
audioReceiverStats: n,
|
|
2640
2683
|
synchronizationSourcesAudio: s.audio
|
|
2641
2684
|
}),
|
|
@@ -2647,8 +2690,8 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2647
2690
|
videoSenderFirstStats: e,
|
|
2648
2691
|
videoSenderSecondStats: t,
|
|
2649
2692
|
audioReceiverStats: s,
|
|
2650
|
-
videoReceiverFirstStats:
|
|
2651
|
-
videoReceiverSecondStats:
|
|
2693
|
+
videoReceiverFirstStats: r,
|
|
2694
|
+
videoReceiverSecondStats: i,
|
|
2652
2695
|
synchronizationSources: a
|
|
2653
2696
|
}) => {
|
|
2654
2697
|
const o = Wt({
|
|
@@ -2657,8 +2700,8 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2657
2700
|
videoSenderSecondStats: t
|
|
2658
2701
|
}), c = Ht({
|
|
2659
2702
|
audioReceiverStats: s,
|
|
2660
|
-
videoReceiverFirstStats:
|
|
2661
|
-
videoReceiverSecondStats:
|
|
2703
|
+
videoReceiverFirstStats: r,
|
|
2704
|
+
videoReceiverSecondStats: i,
|
|
2662
2705
|
synchronizationSources: a
|
|
2663
2706
|
});
|
|
2664
2707
|
return {
|
|
@@ -2666,24 +2709,24 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2666
2709
|
inbound: c
|
|
2667
2710
|
};
|
|
2668
2711
|
}, Gt = async (n) => {
|
|
2669
|
-
const e = "audio", t = "video", s = n.getSenders(),
|
|
2712
|
+
const e = "audio", t = "video", s = n.getSenders(), r = s.find((u) => u.track?.kind === e), i = s.filter((u) => u.track?.kind === t), a = n.getReceivers(), o = a.find((u) => u.track.kind === e), c = a.filter((u) => u.track.kind === t), d = {
|
|
2670
2713
|
trackIdentifier: o?.track.id,
|
|
2671
2714
|
item: o?.getSynchronizationSources()[0]
|
|
2672
2715
|
}, T = {
|
|
2673
2716
|
trackIdentifier: c[0]?.track.id,
|
|
2674
2717
|
item: c[0]?.getSynchronizationSources()[0]
|
|
2675
2718
|
}, S = {
|
|
2676
|
-
audio:
|
|
2719
|
+
audio: d,
|
|
2677
2720
|
video: T
|
|
2678
2721
|
};
|
|
2679
2722
|
return Promise.all([
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2723
|
+
r?.getStats() ?? Promise.resolve(void 0),
|
|
2724
|
+
i[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2725
|
+
i[1]?.getStats() ?? Promise.resolve(void 0),
|
|
2683
2726
|
o?.getStats() ?? Promise.resolve(void 0),
|
|
2684
2727
|
c[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2685
2728
|
c[1]?.getStats() ?? Promise.resolve(void 0)
|
|
2686
|
-
]).then((
|
|
2729
|
+
]).then((u) => {
|
|
2687
2730
|
const [
|
|
2688
2731
|
E,
|
|
2689
2732
|
m,
|
|
@@ -2691,7 +2734,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2691
2734
|
R,
|
|
2692
2735
|
D,
|
|
2693
2736
|
$
|
|
2694
|
-
] =
|
|
2737
|
+
] = u;
|
|
2695
2738
|
return {
|
|
2696
2739
|
synchronizationSources: S,
|
|
2697
2740
|
audioSenderStats: E,
|
|
@@ -2703,7 +2746,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2703
2746
|
};
|
|
2704
2747
|
});
|
|
2705
2748
|
}, Qt = (n) => {
|
|
2706
|
-
|
|
2749
|
+
h(String(n));
|
|
2707
2750
|
};
|
|
2708
2751
|
class Yt {
|
|
2709
2752
|
events;
|
|
@@ -2747,16 +2790,16 @@ class Yt {
|
|
|
2747
2790
|
onError: t
|
|
2748
2791
|
}) => {
|
|
2749
2792
|
const s = X();
|
|
2750
|
-
this.requesterAllStatistics.request(e).then((
|
|
2751
|
-
this.events.trigger("collected", xt(
|
|
2793
|
+
this.requesterAllStatistics.request(e).then((r) => {
|
|
2794
|
+
this.events.trigger("collected", xt(r));
|
|
2752
2795
|
const a = X() - s;
|
|
2753
2796
|
let o = b;
|
|
2754
2797
|
a > 48 ? o = b * 4 : a > 32 ? o = b * 3 : a > 16 && (o = b * 2), this.start(e, {
|
|
2755
2798
|
onError: t,
|
|
2756
2799
|
interval: o
|
|
2757
2800
|
});
|
|
2758
|
-
}).catch((
|
|
2759
|
-
t && t(
|
|
2801
|
+
}).catch((r) => {
|
|
2802
|
+
t && t(r);
|
|
2760
2803
|
});
|
|
2761
2804
|
};
|
|
2762
2805
|
}
|
|
@@ -2808,15 +2851,15 @@ class zt {
|
|
|
2808
2851
|
};
|
|
2809
2852
|
maybeSendStats() {
|
|
2810
2853
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
2811
|
-
|
|
2854
|
+
h("Failed to send stats", e);
|
|
2812
2855
|
});
|
|
2813
2856
|
}
|
|
2814
2857
|
}
|
|
2815
|
-
const Xt = (n, e) => n.filter((s) => e.some((
|
|
2816
|
-
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs,
|
|
2817
|
-
return Xt(s,
|
|
2858
|
+
const Xt = (n, e) => n.filter((s) => e.some((r) => r.clockRate === s.clockRate && r.mimeType === s.mimeType && r.channels === s.channels && r.sdpFmtpLine === s.sdpFmtpLine)), Jt = (n) => {
|
|
2859
|
+
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, r = t === null ? [] : t.codecs;
|
|
2860
|
+
return Xt(s, r);
|
|
2818
2861
|
}, Kt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
2819
|
-
const
|
|
2862
|
+
const r = e.indexOf(t.mimeType), i = e.indexOf(s.mimeType), a = r === -1 ? Number.MAX_VALUE : r, o = i === -1 ? Number.MAX_VALUE : i;
|
|
2820
2863
|
return a - o;
|
|
2821
2864
|
}), jt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Zt = (n, {
|
|
2822
2865
|
preferredMimeTypesVideoCodecs: e,
|
|
@@ -2824,11 +2867,11 @@ const Xt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate &
|
|
|
2824
2867
|
}) => {
|
|
2825
2868
|
try {
|
|
2826
2869
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
2827
|
-
const s = Jt("video"),
|
|
2828
|
-
n.setCodecPreferences(
|
|
2870
|
+
const s = Jt("video"), r = jt(s, t), i = Kt(r, e);
|
|
2871
|
+
n.setCodecPreferences(i);
|
|
2829
2872
|
}
|
|
2830
2873
|
} catch (s) {
|
|
2831
|
-
|
|
2874
|
+
h("setCodecPreferences error", s);
|
|
2832
2875
|
}
|
|
2833
2876
|
};
|
|
2834
2877
|
class en {
|
|
@@ -2852,8 +2895,8 @@ class en {
|
|
|
2852
2895
|
if (s === "audio")
|
|
2853
2896
|
this.transceivers.mainAudio ??= e;
|
|
2854
2897
|
else {
|
|
2855
|
-
const { mid:
|
|
2856
|
-
|
|
2898
|
+
const { mid: r } = e;
|
|
2899
|
+
r === "2" ? this.transceivers.presentationVideo ??= e : this.transceivers.mainVideo ??= e;
|
|
2857
2900
|
}
|
|
2858
2901
|
}
|
|
2859
2902
|
/**
|
|
@@ -2910,10 +2953,10 @@ class en {
|
|
|
2910
2953
|
*/
|
|
2911
2954
|
handleRestart = (e) => {
|
|
2912
2955
|
this.updateTransceivers(e).catch((t) => {
|
|
2913
|
-
|
|
2956
|
+
h("Failed to update transceivers", t);
|
|
2914
2957
|
}).finally(() => {
|
|
2915
2958
|
this.callManager.restartIce().catch((t) => {
|
|
2916
|
-
|
|
2959
|
+
h("Failed to restart ICE", t);
|
|
2917
2960
|
});
|
|
2918
2961
|
});
|
|
2919
2962
|
};
|
|
@@ -2924,8 +2967,8 @@ class en {
|
|
|
2924
2967
|
const { videoTrackCount: t } = e;
|
|
2925
2968
|
t === 2 && (this.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
|
|
2926
2969
|
direction: "recvonly"
|
|
2927
|
-
}).catch((
|
|
2928
|
-
|
|
2970
|
+
}).catch((i) => {
|
|
2971
|
+
h("Failed to add presentation video transceiver", i);
|
|
2929
2972
|
}));
|
|
2930
2973
|
};
|
|
2931
2974
|
subscribe() {
|
|
@@ -2966,7 +3009,7 @@ class an {
|
|
|
2966
3009
|
*/
|
|
2967
3010
|
async run() {
|
|
2968
3011
|
return this.stackPromises().catch((e) => {
|
|
2969
|
-
|
|
3012
|
+
h("TaskQueue: error", e);
|
|
2970
3013
|
});
|
|
2971
3014
|
}
|
|
2972
3015
|
}
|
|
@@ -2977,21 +3020,21 @@ class on {
|
|
|
2977
3020
|
this.onSetParameters = e, this.taskQueue = new an();
|
|
2978
3021
|
}
|
|
2979
3022
|
async setEncodingsToSender(e, t) {
|
|
2980
|
-
return this.taskQueue.add(async () =>
|
|
3023
|
+
return this.taskQueue.add(async () => he(e, t, this.onSetParameters));
|
|
2981
3024
|
}
|
|
2982
3025
|
stop() {
|
|
2983
3026
|
this.taskQueue.stop();
|
|
2984
3027
|
}
|
|
2985
3028
|
}
|
|
2986
|
-
const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), cn = 1e6,
|
|
2987
|
-
const t =
|
|
3029
|
+
const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), cn = 1e6, f = (n) => n * cn, Re = f(0.06), Ie = f(4), hn = (n) => n <= 64 ? Re : n <= 128 ? f(0.12) : n <= 256 ? f(0.25) : n <= 384 ? f(0.32) : n <= 426 ? f(0.38) : n <= 640 ? f(0.5) : n <= 848 ? f(0.7) : n <= 1280 ? f(1) : n <= 1920 ? f(2) : Ie, dn = "av1", ln = (n) => Ne(n, dn), un = 0.6, Y = (n, e) => ln(e) ? n * un : n, gn = (n) => Y(Re, n), Tn = (n) => Y(Ie, n), j = (n, e) => {
|
|
3030
|
+
const t = hn(n);
|
|
2988
3031
|
return Y(t, e);
|
|
2989
|
-
},
|
|
3032
|
+
}, q = 1, Sn = ({
|
|
2990
3033
|
videoTrack: n,
|
|
2991
3034
|
targetSize: e
|
|
2992
3035
|
}) => {
|
|
2993
|
-
const t = n.getSettings(), s = t.width,
|
|
2994
|
-
return Math.max(
|
|
3036
|
+
const t = n.getSettings(), s = t.width, r = t.height, i = s === void 0 ? q : s / e.width, a = r === void 0 ? q : r / e.height;
|
|
3037
|
+
return Math.max(i, a, q);
|
|
2995
3038
|
};
|
|
2996
3039
|
class Cn {
|
|
2997
3040
|
ignoreForCodec;
|
|
@@ -3012,8 +3055,8 @@ class Cn {
|
|
|
3012
3055
|
senderFinder: e,
|
|
3013
3056
|
codecProvider: t,
|
|
3014
3057
|
parametersSetter: s
|
|
3015
|
-
},
|
|
3016
|
-
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec =
|
|
3058
|
+
}, r) {
|
|
3059
|
+
this.senderFinder = e, this.codecProvider = t, this.parametersSetter = s, this.ignoreForCodec = r.ignoreForCodec;
|
|
3017
3060
|
}
|
|
3018
3061
|
/**
|
|
3019
3062
|
* Выполняет балансировку на основе заголовков от сервера
|
|
@@ -3022,21 +3065,21 @@ class Cn {
|
|
|
3022
3065
|
* @returns Promise с результатом балансировки
|
|
3023
3066
|
*/
|
|
3024
3067
|
async balance(e, t) {
|
|
3025
|
-
const s = e.getSenders(),
|
|
3026
|
-
if (!
|
|
3027
|
-
return { ...this.resultNoChanged, sender:
|
|
3028
|
-
const
|
|
3029
|
-
if (Ne(
|
|
3030
|
-
return { ...this.resultNoChanged, sender:
|
|
3068
|
+
const s = e.getSenders(), r = this.senderFinder.findVideoSender(s);
|
|
3069
|
+
if (!r?.track)
|
|
3070
|
+
return { ...this.resultNoChanged, sender: r };
|
|
3071
|
+
const i = await this.codecProvider.getCodecFromSender(r);
|
|
3072
|
+
if (Ne(i, this.ignoreForCodec))
|
|
3073
|
+
return { ...this.resultNoChanged, sender: r };
|
|
3031
3074
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
3032
3075
|
return this.processSender(
|
|
3033
3076
|
{ mainCam: a, resolutionMainCam: o },
|
|
3034
3077
|
{
|
|
3035
|
-
sender:
|
|
3036
|
-
codec:
|
|
3037
|
-
videoTrack:
|
|
3078
|
+
sender: r,
|
|
3079
|
+
codec: i,
|
|
3080
|
+
videoTrack: r.track
|
|
3038
3081
|
}
|
|
3039
|
-
).then((c) => ({ ...c, sender:
|
|
3082
|
+
).then((c) => ({ ...c, sender: r }));
|
|
3040
3083
|
}
|
|
3041
3084
|
/**
|
|
3042
3085
|
* Обрабатывает отправитель в зависимости от команды управления
|
|
@@ -3044,16 +3087,16 @@ class Cn {
|
|
|
3044
3087
|
* @returns Promise с результатом обработки
|
|
3045
3088
|
*/
|
|
3046
3089
|
async processSender(e, t) {
|
|
3047
|
-
const { mainCam: s, resolutionMainCam:
|
|
3090
|
+
const { mainCam: s, resolutionMainCam: r } = e;
|
|
3048
3091
|
switch (s) {
|
|
3049
|
-
case
|
|
3092
|
+
case v.PAUSE_MAIN_CAM:
|
|
3050
3093
|
return this.downgradeResolutionSender(t);
|
|
3051
|
-
case
|
|
3094
|
+
case v.RESUME_MAIN_CAM:
|
|
3052
3095
|
return this.setBitrateByTrackResolution(t);
|
|
3053
|
-
case
|
|
3054
|
-
return
|
|
3055
|
-
case
|
|
3056
|
-
case
|
|
3096
|
+
case v.MAX_MAIN_CAM_RESOLUTION:
|
|
3097
|
+
return r !== void 0 ? this.setResolutionSender(r, t) : this.setBitrateByTrackResolution(t);
|
|
3098
|
+
case v.ADMIN_STOP_MAIN_CAM:
|
|
3099
|
+
case v.ADMIN_START_MAIN_CAM:
|
|
3057
3100
|
case void 0:
|
|
3058
3101
|
return this.setBitrateByTrackResolution(t);
|
|
3059
3102
|
default:
|
|
@@ -3066,11 +3109,11 @@ class Cn {
|
|
|
3066
3109
|
* @returns Promise с результатом
|
|
3067
3110
|
*/
|
|
3068
3111
|
async downgradeResolutionSender(e) {
|
|
3069
|
-
const { sender: t, codec: s } = e,
|
|
3112
|
+
const { sender: t, codec: s } = e, r = {
|
|
3070
3113
|
scaleResolutionDownBy: 200,
|
|
3071
|
-
maxBitrate:
|
|
3114
|
+
maxBitrate: gn(s)
|
|
3072
3115
|
};
|
|
3073
|
-
return this.parametersSetter.setEncodingsToSender(t,
|
|
3116
|
+
return this.parametersSetter.setEncodingsToSender(t, r);
|
|
3074
3117
|
}
|
|
3075
3118
|
/**
|
|
3076
3119
|
* Устанавливает битрейт на основе разрешения трека
|
|
@@ -3078,7 +3121,7 @@ class Cn {
|
|
|
3078
3121
|
* @returns Promise с результатом
|
|
3079
3122
|
*/
|
|
3080
3123
|
async setBitrateByTrackResolution(e) {
|
|
3081
|
-
const { sender: t, videoTrack: s, codec:
|
|
3124
|
+
const { sender: t, videoTrack: s, codec: r } = e, a = s.getSettings().width, o = a === void 0 ? Tn(r) : j(a, r);
|
|
3082
3125
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
3083
3126
|
scaleResolutionDownBy: 1,
|
|
3084
3127
|
maxBitrate: o
|
|
@@ -3091,17 +3134,17 @@ class Cn {
|
|
|
3091
3134
|
* @returns Promise с результатом
|
|
3092
3135
|
*/
|
|
3093
3136
|
async setResolutionSender(e, t) {
|
|
3094
|
-
const [s,
|
|
3137
|
+
const [s, r] = e.split("x"), { sender: i, videoTrack: a, codec: o } = t, c = {
|
|
3095
3138
|
width: Number(s),
|
|
3096
|
-
height: Number(
|
|
3097
|
-
},
|
|
3139
|
+
height: Number(r)
|
|
3140
|
+
}, d = Sn({
|
|
3098
3141
|
videoTrack: a,
|
|
3099
3142
|
targetSize: c
|
|
3100
3143
|
}), T = j(c.width, o), S = {
|
|
3101
|
-
scaleResolutionDownBy:
|
|
3144
|
+
scaleResolutionDownBy: d,
|
|
3102
3145
|
maxBitrate: T
|
|
3103
3146
|
};
|
|
3104
|
-
return this.parametersSetter.setEncodingsToSender(
|
|
3147
|
+
return this.parametersSetter.setEncodingsToSender(i, S);
|
|
3105
3148
|
}
|
|
3106
3149
|
}
|
|
3107
3150
|
const En = (n) => n.find((e) => e.track?.kind === "video");
|
|
@@ -3143,8 +3186,8 @@ class Nn {
|
|
|
3143
3186
|
attachSender(e, t) {
|
|
3144
3187
|
this.currentSender = e;
|
|
3145
3188
|
const s = e.replaceTrack.bind(e);
|
|
3146
|
-
this.originalReplaceTrack = s, e.replaceTrack = async (
|
|
3147
|
-
await s(
|
|
3189
|
+
this.originalReplaceTrack = s, e.replaceTrack = async (r) => {
|
|
3190
|
+
await s(r), this.attachTrack(t, r ?? void 0), t();
|
|
3148
3191
|
}, this.attachTrack(t, e.track);
|
|
3149
3192
|
}
|
|
3150
3193
|
detachSender() {
|
|
@@ -3153,8 +3196,8 @@ class Nn {
|
|
|
3153
3196
|
attachTrack(e, t) {
|
|
3154
3197
|
if (this.detachTrack(), !t)
|
|
3155
3198
|
return;
|
|
3156
|
-
const { width: s, height:
|
|
3157
|
-
this.lastWidth = s, this.lastHeight =
|
|
3199
|
+
const { width: s, height: r } = t.getSettings();
|
|
3200
|
+
this.lastWidth = s, this.lastHeight = r, this.currentPollIntervalMs = this.pollIntervalMs, this.schedulePoll(t, e);
|
|
3158
3201
|
}
|
|
3159
3202
|
/**
|
|
3160
3203
|
* Периодически опрашивает track с экспоненциальной адаптацией частоты.
|
|
@@ -3163,8 +3206,8 @@ class Nn {
|
|
|
3163
3206
|
*/
|
|
3164
3207
|
schedulePoll(e, t) {
|
|
3165
3208
|
const s = () => {
|
|
3166
|
-
const { width:
|
|
3167
|
-
|
|
3209
|
+
const { width: r, height: i } = e.getSettings();
|
|
3210
|
+
r !== this.lastWidth || i !== this.lastHeight ? (this.lastWidth = r, this.lastHeight = i, this.currentPollIntervalMs = this.pollIntervalMs, t()) : this.currentPollIntervalMs = Math.min(
|
|
3168
3211
|
this.currentPollIntervalMs * 2,
|
|
3169
3212
|
this.maxPollIntervalMs
|
|
3170
3213
|
), this.setTimeoutRequest.request(s, this.currentPollIntervalMs);
|
|
@@ -3204,10 +3247,10 @@ class In {
|
|
|
3204
3247
|
trackMonitor;
|
|
3205
3248
|
constructor(e, t, {
|
|
3206
3249
|
ignoreForCodec: s,
|
|
3207
|
-
onSetParameters:
|
|
3208
|
-
pollIntervalMs:
|
|
3250
|
+
onSetParameters: r,
|
|
3251
|
+
pollIntervalMs: i
|
|
3209
3252
|
} = {}) {
|
|
3210
|
-
this.getConnection = t, this.eventHandler = new Rn(e), this.parametersSetterWithQueue = new on(
|
|
3253
|
+
this.getConnection = t, this.eventHandler = new Rn(e), this.parametersSetterWithQueue = new on(r), this.senderBalancer = new Cn(
|
|
3211
3254
|
{
|
|
3212
3255
|
senderFinder: new An(),
|
|
3213
3256
|
codecProvider: new rn(),
|
|
@@ -3216,7 +3259,7 @@ class In {
|
|
|
3216
3259
|
{
|
|
3217
3260
|
ignoreForCodec: s
|
|
3218
3261
|
}
|
|
3219
|
-
), this.trackMonitor = new Nn({ pollIntervalMs:
|
|
3262
|
+
), this.trackMonitor = new Nn({ pollIntervalMs: i });
|
|
3220
3263
|
}
|
|
3221
3264
|
/**
|
|
3222
3265
|
* Подписывается на события управления главной камерой
|
|
@@ -3247,7 +3290,7 @@ class In {
|
|
|
3247
3290
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
3248
3291
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
3249
3292
|
this.balance().catch((s) => {
|
|
3250
|
-
|
|
3293
|
+
h("balance on track change: error", s);
|
|
3251
3294
|
});
|
|
3252
3295
|
}), t;
|
|
3253
3296
|
}
|
|
@@ -3257,7 +3300,7 @@ class In {
|
|
|
3257
3300
|
*/
|
|
3258
3301
|
handleMainCamControl = (e) => {
|
|
3259
3302
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
3260
|
-
|
|
3303
|
+
h("handleMainCamControl: error", t);
|
|
3261
3304
|
});
|
|
3262
3305
|
};
|
|
3263
3306
|
}
|
|
@@ -3280,8 +3323,8 @@ class pn {
|
|
|
3280
3323
|
() => e.connection,
|
|
3281
3324
|
{
|
|
3282
3325
|
...s,
|
|
3283
|
-
onSetParameters: (
|
|
3284
|
-
this.events.trigger("parameters-updated",
|
|
3326
|
+
onSetParameters: (r) => {
|
|
3327
|
+
this.events.trigger("parameters-updated", r), s.onSetParameters?.(r);
|
|
3285
3328
|
}
|
|
3286
3329
|
}
|
|
3287
3330
|
), this.subscribe();
|
|
@@ -3337,7 +3380,7 @@ class pn {
|
|
|
3337
3380
|
scheduleBalancingStart() {
|
|
3338
3381
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
3339
3382
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
3340
|
-
|
|
3383
|
+
h("startBalancing: error", e);
|
|
3341
3384
|
});
|
|
3342
3385
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
3343
3386
|
}
|
|
@@ -3345,11 +3388,11 @@ class pn {
|
|
|
3345
3388
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
3346
3389
|
}
|
|
3347
3390
|
}
|
|
3348
|
-
const mn = 1e6, _n = Se.map((n) => `auto-connect:${n}`), Mn =
|
|
3391
|
+
const mn = 1e6, _n = Se.map((n) => `auto-connect:${n}`), Mn = ue.map((n) => `connection:${n}`), fn = re.map((n) => `call:${n}`), vn = ne.map((n) => `api:${n}`), Pn = Ce.map((n) => `incoming-call:${n}`), On = de.map((n) => `presentation:${n}`), yn = Ee.map((n) => `stats:${n}`), Dn = pe.map((n) => `video-balancer:${n}`), bn = [
|
|
3349
3392
|
..._n,
|
|
3350
3393
|
...Mn,
|
|
3351
|
-
...vn,
|
|
3352
3394
|
...fn,
|
|
3395
|
+
...vn,
|
|
3353
3396
|
...Pn,
|
|
3354
3397
|
...On,
|
|
3355
3398
|
...yn,
|
|
@@ -3372,15 +3415,15 @@ class Gn {
|
|
|
3372
3415
|
constructor({ JsSIP: e }, {
|
|
3373
3416
|
preferredMimeTypesVideoCodecs: t,
|
|
3374
3417
|
excludeMimeTypesVideoCodecs: s,
|
|
3375
|
-
videoBalancerOptions:
|
|
3376
|
-
autoConnectorOptions:
|
|
3418
|
+
videoBalancerOptions: r,
|
|
3419
|
+
autoConnectorOptions: i
|
|
3377
3420
|
} = {}) {
|
|
3378
3421
|
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new k(bn), this.connectionManager = new pt({ JsSIP: e }), this.connectionQueueManager = new mt({
|
|
3379
3422
|
connectionManager: this.connectionManager
|
|
3380
3423
|
}), this.callManager = new ze(), this.apiManager = new Fe({
|
|
3381
3424
|
connectionManager: this.connectionManager,
|
|
3382
3425
|
callManager: this.callManager
|
|
3383
|
-
}), this.incomingCallManager = new $t(this.connectionManager), this.presentationManager = new
|
|
3426
|
+
}), this.incomingCallManager = new $t(this.connectionManager), this.presentationManager = new ht({
|
|
3384
3427
|
callManager: this.callManager,
|
|
3385
3428
|
maxBitrate: mn
|
|
3386
3429
|
}), this.statsManager = new zt({
|
|
@@ -3392,14 +3435,14 @@ class Gn {
|
|
|
3392
3435
|
connectionManager: this.connectionManager,
|
|
3393
3436
|
callManager: this.callManager
|
|
3394
3437
|
},
|
|
3395
|
-
|
|
3438
|
+
i
|
|
3396
3439
|
), this.transceiverManager = new en({
|
|
3397
3440
|
callManager: this.callManager,
|
|
3398
3441
|
apiManager: this.apiManager
|
|
3399
3442
|
}), this.videoSendingBalancerManager = new pn(
|
|
3400
3443
|
this.callManager,
|
|
3401
3444
|
this.apiManager,
|
|
3402
|
-
|
|
3445
|
+
r
|
|
3403
3446
|
), this.subscribe();
|
|
3404
3447
|
}
|
|
3405
3448
|
get requestedConnection() {
|
|
@@ -3506,7 +3549,7 @@ class Gn {
|
|
|
3506
3549
|
getRemoteStreams = () => this.callManager.getRemoteStreams();
|
|
3507
3550
|
replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
|
|
3508
3551
|
async startPresentation(e, t = {}) {
|
|
3509
|
-
const { isP2P: s, callLimit:
|
|
3552
|
+
const { isP2P: s, callLimit: r, onAddedTransceiver: i, ...a } = t;
|
|
3510
3553
|
return this.presentationManager.startPresentation(
|
|
3511
3554
|
async () => {
|
|
3512
3555
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
@@ -3514,9 +3557,9 @@ class Gn {
|
|
|
3514
3557
|
e,
|
|
3515
3558
|
{
|
|
3516
3559
|
...a,
|
|
3517
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
3560
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(i)
|
|
3518
3561
|
},
|
|
3519
|
-
|
|
3562
|
+
r === void 0 ? void 0 : { callLimit: r }
|
|
3520
3563
|
);
|
|
3521
3564
|
}
|
|
3522
3565
|
async stopPresentation(e = {}) {
|
|
@@ -3526,15 +3569,15 @@ class Gn {
|
|
|
3526
3569
|
});
|
|
3527
3570
|
}
|
|
3528
3571
|
async updatePresentation(e, t = {}) {
|
|
3529
|
-
const { isP2P: s, onAddedTransceiver:
|
|
3572
|
+
const { isP2P: s, onAddedTransceiver: r, ...i } = t;
|
|
3530
3573
|
return this.presentationManager.updatePresentation(
|
|
3531
3574
|
async () => {
|
|
3532
3575
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
3533
3576
|
},
|
|
3534
3577
|
e,
|
|
3535
3578
|
{
|
|
3536
|
-
...
|
|
3537
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
3579
|
+
...i,
|
|
3580
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(r)
|
|
3538
3581
|
}
|
|
3539
3582
|
);
|
|
3540
3583
|
}
|
|
@@ -3590,21 +3633,21 @@ class Gn {
|
|
|
3590
3633
|
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);
|
|
3591
3634
|
}
|
|
3592
3635
|
bridgeEvents = (e, t) => {
|
|
3593
|
-
t.events.eachTriggers((s,
|
|
3594
|
-
t.on(
|
|
3595
|
-
this.events.trigger(`${e}:${
|
|
3636
|
+
t.events.eachTriggers((s, r) => {
|
|
3637
|
+
t.on(r, (i) => {
|
|
3638
|
+
this.events.trigger(`${e}:${r}`, i);
|
|
3596
3639
|
});
|
|
3597
3640
|
});
|
|
3598
3641
|
};
|
|
3599
|
-
resolveHandleAddTransceiver = (e) => async (t, s,
|
|
3600
|
-
this.setCodecPreferences(t), await e?.(t, s,
|
|
3642
|
+
resolveHandleAddTransceiver = (e) => async (t, s, r) => {
|
|
3643
|
+
this.setCodecPreferences(t), await e?.(t, s, r);
|
|
3601
3644
|
};
|
|
3602
3645
|
}
|
|
3603
3646
|
export {
|
|
3604
3647
|
ae as E,
|
|
3605
3648
|
ke as O,
|
|
3606
3649
|
Gn as S,
|
|
3607
|
-
|
|
3650
|
+
it as a,
|
|
3608
3651
|
Be as b,
|
|
3609
3652
|
xn as c,
|
|
3610
3653
|
Hn as d,
|
|
@@ -3613,7 +3656,7 @@ export {
|
|
|
3613
3656
|
Yt as g,
|
|
3614
3657
|
Nt as h,
|
|
3615
3658
|
sn as i,
|
|
3616
|
-
|
|
3659
|
+
h as l,
|
|
3617
3660
|
F as p,
|
|
3618
|
-
|
|
3661
|
+
he as s
|
|
3619
3662
|
};
|