sip-connector 19.6.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-JzZVT23M.js → @SipConnector-DXMX6l2G.js} +425 -394
- package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +8 -0
- package/dist/AutoConnectorManager/types.d.ts +15 -0
- package/dist/StatsPeerConnection/types.d.ts +6 -32
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/tools/__tests-utils__/parseObject.d.ts +1 -3
- package/package.json +9 -9
- package/dist/@SipConnector-1uu5lXCq.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,7 +1064,7 @@ class dt {
|
|
|
1064
1064
|
delete this.streamPresentationCurrent;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
|
-
class
|
|
1067
|
+
class dt {
|
|
1068
1068
|
data;
|
|
1069
1069
|
getUa;
|
|
1070
1070
|
constructor(e) {
|
|
@@ -1162,8 +1162,8 @@ const le = [
|
|
|
1162
1162
|
"connect-failed",
|
|
1163
1163
|
"connect-parameters-resolve-success",
|
|
1164
1164
|
"connect-parameters-resolve-failed"
|
|
1165
|
-
],
|
|
1166
|
-
class
|
|
1165
|
+
], ue = [...le, ...lt], ut = 3;
|
|
1166
|
+
class gt {
|
|
1167
1167
|
cancelableConnectWithRepeatedCalls;
|
|
1168
1168
|
JsSIP;
|
|
1169
1169
|
events;
|
|
@@ -1182,15 +1182,15 @@ class ut {
|
|
|
1182
1182
|
}
|
|
1183
1183
|
connect = async (e, t) => (this.cancelRequests(), this.connectWithDuplicatedCalls(e, t));
|
|
1184
1184
|
set = async ({ displayName: e }) => new Promise((t, s) => {
|
|
1185
|
-
const
|
|
1186
|
-
if (!
|
|
1185
|
+
const r = this.getUa();
|
|
1186
|
+
if (!r) {
|
|
1187
1187
|
s(new Error("this.ua is not initialized"));
|
|
1188
1188
|
return;
|
|
1189
1189
|
}
|
|
1190
|
-
let
|
|
1190
|
+
let i = !1;
|
|
1191
1191
|
const a = this.getConnectionConfiguration();
|
|
1192
|
-
e !== void 0 && e !== a?.displayName && (
|
|
1193
|
-
const o =
|
|
1192
|
+
e !== void 0 && e !== a?.displayName && (i = r.set("display_name", ie(e)), this.updateConnectionConfiguration("displayName", e));
|
|
1193
|
+
const o = i;
|
|
1194
1194
|
o ? t(o) : s(new Error("nothing changed"));
|
|
1195
1195
|
});
|
|
1196
1196
|
disconnect = async () => {
|
|
@@ -1207,26 +1207,26 @@ class ut {
|
|
|
1207
1207
|
cancelRequests() {
|
|
1208
1208
|
this.cancelConnectWithRepeatedCalls();
|
|
1209
1209
|
}
|
|
1210
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
1211
|
-
const s = async () => this.connectInner(e),
|
|
1212
|
-
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e),
|
|
1213
|
-
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;
|
|
1214
1214
|
};
|
|
1215
1215
|
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ee({
|
|
1216
1216
|
targetFunction: s,
|
|
1217
|
-
isComplete:
|
|
1217
|
+
isComplete: r,
|
|
1218
1218
|
callLimit: t,
|
|
1219
1219
|
isRejectAsValid: !0,
|
|
1220
1220
|
isCheckBeforeCall: !1
|
|
1221
|
-
}), this.cancelableConnectWithRepeatedCalls.then((
|
|
1222
|
-
if ("ua" in
|
|
1223
|
-
return
|
|
1224
|
-
throw
|
|
1221
|
+
}), this.cancelableConnectWithRepeatedCalls.then((i) => {
|
|
1222
|
+
if ("ua" in i && i.ua instanceof this.JsSIP.UA)
|
|
1223
|
+
return i;
|
|
1224
|
+
throw i;
|
|
1225
1225
|
});
|
|
1226
1226
|
};
|
|
1227
1227
|
hasEqualConnectionConfiguration(e) {
|
|
1228
|
-
const { configuration: t } = this.uaFactory.createConfiguration(e),
|
|
1229
|
-
return
|
|
1228
|
+
const { configuration: t } = this.uaFactory.createConfiguration(e), 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;
|
|
1230
1230
|
}
|
|
1231
1231
|
connectInner = async (e) => this.initUa(e).then(async () => this.start()).then((t) => {
|
|
1232
1232
|
const s = this.getConnectionConfiguration();
|
|
@@ -1241,21 +1241,21 @@ class ut {
|
|
|
1241
1241
|
user: e,
|
|
1242
1242
|
password: t,
|
|
1243
1243
|
sipServerUrl: s,
|
|
1244
|
-
sipWebSocketServerURL:
|
|
1245
|
-
remoteAddress:
|
|
1244
|
+
sipWebSocketServerURL: r,
|
|
1245
|
+
remoteAddress: i,
|
|
1246
1246
|
sessionTimers: a,
|
|
1247
1247
|
registerExpires: o,
|
|
1248
1248
|
connectionRecoveryMinInterval: c,
|
|
1249
|
-
connectionRecoveryMaxInterval:
|
|
1249
|
+
connectionRecoveryMaxInterval: d,
|
|
1250
1250
|
userAgent: T,
|
|
1251
1251
|
displayName: S = "",
|
|
1252
|
-
register:
|
|
1252
|
+
register: u = !1,
|
|
1253
1253
|
extraHeaders: E = []
|
|
1254
1254
|
}) => {
|
|
1255
1255
|
this.stateMachine.startInitUa(), this.setConnectionConfiguration({
|
|
1256
1256
|
sipServerUrl: s,
|
|
1257
1257
|
displayName: S,
|
|
1258
|
-
register:
|
|
1258
|
+
register: u,
|
|
1259
1259
|
user: e,
|
|
1260
1260
|
password: t
|
|
1261
1261
|
}), this.getUa() && await this.disconnect();
|
|
@@ -1264,15 +1264,15 @@ class ut {
|
|
|
1264
1264
|
user: e,
|
|
1265
1265
|
password: t,
|
|
1266
1266
|
sipServerUrl: s,
|
|
1267
|
-
sipWebSocketServerURL:
|
|
1267
|
+
sipWebSocketServerURL: r,
|
|
1268
1268
|
displayName: S,
|
|
1269
|
-
register:
|
|
1269
|
+
register: u,
|
|
1270
1270
|
sessionTimers: a,
|
|
1271
1271
|
registerExpires: o,
|
|
1272
1272
|
connectionRecoveryMinInterval: c,
|
|
1273
|
-
connectionRecoveryMaxInterval:
|
|
1273
|
+
connectionRecoveryMaxInterval: d,
|
|
1274
1274
|
userAgent: T,
|
|
1275
|
-
remoteAddress:
|
|
1275
|
+
remoteAddress: i,
|
|
1276
1276
|
extraHeaders: E
|
|
1277
1277
|
},
|
|
1278
1278
|
this.events
|
|
@@ -1285,29 +1285,29 @@ class ut {
|
|
|
1285
1285
|
t(new Error("this.ua is not initialized"));
|
|
1286
1286
|
return;
|
|
1287
1287
|
}
|
|
1288
|
-
let
|
|
1289
|
-
|
|
1288
|
+
let r;
|
|
1289
|
+
r = ((c, d) => {
|
|
1290
1290
|
if (this.getConnectionConfiguration()?.register === !0)
|
|
1291
|
-
return this.registrationManager.subscribeToStartEvents(c,
|
|
1292
|
-
const S = C.CONNECTED,
|
|
1293
|
-
return this.events.on(S, c),
|
|
1294
|
-
this.events.on(E,
|
|
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);
|
|
1295
1295
|
}), () => {
|
|
1296
|
-
this.events.off(S, c),
|
|
1297
|
-
this.events.off(E,
|
|
1296
|
+
this.events.off(S, c), u.forEach((E) => {
|
|
1297
|
+
this.events.off(E, d);
|
|
1298
1298
|
});
|
|
1299
1299
|
};
|
|
1300
1300
|
})(() => {
|
|
1301
|
-
|
|
1301
|
+
r?.(), e(s);
|
|
1302
1302
|
}, (c) => {
|
|
1303
|
-
|
|
1303
|
+
r?.(), t(c);
|
|
1304
1304
|
}), s.start();
|
|
1305
1305
|
});
|
|
1306
1306
|
cancelConnectWithRepeatedCalls() {
|
|
1307
1307
|
this.cancelableConnectWithRepeatedCalls?.cancel();
|
|
1308
1308
|
}
|
|
1309
1309
|
}
|
|
1310
|
-
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 || {});
|
|
1311
1311
|
const Tt = Oe({
|
|
1312
1312
|
types: {
|
|
1313
1313
|
context: {},
|
|
@@ -1315,10 +1315,10 @@ const Tt = Oe({
|
|
|
1315
1315
|
},
|
|
1316
1316
|
actions: {
|
|
1317
1317
|
logTransition: (n, e) => {
|
|
1318
|
-
|
|
1318
|
+
h(`State transition: ${e.from} -> ${e.to} (${e.event})`);
|
|
1319
1319
|
},
|
|
1320
1320
|
logStateChange: (n, e) => {
|
|
1321
|
-
|
|
1321
|
+
h("ConnectionStateMachine state changed", e.state);
|
|
1322
1322
|
}
|
|
1323
1323
|
}
|
|
1324
1324
|
}).createMachine({
|
|
@@ -1631,8 +1631,8 @@ class St {
|
|
|
1631
1631
|
constructor(e) {
|
|
1632
1632
|
this.events = e, this.actor = ye(Tt), this.actorSubscription = this.actor.subscribe((t) => {
|
|
1633
1633
|
const s = t.value;
|
|
1634
|
-
this.stateChangeListeners.forEach((
|
|
1635
|
-
|
|
1634
|
+
this.stateChangeListeners.forEach((r) => {
|
|
1635
|
+
r(s);
|
|
1636
1636
|
});
|
|
1637
1637
|
}), this.actor.start(), this.subscribeToEvents();
|
|
1638
1638
|
}
|
|
@@ -1715,7 +1715,7 @@ class St {
|
|
|
1715
1715
|
return this.actor.getSnapshot().can({ type: e });
|
|
1716
1716
|
}
|
|
1717
1717
|
getValidEvents() {
|
|
1718
|
-
return Object.values(
|
|
1718
|
+
return Object.values(ge).filter((e) => this.canTransition(e));
|
|
1719
1719
|
}
|
|
1720
1720
|
hasState(e) {
|
|
1721
1721
|
return this.actor.getSnapshot().matches(e);
|
|
@@ -1723,7 +1723,7 @@ class St {
|
|
|
1723
1723
|
sendEvent(e) {
|
|
1724
1724
|
const t = this.actor.getSnapshot(), s = { type: e };
|
|
1725
1725
|
if (!t.can(s)) {
|
|
1726
|
-
|
|
1726
|
+
h(
|
|
1727
1727
|
`Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
|
|
1728
1728
|
);
|
|
1729
1729
|
return;
|
|
@@ -1806,17 +1806,17 @@ class Ct {
|
|
|
1806
1806
|
try {
|
|
1807
1807
|
await this.unregister();
|
|
1808
1808
|
} catch (e) {
|
|
1809
|
-
|
|
1809
|
+
h("tryRegister", e);
|
|
1810
1810
|
}
|
|
1811
1811
|
return this.register();
|
|
1812
1812
|
}
|
|
1813
1813
|
subscribeToStartEvents(e, t) {
|
|
1814
|
-
const s = C.REGISTERED,
|
|
1815
|
-
return this.events.on(s, e),
|
|
1816
|
-
this.events.on(
|
|
1814
|
+
const s = C.REGISTERED, r = [C.REGISTRATION_FAILED, C.DISCONNECTED];
|
|
1815
|
+
return this.events.on(s, e), r.forEach((i) => {
|
|
1816
|
+
this.events.on(i, t);
|
|
1817
1817
|
}), () => {
|
|
1818
|
-
this.events.off(s, e),
|
|
1819
|
-
this.events.off(
|
|
1818
|
+
this.events.off(s, e), r.forEach((i) => {
|
|
1819
|
+
this.events.off(i, t);
|
|
1820
1820
|
});
|
|
1821
1821
|
};
|
|
1822
1822
|
}
|
|
@@ -1831,14 +1831,14 @@ class Et {
|
|
|
1831
1831
|
* Отправляет SIP OPTIONS запрос к указанному адресу
|
|
1832
1832
|
*/
|
|
1833
1833
|
async sendOptions(e, t, s) {
|
|
1834
|
-
const
|
|
1835
|
-
return new Promise((
|
|
1834
|
+
const r = this.getUaProtected();
|
|
1835
|
+
return new Promise((i, a) => {
|
|
1836
1836
|
try {
|
|
1837
|
-
|
|
1837
|
+
r.sendOptions(e, t, {
|
|
1838
1838
|
extraHeaders: s,
|
|
1839
1839
|
eventHandlers: {
|
|
1840
1840
|
succeeded: () => {
|
|
1841
|
-
|
|
1841
|
+
i();
|
|
1842
1842
|
},
|
|
1843
1843
|
failed: a
|
|
1844
1844
|
}
|
|
@@ -1852,8 +1852,8 @@ class Et {
|
|
|
1852
1852
|
* Отправляет SIP OPTIONS запрос к собственному URI (ping)
|
|
1853
1853
|
*/
|
|
1854
1854
|
async ping(e, t) {
|
|
1855
|
-
const
|
|
1856
|
-
return this.sendOptions(
|
|
1855
|
+
const r = this.getUaProtected().configuration.uri;
|
|
1856
|
+
return this.sendOptions(r, e, t);
|
|
1857
1857
|
}
|
|
1858
1858
|
/**
|
|
1859
1859
|
* Проверяет доступность телефонии, создавая временное соединение
|
|
@@ -1862,27 +1862,27 @@ class Et {
|
|
|
1862
1862
|
userAgent: e,
|
|
1863
1863
|
displayName: t,
|
|
1864
1864
|
sipServerUrl: s,
|
|
1865
|
-
sipWebSocketServerURL:
|
|
1866
|
-
remoteAddress:
|
|
1865
|
+
sipWebSocketServerURL: r,
|
|
1866
|
+
remoteAddress: i,
|
|
1867
1867
|
extraHeaders: a
|
|
1868
1868
|
}) {
|
|
1869
1869
|
return new Promise((o, c) => {
|
|
1870
|
-
const { configuration:
|
|
1871
|
-
sipWebSocketServerURL:
|
|
1870
|
+
const { configuration: d } = this.uaFactory.createConfiguration({
|
|
1871
|
+
sipWebSocketServerURL: r,
|
|
1872
1872
|
displayName: t,
|
|
1873
1873
|
userAgent: e,
|
|
1874
1874
|
sipServerUrl: s
|
|
1875
|
-
}), T = this.uaFactory.createUA({ ...
|
|
1875
|
+
}), T = this.uaFactory.createUA({ ...d, remoteAddress: i, extraHeaders: a }), S = () => {
|
|
1876
1876
|
const E = new Error("Telephony is not available");
|
|
1877
1877
|
c(E);
|
|
1878
1878
|
};
|
|
1879
1879
|
T.once(C.DISCONNECTED, S);
|
|
1880
|
-
const
|
|
1880
|
+
const u = () => {
|
|
1881
1881
|
T.removeAllListeners(), T.once(C.DISCONNECTED, () => {
|
|
1882
1882
|
o();
|
|
1883
1883
|
}), T.stop();
|
|
1884
1884
|
};
|
|
1885
|
-
T.once(C.CONNECTED,
|
|
1885
|
+
T.once(C.CONNECTED, u), T.start();
|
|
1886
1886
|
});
|
|
1887
1887
|
}
|
|
1888
1888
|
}
|
|
@@ -1902,12 +1902,12 @@ class y {
|
|
|
1902
1902
|
register: e,
|
|
1903
1903
|
password: t,
|
|
1904
1904
|
user: s,
|
|
1905
|
-
sipServerUrl:
|
|
1906
|
-
sipWebSocketServerURL:
|
|
1905
|
+
sipServerUrl: r,
|
|
1906
|
+
sipWebSocketServerURL: i
|
|
1907
1907
|
}) {
|
|
1908
|
-
if (!i)
|
|
1909
|
-
throw new Error("sipServerUrl is required");
|
|
1910
1908
|
if (!r)
|
|
1909
|
+
throw new Error("sipServerUrl is required");
|
|
1910
|
+
if (!i)
|
|
1911
1911
|
throw new Error("sipWebSocketServerURL is required");
|
|
1912
1912
|
if (e && (t === void 0 || t === ""))
|
|
1913
1913
|
throw new Error("password is required for authorized connection");
|
|
@@ -1925,13 +1925,13 @@ class y {
|
|
|
1925
1925
|
user: e,
|
|
1926
1926
|
password: t,
|
|
1927
1927
|
sipWebSocketServerURL: s,
|
|
1928
|
-
displayName:
|
|
1929
|
-
sipServerUrl:
|
|
1928
|
+
displayName: r = "",
|
|
1929
|
+
sipServerUrl: i,
|
|
1930
1930
|
register: a = !1,
|
|
1931
1931
|
sessionTimers: o = !1,
|
|
1932
1932
|
registerExpires: c = 300,
|
|
1933
1933
|
// 5 minutes in sec
|
|
1934
|
-
connectionRecoveryMinInterval:
|
|
1934
|
+
connectionRecoveryMinInterval: d = 2,
|
|
1935
1935
|
connectionRecoveryMaxInterval: T = 6,
|
|
1936
1936
|
userAgent: S
|
|
1937
1937
|
}) {
|
|
@@ -1939,22 +1939,22 @@ class y {
|
|
|
1939
1939
|
register: a,
|
|
1940
1940
|
password: t,
|
|
1941
1941
|
user: e,
|
|
1942
|
-
sipServerUrl:
|
|
1942
|
+
sipServerUrl: i,
|
|
1943
1943
|
sipWebSocketServerURL: s
|
|
1944
1944
|
});
|
|
1945
|
-
const
|
|
1945
|
+
const u = y.resolveAuthorizationUser(a, e), E = Ve(i), m = E(u), I = new this.JsSIP.WebSocketInterface(s);
|
|
1946
1946
|
return {
|
|
1947
1947
|
configuration: {
|
|
1948
1948
|
password: t,
|
|
1949
1949
|
register: a,
|
|
1950
1950
|
uri: m,
|
|
1951
|
-
display_name:
|
|
1951
|
+
display_name: ie(r),
|
|
1952
1952
|
user_agent: S,
|
|
1953
1953
|
sdpSemantics: "unified-plan",
|
|
1954
1954
|
sockets: [I],
|
|
1955
1955
|
session_timers: o,
|
|
1956
1956
|
register_expires: c,
|
|
1957
|
-
connection_recovery_min_interval:
|
|
1957
|
+
connection_recovery_min_interval: d,
|
|
1958
1958
|
connection_recovery_max_interval: T
|
|
1959
1959
|
},
|
|
1960
1960
|
helpers: {
|
|
@@ -1964,22 +1964,22 @@ class y {
|
|
|
1964
1964
|
};
|
|
1965
1965
|
}
|
|
1966
1966
|
createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
|
|
1967
|
-
const
|
|
1968
|
-
return
|
|
1967
|
+
const r = new this.JsSIP.UA(s), i = y.buildExtraHeaders(e, t);
|
|
1968
|
+
return i.length > 0 && r.registrator().setExtraHeaders(i), r;
|
|
1969
1969
|
}
|
|
1970
1970
|
/**
|
|
1971
1971
|
* Создает UA с полным жизненным циклом - конфигурация + создание + настройка событий
|
|
1972
1972
|
*/
|
|
1973
1973
|
createUAWithConfiguration(e, t) {
|
|
1974
|
-
const { configuration: s, helpers:
|
|
1974
|
+
const { configuration: s, helpers: r } = this.createConfiguration(e), i = this.createUA({
|
|
1975
1975
|
...s,
|
|
1976
1976
|
remoteAddress: e.remoteAddress,
|
|
1977
1977
|
extraHeaders: e.extraHeaders
|
|
1978
1978
|
});
|
|
1979
1979
|
return t.eachTriggers((a, o) => {
|
|
1980
|
-
const c = le.find((
|
|
1981
|
-
c &&
|
|
1982
|
-
}), { ua:
|
|
1980
|
+
const c = le.find((d) => d === o);
|
|
1981
|
+
c && i.on(c, a);
|
|
1982
|
+
}), { ua: i, helpers: r };
|
|
1983
1983
|
}
|
|
1984
1984
|
}
|
|
1985
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;
|
|
@@ -1995,15 +1995,15 @@ class pt {
|
|
|
1995
1995
|
configurationManager;
|
|
1996
1996
|
JsSIP;
|
|
1997
1997
|
constructor({ JsSIP: e }) {
|
|
1998
|
-
this.JsSIP = e, this.events = new U(
|
|
1998
|
+
this.JsSIP = e, this.events = new U(ue), this.uaFactory = new y(e), this.registrationManager = new Ct({
|
|
1999
1999
|
events: this.events,
|
|
2000
2000
|
getUaProtected: this.getUaProtected
|
|
2001
|
-
}), this.stateMachine = new St(this.events), this.configurationManager = new
|
|
2001
|
+
}), this.stateMachine = new St(this.events), this.configurationManager = new dt({
|
|
2002
2002
|
getUa: this.getUa
|
|
2003
2003
|
}), this.sipOperations = new Et({
|
|
2004
2004
|
uaFactory: this.uaFactory,
|
|
2005
2005
|
getUaProtected: this.getUaProtected
|
|
2006
|
-
}), this.connectionFlow = new
|
|
2006
|
+
}), this.connectionFlow = new gt({
|
|
2007
2007
|
JsSIP: this.JsSIP,
|
|
2008
2008
|
events: this.events,
|
|
2009
2009
|
uaFactory: this.uaFactory,
|
|
@@ -2056,7 +2056,7 @@ class pt {
|
|
|
2056
2056
|
return this.configurationManager.isRegister();
|
|
2057
2057
|
}
|
|
2058
2058
|
connect = async (e, t) => this.disconnect().catch((s) => {
|
|
2059
|
-
|
|
2059
|
+
h("connect: disconnect error", s);
|
|
2060
2060
|
}).then(async () => this.connectWithProcessError(e, t));
|
|
2061
2061
|
set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
|
|
2062
2062
|
disconnect = async () => {
|
|
@@ -2106,12 +2106,12 @@ class pt {
|
|
|
2106
2106
|
connectWithProcessError = async (e, t) => {
|
|
2107
2107
|
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
2108
2108
|
throw Rt();
|
|
2109
|
-
return this.processConnect(e, t).catch(async (
|
|
2110
|
-
const
|
|
2109
|
+
return this.processConnect(e, t).catch(async (r) => {
|
|
2110
|
+
const i = r;
|
|
2111
2111
|
return this.disconnect().then(() => {
|
|
2112
|
-
throw
|
|
2112
|
+
throw i;
|
|
2113
2113
|
}).catch(() => {
|
|
2114
|
-
throw
|
|
2114
|
+
throw i;
|
|
2115
2115
|
});
|
|
2116
2116
|
});
|
|
2117
2117
|
};
|
|
@@ -2120,8 +2120,8 @@ class pt {
|
|
|
2120
2120
|
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
|
|
2121
2121
|
...s
|
|
2122
2122
|
}), s)).catch((s) => {
|
|
2123
|
-
const
|
|
2124
|
-
throw this.events.trigger(C.CONNECT_FAILED,
|
|
2123
|
+
const r = s ?? new Error("Failed to connect to server");
|
|
2124
|
+
throw this.events.trigger(C.CONNECT_FAILED, r), r;
|
|
2125
2125
|
}));
|
|
2126
2126
|
}
|
|
2127
2127
|
class mt {
|
|
@@ -2175,7 +2175,7 @@ class Mt {
|
|
|
2175
2175
|
this.countInner = this.initialCount, this.finishAttempt();
|
|
2176
2176
|
}
|
|
2177
2177
|
}
|
|
2178
|
-
class
|
|
2178
|
+
class ft {
|
|
2179
2179
|
connectionManager;
|
|
2180
2180
|
interval;
|
|
2181
2181
|
checkTelephonyByTimeout = void 0;
|
|
@@ -2197,8 +2197,8 @@ class vt {
|
|
|
2197
2197
|
request: async () => {
|
|
2198
2198
|
if (!this.cancelableBeforeRequest)
|
|
2199
2199
|
throw new Error("cancelableBeforeRequest is not defined");
|
|
2200
|
-
const
|
|
2201
|
-
return this.connectionManager.checkTelephony(
|
|
2200
|
+
const r = await this.cancelableBeforeRequest.request();
|
|
2201
|
+
return this.connectionManager.checkTelephony(r);
|
|
2202
2202
|
}
|
|
2203
2203
|
}), this.checkTelephonyByTimeout.start(void 0, {
|
|
2204
2204
|
onFailRequest: s,
|
|
@@ -2220,7 +2220,7 @@ const Se = [
|
|
|
2220
2220
|
"changed-attempt-status",
|
|
2221
2221
|
"stop-attempts-by-error",
|
|
2222
2222
|
"limit-reached-attempts"
|
|
2223
|
-
],
|
|
2223
|
+
], vt = 15e3, Pt = 2;
|
|
2224
2224
|
class Ot {
|
|
2225
2225
|
connectionManager;
|
|
2226
2226
|
pingServerByTimeoutWithFailCalls;
|
|
@@ -2228,14 +2228,14 @@ class Ot {
|
|
|
2228
2228
|
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Me(Pt, {
|
|
2229
2229
|
whenPossibleRequest: async () => {
|
|
2230
2230
|
},
|
|
2231
|
-
requestInterval:
|
|
2232
|
-
request: async () => (
|
|
2233
|
-
|
|
2231
|
+
requestInterval: vt,
|
|
2232
|
+
request: async () => (h("ping"), this.connectionManager.ping().then(() => {
|
|
2233
|
+
h("ping success");
|
|
2234
2234
|
}))
|
|
2235
2235
|
});
|
|
2236
2236
|
}
|
|
2237
2237
|
start({ onFailRequest: e }) {
|
|
2238
|
-
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(
|
|
2238
|
+
this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(h);
|
|
2239
2239
|
}
|
|
2240
2240
|
stop() {
|
|
2241
2241
|
this.pingServerByTimeoutWithFailCalls.stop();
|
|
@@ -2254,12 +2254,12 @@ class yt {
|
|
|
2254
2254
|
});
|
|
2255
2255
|
}
|
|
2256
2256
|
start({ onFailRequest: e }) {
|
|
2257
|
-
|
|
2257
|
+
h("start"), this.disposeCallStatusChange = this.callManager.on("call-status-changed", () => {
|
|
2258
2258
|
this.handleCallStatusChange({ onFailRequest: e });
|
|
2259
2259
|
}), this.handleCallStatusChange({ onFailRequest: e });
|
|
2260
2260
|
}
|
|
2261
2261
|
stop() {
|
|
2262
|
-
|
|
2262
|
+
h("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
|
|
2263
2263
|
}
|
|
2264
2264
|
unsubscribeCallStatusChange() {
|
|
2265
2265
|
this.disposeCallStatusChange?.(), this.disposeCallStatusChange = void 0;
|
|
@@ -2316,15 +2316,17 @@ class Bt {
|
|
|
2316
2316
|
cancelableRequestBeforeRetry;
|
|
2317
2317
|
onBeforeRetry;
|
|
2318
2318
|
canRetryOnError;
|
|
2319
|
+
networkInterfacesSubscriber;
|
|
2320
|
+
resumeFromSleepModeSubscriber;
|
|
2319
2321
|
constructor({
|
|
2320
2322
|
connectionQueueManager: e,
|
|
2321
2323
|
connectionManager: t,
|
|
2322
2324
|
callManager: s
|
|
2323
|
-
},
|
|
2324
|
-
const
|
|
2325
|
-
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({
|
|
2326
2328
|
connectionManager: t,
|
|
2327
|
-
interval:
|
|
2329
|
+
interval: r?.checkTelephonyRequestInterval ?? wt
|
|
2328
2330
|
}), this.pingServerIfNotActiveCallRequester = new yt({
|
|
2329
2331
|
connectionManager: t,
|
|
2330
2332
|
callManager: s
|
|
@@ -2333,19 +2335,17 @@ class Bt {
|
|
|
2333
2335
|
callManager: s
|
|
2334
2336
|
}), this.attemptsState = new Mt({
|
|
2335
2337
|
onStatusChange: this.emitStatusChange
|
|
2336
|
-
}), this.cancelableRequestBeforeRetry = new G(
|
|
2337
|
-
|
|
2338
|
+
}), this.cancelableRequestBeforeRetry = new G(i), this.delayBetweenAttempts = new fe(
|
|
2339
|
+
r?.timeoutBetweenAttempts ?? bt
|
|
2338
2340
|
);
|
|
2339
2341
|
}
|
|
2340
2342
|
start(e) {
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
+
h("auto connector start"), this.stop(), this.connect(e).catch((t) => {
|
|
2344
|
+
h("auto connector failed to connect:", t);
|
|
2343
2345
|
});
|
|
2344
2346
|
}
|
|
2345
2347
|
stop() {
|
|
2346
|
-
|
|
2347
|
-
d("auto connector disconnect: error", e);
|
|
2348
|
-
});
|
|
2348
|
+
h("auto connector stop"), this.unsubscribeFromNetworkInterfaces(), this.shutdown();
|
|
2349
2349
|
}
|
|
2350
2350
|
on(e, t) {
|
|
2351
2351
|
return this.events.on(e, t);
|
|
@@ -2362,72 +2362,103 @@ class Bt {
|
|
|
2362
2362
|
off(e, t) {
|
|
2363
2363
|
this.events.off(e, t);
|
|
2364
2364
|
}
|
|
2365
|
+
shutdown() {
|
|
2366
|
+
h("shutdown"), this.stopAttempts(), this.stopConnectTriggers(), this.connectionQueueManager.disconnect().catch((e) => {
|
|
2367
|
+
h("auto connector disconnect: error", e);
|
|
2368
|
+
});
|
|
2369
|
+
}
|
|
2365
2370
|
stopAttempts() {
|
|
2366
2371
|
this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
|
|
2367
2372
|
}
|
|
2368
2373
|
stopConnectTriggers() {
|
|
2369
|
-
|
|
2374
|
+
h("stopConnectTriggers"), this.stopPingServerIfNotActiveCallRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
|
|
2370
2375
|
}
|
|
2371
2376
|
runCheckTelephony(e) {
|
|
2372
|
-
|
|
2377
|
+
h("runCheckTelephony"), this.checkTelephonyRequester.start({
|
|
2373
2378
|
onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
|
|
2374
2379
|
onSuccessRequest: () => {
|
|
2375
|
-
|
|
2380
|
+
h("runCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
|
|
2376
2381
|
},
|
|
2377
2382
|
onFailRequest: (t) => {
|
|
2378
|
-
|
|
2383
|
+
h("runCheckTelephony: onFailRequest", t.message);
|
|
2379
2384
|
}
|
|
2380
2385
|
});
|
|
2381
2386
|
}
|
|
2382
2387
|
async connect(e) {
|
|
2383
|
-
if (
|
|
2384
|
-
|
|
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);
|
|
2385
2390
|
return;
|
|
2386
2391
|
}
|
|
2387
2392
|
return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.processConnect(e);
|
|
2388
2393
|
}
|
|
2389
2394
|
async processConnect(e) {
|
|
2390
2395
|
try {
|
|
2391
|
-
await this.connectionQueueManager.connect(e.getParameters, e.options),
|
|
2396
|
+
await this.connectionQueueManager.connect(e.getParameters, e.options), h("processConnect success"), this.handleSucceededAttempt(e);
|
|
2392
2397
|
} catch (t) {
|
|
2393
2398
|
if (Nt(t)) {
|
|
2394
2399
|
this.attemptsState.finishAttempt(), this.handleSucceededAttempt(e);
|
|
2395
2400
|
return;
|
|
2396
2401
|
}
|
|
2397
2402
|
if (!this.canRetryOnError(t)) {
|
|
2398
|
-
|
|
2403
|
+
h("processConnect: error does not allow retry", t), this.attemptsState.finishAttempt(), this.events.trigger(M.STOP_ATTEMPTS_BY_ERROR, t);
|
|
2399
2404
|
return;
|
|
2400
2405
|
}
|
|
2401
2406
|
if (De(t)) {
|
|
2402
|
-
|
|
2407
|
+
h("processConnect: not actual error", t), this.attemptsState.finishAttempt(), this.events.trigger(M.CANCELLED_ATTEMPTS, t);
|
|
2403
2408
|
return;
|
|
2404
2409
|
}
|
|
2405
|
-
|
|
2410
|
+
h("processConnect: error", t), this.reconnect(e);
|
|
2406
2411
|
}
|
|
2407
2412
|
}
|
|
2408
2413
|
handleLimitReached(e) {
|
|
2409
2414
|
this.attemptsState.finishAttempt(), this.events.trigger(M.LIMIT_REACHED_ATTEMPTS, new Error("Limit reached")), this.runCheckTelephony(e);
|
|
2410
2415
|
}
|
|
2411
2416
|
handleSucceededAttempt(e) {
|
|
2412
|
-
|
|
2417
|
+
h("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.subscribeToNetworkInterfaces(e), this.events.trigger(M.SUCCESS);
|
|
2413
2418
|
}
|
|
2414
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) {
|
|
2415
2448
|
this.pingServerIfNotActiveCallRequester.start({
|
|
2416
2449
|
onFailRequest: () => {
|
|
2417
|
-
|
|
2450
|
+
h("pingServer onFailRequest"), this.start(e);
|
|
2418
2451
|
}
|
|
2419
|
-
}), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
|
|
2420
|
-
d("registrationFailedOutOfCallListener callback"), this.start(e);
|
|
2421
2452
|
});
|
|
2422
2453
|
}
|
|
2423
2454
|
connectIfDisconnected(e) {
|
|
2424
2455
|
const t = this.hasFailedOrDisconnectedConnection();
|
|
2425
|
-
|
|
2456
|
+
h("connectIfDisconnected: isFailedOrDisconnected", t), t ? this.start(e) : (this.stopConnectTriggers(), this.events.trigger(M.SUCCESS));
|
|
2426
2457
|
}
|
|
2427
2458
|
reconnect(e) {
|
|
2428
|
-
|
|
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) => {
|
|
2429
2460
|
const s = t instanceof Error ? t : new Error("Failed to reconnect");
|
|
2430
|
-
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);
|
|
2431
2462
|
});
|
|
2432
2463
|
}
|
|
2433
2464
|
hasFailedOrDisconnectedConnection() {
|
|
@@ -2484,10 +2515,10 @@ class $t {
|
|
|
2484
2515
|
} = {}) {
|
|
2485
2516
|
return new Promise((t, s) => {
|
|
2486
2517
|
try {
|
|
2487
|
-
const
|
|
2488
|
-
this.removeIncomingSession(), this.events.trigger(w.DECLINED_INCOMING_CALL,
|
|
2489
|
-
} catch (
|
|
2490
|
-
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);
|
|
2491
2522
|
}
|
|
2492
2523
|
});
|
|
2493
2524
|
}
|
|
@@ -2541,7 +2572,7 @@ var A = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUN
|
|
|
2541
2572
|
const Ee = ["collected"], X = () => "performance" in window ? performance.now() : Date.now(), L = (n) => [...n.keys()].reduce((e, t) => {
|
|
2542
2573
|
const s = n.get(t);
|
|
2543
2574
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
2544
|
-
}, {}),
|
|
2575
|
+
}, {}), qt = (n) => {
|
|
2545
2576
|
if (!n)
|
|
2546
2577
|
return {
|
|
2547
2578
|
outboundRtp: void 0,
|
|
@@ -2587,7 +2618,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2587
2618
|
codec: t[A.CODEC],
|
|
2588
2619
|
synchronizationSources: e
|
|
2589
2620
|
};
|
|
2590
|
-
},
|
|
2621
|
+
}, Vt = ({
|
|
2591
2622
|
audioReceiverStats: n,
|
|
2592
2623
|
synchronizationSourcesAudio: e
|
|
2593
2624
|
}) => {
|
|
@@ -2629,7 +2660,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2629
2660
|
}) => ({
|
|
2630
2661
|
video: J(e),
|
|
2631
2662
|
secondVideo: J(t),
|
|
2632
|
-
audio:
|
|
2663
|
+
audio: qt(n),
|
|
2633
2664
|
additional: Ae(
|
|
2634
2665
|
n ?? e ?? t
|
|
2635
2666
|
)
|
|
@@ -2647,7 +2678,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2647
2678
|
videoReceiversStats: t,
|
|
2648
2679
|
synchronizationSourcesVideo: s.video
|
|
2649
2680
|
}),
|
|
2650
|
-
audio:
|
|
2681
|
+
audio: Vt({
|
|
2651
2682
|
audioReceiverStats: n,
|
|
2652
2683
|
synchronizationSourcesAudio: s.audio
|
|
2653
2684
|
}),
|
|
@@ -2659,8 +2690,8 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2659
2690
|
videoSenderFirstStats: e,
|
|
2660
2691
|
videoSenderSecondStats: t,
|
|
2661
2692
|
audioReceiverStats: s,
|
|
2662
|
-
videoReceiverFirstStats:
|
|
2663
|
-
videoReceiverSecondStats:
|
|
2693
|
+
videoReceiverFirstStats: r,
|
|
2694
|
+
videoReceiverSecondStats: i,
|
|
2664
2695
|
synchronizationSources: a
|
|
2665
2696
|
}) => {
|
|
2666
2697
|
const o = Wt({
|
|
@@ -2669,8 +2700,8 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2669
2700
|
videoSenderSecondStats: t
|
|
2670
2701
|
}), c = Ht({
|
|
2671
2702
|
audioReceiverStats: s,
|
|
2672
|
-
videoReceiverFirstStats:
|
|
2673
|
-
videoReceiverSecondStats:
|
|
2703
|
+
videoReceiverFirstStats: r,
|
|
2704
|
+
videoReceiverSecondStats: i,
|
|
2674
2705
|
synchronizationSources: a
|
|
2675
2706
|
});
|
|
2676
2707
|
return {
|
|
@@ -2678,24 +2709,24 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2678
2709
|
inbound: c
|
|
2679
2710
|
};
|
|
2680
2711
|
}, Gt = async (n) => {
|
|
2681
|
-
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 = {
|
|
2682
2713
|
trackIdentifier: o?.track.id,
|
|
2683
2714
|
item: o?.getSynchronizationSources()[0]
|
|
2684
2715
|
}, T = {
|
|
2685
2716
|
trackIdentifier: c[0]?.track.id,
|
|
2686
2717
|
item: c[0]?.getSynchronizationSources()[0]
|
|
2687
2718
|
}, S = {
|
|
2688
|
-
audio:
|
|
2719
|
+
audio: d,
|
|
2689
2720
|
video: T
|
|
2690
2721
|
};
|
|
2691
2722
|
return Promise.all([
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2723
|
+
r?.getStats() ?? Promise.resolve(void 0),
|
|
2724
|
+
i[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2725
|
+
i[1]?.getStats() ?? Promise.resolve(void 0),
|
|
2695
2726
|
o?.getStats() ?? Promise.resolve(void 0),
|
|
2696
2727
|
c[0]?.getStats() ?? Promise.resolve(void 0),
|
|
2697
2728
|
c[1]?.getStats() ?? Promise.resolve(void 0)
|
|
2698
|
-
]).then((
|
|
2729
|
+
]).then((u) => {
|
|
2699
2730
|
const [
|
|
2700
2731
|
E,
|
|
2701
2732
|
m,
|
|
@@ -2703,7 +2734,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2703
2734
|
R,
|
|
2704
2735
|
D,
|
|
2705
2736
|
$
|
|
2706
|
-
] =
|
|
2737
|
+
] = u;
|
|
2707
2738
|
return {
|
|
2708
2739
|
synchronizationSources: S,
|
|
2709
2740
|
audioSenderStats: E,
|
|
@@ -2715,7 +2746,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
|
|
|
2715
2746
|
};
|
|
2716
2747
|
});
|
|
2717
2748
|
}, Qt = (n) => {
|
|
2718
|
-
|
|
2749
|
+
h(String(n));
|
|
2719
2750
|
};
|
|
2720
2751
|
class Yt {
|
|
2721
2752
|
events;
|
|
@@ -2759,16 +2790,16 @@ class Yt {
|
|
|
2759
2790
|
onError: t
|
|
2760
2791
|
}) => {
|
|
2761
2792
|
const s = X();
|
|
2762
|
-
this.requesterAllStatistics.request(e).then((
|
|
2763
|
-
this.events.trigger("collected", xt(
|
|
2793
|
+
this.requesterAllStatistics.request(e).then((r) => {
|
|
2794
|
+
this.events.trigger("collected", xt(r));
|
|
2764
2795
|
const a = X() - s;
|
|
2765
2796
|
let o = b;
|
|
2766
2797
|
a > 48 ? o = b * 4 : a > 32 ? o = b * 3 : a > 16 && (o = b * 2), this.start(e, {
|
|
2767
2798
|
onError: t,
|
|
2768
2799
|
interval: o
|
|
2769
2800
|
});
|
|
2770
|
-
}).catch((
|
|
2771
|
-
t && t(
|
|
2801
|
+
}).catch((r) => {
|
|
2802
|
+
t && t(r);
|
|
2772
2803
|
});
|
|
2773
2804
|
};
|
|
2774
2805
|
}
|
|
@@ -2820,15 +2851,15 @@ class zt {
|
|
|
2820
2851
|
};
|
|
2821
2852
|
maybeSendStats() {
|
|
2822
2853
|
this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
|
|
2823
|
-
|
|
2854
|
+
h("Failed to send stats", e);
|
|
2824
2855
|
});
|
|
2825
2856
|
}
|
|
2826
2857
|
}
|
|
2827
|
-
const Xt = (n, e) => n.filter((s) => e.some((
|
|
2828
|
-
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs,
|
|
2829
|
-
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);
|
|
2830
2861
|
}, Kt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
2831
|
-
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;
|
|
2832
2863
|
return a - o;
|
|
2833
2864
|
}), jt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Zt = (n, {
|
|
2834
2865
|
preferredMimeTypesVideoCodecs: e,
|
|
@@ -2836,11 +2867,11 @@ const Xt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate &
|
|
|
2836
2867
|
}) => {
|
|
2837
2868
|
try {
|
|
2838
2869
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
2839
|
-
const s = Jt("video"),
|
|
2840
|
-
n.setCodecPreferences(
|
|
2870
|
+
const s = Jt("video"), r = jt(s, t), i = Kt(r, e);
|
|
2871
|
+
n.setCodecPreferences(i);
|
|
2841
2872
|
}
|
|
2842
2873
|
} catch (s) {
|
|
2843
|
-
|
|
2874
|
+
h("setCodecPreferences error", s);
|
|
2844
2875
|
}
|
|
2845
2876
|
};
|
|
2846
2877
|
class en {
|
|
@@ -2864,8 +2895,8 @@ class en {
|
|
|
2864
2895
|
if (s === "audio")
|
|
2865
2896
|
this.transceivers.mainAudio ??= e;
|
|
2866
2897
|
else {
|
|
2867
|
-
const { mid:
|
|
2868
|
-
|
|
2898
|
+
const { mid: r } = e;
|
|
2899
|
+
r === "2" ? this.transceivers.presentationVideo ??= e : this.transceivers.mainVideo ??= e;
|
|
2869
2900
|
}
|
|
2870
2901
|
}
|
|
2871
2902
|
/**
|
|
@@ -2922,10 +2953,10 @@ class en {
|
|
|
2922
2953
|
*/
|
|
2923
2954
|
handleRestart = (e) => {
|
|
2924
2955
|
this.updateTransceivers(e).catch((t) => {
|
|
2925
|
-
|
|
2956
|
+
h("Failed to update transceivers", t);
|
|
2926
2957
|
}).finally(() => {
|
|
2927
2958
|
this.callManager.restartIce().catch((t) => {
|
|
2928
|
-
|
|
2959
|
+
h("Failed to restart ICE", t);
|
|
2929
2960
|
});
|
|
2930
2961
|
});
|
|
2931
2962
|
};
|
|
@@ -2936,8 +2967,8 @@ class en {
|
|
|
2936
2967
|
const { videoTrackCount: t } = e;
|
|
2937
2968
|
t === 2 && (this.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
|
|
2938
2969
|
direction: "recvonly"
|
|
2939
|
-
}).catch((
|
|
2940
|
-
|
|
2970
|
+
}).catch((i) => {
|
|
2971
|
+
h("Failed to add presentation video transceiver", i);
|
|
2941
2972
|
}));
|
|
2942
2973
|
};
|
|
2943
2974
|
subscribe() {
|
|
@@ -2978,7 +3009,7 @@ class an {
|
|
|
2978
3009
|
*/
|
|
2979
3010
|
async run() {
|
|
2980
3011
|
return this.stackPromises().catch((e) => {
|
|
2981
|
-
|
|
3012
|
+
h("TaskQueue: error", e);
|
|
2982
3013
|
});
|
|
2983
3014
|
}
|
|
2984
3015
|
}
|
|
@@ -2989,21 +3020,21 @@ class on {
|
|
|
2989
3020
|
this.onSetParameters = e, this.taskQueue = new an();
|
|
2990
3021
|
}
|
|
2991
3022
|
async setEncodingsToSender(e, t) {
|
|
2992
|
-
return this.taskQueue.add(async () =>
|
|
3023
|
+
return this.taskQueue.add(async () => he(e, t, this.onSetParameters));
|
|
2993
3024
|
}
|
|
2994
3025
|
stop() {
|
|
2995
3026
|
this.taskQueue.stop();
|
|
2996
3027
|
}
|
|
2997
3028
|
}
|
|
2998
|
-
const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), cn = 1e6,
|
|
2999
|
-
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);
|
|
3000
3031
|
return Y(t, e);
|
|
3001
|
-
},
|
|
3032
|
+
}, q = 1, Sn = ({
|
|
3002
3033
|
videoTrack: n,
|
|
3003
3034
|
targetSize: e
|
|
3004
3035
|
}) => {
|
|
3005
|
-
const t = n.getSettings(), s = t.width,
|
|
3006
|
-
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);
|
|
3007
3038
|
};
|
|
3008
3039
|
class Cn {
|
|
3009
3040
|
ignoreForCodec;
|
|
@@ -3024,8 +3055,8 @@ class Cn {
|
|
|
3024
3055
|
senderFinder: e,
|
|
3025
3056
|
codecProvider: t,
|
|
3026
3057
|
parametersSetter: s
|
|
3027
|
-
},
|
|
3028
|
-
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;
|
|
3029
3060
|
}
|
|
3030
3061
|
/**
|
|
3031
3062
|
* Выполняет балансировку на основе заголовков от сервера
|
|
@@ -3034,21 +3065,21 @@ class Cn {
|
|
|
3034
3065
|
* @returns Promise с результатом балансировки
|
|
3035
3066
|
*/
|
|
3036
3067
|
async balance(e, t) {
|
|
3037
|
-
const s = e.getSenders(),
|
|
3038
|
-
if (!
|
|
3039
|
-
return { ...this.resultNoChanged, sender:
|
|
3040
|
-
const
|
|
3041
|
-
if (Ne(
|
|
3042
|
-
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 };
|
|
3043
3074
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
3044
3075
|
return this.processSender(
|
|
3045
3076
|
{ mainCam: a, resolutionMainCam: o },
|
|
3046
3077
|
{
|
|
3047
|
-
sender:
|
|
3048
|
-
codec:
|
|
3049
|
-
videoTrack:
|
|
3078
|
+
sender: r,
|
|
3079
|
+
codec: i,
|
|
3080
|
+
videoTrack: r.track
|
|
3050
3081
|
}
|
|
3051
|
-
).then((c) => ({ ...c, sender:
|
|
3082
|
+
).then((c) => ({ ...c, sender: r }));
|
|
3052
3083
|
}
|
|
3053
3084
|
/**
|
|
3054
3085
|
* Обрабатывает отправитель в зависимости от команды управления
|
|
@@ -3056,16 +3087,16 @@ class Cn {
|
|
|
3056
3087
|
* @returns Promise с результатом обработки
|
|
3057
3088
|
*/
|
|
3058
3089
|
async processSender(e, t) {
|
|
3059
|
-
const { mainCam: s, resolutionMainCam:
|
|
3090
|
+
const { mainCam: s, resolutionMainCam: r } = e;
|
|
3060
3091
|
switch (s) {
|
|
3061
|
-
case
|
|
3092
|
+
case v.PAUSE_MAIN_CAM:
|
|
3062
3093
|
return this.downgradeResolutionSender(t);
|
|
3063
|
-
case
|
|
3094
|
+
case v.RESUME_MAIN_CAM:
|
|
3064
3095
|
return this.setBitrateByTrackResolution(t);
|
|
3065
|
-
case
|
|
3066
|
-
return
|
|
3067
|
-
case
|
|
3068
|
-
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:
|
|
3069
3100
|
case void 0:
|
|
3070
3101
|
return this.setBitrateByTrackResolution(t);
|
|
3071
3102
|
default:
|
|
@@ -3078,11 +3109,11 @@ class Cn {
|
|
|
3078
3109
|
* @returns Promise с результатом
|
|
3079
3110
|
*/
|
|
3080
3111
|
async downgradeResolutionSender(e) {
|
|
3081
|
-
const { sender: t, codec: s } = e,
|
|
3112
|
+
const { sender: t, codec: s } = e, r = {
|
|
3082
3113
|
scaleResolutionDownBy: 200,
|
|
3083
|
-
maxBitrate:
|
|
3114
|
+
maxBitrate: gn(s)
|
|
3084
3115
|
};
|
|
3085
|
-
return this.parametersSetter.setEncodingsToSender(t,
|
|
3116
|
+
return this.parametersSetter.setEncodingsToSender(t, r);
|
|
3086
3117
|
}
|
|
3087
3118
|
/**
|
|
3088
3119
|
* Устанавливает битрейт на основе разрешения трека
|
|
@@ -3090,7 +3121,7 @@ class Cn {
|
|
|
3090
3121
|
* @returns Promise с результатом
|
|
3091
3122
|
*/
|
|
3092
3123
|
async setBitrateByTrackResolution(e) {
|
|
3093
|
-
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);
|
|
3094
3125
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
3095
3126
|
scaleResolutionDownBy: 1,
|
|
3096
3127
|
maxBitrate: o
|
|
@@ -3103,17 +3134,17 @@ class Cn {
|
|
|
3103
3134
|
* @returns Promise с результатом
|
|
3104
3135
|
*/
|
|
3105
3136
|
async setResolutionSender(e, t) {
|
|
3106
|
-
const [s,
|
|
3137
|
+
const [s, r] = e.split("x"), { sender: i, videoTrack: a, codec: o } = t, c = {
|
|
3107
3138
|
width: Number(s),
|
|
3108
|
-
height: Number(
|
|
3109
|
-
},
|
|
3139
|
+
height: Number(r)
|
|
3140
|
+
}, d = Sn({
|
|
3110
3141
|
videoTrack: a,
|
|
3111
3142
|
targetSize: c
|
|
3112
3143
|
}), T = j(c.width, o), S = {
|
|
3113
|
-
scaleResolutionDownBy:
|
|
3144
|
+
scaleResolutionDownBy: d,
|
|
3114
3145
|
maxBitrate: T
|
|
3115
3146
|
};
|
|
3116
|
-
return this.parametersSetter.setEncodingsToSender(
|
|
3147
|
+
return this.parametersSetter.setEncodingsToSender(i, S);
|
|
3117
3148
|
}
|
|
3118
3149
|
}
|
|
3119
3150
|
const En = (n) => n.find((e) => e.track?.kind === "video");
|
|
@@ -3155,8 +3186,8 @@ class Nn {
|
|
|
3155
3186
|
attachSender(e, t) {
|
|
3156
3187
|
this.currentSender = e;
|
|
3157
3188
|
const s = e.replaceTrack.bind(e);
|
|
3158
|
-
this.originalReplaceTrack = s, e.replaceTrack = async (
|
|
3159
|
-
await s(
|
|
3189
|
+
this.originalReplaceTrack = s, e.replaceTrack = async (r) => {
|
|
3190
|
+
await s(r), this.attachTrack(t, r ?? void 0), t();
|
|
3160
3191
|
}, this.attachTrack(t, e.track);
|
|
3161
3192
|
}
|
|
3162
3193
|
detachSender() {
|
|
@@ -3165,8 +3196,8 @@ class Nn {
|
|
|
3165
3196
|
attachTrack(e, t) {
|
|
3166
3197
|
if (this.detachTrack(), !t)
|
|
3167
3198
|
return;
|
|
3168
|
-
const { width: s, height:
|
|
3169
|
-
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);
|
|
3170
3201
|
}
|
|
3171
3202
|
/**
|
|
3172
3203
|
* Периодически опрашивает track с экспоненциальной адаптацией частоты.
|
|
@@ -3175,8 +3206,8 @@ class Nn {
|
|
|
3175
3206
|
*/
|
|
3176
3207
|
schedulePoll(e, t) {
|
|
3177
3208
|
const s = () => {
|
|
3178
|
-
const { width:
|
|
3179
|
-
|
|
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(
|
|
3180
3211
|
this.currentPollIntervalMs * 2,
|
|
3181
3212
|
this.maxPollIntervalMs
|
|
3182
3213
|
), this.setTimeoutRequest.request(s, this.currentPollIntervalMs);
|
|
@@ -3216,10 +3247,10 @@ class In {
|
|
|
3216
3247
|
trackMonitor;
|
|
3217
3248
|
constructor(e, t, {
|
|
3218
3249
|
ignoreForCodec: s,
|
|
3219
|
-
onSetParameters:
|
|
3220
|
-
pollIntervalMs:
|
|
3250
|
+
onSetParameters: r,
|
|
3251
|
+
pollIntervalMs: i
|
|
3221
3252
|
} = {}) {
|
|
3222
|
-
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(
|
|
3223
3254
|
{
|
|
3224
3255
|
senderFinder: new An(),
|
|
3225
3256
|
codecProvider: new rn(),
|
|
@@ -3228,7 +3259,7 @@ class In {
|
|
|
3228
3259
|
{
|
|
3229
3260
|
ignoreForCodec: s
|
|
3230
3261
|
}
|
|
3231
|
-
), this.trackMonitor = new Nn({ pollIntervalMs:
|
|
3262
|
+
), this.trackMonitor = new Nn({ pollIntervalMs: i });
|
|
3232
3263
|
}
|
|
3233
3264
|
/**
|
|
3234
3265
|
* Подписывается на события управления главной камерой
|
|
@@ -3259,7 +3290,7 @@ class In {
|
|
|
3259
3290
|
const t = await this.senderBalancer.balance(e, this.serverHeaders);
|
|
3260
3291
|
return this.trackMonitor.subscribe(t.sender, () => {
|
|
3261
3292
|
this.balance().catch((s) => {
|
|
3262
|
-
|
|
3293
|
+
h("balance on track change: error", s);
|
|
3263
3294
|
});
|
|
3264
3295
|
}), t;
|
|
3265
3296
|
}
|
|
@@ -3269,7 +3300,7 @@ class In {
|
|
|
3269
3300
|
*/
|
|
3270
3301
|
handleMainCamControl = (e) => {
|
|
3271
3302
|
this.serverHeaders = e, this.balance().catch((t) => {
|
|
3272
|
-
|
|
3303
|
+
h("handleMainCamControl: error", t);
|
|
3273
3304
|
});
|
|
3274
3305
|
};
|
|
3275
3306
|
}
|
|
@@ -3292,8 +3323,8 @@ class pn {
|
|
|
3292
3323
|
() => e.connection,
|
|
3293
3324
|
{
|
|
3294
3325
|
...s,
|
|
3295
|
-
onSetParameters: (
|
|
3296
|
-
this.events.trigger("parameters-updated",
|
|
3326
|
+
onSetParameters: (r) => {
|
|
3327
|
+
this.events.trigger("parameters-updated", r), s.onSetParameters?.(r);
|
|
3297
3328
|
}
|
|
3298
3329
|
}
|
|
3299
3330
|
), this.subscribe();
|
|
@@ -3349,7 +3380,7 @@ class pn {
|
|
|
3349
3380
|
scheduleBalancingStart() {
|
|
3350
3381
|
this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
|
|
3351
3382
|
this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
|
|
3352
|
-
|
|
3383
|
+
h("startBalancing: error", e);
|
|
3353
3384
|
});
|
|
3354
3385
|
}, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
|
|
3355
3386
|
}
|
|
@@ -3357,11 +3388,11 @@ class pn {
|
|
|
3357
3388
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
3358
3389
|
}
|
|
3359
3390
|
}
|
|
3360
|
-
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 = [
|
|
3361
3392
|
..._n,
|
|
3362
3393
|
...Mn,
|
|
3363
|
-
...vn,
|
|
3364
3394
|
...fn,
|
|
3395
|
+
...vn,
|
|
3365
3396
|
...Pn,
|
|
3366
3397
|
...On,
|
|
3367
3398
|
...yn,
|
|
@@ -3384,15 +3415,15 @@ class Gn {
|
|
|
3384
3415
|
constructor({ JsSIP: e }, {
|
|
3385
3416
|
preferredMimeTypesVideoCodecs: t,
|
|
3386
3417
|
excludeMimeTypesVideoCodecs: s,
|
|
3387
|
-
videoBalancerOptions:
|
|
3388
|
-
autoConnectorOptions:
|
|
3418
|
+
videoBalancerOptions: r,
|
|
3419
|
+
autoConnectorOptions: i
|
|
3389
3420
|
} = {}) {
|
|
3390
3421
|
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new k(bn), this.connectionManager = new pt({ JsSIP: e }), this.connectionQueueManager = new mt({
|
|
3391
3422
|
connectionManager: this.connectionManager
|
|
3392
3423
|
}), this.callManager = new ze(), this.apiManager = new Fe({
|
|
3393
3424
|
connectionManager: this.connectionManager,
|
|
3394
3425
|
callManager: this.callManager
|
|
3395
|
-
}), this.incomingCallManager = new $t(this.connectionManager), this.presentationManager = new
|
|
3426
|
+
}), this.incomingCallManager = new $t(this.connectionManager), this.presentationManager = new ht({
|
|
3396
3427
|
callManager: this.callManager,
|
|
3397
3428
|
maxBitrate: mn
|
|
3398
3429
|
}), this.statsManager = new zt({
|
|
@@ -3404,14 +3435,14 @@ class Gn {
|
|
|
3404
3435
|
connectionManager: this.connectionManager,
|
|
3405
3436
|
callManager: this.callManager
|
|
3406
3437
|
},
|
|
3407
|
-
|
|
3438
|
+
i
|
|
3408
3439
|
), this.transceiverManager = new en({
|
|
3409
3440
|
callManager: this.callManager,
|
|
3410
3441
|
apiManager: this.apiManager
|
|
3411
3442
|
}), this.videoSendingBalancerManager = new pn(
|
|
3412
3443
|
this.callManager,
|
|
3413
3444
|
this.apiManager,
|
|
3414
|
-
|
|
3445
|
+
r
|
|
3415
3446
|
), this.subscribe();
|
|
3416
3447
|
}
|
|
3417
3448
|
get requestedConnection() {
|
|
@@ -3518,7 +3549,7 @@ class Gn {
|
|
|
3518
3549
|
getRemoteStreams = () => this.callManager.getRemoteStreams();
|
|
3519
3550
|
replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
|
|
3520
3551
|
async startPresentation(e, t = {}) {
|
|
3521
|
-
const { isP2P: s, callLimit:
|
|
3552
|
+
const { isP2P: s, callLimit: r, onAddedTransceiver: i, ...a } = t;
|
|
3522
3553
|
return this.presentationManager.startPresentation(
|
|
3523
3554
|
async () => {
|
|
3524
3555
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
@@ -3526,9 +3557,9 @@ class Gn {
|
|
|
3526
3557
|
e,
|
|
3527
3558
|
{
|
|
3528
3559
|
...a,
|
|
3529
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
3560
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(i)
|
|
3530
3561
|
},
|
|
3531
|
-
|
|
3562
|
+
r === void 0 ? void 0 : { callLimit: r }
|
|
3532
3563
|
);
|
|
3533
3564
|
}
|
|
3534
3565
|
async stopPresentation(e = {}) {
|
|
@@ -3538,15 +3569,15 @@ class Gn {
|
|
|
3538
3569
|
});
|
|
3539
3570
|
}
|
|
3540
3571
|
async updatePresentation(e, t = {}) {
|
|
3541
|
-
const { isP2P: s, onAddedTransceiver:
|
|
3572
|
+
const { isP2P: s, onAddedTransceiver: r, ...i } = t;
|
|
3542
3573
|
return this.presentationManager.updatePresentation(
|
|
3543
3574
|
async () => {
|
|
3544
3575
|
s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
|
|
3545
3576
|
},
|
|
3546
3577
|
e,
|
|
3547
3578
|
{
|
|
3548
|
-
...
|
|
3549
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
3579
|
+
...i,
|
|
3580
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(r)
|
|
3550
3581
|
}
|
|
3551
3582
|
);
|
|
3552
3583
|
}
|
|
@@ -3602,21 +3633,21 @@ class Gn {
|
|
|
3602
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);
|
|
3603
3634
|
}
|
|
3604
3635
|
bridgeEvents = (e, t) => {
|
|
3605
|
-
t.events.eachTriggers((s,
|
|
3606
|
-
t.on(
|
|
3607
|
-
this.events.trigger(`${e}:${
|
|
3636
|
+
t.events.eachTriggers((s, r) => {
|
|
3637
|
+
t.on(r, (i) => {
|
|
3638
|
+
this.events.trigger(`${e}:${r}`, i);
|
|
3608
3639
|
});
|
|
3609
3640
|
});
|
|
3610
3641
|
};
|
|
3611
|
-
resolveHandleAddTransceiver = (e) => async (t, s,
|
|
3612
|
-
this.setCodecPreferences(t), await e?.(t, s,
|
|
3642
|
+
resolveHandleAddTransceiver = (e) => async (t, s, r) => {
|
|
3643
|
+
this.setCodecPreferences(t), await e?.(t, s, r);
|
|
3613
3644
|
};
|
|
3614
3645
|
}
|
|
3615
3646
|
export {
|
|
3616
3647
|
ae as E,
|
|
3617
3648
|
ke as O,
|
|
3618
3649
|
Gn as S,
|
|
3619
|
-
|
|
3650
|
+
it as a,
|
|
3620
3651
|
Be as b,
|
|
3621
3652
|
xn as c,
|
|
3622
3653
|
Hn as d,
|
|
@@ -3625,7 +3656,7 @@ export {
|
|
|
3625
3656
|
Yt as g,
|
|
3626
3657
|
Nt as h,
|
|
3627
3658
|
sn as i,
|
|
3628
|
-
|
|
3659
|
+
h as l,
|
|
3629
3660
|
F as p,
|
|
3630
|
-
|
|
3661
|
+
he as s
|
|
3631
3662
|
};
|