sip-connector 25.4.0 → 25.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{@SipConnector-BY37Gd_k.js → @SipConnector-BELPR0PD.js} +697 -541
- package/dist/@SipConnector-CxGaQvhB.cjs +1 -0
- package/dist/ApiManager/@ApiManager.d.ts +2 -0
- package/dist/ApiManager/constants.d.ts +3 -1
- package/dist/ApiManager/events.d.ts +7 -2
- package/dist/CallManager/@CallManager.d.ts +6 -1
- package/dist/CallManager/CallStateMachine.d.ts +21 -2
- package/dist/ConnectionManager/@ConnectionManager.d.ts +1 -0
- package/dist/PeerToPeerManager/@PeerToPeerManager.d.ts +19 -0
- package/dist/PeerToPeerManager/index.d.ts +1 -0
- package/dist/PresentationManager/@PresentationManager.d.ts +0 -1
- package/dist/SipConnector/@SipConnector.d.ts +3 -5
- package/dist/SipConnector/events.d.ts +2 -2
- package/dist/SipConnectorFacade/@SipConnectorFacade.d.ts +3 -7
- package/dist/doMock.cjs +1 -1
- package/dist/doMock.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +186 -191
- package/dist/tools/hasPeerToPeer.d.ts +2 -0
- package/dist/tools/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/@SipConnector-m2VXGxw1.cjs +0 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { IncomingResponse as rt, C as at } from "@krivega/jssip";
|
|
2
|
+
import oe from "debug";
|
|
3
|
+
import { TypedEvents as M } from "events-constructor";
|
|
4
|
+
import { CancelableRequest as X, isCanceledError as ot } from "@krivega/cancelable-promise";
|
|
5
|
+
import { resolveRequesterByTimeout as ct, requesterByTimeoutsWithFailCalls as dt, DelayRequester as ht, hasCanceledError as lt, SetTimeoutRequest as ve } from "@krivega/timeout-requester";
|
|
6
|
+
import { repeatedCallsAsync as ce, hasCanceledError as ut } from "repeated-calls";
|
|
7
|
+
import { createActor as gt, setup as V, assign as v } from "xstate";
|
|
8
|
+
import { createStackPromises as fe, isPromiseIsNotActualError as Tt } from "stack-promises";
|
|
8
9
|
import "ua-parser-js";
|
|
9
10
|
import "sequent-promises";
|
|
10
|
-
import
|
|
11
|
-
const
|
|
11
|
+
import Et from "lodash";
|
|
12
|
+
const de = "sip-connector", d = oe(de), ue = (n, e) => {
|
|
12
13
|
d(`${n}:`, e);
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
var
|
|
19
|
-
const
|
|
14
|
+
}, Gi = () => {
|
|
15
|
+
oe.enable(de);
|
|
16
|
+
}, qi = () => {
|
|
17
|
+
oe.enable(`-${de}`);
|
|
18
|
+
}, St = "Error decline with 603", mt = 1006, pt = (n) => typeof n == "object" && n !== null && "code" in n && n.code === mt, Ct = (n) => n.message === St;
|
|
19
|
+
var z = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(z || {}), P = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", 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))(P || {}), O = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.STATS = "application/vinteo.webrtc.stats", n))(O || {}), b = /* @__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))(b || {}), J = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(J || {}), Me = /* @__PURE__ */ ((n) => (n.H264 = "H264", n.VP8 = "VP8", n.VP9 = "VP9", n.AV1 = "AV1", n))(Me || {}), h = /* @__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.CONTENTED_STREAM_STATE = "x-webrtc-share-state", n.CONTENTED_STREAM_CODEC = "x-webrtc-share-codec", n.AVAILABLE_INCOMING_BITRATE = "x-webrtc-available-incoming-bitrate", n.AUDIO_TRACK_COUNT = "x-webrtc-audio-track-count", n.VIDEO_TRACK_COUNT = "x-webrtc-video-track-count", n.TRACKS_DIRECTION = "x-webrtc-tracks-direction", n.AUDIO_ID = "x-webrtc-audioid", n.BEARER_TOKEN = "x-bearer-token", n.IS_DIRECT_PEER_TO_PEER = "x-webrtc-is-direct-p2p", n))(h || {}), q = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(q || {}), F = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: CONTENTEND", n.ACK_PERMISSION_TO_START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.STOPPED_CLIENT_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.ENABLE_MAIN_CAM = "x-webrtc-request-enable-media-device: LETMESTARTMAINCAM", n))(F || {}), j = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(j || {}), _e = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(_e || {}), u = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "enter-room", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "use-license", n.NEW_DTMF = "new-dtmf", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CONTENTED_STREAM_AVAILABLE = "contented-stream:available", n.CONTENTED_STREAM_NOT_AVAILABLE = "contented-stream:not-available", n.PRESENTATION_MUST_STOP = "presentation:must-stop", n.CHANNELS_ALL = "channels:all", n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.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.FAILED_SEND_ROOM_DIRECT_P2P = "failed-send-room-direct-p2p", n))(u || {});
|
|
20
|
+
const be = [
|
|
20
21
|
"enter-room",
|
|
21
22
|
"main-cam-control",
|
|
22
23
|
"use-license",
|
|
@@ -44,16 +45,23 @@ const Me = [
|
|
|
44
45
|
"admin:stop-main-cam",
|
|
45
46
|
"admin:start-mic",
|
|
46
47
|
"admin:stop-mic",
|
|
47
|
-
"admin:force-sync-media-state"
|
|
48
|
-
|
|
48
|
+
"admin:force-sync-media-state",
|
|
49
|
+
"failed-send-room-direct-p2p"
|
|
50
|
+
], Rt = () => new M(be), Nt = (n) => typeof n == "string" && n.trim().length > 0, w = (n, e) => {
|
|
49
51
|
const t = e.toLowerCase(), s = Object.entries(n).find(([, i]) => typeof i == "string" && i.toLowerCase() === t);
|
|
50
52
|
return s ? s[1] : void 0;
|
|
51
|
-
},
|
|
52
|
-
if (
|
|
53
|
+
}, At = (n) => typeof n == "string" && !Number.isNaN(Number(n)) && Number.isFinite(Number(n)), It = (n) => {
|
|
54
|
+
if (At(n))
|
|
53
55
|
return Number(n);
|
|
54
|
-
},
|
|
56
|
+
}, vt = (n) => {
|
|
57
|
+
const e = n.toLowerCase();
|
|
58
|
+
if (e === "true" || e === "1")
|
|
59
|
+
return !0;
|
|
60
|
+
if (e === "false" || e === "0")
|
|
61
|
+
return !1;
|
|
62
|
+
}, N = (n, e) => {
|
|
55
63
|
const t = n.getHeader(e.toLowerCase());
|
|
56
|
-
if (!
|
|
64
|
+
if (!Nt(t))
|
|
57
65
|
return;
|
|
58
66
|
const s = t.toLowerCase();
|
|
59
67
|
switch (e) {
|
|
@@ -76,33 +84,35 @@ const Me = [
|
|
|
76
84
|
case h.AVAILABLE_INCOMING_BITRATE:
|
|
77
85
|
case h.AUDIO_TRACK_COUNT:
|
|
78
86
|
case h.VIDEO_TRACK_COUNT:
|
|
79
|
-
return
|
|
87
|
+
return It(s);
|
|
80
88
|
case h.CONTENTED_STREAM_CODEC:
|
|
81
|
-
return
|
|
89
|
+
return w(Me, s);
|
|
82
90
|
case h.CONTENT_TYPE:
|
|
83
|
-
return
|
|
91
|
+
return w(P, s);
|
|
84
92
|
case h.CONTENT_USE_LICENSE:
|
|
85
|
-
return
|
|
93
|
+
return w(_e, s);
|
|
86
94
|
case h.MAIN_CAM:
|
|
87
|
-
return
|
|
95
|
+
return w(b, s);
|
|
88
96
|
case h.MIC:
|
|
89
|
-
return
|
|
97
|
+
return w(J, s);
|
|
90
98
|
case h.MEDIA_SYNC:
|
|
91
|
-
return
|
|
99
|
+
return w(j, s);
|
|
92
100
|
case h.CONTENT_PARTICIPANT_STATE:
|
|
93
|
-
return
|
|
101
|
+
return w(z, s);
|
|
94
102
|
case h.CONTENTED_STREAM_STATE:
|
|
95
|
-
return
|
|
103
|
+
return w(q, s);
|
|
104
|
+
case h.IS_DIRECT_PEER_TO_PEER:
|
|
105
|
+
return vt(s);
|
|
96
106
|
default:
|
|
97
107
|
return;
|
|
98
108
|
}
|
|
99
109
|
};
|
|
100
|
-
var
|
|
101
|
-
class
|
|
110
|
+
var f = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(f || {});
|
|
111
|
+
class ft {
|
|
102
112
|
events;
|
|
103
113
|
callManager;
|
|
104
114
|
constructor() {
|
|
105
|
-
this.events =
|
|
115
|
+
this.events = Rt();
|
|
106
116
|
}
|
|
107
117
|
subscribe({
|
|
108
118
|
connectionManager: e,
|
|
@@ -141,6 +151,11 @@ class Nt {
|
|
|
141
151
|
];
|
|
142
152
|
return s.sendInfo(O.CHANNELS, void 0, { extraHeaders: a });
|
|
143
153
|
}
|
|
154
|
+
sendEnterRoom(e) {
|
|
155
|
+
this.sendEnterRoomProtected(e).catch((t) => {
|
|
156
|
+
this.events.trigger(u.FAILED_SEND_ROOM_DIRECT_P2P, { error: t });
|
|
157
|
+
});
|
|
158
|
+
}
|
|
144
159
|
async sendMediaState({ cam: e, mic: t }, s = {}) {
|
|
145
160
|
const i = this.getEstablishedRTCSessionProtected(), r = `${h.MEDIA_STATE}: currentstate`, a = `${h.MAIN_CAM_STATE}: ${Number(e)}`, o = `${h.MIC_STATE}: ${Number(t)}`, c = [
|
|
146
161
|
r,
|
|
@@ -203,7 +218,7 @@ class Nt {
|
|
|
203
218
|
...e,
|
|
204
219
|
extraHeaders: s
|
|
205
220
|
}).catch((i) => {
|
|
206
|
-
if (
|
|
221
|
+
if (Ct(i))
|
|
207
222
|
throw i;
|
|
208
223
|
});
|
|
209
224
|
}
|
|
@@ -244,55 +259,55 @@ class Nt {
|
|
|
244
259
|
};
|
|
245
260
|
handleNotify = (e) => {
|
|
246
261
|
switch (e.cmd) {
|
|
247
|
-
case
|
|
262
|
+
case f.CHANNELS: {
|
|
248
263
|
const t = e;
|
|
249
264
|
this.triggerChannelsNotify(t);
|
|
250
265
|
break;
|
|
251
266
|
}
|
|
252
|
-
case
|
|
267
|
+
case f.WEBCAST_STARTED: {
|
|
253
268
|
const t = e;
|
|
254
269
|
this.triggerWebcastStartedNotify(t);
|
|
255
270
|
break;
|
|
256
271
|
}
|
|
257
|
-
case
|
|
272
|
+
case f.WEBCAST_STOPPED: {
|
|
258
273
|
const t = e;
|
|
259
274
|
this.triggerWebcastStoppedNotify(t);
|
|
260
275
|
break;
|
|
261
276
|
}
|
|
262
|
-
case
|
|
277
|
+
case f.ADDED_TO_LIST_MODERATORS: {
|
|
263
278
|
const t = e;
|
|
264
279
|
this.triggerAddedToListModeratorsNotify(t);
|
|
265
280
|
break;
|
|
266
281
|
}
|
|
267
|
-
case
|
|
282
|
+
case f.REMOVED_FROM_LIST_MODERATORS: {
|
|
268
283
|
const t = e;
|
|
269
284
|
this.triggerRemovedFromListModeratorsNotify(t);
|
|
270
285
|
break;
|
|
271
286
|
}
|
|
272
|
-
case
|
|
287
|
+
case f.ACCEPTING_WORD_REQUEST: {
|
|
273
288
|
const t = e;
|
|
274
289
|
this.triggerParticipationAcceptingWordRequest(t);
|
|
275
290
|
break;
|
|
276
291
|
}
|
|
277
|
-
case
|
|
292
|
+
case f.CANCELLING_WORD_REQUEST: {
|
|
278
293
|
const t = e;
|
|
279
294
|
this.triggerParticipationCancellingWordRequest(t);
|
|
280
295
|
break;
|
|
281
296
|
}
|
|
282
|
-
case
|
|
297
|
+
case f.MOVE_REQUEST_TO_STREAM: {
|
|
283
298
|
const t = e;
|
|
284
299
|
this.triggerParticipantMoveRequestToStream(t);
|
|
285
300
|
break;
|
|
286
301
|
}
|
|
287
|
-
case
|
|
302
|
+
case f.ACCOUNT_CHANGED: {
|
|
288
303
|
this.triggerAccountChangedNotify();
|
|
289
304
|
break;
|
|
290
305
|
}
|
|
291
|
-
case
|
|
306
|
+
case f.ACCOUNT_DELETED: {
|
|
292
307
|
this.triggerAccountDeletedNotify();
|
|
293
308
|
break;
|
|
294
309
|
}
|
|
295
|
-
case
|
|
310
|
+
case f.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
|
|
296
311
|
const t = e;
|
|
297
312
|
this.triggerConferenceParticipantTokenIssued(t);
|
|
298
313
|
break;
|
|
@@ -305,34 +320,34 @@ class Nt {
|
|
|
305
320
|
const { originator: t } = e;
|
|
306
321
|
if (t !== "remote")
|
|
307
322
|
return;
|
|
308
|
-
const { request: s } = e, i = s, r =
|
|
323
|
+
const { request: s } = e, i = s, r = N(i, h.CONTENT_TYPE);
|
|
309
324
|
if (r !== void 0)
|
|
310
325
|
switch (r) {
|
|
311
|
-
case
|
|
326
|
+
case P.ENTER_ROOM: {
|
|
312
327
|
this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
|
|
313
328
|
break;
|
|
314
329
|
}
|
|
315
|
-
case
|
|
330
|
+
case P.NOTIFY: {
|
|
316
331
|
this.maybeHandleNotify(i);
|
|
317
332
|
break;
|
|
318
333
|
}
|
|
319
|
-
case
|
|
334
|
+
case P.SHARE_STATE: {
|
|
320
335
|
this.triggerContentedStreamState(i);
|
|
321
336
|
break;
|
|
322
337
|
}
|
|
323
|
-
case
|
|
338
|
+
case P.MAIN_CAM: {
|
|
324
339
|
this.triggerMainCamControl(i);
|
|
325
340
|
break;
|
|
326
341
|
}
|
|
327
|
-
case
|
|
342
|
+
case P.MIC: {
|
|
328
343
|
this.triggerMicControl(i);
|
|
329
344
|
break;
|
|
330
345
|
}
|
|
331
|
-
case
|
|
346
|
+
case P.USE_LICENSE: {
|
|
332
347
|
this.triggerUseLicense(i);
|
|
333
348
|
break;
|
|
334
349
|
}
|
|
335
|
-
case
|
|
350
|
+
case P.PARTICIPANT_STATE: {
|
|
336
351
|
this.maybeTriggerParticipantMoveRequest(i);
|
|
337
352
|
break;
|
|
338
353
|
}
|
|
@@ -429,7 +444,7 @@ class Nt {
|
|
|
429
444
|
);
|
|
430
445
|
};
|
|
431
446
|
maybeTriggerChannels = (e) => {
|
|
432
|
-
const t =
|
|
447
|
+
const t = N(e, h.INPUT_CHANNELS), s = N(e, h.OUTPUT_CHANNELS);
|
|
433
448
|
if (t !== void 0 && s !== void 0) {
|
|
434
449
|
const i = {
|
|
435
450
|
inputChannels: t,
|
|
@@ -439,15 +454,20 @@ class Nt {
|
|
|
439
454
|
}
|
|
440
455
|
};
|
|
441
456
|
triggerEnterRoom = (e) => {
|
|
442
|
-
const t =
|
|
443
|
-
t !== void 0 && s !== void 0 && this.events.trigger(u.ENTER_ROOM, {
|
|
457
|
+
const t = N(e, h.CONTENT_ENTER_ROOM), s = N(e, h.PARTICIPANT_NAME), i = N(e, h.BEARER_TOKEN), r = N(e, h.IS_DIRECT_PEER_TO_PEER);
|
|
458
|
+
t !== void 0 && s !== void 0 && this.events.trigger(u.ENTER_ROOM, {
|
|
459
|
+
room: t,
|
|
460
|
+
participantName: s,
|
|
461
|
+
bearerToken: i,
|
|
462
|
+
isDirectPeerToPeer: r
|
|
463
|
+
});
|
|
444
464
|
};
|
|
445
465
|
triggerContentedStreamState = (e) => {
|
|
446
|
-
const t =
|
|
466
|
+
const t = N(e, h.CONTENTED_STREAM_STATE);
|
|
447
467
|
if (t !== void 0)
|
|
448
468
|
switch (t) {
|
|
449
469
|
case q.AVAILABLE_CONTENTED_STREAM: {
|
|
450
|
-
const s =
|
|
470
|
+
const s = N(e, h.CONTENTED_STREAM_CODEC);
|
|
451
471
|
this.events.trigger(u.CONTENTED_STREAM_AVAILABLE, { codec: s });
|
|
452
472
|
break;
|
|
453
473
|
}
|
|
@@ -462,16 +482,16 @@ class Nt {
|
|
|
462
482
|
}
|
|
463
483
|
};
|
|
464
484
|
maybeTriggerParticipantMoveRequest = (e) => {
|
|
465
|
-
const t =
|
|
466
|
-
t ===
|
|
485
|
+
const t = N(e, h.CONTENT_PARTICIPANT_STATE), s = N(e, h.AUDIO_ID);
|
|
486
|
+
t === z.SPECTATOR && (s === void 0 ? (this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC, {}), this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, { isSynthetic: !0 })) : (this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID, {
|
|
467
487
|
audioId: s
|
|
468
488
|
}), this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, {
|
|
469
489
|
isSynthetic: !1,
|
|
470
490
|
audioId: s
|
|
471
|
-
}))), t ===
|
|
491
|
+
}))), t === z.PARTICIPANT && this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
|
|
472
492
|
};
|
|
473
493
|
triggerMainCamControl = (e) => {
|
|
474
|
-
const t =
|
|
494
|
+
const t = N(e, h.MAIN_CAM), s = N(e, h.MEDIA_SYNC), i = s === j.ADMIN_SYNC_FORCED;
|
|
475
495
|
if (t === b.ADMIN_START_MAIN_CAM) {
|
|
476
496
|
this.events.trigger(u.ADMIN_START_MAIN_CAM, { isSyncForced: i });
|
|
477
497
|
return;
|
|
@@ -481,26 +501,29 @@ class Nt {
|
|
|
481
501
|
return;
|
|
482
502
|
}
|
|
483
503
|
(t === b.RESUME_MAIN_CAM || t === b.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(u.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
|
|
484
|
-
const r =
|
|
504
|
+
const r = N(e, h.MAIN_CAM_RESOLUTION);
|
|
485
505
|
this.events.trigger(u.MAIN_CAM_CONTROL, {
|
|
486
506
|
mainCam: t,
|
|
487
507
|
resolutionMainCam: r
|
|
488
508
|
});
|
|
489
509
|
};
|
|
490
510
|
triggerMicControl = (e) => {
|
|
491
|
-
const t =
|
|
492
|
-
t ===
|
|
511
|
+
const t = N(e, h.MIC), i = N(e, h.MEDIA_SYNC) === j.ADMIN_SYNC_FORCED;
|
|
512
|
+
t === J.ADMIN_START_MIC ? this.events.trigger(u.ADMIN_START_MIC, { isSyncForced: i }) : t === J.ADMIN_STOP_MIC && this.events.trigger(u.ADMIN_STOP_MIC, { isSyncForced: i });
|
|
493
513
|
};
|
|
494
514
|
triggerUseLicense = (e) => {
|
|
495
|
-
const t =
|
|
515
|
+
const t = N(e, h.CONTENT_USE_LICENSE);
|
|
496
516
|
t !== void 0 && this.events.trigger(u.USE_LICENSE, t);
|
|
497
517
|
};
|
|
518
|
+
async sendEnterRoomProtected(e) {
|
|
519
|
+
return this.getEstablishedRTCSessionProtected().sendInfo(P.ENTER_ROOM, void 0, { extraHeaders: e });
|
|
520
|
+
}
|
|
498
521
|
}
|
|
499
|
-
const
|
|
522
|
+
const Mt = /^p2p.+to.+$/i, Oe = (n) => n !== void 0 && n.length > 0 && Mt.test(n), _t = "purgatory", Pe = (n) => n === _t, bt = (n, e) => {
|
|
500
523
|
n.getVideoTracks().forEach((s) => {
|
|
501
524
|
"contentHint" in s && s.contentHint !== e && (s.contentHint = e);
|
|
502
525
|
});
|
|
503
|
-
},
|
|
526
|
+
}, Y = (n, {
|
|
504
527
|
directionVideo: e,
|
|
505
528
|
directionAudio: t,
|
|
506
529
|
contentHint: s
|
|
@@ -508,8 +531,8 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
|
|
|
508
531
|
if (!n || e === "recvonly" && t === "recvonly")
|
|
509
532
|
return;
|
|
510
533
|
const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
|
|
511
|
-
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" &&
|
|
512
|
-
},
|
|
534
|
+
return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && bt(o, s), o;
|
|
535
|
+
}, Ot = "api/v2/rtp2webrtc/offer", Pt = async ({
|
|
513
536
|
serverUrl: n,
|
|
514
537
|
conferenceNumber: e,
|
|
515
538
|
quality: t,
|
|
@@ -518,7 +541,7 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
|
|
|
518
541
|
token: r
|
|
519
542
|
}) => {
|
|
520
543
|
const a = new URL(
|
|
521
|
-
`https://${n.replace(/\/$/, "")}/${
|
|
544
|
+
`https://${n.replace(/\/$/, "")}/${Ot}/${encodeURIComponent(e)}`
|
|
522
545
|
);
|
|
523
546
|
a.searchParams.set("quality", t), a.searchParams.set("audio", String(s));
|
|
524
547
|
const o = {
|
|
@@ -540,39 +563,39 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
|
|
|
540
563
|
return l;
|
|
541
564
|
}
|
|
542
565
|
};
|
|
543
|
-
},
|
|
566
|
+
}, yt = (n, e) => (n.degradationPreference = e.degradationPreference, n), Dt = (n, e) => {
|
|
544
567
|
n.encodings ??= [];
|
|
545
568
|
for (let t = n.encodings.length; t < e; t += 1)
|
|
546
569
|
n.encodings.push({});
|
|
547
570
|
return n;
|
|
548
|
-
},
|
|
549
|
-
if (
|
|
571
|
+
}, ye = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Lt = ye(), wt = (n, e) => {
|
|
572
|
+
if (Lt(n, e))
|
|
550
573
|
return n;
|
|
551
|
-
},
|
|
552
|
-
const s = n.maxBitrate, i =
|
|
574
|
+
}, Ut = (n, e, { isResetAllowed: t = !1 } = {}) => {
|
|
575
|
+
const s = n.maxBitrate, i = wt(e, s);
|
|
553
576
|
return (i !== void 0 || t) && (n.maxBitrate = i), n;
|
|
554
|
-
},
|
|
555
|
-
|
|
556
|
-
),
|
|
557
|
-
const t = n === void 0 ? void 0 : Math.max(n,
|
|
558
|
-
if (t !== void 0 &&
|
|
577
|
+
}, De = 1, Ft = ye(
|
|
578
|
+
De
|
|
579
|
+
), kt = (n, e) => {
|
|
580
|
+
const t = n === void 0 ? void 0 : Math.max(n, De);
|
|
581
|
+
if (t !== void 0 && Ft(
|
|
559
582
|
t,
|
|
560
583
|
e
|
|
561
584
|
))
|
|
562
585
|
return t;
|
|
563
|
-
},
|
|
564
|
-
const t = n.scaleResolutionDownBy, s =
|
|
586
|
+
}, Bt = (n, e) => {
|
|
587
|
+
const t = n.scaleResolutionDownBy, s = kt(
|
|
565
588
|
e,
|
|
566
589
|
t
|
|
567
590
|
);
|
|
568
591
|
return s !== void 0 && (n.scaleResolutionDownBy = s), n;
|
|
569
|
-
},
|
|
592
|
+
}, $t = (n, e, { isResetAllowed: t } = {}) => {
|
|
570
593
|
const s = e.encodings?.length ?? 0;
|
|
571
|
-
return
|
|
594
|
+
return Dt(n, s), n.encodings.forEach((i, r) => {
|
|
572
595
|
const a = (e?.encodings ?? [])[r], o = a?.maxBitrate, c = a?.scaleResolutionDownBy;
|
|
573
|
-
|
|
596
|
+
Ut(i, o, { isResetAllowed: t }), Bt(i, c);
|
|
574
597
|
}), n;
|
|
575
|
-
},
|
|
598
|
+
}, Gt = (n, e) => {
|
|
576
599
|
if (n.codecs?.length !== e.codecs?.length)
|
|
577
600
|
return !0;
|
|
578
601
|
for (let t = 0; t < (n.codecs?.length ?? 0); t++)
|
|
@@ -589,15 +612,15 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
|
|
|
589
612
|
if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
|
|
590
613
|
return !0;
|
|
591
614
|
return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
|
|
592
|
-
},
|
|
615
|
+
}, ie = async (n, e, { isResetAllowed: t } = {}) => {
|
|
593
616
|
const s = n.getParameters(), i = JSON.parse(
|
|
594
617
|
JSON.stringify(s)
|
|
595
618
|
);
|
|
596
|
-
|
|
597
|
-
const r =
|
|
619
|
+
$t(s, e, { isResetAllowed: t }), yt(s, e);
|
|
620
|
+
const r = Gt(i, s);
|
|
598
621
|
return r && await n.setParameters(s), { parameters: s, isChanged: r };
|
|
599
|
-
},
|
|
600
|
-
const { isChanged: s, parameters: i } = await
|
|
622
|
+
}, Le = async (n, e, t) => {
|
|
623
|
+
const { isChanged: s, parameters: i } = await ie(n, {
|
|
601
624
|
encodings: [
|
|
602
625
|
{
|
|
603
626
|
scaleResolutionDownBy: e.scaleResolutionDownBy,
|
|
@@ -606,12 +629,12 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
|
|
|
606
629
|
]
|
|
607
630
|
});
|
|
608
631
|
return s && t && t(i), { isChanged: s, parameters: i };
|
|
609
|
-
},
|
|
610
|
-
const s =
|
|
632
|
+
}, qt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Vt = async (n, e, t) => {
|
|
633
|
+
const s = qt(n, e);
|
|
611
634
|
if (s)
|
|
612
|
-
return
|
|
635
|
+
return Le(s, { maxBitrate: t });
|
|
613
636
|
};
|
|
614
|
-
class
|
|
637
|
+
class xt {
|
|
615
638
|
command = void 0;
|
|
616
639
|
unsubscribe;
|
|
617
640
|
options;
|
|
@@ -632,7 +655,7 @@ class x {
|
|
|
632
655
|
subscriptions = [];
|
|
633
656
|
stateChangeListeners = /* @__PURE__ */ new Set();
|
|
634
657
|
constructor(e) {
|
|
635
|
-
this.actor =
|
|
658
|
+
this.actor = gt(e), this.actor.start(), this.addSubscription(
|
|
636
659
|
this.subscribe((t) => {
|
|
637
660
|
const s = t.value;
|
|
638
661
|
this.stateChangeListeners.forEach((i) => {
|
|
@@ -674,37 +697,38 @@ class x {
|
|
|
674
697
|
return this.subscriptions.push(t), t;
|
|
675
698
|
}
|
|
676
699
|
}
|
|
677
|
-
var
|
|
678
|
-
const
|
|
700
|
+
var re = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.PURGATORY = "call:purgatory", n.P2P_ROOM = "call:p2pRoom", n.DIRECT_P2P_ROOM = "call:directP2pRoom", n.IN_ROOM = "call:inRoom", n))(re || {});
|
|
701
|
+
const A = "evaluate", K = (n) => typeof n == "string" && n.length > 0, H = (n) => "number" in n && K(n.number) && typeof n.answer == "boolean", Z = (n) => "room" in n && K(n.room) && K(n.participantName), ee = (n) => "token" in n && K(n.token), we = ({ isDirectPeerToPeer: n }) => n === !0, Ht = (n) => Pe(n.room) || Oe(n.room) || we(n), Wt = (n) => H(n) && Z(n) && !ee(n) && "room" in n && Pe(n.room), Qt = (n) => H(n) && Z(n) && !ee(n) && "room" in n && Oe(n.room), Yt = (n) => "isDirectPeerToPeer" in n && we(n), zt = (n) => H(n) && Z(n) && !ee(n) && "room" in n && Yt(n), Ue = (n) => H(n) && Z(n) && ee(n), Jt = {}, ge = () => ({
|
|
679
702
|
number: void 0,
|
|
680
703
|
answer: void 0,
|
|
681
704
|
room: void 0,
|
|
682
705
|
participantName: void 0,
|
|
683
|
-
token: void 0
|
|
684
|
-
|
|
706
|
+
token: void 0,
|
|
707
|
+
isDirectPeerToPeer: void 0
|
|
708
|
+
}), jt = V({
|
|
685
709
|
types: {
|
|
686
|
-
context:
|
|
710
|
+
context: Jt,
|
|
687
711
|
events: {}
|
|
688
712
|
},
|
|
689
713
|
actions: {
|
|
690
|
-
setConnecting:
|
|
691
|
-
...
|
|
714
|
+
setConnecting: v(({ event: n, context: e }) => n.type !== "CALL.CONNECTING" ? e : {
|
|
715
|
+
...ge(),
|
|
692
716
|
number: n.number,
|
|
693
717
|
answer: n.answer
|
|
694
718
|
}),
|
|
695
|
-
setRoomInfo:
|
|
719
|
+
setRoomInfo: v(({ event: n, context: e }) => {
|
|
696
720
|
if (n.type !== "CALL.ENTER_ROOM")
|
|
697
721
|
return e;
|
|
698
722
|
const t = {
|
|
699
723
|
room: n.room,
|
|
700
724
|
participantName: n.participantName
|
|
701
725
|
};
|
|
702
|
-
return n.token !== void 0 ? t.token = n.token :
|
|
726
|
+
return n.token !== void 0 ? t.token = n.token : Ht(n) && (t.token = void 0), n.isDirectPeerToPeer !== void 0 && (t.isDirectPeerToPeer = n.isDirectPeerToPeer), t;
|
|
703
727
|
}),
|
|
704
|
-
setTokenInfo:
|
|
728
|
+
setTokenInfo: v(({ event: n, context: e }) => n.type !== "CALL.TOKEN_ISSUED" ? e : {
|
|
705
729
|
token: n.token
|
|
706
730
|
}),
|
|
707
|
-
reset:
|
|
731
|
+
reset: v(ge())
|
|
708
732
|
}
|
|
709
733
|
}).createMachine({
|
|
710
734
|
id: "call",
|
|
@@ -714,7 +738,7 @@ const M = "evaluate", j = (n) => typeof n == "string" && n.length > 0, oe = (n)
|
|
|
714
738
|
"call:idle": {
|
|
715
739
|
on: {
|
|
716
740
|
"CALL.CONNECTING": {
|
|
717
|
-
target:
|
|
741
|
+
target: A,
|
|
718
742
|
actions: "setConnecting"
|
|
719
743
|
}
|
|
720
744
|
}
|
|
@@ -722,15 +746,15 @@ const M = "evaluate", j = (n) => typeof n == "string" && n.length > 0, oe = (n)
|
|
|
722
746
|
"call:connecting": {
|
|
723
747
|
on: {
|
|
724
748
|
"CALL.ENTER_ROOM": {
|
|
725
|
-
target:
|
|
749
|
+
target: A,
|
|
726
750
|
actions: "setRoomInfo"
|
|
727
751
|
},
|
|
728
752
|
"CALL.TOKEN_ISSUED": {
|
|
729
|
-
target:
|
|
753
|
+
target: A,
|
|
730
754
|
actions: "setTokenInfo"
|
|
731
755
|
},
|
|
732
756
|
"CALL.RESET": {
|
|
733
|
-
target:
|
|
757
|
+
target: A,
|
|
734
758
|
actions: "reset"
|
|
735
759
|
}
|
|
736
760
|
}
|
|
@@ -738,32 +762,40 @@ const M = "evaluate", j = (n) => typeof n == "string" && n.length > 0, oe = (n)
|
|
|
738
762
|
"call:inRoom": {
|
|
739
763
|
on: {
|
|
740
764
|
"CALL.ENTER_ROOM": {
|
|
741
|
-
target:
|
|
765
|
+
target: A,
|
|
742
766
|
actions: "setRoomInfo"
|
|
743
767
|
},
|
|
744
768
|
"CALL.TOKEN_ISSUED": {
|
|
745
|
-
target:
|
|
769
|
+
target: A,
|
|
746
770
|
actions: "setTokenInfo"
|
|
747
771
|
},
|
|
748
772
|
"CALL.RESET": {
|
|
749
|
-
target:
|
|
773
|
+
target: A,
|
|
750
774
|
actions: "reset"
|
|
751
775
|
}
|
|
752
776
|
}
|
|
753
777
|
},
|
|
754
|
-
[
|
|
778
|
+
[A]: {
|
|
755
779
|
always: [
|
|
756
780
|
{
|
|
757
781
|
target: "call:inRoom",
|
|
758
|
-
guard: ({ context: n }) =>
|
|
782
|
+
guard: ({ context: n }) => Ue(n)
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
target: "call:directP2pRoom",
|
|
786
|
+
guard: ({ context: n }) => zt(n)
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
target: "call:p2pRoom",
|
|
790
|
+
guard: ({ context: n }) => Qt(n)
|
|
759
791
|
},
|
|
760
792
|
{
|
|
761
793
|
target: "call:purgatory",
|
|
762
|
-
guard: ({ context: n }) =>
|
|
794
|
+
guard: ({ context: n }) => Wt(n)
|
|
763
795
|
},
|
|
764
796
|
{
|
|
765
797
|
target: "call:connecting",
|
|
766
|
-
guard: ({ context: n }) =>
|
|
798
|
+
guard: ({ context: n }) => H(n)
|
|
767
799
|
},
|
|
768
800
|
{
|
|
769
801
|
target: "call:idle"
|
|
@@ -774,24 +806,56 @@ const M = "evaluate", j = (n) => typeof n == "string" && n.length > 0, oe = (n)
|
|
|
774
806
|
"call:purgatory": {
|
|
775
807
|
on: {
|
|
776
808
|
"CALL.ENTER_ROOM": {
|
|
777
|
-
target:
|
|
809
|
+
target: A,
|
|
810
|
+
actions: "setRoomInfo"
|
|
811
|
+
},
|
|
812
|
+
"CALL.TOKEN_ISSUED": {
|
|
813
|
+
target: A,
|
|
814
|
+
actions: "setTokenInfo"
|
|
815
|
+
},
|
|
816
|
+
"CALL.RESET": {
|
|
817
|
+
target: A,
|
|
818
|
+
actions: "reset"
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
},
|
|
822
|
+
"call:p2pRoom": {
|
|
823
|
+
on: {
|
|
824
|
+
"CALL.ENTER_ROOM": {
|
|
825
|
+
target: A,
|
|
826
|
+
actions: "setRoomInfo"
|
|
827
|
+
},
|
|
828
|
+
"CALL.TOKEN_ISSUED": {
|
|
829
|
+
target: A,
|
|
830
|
+
actions: "setTokenInfo"
|
|
831
|
+
},
|
|
832
|
+
"CALL.RESET": {
|
|
833
|
+
target: A,
|
|
834
|
+
actions: "reset"
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
"call:directP2pRoom": {
|
|
839
|
+
on: {
|
|
840
|
+
"CALL.ENTER_ROOM": {
|
|
841
|
+
target: A,
|
|
778
842
|
actions: "setRoomInfo"
|
|
779
843
|
},
|
|
780
844
|
"CALL.TOKEN_ISSUED": {
|
|
781
|
-
target:
|
|
845
|
+
target: A,
|
|
782
846
|
actions: "setTokenInfo"
|
|
783
847
|
},
|
|
784
848
|
"CALL.RESET": {
|
|
785
|
-
target:
|
|
849
|
+
target: A,
|
|
786
850
|
actions: "reset"
|
|
787
851
|
}
|
|
788
852
|
}
|
|
789
853
|
}
|
|
790
854
|
}
|
|
791
855
|
});
|
|
792
|
-
class
|
|
856
|
+
class Kt extends x {
|
|
793
857
|
constructor(e) {
|
|
794
|
-
super(
|
|
858
|
+
super(jt), this.subscribeToEvents(e);
|
|
795
859
|
}
|
|
796
860
|
get isIdle() {
|
|
797
861
|
return this.state === "call:idle";
|
|
@@ -802,16 +866,22 @@ class qt extends x {
|
|
|
802
866
|
get isInPurgatory() {
|
|
803
867
|
return this.state === "call:purgatory";
|
|
804
868
|
}
|
|
869
|
+
get isP2PRoom() {
|
|
870
|
+
return this.state === "call:p2pRoom";
|
|
871
|
+
}
|
|
872
|
+
get isDirectP2PRoom() {
|
|
873
|
+
return this.state === "call:directP2pRoom";
|
|
874
|
+
}
|
|
805
875
|
get isInRoom() {
|
|
806
876
|
return this.state === "call:inRoom";
|
|
807
877
|
}
|
|
808
878
|
/** Контекст в состоянии IN_ROOM; undefined в остальных состояниях. Использовать вместо каста context. */
|
|
809
879
|
get inRoomContext() {
|
|
810
880
|
const { context: e } = this;
|
|
811
|
-
return
|
|
881
|
+
return Ue(e) ? e : void 0;
|
|
812
882
|
}
|
|
813
883
|
get isActive() {
|
|
814
|
-
return this.isInRoom || this.isInPurgatory;
|
|
884
|
+
return this.isInRoom || this.isInPurgatory || this.isP2PRoom || this.isDirectP2PRoom;
|
|
815
885
|
}
|
|
816
886
|
get isPending() {
|
|
817
887
|
return this.isConnecting;
|
|
@@ -826,6 +896,13 @@ class qt extends x {
|
|
|
826
896
|
if ("token" in e)
|
|
827
897
|
return e.token;
|
|
828
898
|
}
|
|
899
|
+
get isCallInitiator() {
|
|
900
|
+
return !this.isCallAnswerer;
|
|
901
|
+
}
|
|
902
|
+
get isCallAnswerer() {
|
|
903
|
+
const { context: e } = this;
|
|
904
|
+
return "answer" in e ? e.answer : !1;
|
|
905
|
+
}
|
|
829
906
|
reset() {
|
|
830
907
|
this.send({ type: "CALL.RESET" });
|
|
831
908
|
}
|
|
@@ -840,8 +917,14 @@ class qt extends x {
|
|
|
840
917
|
}
|
|
841
918
|
subscribeToApiEvents(e) {
|
|
842
919
|
this.addSubscription(
|
|
843
|
-
e.on("enter-room", ({ room: t, participantName: s, bearerToken: i }) => {
|
|
844
|
-
this.send({
|
|
920
|
+
e.on("enter-room", ({ room: t, participantName: s, bearerToken: i, isDirectPeerToPeer: r }) => {
|
|
921
|
+
this.send({
|
|
922
|
+
type: "CALL.ENTER_ROOM",
|
|
923
|
+
room: t,
|
|
924
|
+
participantName: s,
|
|
925
|
+
token: i,
|
|
926
|
+
isDirectPeerToPeer: r
|
|
927
|
+
});
|
|
845
928
|
})
|
|
846
929
|
), this.addSubscription(
|
|
847
930
|
e.on("conference:participant-token-issued", ({ jwt: t }) => {
|
|
@@ -865,8 +948,8 @@ class qt extends x {
|
|
|
865
948
|
);
|
|
866
949
|
}
|
|
867
950
|
}
|
|
868
|
-
var
|
|
869
|
-
const
|
|
951
|
+
var E = /* @__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.START_CALL = "start-call", 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.REMOTE_TRACKS_CHANGED = "remote-tracks-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n.RECV_SESSION_STARTED = "recv-session-started", n.RECV_SESSION_ENDED = "recv-session-ended", n.RECV_QUALITY_CHANGED = "recv-quality-changed", n))(E || {}), Xt = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(Xt || {});
|
|
952
|
+
const Fe = [
|
|
870
953
|
"peerconnection",
|
|
871
954
|
"connecting",
|
|
872
955
|
"sending",
|
|
@@ -897,7 +980,7 @@ const Le = [
|
|
|
897
980
|
"peerconnection:createanswerfailed",
|
|
898
981
|
"peerconnection:setlocaldescriptionfailed",
|
|
899
982
|
"peerconnection:setremotedescriptionfailed"
|
|
900
|
-
],
|
|
983
|
+
], Zt = [
|
|
901
984
|
"start-call",
|
|
902
985
|
"peerconnection:confirmed",
|
|
903
986
|
"peerconnection:ontrack",
|
|
@@ -908,11 +991,11 @@ const Le = [
|
|
|
908
991
|
"recv-session-started",
|
|
909
992
|
"recv-session-ended",
|
|
910
993
|
"recv-quality-changed"
|
|
911
|
-
],
|
|
912
|
-
...
|
|
913
|
-
...
|
|
914
|
-
],
|
|
915
|
-
class
|
|
994
|
+
], ke = [
|
|
995
|
+
...Fe,
|
|
996
|
+
...Zt
|
|
997
|
+
], en = () => new M(ke), tn = 6e3, nn = 1e3, Q = (n, e) => n.getSenders().filter((t) => t.track?.kind === e), sn = (n) => n === "audio" ? tn : nn, rn = (n) => n.track !== null;
|
|
998
|
+
class an {
|
|
916
999
|
previousBitrates = /* @__PURE__ */ new Map();
|
|
917
1000
|
/**
|
|
918
1001
|
* Устанавливает минимальный битрейт для указанных типов потоков
|
|
@@ -923,18 +1006,18 @@ class Jt {
|
|
|
923
1006
|
const s = [];
|
|
924
1007
|
if (!e)
|
|
925
1008
|
return;
|
|
926
|
-
(t === "audio" || t === "all") && s.push(...
|
|
927
|
-
const i = s.filter(
|
|
1009
|
+
(t === "audio" || t === "all") && s.push(...Q(e, "audio")), (t === "video" || t === "all") && s.push(...Q(e, "video"));
|
|
1010
|
+
const i = s.filter(rn).map(async (r) => {
|
|
928
1011
|
const a = r.getParameters();
|
|
929
1012
|
this.saveCurrentBitrate(r, a);
|
|
930
1013
|
const o = {
|
|
931
1014
|
...a,
|
|
932
1015
|
encodings: a.encodings.map((c) => ({
|
|
933
1016
|
...c,
|
|
934
|
-
maxBitrate:
|
|
1017
|
+
maxBitrate: sn(r.track.kind)
|
|
935
1018
|
}))
|
|
936
1019
|
};
|
|
937
|
-
await
|
|
1020
|
+
await ie(r, o);
|
|
938
1021
|
});
|
|
939
1022
|
await Promise.all(i);
|
|
940
1023
|
}
|
|
@@ -947,7 +1030,7 @@ class Jt {
|
|
|
947
1030
|
const s = [];
|
|
948
1031
|
if (!e)
|
|
949
1032
|
return;
|
|
950
|
-
(t === "audio" || t === "all") && s.push(...
|
|
1033
|
+
(t === "audio" || t === "all") && s.push(...Q(e, "audio")), (t === "video" || t === "all") && s.push(...Q(e, "video"));
|
|
951
1034
|
const i = s.map(async (r) => {
|
|
952
1035
|
const a = this.getSavedBitrate(r);
|
|
953
1036
|
if (a) {
|
|
@@ -955,7 +1038,7 @@ class Jt {
|
|
|
955
1038
|
...r.getParameters(),
|
|
956
1039
|
encodings: a
|
|
957
1040
|
};
|
|
958
|
-
await
|
|
1041
|
+
await ie(r, c, { isResetAllowed: !0 }), this.clearSavedBitrate(r);
|
|
959
1042
|
}
|
|
960
1043
|
});
|
|
961
1044
|
await Promise.all(i);
|
|
@@ -998,16 +1081,16 @@ class Jt {
|
|
|
998
1081
|
this.previousBitrates.set(e, s);
|
|
999
1082
|
}
|
|
1000
1083
|
}
|
|
1001
|
-
var
|
|
1002
|
-
class
|
|
1084
|
+
var Be = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(Be || {});
|
|
1085
|
+
class on {
|
|
1003
1086
|
events;
|
|
1004
1087
|
rtcSession;
|
|
1005
1088
|
disposers = /* @__PURE__ */ new Set();
|
|
1006
1089
|
onReset;
|
|
1007
1090
|
// Менеджер состояния битрейта
|
|
1008
|
-
bitrateStateManager = new
|
|
1091
|
+
bitrateStateManager = new an();
|
|
1009
1092
|
constructor(e, { onReset: t }) {
|
|
1010
|
-
this.events = e, this.onReset = t, e.on(
|
|
1093
|
+
this.events = e, this.onReset = t, e.on(E.FAILED, this.handleEnded), e.on(E.ENDED, this.handleEnded);
|
|
1011
1094
|
}
|
|
1012
1095
|
get connection() {
|
|
1013
1096
|
return this.rtcSession?.connection;
|
|
@@ -1031,14 +1114,14 @@ class jt {
|
|
|
1031
1114
|
contentHint: l,
|
|
1032
1115
|
offerToReceiveAudio: T = !0,
|
|
1033
1116
|
offerToReceiveVideo: g = !0,
|
|
1034
|
-
degradationPreference:
|
|
1035
|
-
sendEncodings:
|
|
1117
|
+
degradationPreference: S,
|
|
1118
|
+
sendEncodings: R,
|
|
1036
1119
|
onAddedTransceiver: D
|
|
1037
|
-
}) => new Promise((
|
|
1038
|
-
this.handleCall().then(
|
|
1120
|
+
}) => new Promise((I, U) => {
|
|
1121
|
+
this.handleCall().then(I).catch((B) => {
|
|
1039
1122
|
U(B);
|
|
1040
1123
|
}), this.rtcSession = e.call(t(s), {
|
|
1041
|
-
mediaStream:
|
|
1124
|
+
mediaStream: Y(i, {
|
|
1042
1125
|
directionVideo: o,
|
|
1043
1126
|
directionAudio: c,
|
|
1044
1127
|
contentHint: l
|
|
@@ -1057,8 +1140,8 @@ class jt {
|
|
|
1057
1140
|
extraHeaders: r,
|
|
1058
1141
|
directionVideo: o,
|
|
1059
1142
|
directionAudio: c,
|
|
1060
|
-
degradationPreference:
|
|
1061
|
-
sendEncodings:
|
|
1143
|
+
degradationPreference: S,
|
|
1144
|
+
sendEncodings: R,
|
|
1062
1145
|
onAddedTransceiver: D
|
|
1063
1146
|
});
|
|
1064
1147
|
});
|
|
@@ -1066,7 +1149,7 @@ class jt {
|
|
|
1066
1149
|
const { rtcSession: e } = this;
|
|
1067
1150
|
if (e && !e.isEnded())
|
|
1068
1151
|
return e.terminateAsync({
|
|
1069
|
-
cause:
|
|
1152
|
+
cause: Be.CANCELED
|
|
1070
1153
|
}).finally(() => {
|
|
1071
1154
|
this.reset();
|
|
1072
1155
|
});
|
|
@@ -1083,11 +1166,11 @@ class jt {
|
|
|
1083
1166
|
contentHint: l,
|
|
1084
1167
|
degradationPreference: T,
|
|
1085
1168
|
sendEncodings: g,
|
|
1086
|
-
onAddedTransceiver:
|
|
1087
|
-
}) => new Promise((
|
|
1169
|
+
onAddedTransceiver: S
|
|
1170
|
+
}) => new Promise((R, D) => {
|
|
1088
1171
|
try {
|
|
1089
|
-
this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(
|
|
1090
|
-
D(
|
|
1172
|
+
this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(R).catch((I) => {
|
|
1173
|
+
D(I);
|
|
1091
1174
|
}), e.answer({
|
|
1092
1175
|
pcConfig: {
|
|
1093
1176
|
iceServers: i
|
|
@@ -1096,7 +1179,7 @@ class jt {
|
|
|
1096
1179
|
offerToReceiveAudio: o,
|
|
1097
1180
|
offerToReceiveVideo: c
|
|
1098
1181
|
},
|
|
1099
|
-
mediaStream:
|
|
1182
|
+
mediaStream: Y(t, {
|
|
1100
1183
|
directionVideo: r,
|
|
1101
1184
|
directionAudio: a,
|
|
1102
1185
|
contentHint: l
|
|
@@ -1106,16 +1189,16 @@ class jt {
|
|
|
1106
1189
|
directionAudio: a,
|
|
1107
1190
|
degradationPreference: T,
|
|
1108
1191
|
sendEncodings: g,
|
|
1109
|
-
onAddedTransceiver:
|
|
1192
|
+
onAddedTransceiver: S
|
|
1110
1193
|
});
|
|
1111
|
-
} catch (
|
|
1112
|
-
D(
|
|
1194
|
+
} catch (I) {
|
|
1195
|
+
D(I);
|
|
1113
1196
|
}
|
|
1114
1197
|
});
|
|
1115
1198
|
async replaceMediaStream(e, t) {
|
|
1116
1199
|
if (!this.rtcSession)
|
|
1117
1200
|
throw new Error("No rtcSession established");
|
|
1118
|
-
const { contentHint: s } = t ?? {}, i =
|
|
1201
|
+
const { contentHint: s } = t ?? {}, i = Y(e, { contentHint: s });
|
|
1119
1202
|
if (i === void 0)
|
|
1120
1203
|
throw new Error("No preparedMediaStream");
|
|
1121
1204
|
return this.rtcSession.replaceMediaStream(i, t);
|
|
@@ -1131,7 +1214,7 @@ class jt {
|
|
|
1131
1214
|
*/
|
|
1132
1215
|
setMinBitrateForSenders(e = "all") {
|
|
1133
1216
|
this.bitrateStateManager.setMinBitrateForSenders(this.connection, e).catch((t) => {
|
|
1134
|
-
|
|
1217
|
+
ue("MCUSession.setMinBitrateForSenders", t);
|
|
1135
1218
|
});
|
|
1136
1219
|
}
|
|
1137
1220
|
/**
|
|
@@ -1140,38 +1223,38 @@ class jt {
|
|
|
1140
1223
|
*/
|
|
1141
1224
|
restoreBitrateForSenders(e = "all") {
|
|
1142
1225
|
this.bitrateStateManager.restoreBitrateForSenders(this.connection, e).catch((t) => {
|
|
1143
|
-
|
|
1226
|
+
ue("MCUSession.restoreBitrateForSenders", t);
|
|
1144
1227
|
});
|
|
1145
1228
|
}
|
|
1146
1229
|
handleCall = async () => new Promise((e, t) => {
|
|
1147
1230
|
const s = () => {
|
|
1148
|
-
this.events.on(
|
|
1231
|
+
this.events.on(E.PEER_CONNECTION, l), this.events.on(E.CONFIRMED, T);
|
|
1149
1232
|
}, i = () => {
|
|
1150
|
-
this.events.off(
|
|
1233
|
+
this.events.off(E.PEER_CONNECTION, l), this.events.off(E.CONFIRMED, T);
|
|
1151
1234
|
}, r = () => {
|
|
1152
|
-
this.events.on(
|
|
1235
|
+
this.events.on(E.FAILED, o), this.events.on(E.ENDED, o);
|
|
1153
1236
|
}, a = () => {
|
|
1154
|
-
this.events.off(
|
|
1237
|
+
this.events.off(E.FAILED, o), this.events.off(E.ENDED, o);
|
|
1155
1238
|
}, o = (g) => {
|
|
1156
1239
|
i(), a(), t(g);
|
|
1157
1240
|
};
|
|
1158
1241
|
let c;
|
|
1159
1242
|
const l = ({ peerconnection: g }) => {
|
|
1160
1243
|
c = g;
|
|
1161
|
-
const
|
|
1162
|
-
this.events.trigger(
|
|
1244
|
+
const S = (R) => {
|
|
1245
|
+
this.events.trigger(E.PEER_CONNECTION_ONTRACK, R);
|
|
1163
1246
|
};
|
|
1164
|
-
g.addEventListener("track",
|
|
1165
|
-
g.removeEventListener("track",
|
|
1247
|
+
g.addEventListener("track", S), this.disposers.add(() => {
|
|
1248
|
+
g.removeEventListener("track", S);
|
|
1166
1249
|
});
|
|
1167
1250
|
}, T = () => {
|
|
1168
|
-
c !== void 0 && this.events.trigger(
|
|
1251
|
+
c !== void 0 && this.events.trigger(E.PEER_CONNECTION_CONFIRMED, c), i(), a(), e(c);
|
|
1169
1252
|
};
|
|
1170
1253
|
s(), r();
|
|
1171
1254
|
});
|
|
1172
1255
|
subscribeToSessionEvents(e) {
|
|
1173
1256
|
this.events.eachTriggers((t, s) => {
|
|
1174
|
-
const i =
|
|
1257
|
+
const i = Fe.find((r) => r === s);
|
|
1175
1258
|
i && (e.on(i, t), this.disposers.add(() => {
|
|
1176
1259
|
e.off(i, t);
|
|
1177
1260
|
}));
|
|
@@ -1184,14 +1267,14 @@ class jt {
|
|
|
1184
1267
|
}
|
|
1185
1268
|
handleEnded = (e) => {
|
|
1186
1269
|
const { originator: t } = e;
|
|
1187
|
-
t === "remote" && this.events.trigger(
|
|
1270
|
+
t === "remote" && this.events.trigger(E.ENDED_FROM_SERVER, e), this.reset();
|
|
1188
1271
|
};
|
|
1189
1272
|
reset = () => {
|
|
1190
1273
|
delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.bitrateStateManager.clearAll(), this.onReset();
|
|
1191
1274
|
};
|
|
1192
1275
|
}
|
|
1193
|
-
const
|
|
1194
|
-
class
|
|
1276
|
+
const Te = (n) => n === "auto" ? "high" : n, cn = 10, dn = 100;
|
|
1277
|
+
class hn {
|
|
1195
1278
|
cancelableSendOfferWithRepeatedCalls;
|
|
1196
1279
|
config;
|
|
1197
1280
|
tools;
|
|
@@ -1202,7 +1285,7 @@ class Zt {
|
|
|
1202
1285
|
this.config = {
|
|
1203
1286
|
...e,
|
|
1204
1287
|
quality: s,
|
|
1205
|
-
effectiveQuality:
|
|
1288
|
+
effectiveQuality: Te(s)
|
|
1206
1289
|
}, this.tools = t, this.connection = new RTCPeerConnection(e.pcConfig), this.addTransceivers();
|
|
1207
1290
|
}
|
|
1208
1291
|
get settings() {
|
|
@@ -1220,7 +1303,7 @@ class Zt {
|
|
|
1220
1303
|
async setQuality(e) {
|
|
1221
1304
|
if (!this.lastCallParams)
|
|
1222
1305
|
return !1;
|
|
1223
|
-
const t = this.config.effectiveQuality, s = this.config.quality, i =
|
|
1306
|
+
const t = this.config.effectiveQuality, s = this.config.quality, i = Te(e);
|
|
1224
1307
|
return e === s && i === t ? !1 : (this.config.quality = e, this.config.effectiveQuality = i, i !== t && await this.renegotiate(this.lastCallParams), !0);
|
|
1225
1308
|
}
|
|
1226
1309
|
async applyQuality(e) {
|
|
@@ -1245,11 +1328,11 @@ class Zt {
|
|
|
1245
1328
|
},
|
|
1246
1329
|
s
|
|
1247
1330
|
), r = (o) => !(o instanceof Error);
|
|
1248
|
-
this.cancelableSendOfferWithRepeatedCalls =
|
|
1331
|
+
this.cancelableSendOfferWithRepeatedCalls = ce({
|
|
1249
1332
|
targetFunction: i,
|
|
1250
1333
|
isComplete: r,
|
|
1251
|
-
callLimit:
|
|
1252
|
-
delay:
|
|
1334
|
+
callLimit: cn,
|
|
1335
|
+
delay: dn,
|
|
1253
1336
|
isRejectAsValid: !0,
|
|
1254
1337
|
isCheckBeforeCall: !1
|
|
1255
1338
|
});
|
|
@@ -1287,18 +1370,18 @@ class Zt {
|
|
|
1287
1370
|
this.cancelableSendOfferWithRepeatedCalls?.cancel();
|
|
1288
1371
|
}
|
|
1289
1372
|
}
|
|
1290
|
-
const
|
|
1291
|
-
const t =
|
|
1373
|
+
const $e = (n) => n.getSettings(), ln = (n, e) => {
|
|
1374
|
+
const t = $e(n);
|
|
1292
1375
|
let s = e;
|
|
1293
1376
|
s ??= n.label;
|
|
1294
1377
|
let i = t?.msid;
|
|
1295
1378
|
return i ??= s, i ??= n.id, i;
|
|
1296
|
-
},
|
|
1297
|
-
const t =
|
|
1379
|
+
}, un = (n, e) => {
|
|
1380
|
+
const t = $e(n);
|
|
1298
1381
|
let s = e;
|
|
1299
1382
|
return s ??= t?.msid, s ??= n.label, (s && s.length > 0 ? s : void 0) ?? n.id;
|
|
1300
1383
|
};
|
|
1301
|
-
class
|
|
1384
|
+
class Ee {
|
|
1302
1385
|
participantGroups = /* @__PURE__ */ new Map();
|
|
1303
1386
|
trackToGroup = /* @__PURE__ */ new Map();
|
|
1304
1387
|
trackDisposers = /* @__PURE__ */ new Map();
|
|
@@ -1315,7 +1398,7 @@ class ge {
|
|
|
1315
1398
|
onRemoved: t,
|
|
1316
1399
|
streamHint: s
|
|
1317
1400
|
} = {}) {
|
|
1318
|
-
const i =
|
|
1401
|
+
const i = un(e, s), r = ln(e, s);
|
|
1319
1402
|
if (this.trackToGroup.has(e.id))
|
|
1320
1403
|
return { isAddedTrack: !1, isAddedStream: !1 };
|
|
1321
1404
|
const a = this.getParticipantGroups(i), o = a.get(r), c = !o;
|
|
@@ -1383,16 +1466,16 @@ class ge {
|
|
|
1383
1466
|
return this.participantGroups.set(e, s), s;
|
|
1384
1467
|
}
|
|
1385
1468
|
}
|
|
1386
|
-
const
|
|
1469
|
+
const te = {
|
|
1387
1470
|
type: "participant"
|
|
1388
|
-
},
|
|
1471
|
+
}, gn = {
|
|
1389
1472
|
type: "spectator_synthetic"
|
|
1390
|
-
},
|
|
1473
|
+
}, Tn = (n) => ({
|
|
1391
1474
|
type: "spectator",
|
|
1392
1475
|
recvParams: n
|
|
1393
1476
|
});
|
|
1394
1477
|
class p {
|
|
1395
|
-
role =
|
|
1478
|
+
role = te;
|
|
1396
1479
|
onRoleChanged;
|
|
1397
1480
|
constructor(e) {
|
|
1398
1481
|
this.onRoleChanged = e;
|
|
@@ -1424,13 +1507,13 @@ class p {
|
|
|
1424
1507
|
return this.role;
|
|
1425
1508
|
}
|
|
1426
1509
|
setCallRoleParticipant() {
|
|
1427
|
-
this.changeRole(
|
|
1510
|
+
this.changeRole(te);
|
|
1428
1511
|
}
|
|
1429
1512
|
setCallRoleSpectatorSynthetic() {
|
|
1430
|
-
this.changeRole(
|
|
1513
|
+
this.changeRole(gn);
|
|
1431
1514
|
}
|
|
1432
1515
|
setCallRoleSpectator(e) {
|
|
1433
|
-
this.changeRole(
|
|
1516
|
+
this.changeRole(Tn(e));
|
|
1434
1517
|
}
|
|
1435
1518
|
changeRole(e) {
|
|
1436
1519
|
const t = this.role;
|
|
@@ -1441,7 +1524,7 @@ class p {
|
|
|
1441
1524
|
p.hasSpectator(e) && p.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
|
|
1442
1525
|
}
|
|
1443
1526
|
reset() {
|
|
1444
|
-
this.role =
|
|
1527
|
+
this.role = te;
|
|
1445
1528
|
}
|
|
1446
1529
|
hasParticipant() {
|
|
1447
1530
|
return p.hasParticipant(this.role);
|
|
@@ -1457,13 +1540,13 @@ class p {
|
|
|
1457
1540
|
this.role = e, this.onRoleChanged?.({ previous: t, next: e });
|
|
1458
1541
|
}
|
|
1459
1542
|
}
|
|
1460
|
-
const
|
|
1543
|
+
const En = (n, e) => {
|
|
1461
1544
|
if (!n || !e)
|
|
1462
1545
|
return n === e;
|
|
1463
1546
|
const t = n.mainStream?.id, s = e.mainStream?.id, i = n.contentedStream?.id, r = e.contentedStream?.id;
|
|
1464
1547
|
return t === s && i === r;
|
|
1465
1548
|
};
|
|
1466
|
-
class
|
|
1549
|
+
class Sn {
|
|
1467
1550
|
lastEmittedStreams;
|
|
1468
1551
|
/**
|
|
1469
1552
|
* Проверяет, изменились ли streams с последнего сохраненного состояния
|
|
@@ -1471,7 +1554,7 @@ class an {
|
|
|
1471
1554
|
* @returns true, если streams изменились
|
|
1472
1555
|
*/
|
|
1473
1556
|
hasChanged(e) {
|
|
1474
|
-
return !
|
|
1557
|
+
return !En(this.lastEmittedStreams, e);
|
|
1475
1558
|
}
|
|
1476
1559
|
/**
|
|
1477
1560
|
* Сохраняет текущие streams как последнее эмитнутое состояние
|
|
@@ -1494,8 +1577,8 @@ class an {
|
|
|
1494
1577
|
this.lastEmittedStreams = void 0;
|
|
1495
1578
|
}
|
|
1496
1579
|
}
|
|
1497
|
-
const
|
|
1498
|
-
class
|
|
1580
|
+
const mn = "default", pn = "dual", Cn = "content_", Rn = (n) => `${Cn}${n.toLowerCase()}`, Nn = (n) => [...n.getTracks()].some((e) => e.label.includes(pn));
|
|
1581
|
+
class An {
|
|
1499
1582
|
mainRemoteStreamsManager;
|
|
1500
1583
|
recvRemoteStreamsManager;
|
|
1501
1584
|
constructor(e, t) {
|
|
@@ -1512,7 +1595,7 @@ class un {
|
|
|
1512
1595
|
}) {
|
|
1513
1596
|
const t = this.mainRemoteStreamsManager;
|
|
1514
1597
|
return { manager: t, getRemoteStreams: () => {
|
|
1515
|
-
const i = t.getStreams(), r = i.find((o) => !
|
|
1598
|
+
const i = t.getStreams(), r = i.find((o) => !Nn(o)), a = e.isAvailable ? i.find((o) => o !== r) : void 0;
|
|
1516
1599
|
return { mainStream: r, contentedStream: a };
|
|
1517
1600
|
} };
|
|
1518
1601
|
}
|
|
@@ -1521,7 +1604,7 @@ class un {
|
|
|
1521
1604
|
}) {
|
|
1522
1605
|
const t = this.recvRemoteStreamsManager;
|
|
1523
1606
|
return { manager: t, getRemoteStreams: () => {
|
|
1524
|
-
const r = t.getStreams(
|
|
1607
|
+
const r = t.getStreams(mn)[0], a = this.getRecvRemoteContentedStream({ stateInfo: e });
|
|
1525
1608
|
return { mainStream: r, contentedStream: a };
|
|
1526
1609
|
} };
|
|
1527
1610
|
}
|
|
@@ -1530,12 +1613,12 @@ class un {
|
|
|
1530
1613
|
}) {
|
|
1531
1614
|
if (!e.isAvailable || e.codec === void 0)
|
|
1532
1615
|
return;
|
|
1533
|
-
const t =
|
|
1616
|
+
const t = Rn(e.codec);
|
|
1534
1617
|
return this.recvRemoteStreamsManager.getStreams(t)[0];
|
|
1535
1618
|
}
|
|
1536
1619
|
}
|
|
1537
|
-
const
|
|
1538
|
-
function
|
|
1620
|
+
const Se = (n) => n.streams[0]?.id;
|
|
1621
|
+
function In(n) {
|
|
1539
1622
|
const { inRoomContext: e } = n;
|
|
1540
1623
|
if (e === void 0)
|
|
1541
1624
|
throw new Error(
|
|
@@ -1543,13 +1626,13 @@ function gn(n) {
|
|
|
1543
1626
|
);
|
|
1544
1627
|
return e.token;
|
|
1545
1628
|
}
|
|
1546
|
-
class
|
|
1629
|
+
class vn {
|
|
1547
1630
|
events;
|
|
1548
1631
|
stateMachine;
|
|
1549
1632
|
isPendingCall = !1;
|
|
1550
1633
|
isPendingAnswer = !1;
|
|
1551
|
-
mainRemoteStreamsManager = new
|
|
1552
|
-
recvRemoteStreamsManager = new
|
|
1634
|
+
mainRemoteStreamsManager = new Ee();
|
|
1635
|
+
recvRemoteStreamsManager = new Ee();
|
|
1553
1636
|
streamsManagerProvider;
|
|
1554
1637
|
contentedStreamManager;
|
|
1555
1638
|
roleManager = new p((e) => {
|
|
@@ -1559,17 +1642,17 @@ class Tn {
|
|
|
1559
1642
|
recvSession;
|
|
1560
1643
|
disposeRecvSessionTrackListener;
|
|
1561
1644
|
deferredStartRecvSessionRunner;
|
|
1562
|
-
streamsChangeTracker = new
|
|
1645
|
+
streamsChangeTracker = new Sn();
|
|
1563
1646
|
constructor(e) {
|
|
1564
|
-
this.contentedStreamManager = e, this.events =
|
|
1647
|
+
this.contentedStreamManager = e, this.events = en(), this.mcuSession = new on(this.events, { onReset: this.reset }), this.stateMachine = new Kt(this.events), this.streamsManagerProvider = new An(
|
|
1565
1648
|
this.mainRemoteStreamsManager,
|
|
1566
1649
|
this.recvRemoteStreamsManager
|
|
1567
|
-
), this.deferredStartRecvSessionRunner = new
|
|
1650
|
+
), this.deferredStartRecvSessionRunner = new xt({
|
|
1568
1651
|
subscribe: (t) => this.stateMachine.onStateChange(t),
|
|
1569
|
-
isReady: (t) => t ===
|
|
1570
|
-
isCancelled: (t) => t ===
|
|
1652
|
+
isReady: (t) => t === re.IN_ROOM,
|
|
1653
|
+
isCancelled: (t) => t === re.IDLE,
|
|
1571
1654
|
onExecute: (t) => {
|
|
1572
|
-
const s =
|
|
1655
|
+
const s = In(this.stateMachine);
|
|
1573
1656
|
this.startRecvSession(t.audioId, {
|
|
1574
1657
|
sendOffer: t.sendOffer,
|
|
1575
1658
|
token: s
|
|
@@ -1586,6 +1669,15 @@ class Tn {
|
|
|
1586
1669
|
get isCallActive() {
|
|
1587
1670
|
return this.mcuSession.isCallActive;
|
|
1588
1671
|
}
|
|
1672
|
+
get number() {
|
|
1673
|
+
return this.stateMachine.number;
|
|
1674
|
+
}
|
|
1675
|
+
get isCallInitiator() {
|
|
1676
|
+
return this.stateMachine.isCallInitiator;
|
|
1677
|
+
}
|
|
1678
|
+
get isDirectP2PRoom() {
|
|
1679
|
+
return this.stateMachine.isDirectP2PRoom;
|
|
1680
|
+
}
|
|
1589
1681
|
// For testing purposes
|
|
1590
1682
|
getStreamsManagerProvider() {
|
|
1591
1683
|
return this.streamsManagerProvider;
|
|
@@ -1615,7 +1707,7 @@ class Tn {
|
|
|
1615
1707
|
subscribeToApiEvents(e) {
|
|
1616
1708
|
this.stateMachine.subscribeToApiEvents(e.events);
|
|
1617
1709
|
}
|
|
1618
|
-
startCall = async (e, t, s) => (this.isPendingCall = !0, this.events.emit(
|
|
1710
|
+
startCall = async (e, t, s) => (this.isPendingCall = !0, this.events.emit(E.START_CALL, {
|
|
1619
1711
|
number: s.number,
|
|
1620
1712
|
answer: !1
|
|
1621
1713
|
}), this.mcuSession.startCall(e, t, s).finally(() => {
|
|
@@ -1630,7 +1722,7 @@ class Tn {
|
|
|
1630
1722
|
answerToIncomingCall = async (e, t) => {
|
|
1631
1723
|
this.isPendingAnswer = !0;
|
|
1632
1724
|
const s = e();
|
|
1633
|
-
return this.events.emit(
|
|
1725
|
+
return this.events.emit(E.START_CALL, {
|
|
1634
1726
|
answer: !0,
|
|
1635
1727
|
number: s.remote_identity.uri.user
|
|
1636
1728
|
}), this.mcuSession.answerToIncomingCall(s, t).finally(() => {
|
|
@@ -1679,17 +1771,23 @@ class Tn {
|
|
|
1679
1771
|
if (!this.roleManager.hasSpectator() || !t)
|
|
1680
1772
|
return !1;
|
|
1681
1773
|
const s = t.getQuality(), i = await t.applyQuality(e);
|
|
1682
|
-
return i.applied && this.events.trigger(
|
|
1774
|
+
return i.applied && this.events.trigger(E.RECV_QUALITY_CHANGED, {
|
|
1683
1775
|
previousQuality: s,
|
|
1684
1776
|
quality: e,
|
|
1685
1777
|
effectiveQuality: i.effectiveQuality
|
|
1686
1778
|
}), i.applied;
|
|
1687
1779
|
}
|
|
1780
|
+
async failed(e, t) {
|
|
1781
|
+
this.emitFailedCall(e, t), await this.endCall();
|
|
1782
|
+
}
|
|
1783
|
+
emitFailedCall(e, t) {
|
|
1784
|
+
this.events.trigger(E.FAILED, { message: e, cause: t, originator: "local" });
|
|
1785
|
+
}
|
|
1688
1786
|
reset = () => {
|
|
1689
1787
|
this.mainRemoteStreamsManager.reset(), this.roleManager.reset(), this.recvRemoteStreamsManager.reset(), this.stopRecvSession(), this.deferredStartRecvSessionRunner.cancel(), this.streamsChangeTracker.reset();
|
|
1690
1788
|
};
|
|
1691
1789
|
subscribeCallStatusChange() {
|
|
1692
|
-
const { ACCEPTED: e, CONFIRMED: t, ENDED: s, FAILED: i } =
|
|
1790
|
+
const { ACCEPTED: e, CONFIRMED: t, ENDED: s, FAILED: i } = E, r = this.createCallStatusChangeListener();
|
|
1693
1791
|
this.onRace([e, t, s, i], r);
|
|
1694
1792
|
}
|
|
1695
1793
|
/** Хранит prev/next и эмитит CALL_STATUS_CHANGED только при реальном изменении. */
|
|
@@ -1697,12 +1795,12 @@ class Tn {
|
|
|
1697
1795
|
let e = this.isCallActive;
|
|
1698
1796
|
return () => {
|
|
1699
1797
|
const t = this.isCallActive;
|
|
1700
|
-
t !== e && this.events.trigger(
|
|
1798
|
+
t !== e && this.events.trigger(E.CALL_STATUS_CHANGED, { isCallActive: t }), e = t;
|
|
1701
1799
|
};
|
|
1702
1800
|
}
|
|
1703
1801
|
subscribeMcuRemoteTrackEvents() {
|
|
1704
|
-
this.on(
|
|
1705
|
-
this.addRemoteTrack(this.mainRemoteStreamsManager, e.track,
|
|
1802
|
+
this.on(E.PEER_CONNECTION_ONTRACK, (e) => {
|
|
1803
|
+
this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, Se(e));
|
|
1706
1804
|
});
|
|
1707
1805
|
}
|
|
1708
1806
|
addRemoteTrack(e, t, s) {
|
|
@@ -1737,7 +1835,7 @@ class Tn {
|
|
|
1737
1835
|
this.emitEventChangedRemoteTracks(c, t, { trackId: s, participantId: i }), (a || r) && this.emitEventChangedRemoteStreams(c);
|
|
1738
1836
|
}
|
|
1739
1837
|
emitEventChangedRemoteTracks(e, t, { trackId: s, participantId: i }) {
|
|
1740
|
-
this.events.trigger(
|
|
1838
|
+
this.events.trigger(E.REMOTE_TRACKS_CHANGED, {
|
|
1741
1839
|
streams: e,
|
|
1742
1840
|
changeType: t,
|
|
1743
1841
|
trackId: s,
|
|
@@ -1748,7 +1846,7 @@ class Tn {
|
|
|
1748
1846
|
this.emitEventChangedRemoteStreams(this.getRemoteStreams());
|
|
1749
1847
|
};
|
|
1750
1848
|
emitEventChangedRemoteStreams(e) {
|
|
1751
|
-
this.streamsChangeTracker.hasChanged(e) && (this.streamsChangeTracker.updateLastEmittedStreams(e), this.events.trigger(
|
|
1849
|
+
this.streamsChangeTracker.hasChanged(e) && (this.streamsChangeTracker.updateLastEmittedStreams(e), this.events.trigger(E.REMOTE_STREAMS_CHANGED, { streams: e }));
|
|
1752
1850
|
}
|
|
1753
1851
|
getActiveStreamsManagerTools() {
|
|
1754
1852
|
return this.streamsManagerProvider.getActiveStreamsManagerTools({
|
|
@@ -1758,7 +1856,7 @@ class Tn {
|
|
|
1758
1856
|
}
|
|
1759
1857
|
attachRecvSessionTracks(e) {
|
|
1760
1858
|
const { peerConnection: t } = e, s = (i) => {
|
|
1761
|
-
this.addRemoteTrack(this.recvRemoteStreamsManager, i.track,
|
|
1859
|
+
this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, Se(i));
|
|
1762
1860
|
};
|
|
1763
1861
|
t.addEventListener("track", s), this.disposeRecvSessionTrackListener = () => {
|
|
1764
1862
|
t.removeEventListener("track", s);
|
|
@@ -1771,7 +1869,7 @@ class Tn {
|
|
|
1771
1869
|
this.stopRecvSession();
|
|
1772
1870
|
const r = {
|
|
1773
1871
|
audioChannel: e
|
|
1774
|
-
}, a = new
|
|
1872
|
+
}, a = new hn(r, { sendOffer: t });
|
|
1775
1873
|
this.recvSession = a, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(a), a.call({ conferenceNumber: i, token: s }).then(() => {
|
|
1776
1874
|
this.events.emit("recv-session-started");
|
|
1777
1875
|
}).catch(() => {
|
|
@@ -1808,16 +1906,16 @@ class Tn {
|
|
|
1808
1906
|
return this.mcuSession.renegotiate();
|
|
1809
1907
|
}
|
|
1810
1908
|
}
|
|
1811
|
-
var
|
|
1812
|
-
const
|
|
1909
|
+
var L = /* @__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))(L || {});
|
|
1910
|
+
const Ge = [
|
|
1813
1911
|
"presentation:start",
|
|
1814
1912
|
"presentation:started",
|
|
1815
1913
|
"presentation:end",
|
|
1816
1914
|
"presentation:ended",
|
|
1817
1915
|
"presentation:failed"
|
|
1818
|
-
],
|
|
1819
|
-
var
|
|
1820
|
-
const
|
|
1916
|
+
], fn = () => new M(Ge);
|
|
1917
|
+
var Mn = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(Mn || {});
|
|
1918
|
+
const _n = V({
|
|
1821
1919
|
types: {
|
|
1822
1920
|
context: {},
|
|
1823
1921
|
events: {}
|
|
@@ -1829,10 +1927,10 @@ const mn = V({
|
|
|
1829
1927
|
logStateChange: (n, e) => {
|
|
1830
1928
|
d("PresentationStateMachine state changed", e.state);
|
|
1831
1929
|
},
|
|
1832
|
-
setError:
|
|
1930
|
+
setError: v(({ event: n }) => "error" in n && n.error !== void 0 ? {
|
|
1833
1931
|
lastError: n.error instanceof Error ? n.error : new Error(JSON.stringify(n.error))
|
|
1834
1932
|
} : { lastError: void 0 }),
|
|
1835
|
-
clearError:
|
|
1933
|
+
clearError: v({ lastError: void 0 })
|
|
1836
1934
|
}
|
|
1837
1935
|
}).createMachine({
|
|
1838
1936
|
id: "presentation",
|
|
@@ -2142,9 +2240,9 @@ const mn = V({
|
|
|
2142
2240
|
}
|
|
2143
2241
|
}
|
|
2144
2242
|
});
|
|
2145
|
-
class
|
|
2243
|
+
class bn extends x {
|
|
2146
2244
|
constructor(e) {
|
|
2147
|
-
super(
|
|
2245
|
+
super(_n), this.subscribeCallEvents(e);
|
|
2148
2246
|
}
|
|
2149
2247
|
get isIdle() {
|
|
2150
2248
|
return this.state === "presentation:idle";
|
|
@@ -2184,38 +2282,38 @@ class pn extends x {
|
|
|
2184
2282
|
}
|
|
2185
2283
|
subscribeCallEvents(e) {
|
|
2186
2284
|
this.addSubscription(
|
|
2187
|
-
e.on(
|
|
2285
|
+
e.on(E.START_PRESENTATION, () => {
|
|
2188
2286
|
this.send({ type: "SCREEN.STARTING" });
|
|
2189
2287
|
})
|
|
2190
2288
|
), this.addSubscription(
|
|
2191
|
-
e.on(
|
|
2289
|
+
e.on(E.STARTED_PRESENTATION, () => {
|
|
2192
2290
|
this.send({ type: "SCREEN.STARTED" });
|
|
2193
2291
|
})
|
|
2194
2292
|
), this.addSubscription(
|
|
2195
|
-
e.on(
|
|
2293
|
+
e.on(E.END_PRESENTATION, () => {
|
|
2196
2294
|
this.send({ type: "SCREEN.ENDING" });
|
|
2197
2295
|
})
|
|
2198
2296
|
), this.addSubscription(
|
|
2199
|
-
e.on(
|
|
2297
|
+
e.on(E.ENDED_PRESENTATION, () => {
|
|
2200
2298
|
this.send({ type: "SCREEN.ENDED" });
|
|
2201
2299
|
})
|
|
2202
2300
|
), this.addSubscription(
|
|
2203
|
-
e.on(
|
|
2301
|
+
e.on(E.FAILED_PRESENTATION, (t) => {
|
|
2204
2302
|
this.send({ type: "SCREEN.FAILED", error: t });
|
|
2205
2303
|
})
|
|
2206
2304
|
), this.addSubscription(
|
|
2207
|
-
e.on(
|
|
2305
|
+
e.on(E.ENDED, () => {
|
|
2208
2306
|
this.send({ type: "CALL.ENDED" });
|
|
2209
2307
|
})
|
|
2210
2308
|
), this.addSubscription(
|
|
2211
|
-
e.on(
|
|
2309
|
+
e.on(E.FAILED, (t) => {
|
|
2212
2310
|
this.send({ type: "CALL.FAILED", error: t });
|
|
2213
2311
|
})
|
|
2214
2312
|
);
|
|
2215
2313
|
}
|
|
2216
2314
|
}
|
|
2217
|
-
const
|
|
2218
|
-
class
|
|
2315
|
+
const On = 1, Vi = (n) => ut(n);
|
|
2316
|
+
class Pn {
|
|
2219
2317
|
events;
|
|
2220
2318
|
stateMachine;
|
|
2221
2319
|
promisePendingStartPresentation;
|
|
@@ -2228,7 +2326,7 @@ class Nn {
|
|
|
2228
2326
|
callManager: e,
|
|
2229
2327
|
maxBitrate: t
|
|
2230
2328
|
}) {
|
|
2231
|
-
this.callManager = e, this.maxBitrate = t, this.events =
|
|
2329
|
+
this.callManager = e, this.maxBitrate = t, this.events = fn(), this.stateMachine = new bn(this.callManager.events), this.subscribe();
|
|
2232
2330
|
}
|
|
2233
2331
|
get isPendingPresentation() {
|
|
2234
2332
|
return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
|
|
@@ -2267,8 +2365,8 @@ class Nn {
|
|
|
2267
2365
|
const i = this.callManager.getEstablishedRTCSession();
|
|
2268
2366
|
return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
|
|
2269
2367
|
const a = r instanceof Error ? r : new Error(String(r));
|
|
2270
|
-
throw this.events.trigger(
|
|
2271
|
-
}) : t && this.events.trigger(
|
|
2368
|
+
throw this.events.trigger(L.FAILED_PRESENTATION, a), r;
|
|
2369
|
+
}) : t && this.events.trigger(L.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
|
|
2272
2370
|
this.resetPresentation();
|
|
2273
2371
|
});
|
|
2274
2372
|
}
|
|
@@ -2307,15 +2405,15 @@ class Nn {
|
|
|
2307
2405
|
}
|
|
2308
2406
|
subscribe() {
|
|
2309
2407
|
this.callManager.on("presentation:start", (e) => {
|
|
2310
|
-
this.events.trigger(
|
|
2408
|
+
this.events.trigger(L.START_PRESENTATION, e);
|
|
2311
2409
|
}), this.callManager.on("presentation:started", (e) => {
|
|
2312
|
-
this.events.trigger(
|
|
2410
|
+
this.events.trigger(L.STARTED_PRESENTATION, e);
|
|
2313
2411
|
}), this.callManager.on("presentation:end", (e) => {
|
|
2314
|
-
this.events.trigger(
|
|
2412
|
+
this.events.trigger(L.END_PRESENTATION, e);
|
|
2315
2413
|
}), this.callManager.on("presentation:ended", (e) => {
|
|
2316
|
-
this.events.trigger(
|
|
2414
|
+
this.events.trigger(L.ENDED_PRESENTATION, e);
|
|
2317
2415
|
}), this.callManager.on("presentation:failed", (e) => {
|
|
2318
|
-
this.events.trigger(
|
|
2416
|
+
this.events.trigger(L.FAILED_PRESENTATION, e);
|
|
2319
2417
|
}), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
|
|
2320
2418
|
}
|
|
2321
2419
|
async sendPresentationWithDuplicatedCalls(e, {
|
|
@@ -2323,7 +2421,7 @@ class Nn {
|
|
|
2323
2421
|
stream: s,
|
|
2324
2422
|
presentationOptions: i,
|
|
2325
2423
|
options: r = {
|
|
2326
|
-
callLimit:
|
|
2424
|
+
callLimit: On
|
|
2327
2425
|
}
|
|
2328
2426
|
}) {
|
|
2329
2427
|
const a = async () => this.sendPresentation(
|
|
@@ -2332,7 +2430,7 @@ class Nn {
|
|
|
2332
2430
|
s,
|
|
2333
2431
|
i
|
|
2334
2432
|
), o = () => !!this.streamPresentationCurrent;
|
|
2335
|
-
return this.cancelableSendPresentationWithRepeatedCalls =
|
|
2433
|
+
return this.cancelableSendPresentationWithRepeatedCalls = ce({
|
|
2336
2434
|
targetFunction: a,
|
|
2337
2435
|
isComplete: o,
|
|
2338
2436
|
isRejectAsValid: !0,
|
|
@@ -2347,7 +2445,7 @@ class Nn {
|
|
|
2347
2445
|
sendEncodings: o,
|
|
2348
2446
|
onAddedTransceiver: c
|
|
2349
2447
|
}) {
|
|
2350
|
-
const l =
|
|
2448
|
+
const l = Y(s, { contentHint: r });
|
|
2351
2449
|
if (l === void 0)
|
|
2352
2450
|
throw new Error("No streamPresentationTarget");
|
|
2353
2451
|
this.streamPresentationCurrent = l;
|
|
@@ -2357,8 +2455,8 @@ class Nn {
|
|
|
2357
2455
|
onAddedTransceiver: c
|
|
2358
2456
|
})).then(this.setMaxBitrate).then(() => s).catch((g) => {
|
|
2359
2457
|
this.removeStreamPresentationCurrent();
|
|
2360
|
-
const
|
|
2361
|
-
throw this.events.trigger(
|
|
2458
|
+
const S = g instanceof Error ? g : new Error(String(g));
|
|
2459
|
+
throw this.events.trigger(L.FAILED_PRESENTATION, S), g;
|
|
2362
2460
|
});
|
|
2363
2461
|
return this.promisePendingStartPresentation = T, T.finally(() => {
|
|
2364
2462
|
this.promisePendingStartPresentation = void 0;
|
|
@@ -2369,7 +2467,7 @@ class Nn {
|
|
|
2369
2467
|
if (!e || !t || s === void 0)
|
|
2370
2468
|
return;
|
|
2371
2469
|
const i = e.getSenders();
|
|
2372
|
-
await
|
|
2470
|
+
await Vt(i, t, s);
|
|
2373
2471
|
};
|
|
2374
2472
|
getRtcSessionProtected = () => {
|
|
2375
2473
|
const e = this.callManager.getEstablishedRTCSession();
|
|
@@ -2390,7 +2488,7 @@ class Nn {
|
|
|
2390
2488
|
delete this.streamPresentationCurrent;
|
|
2391
2489
|
}
|
|
2392
2490
|
}
|
|
2393
|
-
class
|
|
2491
|
+
class yn {
|
|
2394
2492
|
data;
|
|
2395
2493
|
getUa;
|
|
2396
2494
|
constructor(e) {
|
|
@@ -2477,7 +2575,7 @@ class Rn {
|
|
|
2477
2575
|
}
|
|
2478
2576
|
}
|
|
2479
2577
|
var m = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(m || {});
|
|
2480
|
-
const
|
|
2578
|
+
const qe = [
|
|
2481
2579
|
"connecting",
|
|
2482
2580
|
"connected",
|
|
2483
2581
|
"disconnected",
|
|
@@ -2487,7 +2585,7 @@ const $e = [
|
|
|
2487
2585
|
"registrationFailed",
|
|
2488
2586
|
"newMessage",
|
|
2489
2587
|
"sipEvent"
|
|
2490
|
-
],
|
|
2588
|
+
], Dn = [
|
|
2491
2589
|
"disconnecting",
|
|
2492
2590
|
"connect-started",
|
|
2493
2591
|
"connect-succeeded",
|
|
@@ -2495,12 +2593,12 @@ const $e = [
|
|
|
2495
2593
|
"connect-parameters-resolve-success",
|
|
2496
2594
|
"connect-parameters-resolve-failed",
|
|
2497
2595
|
"connected-with-configuration"
|
|
2498
|
-
],
|
|
2499
|
-
function
|
|
2596
|
+
], Ve = [...qe, ...Dn], Ln = () => new M(Ve);
|
|
2597
|
+
function wn(n) {
|
|
2500
2598
|
return (e) => `sip:${e}@${n}`;
|
|
2501
2599
|
}
|
|
2502
|
-
const
|
|
2503
|
-
class
|
|
2600
|
+
const Un = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, xe = (n) => n.trim().replaceAll(" ", "_"), Fn = Un(1e5, 99999999), kn = 3;
|
|
2601
|
+
class Bn {
|
|
2504
2602
|
cancelableConnectWithRepeatedCalls;
|
|
2505
2603
|
events;
|
|
2506
2604
|
uaFactory;
|
|
@@ -2525,7 +2623,7 @@ class bn {
|
|
|
2525
2623
|
}
|
|
2526
2624
|
let r = !1;
|
|
2527
2625
|
const a = this.getConnectionConfiguration();
|
|
2528
|
-
e !== void 0 && e !== a?.displayName && (r = i.set("display_name",
|
|
2626
|
+
e !== void 0 && e !== a?.displayName && (r = i.set("display_name", xe(e)), this.updateConnectionConfiguration("displayName", e));
|
|
2529
2627
|
const o = r;
|
|
2530
2628
|
o ? t(o) : s(new Error("nothing changed"));
|
|
2531
2629
|
});
|
|
@@ -2543,12 +2641,12 @@ class bn {
|
|
|
2543
2641
|
cancelRequests() {
|
|
2544
2642
|
this.cancelConnectWithRepeatedCalls();
|
|
2545
2643
|
}
|
|
2546
|
-
connectWithDuplicatedCalls = async (e, { callLimit: t =
|
|
2644
|
+
connectWithDuplicatedCalls = async (e, { callLimit: t = kn } = {}) => {
|
|
2547
2645
|
const s = async () => this.connectInner(e), i = (r) => {
|
|
2548
|
-
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), l = r != null && !
|
|
2646
|
+
const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), l = r != null && !pt(r);
|
|
2549
2647
|
return c || l;
|
|
2550
2648
|
};
|
|
2551
|
-
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls =
|
|
2649
|
+
return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ce({
|
|
2552
2650
|
targetFunction: s,
|
|
2553
2651
|
isComplete: i,
|
|
2554
2652
|
callLimit: t,
|
|
@@ -2582,37 +2680,37 @@ class bn {
|
|
|
2582
2680
|
connectionRecoveryMaxInterval: l,
|
|
2583
2681
|
userAgent: T,
|
|
2584
2682
|
displayName: g = "",
|
|
2585
|
-
register:
|
|
2586
|
-
extraHeaders:
|
|
2683
|
+
register: S = !1,
|
|
2684
|
+
extraHeaders: R = []
|
|
2587
2685
|
}) => {
|
|
2588
2686
|
this.stateMachine.startInitUa(), this.getUa() && await this.disconnect();
|
|
2589
|
-
const { ua:
|
|
2687
|
+
const { ua: I, helpers: U } = this.uaFactory.createUAWithConfiguration(
|
|
2590
2688
|
{
|
|
2591
2689
|
user: e,
|
|
2592
2690
|
password: t,
|
|
2593
2691
|
sipServerIp: s,
|
|
2594
2692
|
sipServerUrl: i,
|
|
2595
2693
|
displayName: g,
|
|
2596
|
-
register:
|
|
2694
|
+
register: S,
|
|
2597
2695
|
sessionTimers: a,
|
|
2598
2696
|
registerExpires: o,
|
|
2599
2697
|
connectionRecoveryMinInterval: c,
|
|
2600
2698
|
connectionRecoveryMaxInterval: l,
|
|
2601
2699
|
userAgent: T,
|
|
2602
2700
|
remoteAddress: r,
|
|
2603
|
-
extraHeaders:
|
|
2701
|
+
extraHeaders: R
|
|
2604
2702
|
},
|
|
2605
2703
|
this.events
|
|
2606
|
-
), B =
|
|
2704
|
+
), B = I.configuration.uri.user;
|
|
2607
2705
|
return this.setConnectionConfiguration({
|
|
2608
2706
|
sipServerIp: s,
|
|
2609
2707
|
sipServerUrl: i,
|
|
2610
2708
|
displayName: g,
|
|
2611
2709
|
authorizationUser: B,
|
|
2612
|
-
register:
|
|
2710
|
+
register: S,
|
|
2613
2711
|
user: e,
|
|
2614
2712
|
password: t
|
|
2615
|
-
}), this.setUa(
|
|
2713
|
+
}), this.setUa(I), this.setGetUri(U.getUri), this.setSocket(U.socket), I;
|
|
2616
2714
|
};
|
|
2617
2715
|
start = async () => new Promise((e, t) => {
|
|
2618
2716
|
const s = this.getUa();
|
|
@@ -2624,12 +2722,12 @@ class bn {
|
|
|
2624
2722
|
i = ((c, l) => {
|
|
2625
2723
|
if (this.getConnectionConfiguration()?.register === !0)
|
|
2626
2724
|
return this.registrationManager.subscribeToStartEvents(c, l);
|
|
2627
|
-
const g = m.CONNECTED,
|
|
2628
|
-
return this.events.on(g, c),
|
|
2629
|
-
this.events.on(
|
|
2725
|
+
const g = m.CONNECTED, S = [m.DISCONNECTED];
|
|
2726
|
+
return this.events.on(g, c), S.forEach((R) => {
|
|
2727
|
+
this.events.on(R, l);
|
|
2630
2728
|
}), () => {
|
|
2631
|
-
this.events.off(g, c),
|
|
2632
|
-
this.events.off(
|
|
2729
|
+
this.events.off(g, c), S.forEach((R) => {
|
|
2730
|
+
this.events.off(R, l);
|
|
2633
2731
|
});
|
|
2634
2732
|
};
|
|
2635
2733
|
})(() => {
|
|
@@ -2648,8 +2746,8 @@ class bn {
|
|
|
2648
2746
|
});
|
|
2649
2747
|
}
|
|
2650
2748
|
}
|
|
2651
|
-
var
|
|
2652
|
-
const
|
|
2749
|
+
var $n = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.PREPARING = "connection:preparing", n.CONNECTING = "connection:connecting", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.ESTABLISHED = "connection:established", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))($n || {}), He = /* @__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))(He || {});
|
|
2750
|
+
const Gn = Object.values(He), qn = V({
|
|
2653
2751
|
types: {
|
|
2654
2752
|
context: {},
|
|
2655
2753
|
events: {}
|
|
@@ -2661,13 +2759,13 @@ const yn = Object.values(Ve), Dn = V({
|
|
|
2661
2759
|
logStateChange: (n, e) => {
|
|
2662
2760
|
d("ConnectionStateMachine state changed", e.state);
|
|
2663
2761
|
},
|
|
2664
|
-
setError:
|
|
2762
|
+
setError: v({
|
|
2665
2763
|
error: ({ event: n }) => {
|
|
2666
2764
|
if (n.type === "CONNECTION_FAILED" && "error" in n)
|
|
2667
2765
|
return n.error;
|
|
2668
2766
|
}
|
|
2669
2767
|
}),
|
|
2670
|
-
clearError:
|
|
2768
|
+
clearError: v({
|
|
2671
2769
|
error: () => {
|
|
2672
2770
|
}
|
|
2673
2771
|
})
|
|
@@ -3029,11 +3127,11 @@ const yn = Object.values(Ve), Dn = V({
|
|
|
3029
3127
|
}
|
|
3030
3128
|
}
|
|
3031
3129
|
});
|
|
3032
|
-
class
|
|
3130
|
+
class Vn extends x {
|
|
3033
3131
|
events;
|
|
3034
3132
|
unsubscribeFromEvents;
|
|
3035
3133
|
constructor(e) {
|
|
3036
|
-
super(
|
|
3134
|
+
super(qn), this.events = e, this.subscribeToEvents();
|
|
3037
3135
|
}
|
|
3038
3136
|
get isIdle() {
|
|
3039
3137
|
return this.hasState(
|
|
@@ -3115,7 +3213,7 @@ class Pn extends x {
|
|
|
3115
3213
|
return this.actor.getSnapshot().can({ type: e });
|
|
3116
3214
|
}
|
|
3117
3215
|
getValidEvents() {
|
|
3118
|
-
return
|
|
3216
|
+
return Gn.filter((e) => this.canTransition(e));
|
|
3119
3217
|
}
|
|
3120
3218
|
hasState(e) {
|
|
3121
3219
|
return this.actor.getSnapshot().matches(e);
|
|
@@ -3187,7 +3285,7 @@ class Pn extends x {
|
|
|
3187
3285
|
this.toFailed(e instanceof Error ? e : void 0);
|
|
3188
3286
|
};
|
|
3189
3287
|
}
|
|
3190
|
-
class
|
|
3288
|
+
class xn {
|
|
3191
3289
|
events;
|
|
3192
3290
|
getUaProtected;
|
|
3193
3291
|
constructor(e) {
|
|
@@ -3224,7 +3322,7 @@ class wn {
|
|
|
3224
3322
|
};
|
|
3225
3323
|
}
|
|
3226
3324
|
}
|
|
3227
|
-
class
|
|
3325
|
+
class Hn {
|
|
3228
3326
|
uaFactory;
|
|
3229
3327
|
getUaProtected;
|
|
3230
3328
|
constructor(e) {
|
|
@@ -3276,20 +3374,20 @@ class Ln {
|
|
|
3276
3374
|
userAgent: e,
|
|
3277
3375
|
sipServerIp: s
|
|
3278
3376
|
}), T = this.uaFactory.createUA({ ...l, remoteAddress: r, extraHeaders: a }), g = () => {
|
|
3279
|
-
const
|
|
3280
|
-
c(
|
|
3377
|
+
const R = new Error("Telephony is not available");
|
|
3378
|
+
c(R);
|
|
3281
3379
|
};
|
|
3282
3380
|
T.once(m.DISCONNECTED, g);
|
|
3283
|
-
const
|
|
3381
|
+
const S = () => {
|
|
3284
3382
|
T.removeAllListeners(), T.once(m.DISCONNECTED, () => {
|
|
3285
3383
|
o();
|
|
3286
3384
|
}), T.stop();
|
|
3287
3385
|
};
|
|
3288
|
-
T.once(m.CONNECTED,
|
|
3386
|
+
T.once(m.CONNECTED, S), T.start();
|
|
3289
3387
|
});
|
|
3290
3388
|
}
|
|
3291
3389
|
}
|
|
3292
|
-
const
|
|
3390
|
+
const Wn = (n) => {
|
|
3293
3391
|
const e = [];
|
|
3294
3392
|
return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
|
|
3295
3393
|
};
|
|
@@ -3318,10 +3416,10 @@ class k {
|
|
|
3318
3416
|
throw new Error("user is required for authorized connection");
|
|
3319
3417
|
}
|
|
3320
3418
|
static resolveAuthorizationUser(e, t) {
|
|
3321
|
-
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${
|
|
3419
|
+
return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Fn()}`;
|
|
3322
3420
|
}
|
|
3323
3421
|
static buildExtraHeaders(e, t) {
|
|
3324
|
-
const s = e !== void 0 && e !== "" ?
|
|
3422
|
+
const s = e !== void 0 && e !== "" ? Wn(e) : [];
|
|
3325
3423
|
return t === void 0 ? s : [...s, ...t];
|
|
3326
3424
|
}
|
|
3327
3425
|
createConfiguration({
|
|
@@ -3345,24 +3443,24 @@ class k {
|
|
|
3345
3443
|
sipServerIp: r,
|
|
3346
3444
|
sipServerUrl: s
|
|
3347
3445
|
});
|
|
3348
|
-
const
|
|
3446
|
+
const S = k.resolveAuthorizationUser(a, e), R = wn(r), D = R(S), I = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
|
|
3349
3447
|
return {
|
|
3350
3448
|
configuration: {
|
|
3351
3449
|
password: t,
|
|
3352
3450
|
register: a,
|
|
3353
3451
|
uri: D,
|
|
3354
|
-
display_name:
|
|
3452
|
+
display_name: xe(i),
|
|
3355
3453
|
user_agent: g,
|
|
3356
3454
|
sdpSemantics: "unified-plan",
|
|
3357
|
-
sockets: [
|
|
3455
|
+
sockets: [I],
|
|
3358
3456
|
session_timers: o,
|
|
3359
3457
|
register_expires: c,
|
|
3360
3458
|
connection_recovery_min_interval: l,
|
|
3361
3459
|
connection_recovery_max_interval: T
|
|
3362
3460
|
},
|
|
3363
3461
|
helpers: {
|
|
3364
|
-
socket:
|
|
3365
|
-
getUri:
|
|
3462
|
+
socket: I,
|
|
3463
|
+
getUri: R
|
|
3366
3464
|
}
|
|
3367
3465
|
};
|
|
3368
3466
|
}
|
|
@@ -3380,13 +3478,13 @@ class k {
|
|
|
3380
3478
|
extraHeaders: e.extraHeaders
|
|
3381
3479
|
});
|
|
3382
3480
|
return t.eachTriggers((a, o) => {
|
|
3383
|
-
const c =
|
|
3481
|
+
const c = qe.find((l) => l === o);
|
|
3384
3482
|
c && r.on(c, a);
|
|
3385
3483
|
}), { ua: r, helpers: i };
|
|
3386
3484
|
}
|
|
3387
3485
|
}
|
|
3388
|
-
const
|
|
3389
|
-
class
|
|
3486
|
+
const We = "Not ready for connection", Qn = (n) => n instanceof Error && n.message === We, Yn = () => new Error(We), zn = async (n) => typeof n == "function" ? n() : n;
|
|
3487
|
+
class Jn {
|
|
3390
3488
|
events;
|
|
3391
3489
|
stateMachine;
|
|
3392
3490
|
ua;
|
|
@@ -3397,15 +3495,15 @@ class $n {
|
|
|
3397
3495
|
sipOperations;
|
|
3398
3496
|
configurationManager;
|
|
3399
3497
|
constructor({ JsSIP: e }) {
|
|
3400
|
-
this.events =
|
|
3498
|
+
this.events = Ln(), this.uaFactory = new k(e), this.registrationManager = new xn({
|
|
3401
3499
|
events: this.events,
|
|
3402
3500
|
getUaProtected: this.getUaProtected
|
|
3403
|
-
}), this.stateMachine = new
|
|
3501
|
+
}), this.stateMachine = new Vn(this.events), this.configurationManager = new yn({
|
|
3404
3502
|
getUa: this.getUa
|
|
3405
|
-
}), this.sipOperations = new
|
|
3503
|
+
}), this.sipOperations = new Hn({
|
|
3406
3504
|
uaFactory: this.uaFactory,
|
|
3407
3505
|
getUaProtected: this.getUaProtected
|
|
3408
|
-
}), this.connectionFlow = new
|
|
3506
|
+
}), this.connectionFlow = new Bn({
|
|
3409
3507
|
events: this.events,
|
|
3410
3508
|
uaFactory: this.uaFactory,
|
|
3411
3509
|
stateMachine: this.stateMachine,
|
|
@@ -3498,6 +3596,13 @@ class $n {
|
|
|
3498
3596
|
}
|
|
3499
3597
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
3500
3598
|
getUri = (e) => e;
|
|
3599
|
+
getUser() {
|
|
3600
|
+
try {
|
|
3601
|
+
return this.getUaProtected().configuration.uri.user;
|
|
3602
|
+
} catch {
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3501
3606
|
getUaProtected = () => {
|
|
3502
3607
|
if (!this.ua)
|
|
3503
3608
|
throw new Error("UA not initialized");
|
|
@@ -3506,7 +3611,7 @@ class $n {
|
|
|
3506
3611
|
getUa = () => this.ua;
|
|
3507
3612
|
connectWithProcessError = async (e, t) => {
|
|
3508
3613
|
if (!(t?.hasReadyForConnection?.() ?? !0))
|
|
3509
|
-
throw
|
|
3614
|
+
throw Yn();
|
|
3510
3615
|
return this.processConnect(e, t).catch(async (i) => {
|
|
3511
3616
|
const r = i;
|
|
3512
3617
|
return this.disconnect().then(() => {
|
|
@@ -3516,7 +3621,7 @@ class $n {
|
|
|
3516
3621
|
});
|
|
3517
3622
|
});
|
|
3518
3623
|
};
|
|
3519
|
-
processConnect = async (e, t) => (this.events.trigger(m.CONNECT_STARTED, {}),
|
|
3624
|
+
processConnect = async (e, t) => (this.events.trigger(m.CONNECT_STARTED, {}), zn(e).then((s) => (this.events.trigger(m.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
|
|
3520
3625
|
throw this.events.trigger(m.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
|
|
3521
3626
|
}).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(m.CONNECT_SUCCEEDED, {
|
|
3522
3627
|
...s
|
|
@@ -3525,9 +3630,9 @@ class $n {
|
|
|
3525
3630
|
throw this.events.trigger(m.CONNECT_FAILED, i), i;
|
|
3526
3631
|
}));
|
|
3527
3632
|
}
|
|
3528
|
-
class
|
|
3633
|
+
class jn {
|
|
3529
3634
|
connectionManager;
|
|
3530
|
-
stackPromises =
|
|
3635
|
+
stackPromises = fe({
|
|
3531
3636
|
noRunIsNotActual: !0
|
|
3532
3637
|
});
|
|
3533
3638
|
constructor({ connectionManager: e }) {
|
|
@@ -3539,11 +3644,11 @@ class Gn {
|
|
|
3539
3644
|
this.stackPromises.stop();
|
|
3540
3645
|
}
|
|
3541
3646
|
}
|
|
3542
|
-
const
|
|
3543
|
-
class
|
|
3544
|
-
countInner =
|
|
3545
|
-
initialCount =
|
|
3546
|
-
limitInner =
|
|
3647
|
+
const me = 0, Kn = 30;
|
|
3648
|
+
class Xn {
|
|
3649
|
+
countInner = me;
|
|
3650
|
+
initialCount = me;
|
|
3651
|
+
limitInner = Kn;
|
|
3547
3652
|
isInProgress = !1;
|
|
3548
3653
|
onStatusChange;
|
|
3549
3654
|
constructor({
|
|
@@ -3576,7 +3681,7 @@ class Vn {
|
|
|
3576
3681
|
this.countInner = this.initialCount, this.finishAttempt();
|
|
3577
3682
|
}
|
|
3578
3683
|
}
|
|
3579
|
-
class
|
|
3684
|
+
class Zn {
|
|
3580
3685
|
connectionManager;
|
|
3581
3686
|
interval;
|
|
3582
3687
|
checkTelephonyByTimeout = void 0;
|
|
@@ -3592,7 +3697,7 @@ class xn {
|
|
|
3592
3697
|
onSuccessRequest: t,
|
|
3593
3698
|
onFailRequest: s
|
|
3594
3699
|
}) {
|
|
3595
|
-
this.stop(), this.cancelableBeforeRequest = new X(e), this.checkTelephonyByTimeout =
|
|
3700
|
+
this.stop(), this.cancelableBeforeRequest = new X(e), this.checkTelephonyByTimeout = ct({
|
|
3596
3701
|
isDontStopOnFail: !0,
|
|
3597
3702
|
requestInterval: this.interval,
|
|
3598
3703
|
request: async () => {
|
|
@@ -3613,7 +3718,7 @@ class xn {
|
|
|
3613
3718
|
}
|
|
3614
3719
|
}
|
|
3615
3720
|
var _ = /* @__PURE__ */ ((n) => (n.BEFORE_ATTEMPT = "before-attempt", n.SUCCESS = "success", n.FAILED_ALL_ATTEMPTS = "failed-all-attempts", n.CANCELLED_ATTEMPTS = "cancelled-attempts", n.CHANGED_ATTEMPT_STATUS = "changed-attempt-status", n.STOP_ATTEMPTS_BY_ERROR = "stop-attempts-by-error", n.LIMIT_REACHED_ATTEMPTS = "limit-reached-attempts", n))(_ || {});
|
|
3616
|
-
const
|
|
3721
|
+
const Qe = [
|
|
3617
3722
|
"before-attempt",
|
|
3618
3723
|
"success",
|
|
3619
3724
|
"failed-all-attempts",
|
|
@@ -3621,8 +3726,8 @@ const He = [
|
|
|
3621
3726
|
"changed-attempt-status",
|
|
3622
3727
|
"stop-attempts-by-error",
|
|
3623
3728
|
"limit-reached-attempts"
|
|
3624
|
-
],
|
|
3625
|
-
class
|
|
3729
|
+
], es = () => new M(Qe);
|
|
3730
|
+
class he {
|
|
3626
3731
|
callManager;
|
|
3627
3732
|
disposers = [];
|
|
3628
3733
|
constructor({ callManager: e }) {
|
|
@@ -3647,15 +3752,15 @@ class ce {
|
|
|
3647
3752
|
this.callManager.isCallActive ? e?.() : t();
|
|
3648
3753
|
}
|
|
3649
3754
|
}
|
|
3650
|
-
const
|
|
3651
|
-
class
|
|
3755
|
+
const ts = 15e3, ns = 2;
|
|
3756
|
+
class ss {
|
|
3652
3757
|
connectionManager;
|
|
3653
3758
|
pingServerByTimeoutWithFailCalls;
|
|
3654
3759
|
constructor({ connectionManager: e }) {
|
|
3655
|
-
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls =
|
|
3760
|
+
this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = dt(ns, {
|
|
3656
3761
|
whenPossibleRequest: async () => {
|
|
3657
3762
|
},
|
|
3658
|
-
requestInterval:
|
|
3763
|
+
requestInterval: ts,
|
|
3659
3764
|
request: async () => (d("ping"), this.connectionManager.ping().then(() => {
|
|
3660
3765
|
d("ping success");
|
|
3661
3766
|
}))
|
|
@@ -3668,16 +3773,16 @@ class Yn {
|
|
|
3668
3773
|
this.pingServerByTimeoutWithFailCalls.stop();
|
|
3669
3774
|
}
|
|
3670
3775
|
}
|
|
3671
|
-
class
|
|
3776
|
+
class is {
|
|
3672
3777
|
pingServerRequester;
|
|
3673
3778
|
notActiveCallSubscriber;
|
|
3674
3779
|
constructor({
|
|
3675
3780
|
connectionManager: e,
|
|
3676
3781
|
callManager: t
|
|
3677
3782
|
}) {
|
|
3678
|
-
this.pingServerRequester = new
|
|
3783
|
+
this.pingServerRequester = new ss({
|
|
3679
3784
|
connectionManager: e
|
|
3680
|
-
}), this.notActiveCallSubscriber = new
|
|
3785
|
+
}), this.notActiveCallSubscriber = new he({ callManager: t });
|
|
3681
3786
|
}
|
|
3682
3787
|
start({ onFailRequest: e }) {
|
|
3683
3788
|
d("start"), this.notActiveCallSubscriber.subscribe({
|
|
@@ -3696,7 +3801,7 @@ class zn {
|
|
|
3696
3801
|
this.notActiveCallSubscriber.unsubscribe();
|
|
3697
3802
|
}
|
|
3698
3803
|
}
|
|
3699
|
-
class
|
|
3804
|
+
class rs {
|
|
3700
3805
|
connectionManager;
|
|
3701
3806
|
isRegistrationFailed = !1;
|
|
3702
3807
|
disposers = [];
|
|
@@ -3705,7 +3810,7 @@ class Jn {
|
|
|
3705
3810
|
connectionManager: e,
|
|
3706
3811
|
callManager: t
|
|
3707
3812
|
}) {
|
|
3708
|
-
this.connectionManager = e, this.notActiveCallSubscriber = new
|
|
3813
|
+
this.connectionManager = e, this.notActiveCallSubscriber = new he({ callManager: t });
|
|
3709
3814
|
}
|
|
3710
3815
|
subscribe(e) {
|
|
3711
3816
|
this.unsubscribe(), this.disposers.push(
|
|
@@ -3732,12 +3837,12 @@ class Jn {
|
|
|
3732
3837
|
this.isRegistrationFailed = !1;
|
|
3733
3838
|
}
|
|
3734
3839
|
}
|
|
3735
|
-
const
|
|
3840
|
+
const as = 3e3, os = 15e3, pe = {
|
|
3736
3841
|
LIMIT_REACHED: "Limit reached",
|
|
3737
3842
|
FAILED_TO_RECONNECT: "Failed to reconnect"
|
|
3738
|
-
},
|
|
3739
|
-
},
|
|
3740
|
-
class
|
|
3843
|
+
}, cs = async () => {
|
|
3844
|
+
}, ds = (n) => !0;
|
|
3845
|
+
class hs {
|
|
3741
3846
|
events;
|
|
3742
3847
|
connectionManager;
|
|
3743
3848
|
connectionQueueManager;
|
|
@@ -3757,21 +3862,21 @@ class es {
|
|
|
3757
3862
|
connectionManager: t,
|
|
3758
3863
|
callManager: s
|
|
3759
3864
|
}, i) {
|
|
3760
|
-
const r = i?.onBeforeRetry ??
|
|
3761
|
-
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events =
|
|
3865
|
+
const r = i?.onBeforeRetry ?? cs, a = i?.canRetryOnError ?? ds;
|
|
3866
|
+
this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = es(), this.checkTelephonyRequester = new Zn({
|
|
3762
3867
|
connectionManager: t,
|
|
3763
|
-
interval: i?.checkTelephonyRequestInterval ??
|
|
3764
|
-
}), this.pingServerIfNotActiveCallRequester = new
|
|
3868
|
+
interval: i?.checkTelephonyRequestInterval ?? os
|
|
3869
|
+
}), this.pingServerIfNotActiveCallRequester = new is({
|
|
3765
3870
|
connectionManager: t,
|
|
3766
3871
|
callManager: s
|
|
3767
|
-
}), this.registrationFailedOutOfCallSubscriber = new
|
|
3872
|
+
}), this.registrationFailedOutOfCallSubscriber = new rs({
|
|
3768
3873
|
connectionManager: t,
|
|
3769
3874
|
callManager: s
|
|
3770
|
-
}), this.attemptsState = new
|
|
3875
|
+
}), this.attemptsState = new Xn({
|
|
3771
3876
|
onStatusChange: this.emitStatusChange
|
|
3772
|
-
}), this.cancelableRequestBeforeRetry = new X(r), this.delayBetweenAttempts = new
|
|
3773
|
-
i?.timeoutBetweenAttempts ??
|
|
3774
|
-
), this.notActiveCallSubscriber = new
|
|
3877
|
+
}), this.cancelableRequestBeforeRetry = new X(r), this.delayBetweenAttempts = new ht(
|
|
3878
|
+
i?.timeoutBetweenAttempts ?? as
|
|
3879
|
+
), this.notActiveCallSubscriber = new he({ callManager: s });
|
|
3775
3880
|
}
|
|
3776
3881
|
start(e) {
|
|
3777
3882
|
d("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
|
|
@@ -3836,7 +3941,7 @@ class es {
|
|
|
3836
3941
|
}
|
|
3837
3942
|
}
|
|
3838
3943
|
handleConnectionError(e, t) {
|
|
3839
|
-
if (
|
|
3944
|
+
if (Qn(e)) {
|
|
3840
3945
|
this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
|
|
3841
3946
|
return;
|
|
3842
3947
|
}
|
|
@@ -3844,14 +3949,14 @@ class es {
|
|
|
3844
3949
|
d("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
|
|
3845
3950
|
return;
|
|
3846
3951
|
}
|
|
3847
|
-
if (
|
|
3952
|
+
if (Tt(e)) {
|
|
3848
3953
|
d("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(_.CANCELLED_ATTEMPTS, e);
|
|
3849
3954
|
return;
|
|
3850
3955
|
}
|
|
3851
3956
|
d("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
|
|
3852
3957
|
}
|
|
3853
3958
|
handleLimitReached(e) {
|
|
3854
|
-
this.attemptsState.finishAttempt(), this.events.trigger(_.LIMIT_REACHED_ATTEMPTS, new Error(
|
|
3959
|
+
this.attemptsState.finishAttempt(), this.events.trigger(_.LIMIT_REACHED_ATTEMPTS, new Error(pe.LIMIT_REACHED)), this.startCheckTelephony(e);
|
|
3855
3960
|
}
|
|
3856
3961
|
handleSucceededAttempt(e) {
|
|
3857
3962
|
d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(_.SUCCESS);
|
|
@@ -3912,8 +4017,8 @@ class es {
|
|
|
3912
4017
|
}
|
|
3913
4018
|
scheduleReconnect(e) {
|
|
3914
4019
|
d("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (d("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (d("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
|
|
3915
|
-
const s = t instanceof Error ? t : new Error(
|
|
3916
|
-
this.attemptsState.finishAttempt(),
|
|
4020
|
+
const s = t instanceof Error ? t : new Error(pe.FAILED_TO_RECONNECT);
|
|
4021
|
+
this.attemptsState.finishAttempt(), ot(t) || lt(t) ? this.events.trigger(_.CANCELLED_ATTEMPTS, s) : this.events.trigger(_.FAILED_ALL_ATTEMPTS, s), d("scheduleReconnect: error", t);
|
|
3917
4022
|
});
|
|
3918
4023
|
}
|
|
3919
4024
|
isConnectionUnavailable() {
|
|
@@ -3924,14 +4029,14 @@ class es {
|
|
|
3924
4029
|
this.events.trigger(_.CHANGED_ATTEMPT_STATUS, { isInProgress: e });
|
|
3925
4030
|
};
|
|
3926
4031
|
}
|
|
3927
|
-
const
|
|
4032
|
+
const ls = V({
|
|
3928
4033
|
types: {
|
|
3929
4034
|
context: {},
|
|
3930
4035
|
events: {}
|
|
3931
4036
|
},
|
|
3932
4037
|
actions: {
|
|
3933
|
-
setCodec:
|
|
3934
|
-
clearCodec:
|
|
4038
|
+
setCodec: v(({ event: n }) => "codec" in n ? { codec: n.codec } : {}),
|
|
4039
|
+
clearCodec: v({ codec: void 0 })
|
|
3935
4040
|
}
|
|
3936
4041
|
}).createMachine({
|
|
3937
4042
|
id: "contented-stream",
|
|
@@ -3965,9 +4070,9 @@ const ts = V({
|
|
|
3965
4070
|
}
|
|
3966
4071
|
}
|
|
3967
4072
|
});
|
|
3968
|
-
class
|
|
4073
|
+
class us extends x {
|
|
3969
4074
|
constructor() {
|
|
3970
|
-
super(
|
|
4075
|
+
super(ls);
|
|
3971
4076
|
}
|
|
3972
4077
|
get isAvailable() {
|
|
3973
4078
|
return this.state === "contented-stream:available";
|
|
@@ -4008,17 +4113,17 @@ class ns extends x {
|
|
|
4008
4113
|
);
|
|
4009
4114
|
}
|
|
4010
4115
|
}
|
|
4011
|
-
var
|
|
4012
|
-
const
|
|
4116
|
+
var ae = /* @__PURE__ */ ((n) => (n.AVAILABLE = "available", n.NOT_AVAILABLE = "not-available", n))(ae || {});
|
|
4117
|
+
const gs = [
|
|
4013
4118
|
"available",
|
|
4014
4119
|
"not-available"
|
|
4015
4120
|
/* NOT_AVAILABLE */
|
|
4016
|
-
],
|
|
4017
|
-
class
|
|
4121
|
+
], Ts = () => new M(gs);
|
|
4122
|
+
class Es {
|
|
4018
4123
|
events;
|
|
4019
4124
|
stateMachine;
|
|
4020
4125
|
constructor() {
|
|
4021
|
-
this.events =
|
|
4126
|
+
this.events = Ts(), this.stateMachine = new us(), this.proxyEvents();
|
|
4022
4127
|
}
|
|
4023
4128
|
get isAvailable() {
|
|
4024
4129
|
return this.stateMachine.isAvailable;
|
|
@@ -4047,19 +4152,19 @@ class rs {
|
|
|
4047
4152
|
proxyEvents() {
|
|
4048
4153
|
this.stateMachine.onStateChange(() => {
|
|
4049
4154
|
const e = this.getStateInfo();
|
|
4050
|
-
e.isAvailable ? this.events.trigger(
|
|
4155
|
+
e.isAvailable ? this.events.trigger(ae.AVAILABLE, { codec: e.codec }) : this.events.trigger(ae.NOT_AVAILABLE, {});
|
|
4051
4156
|
});
|
|
4052
4157
|
}
|
|
4053
4158
|
}
|
|
4054
4159
|
var G = /* @__PURE__ */ ((n) => (n.RINGING = "ringing", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(G || {});
|
|
4055
|
-
const
|
|
4160
|
+
const Ye = [
|
|
4056
4161
|
"ringing",
|
|
4057
4162
|
"declinedIncomingCall",
|
|
4058
4163
|
"terminatedIncomingCall",
|
|
4059
4164
|
"failedIncomingCall"
|
|
4060
|
-
],
|
|
4061
|
-
var
|
|
4062
|
-
const
|
|
4165
|
+
], Ss = () => new M(Ye);
|
|
4166
|
+
var ms = /* @__PURE__ */ ((n) => (n.IDLE = "incoming:idle", n.RINGING = "incoming:ringing", n.CONSUMED = "incoming:consumed", n.DECLINED = "incoming:declined", n.TERMINATED = "incoming:terminated", n.FAILED = "incoming:failed", n))(ms || {});
|
|
4167
|
+
const ps = V({
|
|
4063
4168
|
types: {
|
|
4064
4169
|
context: {},
|
|
4065
4170
|
events: {}
|
|
@@ -4071,11 +4176,11 @@ const cs = V({
|
|
|
4071
4176
|
logStateChange: (n, e) => {
|
|
4072
4177
|
d("IncomingCallStateMachine state changed", e.state);
|
|
4073
4178
|
},
|
|
4074
|
-
rememberIncoming:
|
|
4179
|
+
rememberIncoming: v(({ event: n }) => {
|
|
4075
4180
|
const { data: e } = n;
|
|
4076
4181
|
return { remoteCallerData: e, lastReason: void 0 };
|
|
4077
4182
|
}),
|
|
4078
|
-
rememberReason:
|
|
4183
|
+
rememberReason: v(({ event: n, context: e }) => n.type === "INCOMING.CONSUMED" ? {
|
|
4079
4184
|
remoteCallerData: e.remoteCallerData,
|
|
4080
4185
|
lastReason: "incoming:consumed"
|
|
4081
4186
|
/* CONSUMED */
|
|
@@ -4092,7 +4197,7 @@ const cs = V({
|
|
|
4092
4197
|
lastReason: "incoming:failed"
|
|
4093
4198
|
/* FAILED */
|
|
4094
4199
|
}),
|
|
4095
|
-
clearIncoming:
|
|
4200
|
+
clearIncoming: v(() => ({ remoteCallerData: void 0, lastReason: void 0 }))
|
|
4096
4201
|
}
|
|
4097
4202
|
}).createMachine({
|
|
4098
4203
|
id: "incoming",
|
|
@@ -4391,9 +4496,9 @@ const cs = V({
|
|
|
4391
4496
|
}
|
|
4392
4497
|
}
|
|
4393
4498
|
});
|
|
4394
|
-
class
|
|
4499
|
+
class Cs extends x {
|
|
4395
4500
|
constructor({ incomingEvents: e, connectionEvents: t }) {
|
|
4396
|
-
super(
|
|
4501
|
+
super(ps), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
|
|
4397
4502
|
}
|
|
4398
4503
|
get isIdle() {
|
|
4399
4504
|
return this.state === "incoming:idle";
|
|
@@ -4478,26 +4583,26 @@ class ds extends x {
|
|
|
4478
4583
|
this.send({ type: "INCOMING.CLEAR" });
|
|
4479
4584
|
}
|
|
4480
4585
|
}
|
|
4481
|
-
const
|
|
4586
|
+
const Rs = 486, Ns = 487, ne = (n) => ({
|
|
4482
4587
|
displayName: n.remote_identity.display_name,
|
|
4483
4588
|
host: n.remote_identity.uri.host,
|
|
4484
4589
|
incomingNumber: n.remote_identity.uri.user,
|
|
4485
4590
|
rtcSession: n
|
|
4486
4591
|
});
|
|
4487
|
-
class
|
|
4592
|
+
class As {
|
|
4488
4593
|
events;
|
|
4489
4594
|
stateMachine;
|
|
4490
4595
|
incomingRTCSession;
|
|
4491
4596
|
connectionManager;
|
|
4492
4597
|
constructor(e) {
|
|
4493
|
-
this.connectionManager = e, this.events =
|
|
4598
|
+
this.connectionManager = e, this.events = Ss(), this.stateMachine = new Cs({
|
|
4494
4599
|
incomingEvents: this.events,
|
|
4495
4600
|
connectionEvents: this.connectionManager.events
|
|
4496
4601
|
}), this.start();
|
|
4497
4602
|
}
|
|
4498
4603
|
get remoteCallerData() {
|
|
4499
4604
|
if (this.incomingRTCSession)
|
|
4500
|
-
return
|
|
4605
|
+
return ne(this.incomingRTCSession);
|
|
4501
4606
|
}
|
|
4502
4607
|
get isAvailableIncomingCall() {
|
|
4503
4608
|
return !!this.incomingRTCSession;
|
|
@@ -4519,11 +4624,11 @@ class us {
|
|
|
4519
4624
|
return this.stateMachine.toConsumed(), this.removeIncomingSession(), e;
|
|
4520
4625
|
};
|
|
4521
4626
|
async declineToIncomingCall({
|
|
4522
|
-
statusCode: e =
|
|
4627
|
+
statusCode: e = Ns
|
|
4523
4628
|
} = {}) {
|
|
4524
4629
|
return new Promise((t, s) => {
|
|
4525
4630
|
try {
|
|
4526
|
-
const i = this.getIncomingRTCSession(), r =
|
|
4631
|
+
const i = this.getIncomingRTCSession(), r = ne(i);
|
|
4527
4632
|
this.removeIncomingSession(), this.events.trigger(G.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
|
|
4528
4633
|
} catch (i) {
|
|
4529
4634
|
s(i);
|
|
@@ -4531,7 +4636,7 @@ class us {
|
|
|
4531
4636
|
});
|
|
4532
4637
|
}
|
|
4533
4638
|
async busyIncomingCall() {
|
|
4534
|
-
return this.declineToIncomingCall({ statusCode:
|
|
4639
|
+
return this.declineToIncomingCall({ statusCode: Rs });
|
|
4535
4640
|
}
|
|
4536
4641
|
on(e, t) {
|
|
4537
4642
|
return this.events.on(e, t);
|
|
@@ -4562,7 +4667,7 @@ class us {
|
|
|
4562
4667
|
};
|
|
4563
4668
|
setIncomingSession(e) {
|
|
4564
4669
|
this.incomingRTCSession = e;
|
|
4565
|
-
const t =
|
|
4670
|
+
const t = ne(e);
|
|
4566
4671
|
e.on("failed", (s) => {
|
|
4567
4672
|
this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(G.TERMINATED_INCOMING_CALL, t) : this.events.trigger(G.FAILED_INCOMING_CALL, t);
|
|
4568
4673
|
}), this.events.trigger(G.RINGING, t);
|
|
@@ -4571,26 +4676,62 @@ class us {
|
|
|
4571
4676
|
delete this.incomingRTCSession;
|
|
4572
4677
|
}
|
|
4573
4678
|
}
|
|
4574
|
-
|
|
4575
|
-
|
|
4679
|
+
class Is {
|
|
4680
|
+
apiManager;
|
|
4681
|
+
connectionManager;
|
|
4682
|
+
callManager;
|
|
4683
|
+
get user() {
|
|
4684
|
+
return this.connectionManager?.getUser();
|
|
4685
|
+
}
|
|
4686
|
+
get number() {
|
|
4687
|
+
return this.callManager?.number;
|
|
4688
|
+
}
|
|
4689
|
+
get isCallInitiator() {
|
|
4690
|
+
return !!this.callManager?.isCallInitiator;
|
|
4691
|
+
}
|
|
4692
|
+
get peerToPeerRoom() {
|
|
4693
|
+
if (!(this.user === void 0 || this.number === void 0))
|
|
4694
|
+
return this.isCallInitiator ? `p2p${this.user}to${this.number}` : `p2p${this.number}to${this.user}`;
|
|
4695
|
+
}
|
|
4696
|
+
subscribe({
|
|
4697
|
+
apiManager: e,
|
|
4698
|
+
connectionManager: t,
|
|
4699
|
+
callManager: s
|
|
4700
|
+
}) {
|
|
4701
|
+
this.apiManager = e, this.connectionManager = t, this.callManager = s, s.on("confirmed", this.maybeSendDirectPeerToPeerRoom);
|
|
4702
|
+
}
|
|
4703
|
+
maybeSendDirectPeerToPeerRoom = () => {
|
|
4704
|
+
const { peerToPeerRoom: e, number: t, apiManager: s } = this;
|
|
4705
|
+
if (e === void 0 || t === void 0 || s === void 0)
|
|
4706
|
+
return;
|
|
4707
|
+
const i = [
|
|
4708
|
+
`${h.CONTENT_ENTER_ROOM}: ${this.peerToPeerRoom}`,
|
|
4709
|
+
`${h.PARTICIPANT_NAME}: ${this.number}`,
|
|
4710
|
+
`${h.IS_DIRECT_PEER_TO_PEER}: true`
|
|
4711
|
+
];
|
|
4712
|
+
s.sendEnterRoom(i);
|
|
4713
|
+
};
|
|
4714
|
+
}
|
|
4715
|
+
var ze = /* @__PURE__ */ ((n) => (n.SNAPSHOT_CHANGED = "snapshot-changed", n))(ze || {});
|
|
4716
|
+
const Je = ["snapshot-changed"], vs = () => new M(Je), fs = (n, e) => Object.is(n, e), Ce = (n) => ({
|
|
4576
4717
|
connection: n.connection.getSnapshot(),
|
|
4577
4718
|
call: n.call.getSnapshot(),
|
|
4578
4719
|
incoming: n.incoming.getSnapshot(),
|
|
4579
4720
|
presentation: n.presentation.getSnapshot()
|
|
4580
4721
|
});
|
|
4581
|
-
class
|
|
4722
|
+
class Ms {
|
|
4582
4723
|
events;
|
|
4583
4724
|
machines;
|
|
4584
4725
|
currentSnapshot;
|
|
4585
4726
|
subscribers = /* @__PURE__ */ new Set();
|
|
4586
4727
|
actorSubscriptions = [];
|
|
4587
4728
|
constructor(e) {
|
|
4588
|
-
this.events =
|
|
4729
|
+
this.events = vs(), this.machines = {
|
|
4589
4730
|
connection: e.connectionManager.stateMachine,
|
|
4590
4731
|
call: e.callManager.stateMachine,
|
|
4591
4732
|
incoming: e.incomingCallManager.stateMachine,
|
|
4592
4733
|
presentation: e.presentationManager.stateMachine
|
|
4593
|
-
}, this.currentSnapshot =
|
|
4734
|
+
}, this.currentSnapshot = Ce(this.machines), this.actorSubscriptions.push(
|
|
4594
4735
|
this.machines.connection.subscribe(this.notifySubscribers),
|
|
4595
4736
|
this.machines.call.subscribe(this.notifySubscribers),
|
|
4596
4737
|
this.machines.incoming.subscribe(this.notifySubscribers),
|
|
@@ -4601,7 +4742,7 @@ class Es {
|
|
|
4601
4742
|
return this.currentSnapshot;
|
|
4602
4743
|
}
|
|
4603
4744
|
subscribe(e, t, s) {
|
|
4604
|
-
const i = typeof t == "function", r = i ? e : (T) => T, a = i ? t : e, o = (i ? s : void 0) ??
|
|
4745
|
+
const i = typeof t == "function", r = i ? e : (T) => T, a = i ? t : e, o = (i ? s : void 0) ?? fs, c = r(this.currentSnapshot), l = {
|
|
4605
4746
|
selector: r,
|
|
4606
4747
|
listener: a,
|
|
4607
4748
|
equals: o,
|
|
@@ -4624,12 +4765,12 @@ class Es {
|
|
|
4624
4765
|
}
|
|
4625
4766
|
notifySubscribers = () => {
|
|
4626
4767
|
const e = this.currentSnapshot;
|
|
4627
|
-
this.currentSnapshot =
|
|
4768
|
+
this.currentSnapshot = Ce(this.machines);
|
|
4628
4769
|
for (const t of this.subscribers) {
|
|
4629
4770
|
const s = t.selector(this.currentSnapshot);
|
|
4630
4771
|
t.equals(t.current, s) || (t.current = s, t.listener(s));
|
|
4631
4772
|
}
|
|
4632
|
-
this.events.trigger(
|
|
4773
|
+
this.events.trigger(ze.SNAPSHOT_CHANGED, {
|
|
4633
4774
|
previous: e,
|
|
4634
4775
|
current: this.currentSnapshot
|
|
4635
4776
|
});
|
|
@@ -4637,10 +4778,10 @@ class Es {
|
|
|
4637
4778
|
}
|
|
4638
4779
|
const $ = 1e3;
|
|
4639
4780
|
var C = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", n.MEDIA_SOURCE = "media-source", n.OUTBOUND_RTP = "outbound-rtp", n.REMOTE_INBOUND_RTP = "remote-inbound-rtp", n.CODEC = "codec", n.CANDIDATE_PAIR = "candidate-pair", n.CERTIFICATE = "certificate", n.TRANSPORT = "transport", n.LOCAL_CANDIDATE = "local-candidate", n.REMOTE_CANDIDATE = "remote-candidate", n))(C || {});
|
|
4640
|
-
const
|
|
4781
|
+
const je = ["collected"], _s = () => new M(je), Re = () => "performance" in window ? performance.now() : Date.now(), W = (n) => [...n.keys()].reduce((e, t) => {
|
|
4641
4782
|
const s = n.get(t);
|
|
4642
4783
|
return s === void 0 ? e : { ...e, [s.type]: s };
|
|
4643
|
-
}, {}),
|
|
4784
|
+
}, {}), bs = (n) => {
|
|
4644
4785
|
if (!n)
|
|
4645
4786
|
return {
|
|
4646
4787
|
outboundRtp: void 0,
|
|
@@ -4648,14 +4789,14 @@ const ze = ["collected"], Ss = () => new f(ze), pe = () => "performance" in wind
|
|
|
4648
4789
|
mediaSource: void 0,
|
|
4649
4790
|
remoteInboundRtp: void 0
|
|
4650
4791
|
};
|
|
4651
|
-
const e =
|
|
4792
|
+
const e = W(n);
|
|
4652
4793
|
return {
|
|
4653
4794
|
outboundRtp: e[C.OUTBOUND_RTP],
|
|
4654
4795
|
codec: e[C.CODEC],
|
|
4655
4796
|
mediaSource: e[C.MEDIA_SOURCE],
|
|
4656
4797
|
remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
|
|
4657
4798
|
};
|
|
4658
|
-
},
|
|
4799
|
+
}, Ne = (n) => {
|
|
4659
4800
|
if (!n)
|
|
4660
4801
|
return {
|
|
4661
4802
|
outboundRtp: void 0,
|
|
@@ -4663,14 +4804,14 @@ const ze = ["collected"], Ss = () => new f(ze), pe = () => "performance" in wind
|
|
|
4663
4804
|
mediaSource: void 0,
|
|
4664
4805
|
remoteInboundRtp: void 0
|
|
4665
4806
|
};
|
|
4666
|
-
const e =
|
|
4807
|
+
const e = W(n);
|
|
4667
4808
|
return {
|
|
4668
4809
|
outboundRtp: e[C.OUTBOUND_RTP],
|
|
4669
4810
|
codec: e[C.CODEC],
|
|
4670
4811
|
mediaSource: e[C.MEDIA_SOURCE],
|
|
4671
4812
|
remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
|
|
4672
4813
|
};
|
|
4673
|
-
},
|
|
4814
|
+
}, Ae = ({
|
|
4674
4815
|
videoReceiversStats: n,
|
|
4675
4816
|
synchronizationSourcesVideo: e
|
|
4676
4817
|
}) => {
|
|
@@ -4680,13 +4821,13 @@ const ze = ["collected"], Ss = () => new f(ze), pe = () => "performance" in wind
|
|
|
4680
4821
|
codec: void 0,
|
|
4681
4822
|
synchronizationSources: e
|
|
4682
4823
|
};
|
|
4683
|
-
const t =
|
|
4824
|
+
const t = W(n);
|
|
4684
4825
|
return {
|
|
4685
4826
|
inboundRtp: t[C.INBOUND_RTP],
|
|
4686
4827
|
codec: t[C.CODEC],
|
|
4687
4828
|
synchronizationSources: e
|
|
4688
4829
|
};
|
|
4689
|
-
},
|
|
4830
|
+
}, Os = ({
|
|
4690
4831
|
audioReceiverStats: n,
|
|
4691
4832
|
synchronizationSourcesAudio: e
|
|
4692
4833
|
}) => {
|
|
@@ -4697,14 +4838,14 @@ const ze = ["collected"], Ss = () => new f(ze), pe = () => "performance" in wind
|
|
|
4697
4838
|
remoteOutboundRtp: void 0,
|
|
4698
4839
|
synchronizationSources: e
|
|
4699
4840
|
};
|
|
4700
|
-
const t =
|
|
4841
|
+
const t = W(n);
|
|
4701
4842
|
return {
|
|
4702
4843
|
inboundRtp: t[C.INBOUND_RTP],
|
|
4703
4844
|
codec: t[C.CODEC],
|
|
4704
4845
|
remoteOutboundRtp: t[C.REMOTE_OUTBOUND_RTP],
|
|
4705
4846
|
synchronizationSources: e
|
|
4706
4847
|
};
|
|
4707
|
-
},
|
|
4848
|
+
}, Ke = (n) => {
|
|
4708
4849
|
if (!n)
|
|
4709
4850
|
return {
|
|
4710
4851
|
candidatePair: void 0,
|
|
@@ -4713,7 +4854,7 @@ const ze = ["collected"], Ss = () => new f(ze), pe = () => "performance" in wind
|
|
|
4713
4854
|
remoteCandidate: void 0,
|
|
4714
4855
|
transport: void 0
|
|
4715
4856
|
};
|
|
4716
|
-
const e =
|
|
4857
|
+
const e = W(n);
|
|
4717
4858
|
return {
|
|
4718
4859
|
candidatePair: e[C.CANDIDATE_PAIR],
|
|
4719
4860
|
certificate: e[C.CERTIFICATE],
|
|
@@ -4721,39 +4862,39 @@ const ze = ["collected"], Ss = () => new f(ze), pe = () => "performance" in wind
|
|
|
4721
4862
|
remoteCandidate: e[C.REMOTE_CANDIDATE],
|
|
4722
4863
|
transport: e[C.TRANSPORT]
|
|
4723
4864
|
};
|
|
4724
|
-
},
|
|
4865
|
+
}, Ps = ({
|
|
4725
4866
|
audioSenderStats: n,
|
|
4726
4867
|
videoSenderFirstStats: e,
|
|
4727
4868
|
videoSenderSecondStats: t
|
|
4728
4869
|
}) => ({
|
|
4729
|
-
video:
|
|
4730
|
-
secondVideo:
|
|
4731
|
-
audio:
|
|
4732
|
-
additional:
|
|
4870
|
+
video: Ne(e),
|
|
4871
|
+
secondVideo: Ne(t),
|
|
4872
|
+
audio: bs(n),
|
|
4873
|
+
additional: Ke(
|
|
4733
4874
|
n ?? e ?? t
|
|
4734
4875
|
)
|
|
4735
|
-
}),
|
|
4876
|
+
}), ys = ({
|
|
4736
4877
|
audioReceiverStats: n,
|
|
4737
4878
|
videoReceiverFirstStats: e,
|
|
4738
4879
|
videoReceiverSecondStats: t,
|
|
4739
4880
|
synchronizationSources: s
|
|
4740
4881
|
}) => ({
|
|
4741
|
-
video:
|
|
4882
|
+
video: Ae({
|
|
4742
4883
|
videoReceiversStats: e,
|
|
4743
4884
|
synchronizationSourcesVideo: s.video
|
|
4744
4885
|
}),
|
|
4745
|
-
secondVideo:
|
|
4886
|
+
secondVideo: Ae({
|
|
4746
4887
|
videoReceiversStats: t,
|
|
4747
4888
|
synchronizationSourcesVideo: s.video
|
|
4748
4889
|
}),
|
|
4749
|
-
audio:
|
|
4890
|
+
audio: Os({
|
|
4750
4891
|
audioReceiverStats: n,
|
|
4751
4892
|
synchronizationSourcesAudio: s.audio
|
|
4752
4893
|
}),
|
|
4753
|
-
additional:
|
|
4894
|
+
additional: Ke(
|
|
4754
4895
|
n ?? e ?? t
|
|
4755
4896
|
)
|
|
4756
|
-
}),
|
|
4897
|
+
}), Ds = ({
|
|
4757
4898
|
audioSenderStats: n,
|
|
4758
4899
|
videoSenderFirstStats: e,
|
|
4759
4900
|
videoSenderSecondStats: t,
|
|
@@ -4762,11 +4903,11 @@ const ze = ["collected"], Ss = () => new f(ze), pe = () => "performance" in wind
|
|
|
4762
4903
|
videoReceiverSecondStats: r,
|
|
4763
4904
|
synchronizationSources: a
|
|
4764
4905
|
}) => {
|
|
4765
|
-
const o =
|
|
4906
|
+
const o = Ps({
|
|
4766
4907
|
audioSenderStats: n,
|
|
4767
4908
|
videoSenderFirstStats: e,
|
|
4768
4909
|
videoSenderSecondStats: t
|
|
4769
|
-
}), c =
|
|
4910
|
+
}), c = ys({
|
|
4770
4911
|
audioReceiverStats: s,
|
|
4771
4912
|
videoReceiverFirstStats: i,
|
|
4772
4913
|
videoReceiverSecondStats: r,
|
|
@@ -4776,8 +4917,8 @@ const ze = ["collected"], Ss = () => new f(ze), pe = () => "performance" in wind
|
|
|
4776
4917
|
outbound: o,
|
|
4777
4918
|
inbound: c
|
|
4778
4919
|
};
|
|
4779
|
-
},
|
|
4780
|
-
const e = "audio", t = "video", s = n.getSenders(), i = s.find((
|
|
4920
|
+
}, Ls = async (n) => {
|
|
4921
|
+
const e = "audio", t = "video", s = n.getSenders(), i = s.find((S) => S.track?.kind === e), r = s.filter((S) => S.track?.kind === t), a = n.getReceivers(), o = a.find((S) => S.track.kind === e), c = a.filter((S) => S.track.kind === t), l = {
|
|
4781
4922
|
trackIdentifier: o?.track.id,
|
|
4782
4923
|
item: o?.getSynchronizationSources()[0]
|
|
4783
4924
|
}, T = {
|
|
@@ -4794,41 +4935,41 @@ const ze = ["collected"], Ss = () => new f(ze), pe = () => "performance" in wind
|
|
|
4794
4935
|
o?.getStats() ?? Promise.resolve(void 0),
|
|
4795
4936
|
c[0]?.getStats() ?? Promise.resolve(void 0),
|
|
4796
4937
|
c[1]?.getStats() ?? Promise.resolve(void 0)
|
|
4797
|
-
]).then((
|
|
4938
|
+
]).then((S) => {
|
|
4798
4939
|
const [
|
|
4799
|
-
|
|
4940
|
+
R,
|
|
4800
4941
|
D,
|
|
4801
|
-
|
|
4942
|
+
I,
|
|
4802
4943
|
U,
|
|
4803
4944
|
B,
|
|
4804
|
-
|
|
4805
|
-
] =
|
|
4945
|
+
it
|
|
4946
|
+
] = S;
|
|
4806
4947
|
return {
|
|
4807
4948
|
synchronizationSources: g,
|
|
4808
|
-
audioSenderStats:
|
|
4949
|
+
audioSenderStats: R,
|
|
4809
4950
|
videoSenderFirstStats: D,
|
|
4810
|
-
videoSenderSecondStats:
|
|
4951
|
+
videoSenderSecondStats: I,
|
|
4811
4952
|
audioReceiverStats: U,
|
|
4812
4953
|
videoReceiverFirstStats: B,
|
|
4813
|
-
videoReceiverSecondStats:
|
|
4954
|
+
videoReceiverSecondStats: it
|
|
4814
4955
|
};
|
|
4815
4956
|
});
|
|
4816
|
-
},
|
|
4957
|
+
}, ws = (n) => {
|
|
4817
4958
|
d(String(n));
|
|
4818
4959
|
};
|
|
4819
|
-
class
|
|
4960
|
+
class Us {
|
|
4820
4961
|
events;
|
|
4821
4962
|
setTimeoutRequest;
|
|
4822
|
-
requesterAllStatistics = new X(
|
|
4963
|
+
requesterAllStatistics = new X(Ls);
|
|
4823
4964
|
constructor() {
|
|
4824
|
-
this.events =
|
|
4965
|
+
this.events = _s(), this.setTimeoutRequest = new ve();
|
|
4825
4966
|
}
|
|
4826
4967
|
get requested() {
|
|
4827
4968
|
return this.setTimeoutRequest.requested;
|
|
4828
4969
|
}
|
|
4829
4970
|
start(e, {
|
|
4830
4971
|
interval: t = $,
|
|
4831
|
-
onError: s =
|
|
4972
|
+
onError: s = ws
|
|
4832
4973
|
} = {}) {
|
|
4833
4974
|
this.stop(), this.setTimeoutRequest.request(() => {
|
|
4834
4975
|
this.collectStatistics(e, {
|
|
@@ -4857,10 +4998,10 @@ class vs {
|
|
|
4857
4998
|
collectStatistics = (e, {
|
|
4858
4999
|
onError: t
|
|
4859
5000
|
}) => {
|
|
4860
|
-
const s =
|
|
5001
|
+
const s = Re();
|
|
4861
5002
|
this.requestAllStatistics(e).then((i) => {
|
|
4862
|
-
this.events.trigger("collected",
|
|
4863
|
-
const a =
|
|
5003
|
+
this.events.trigger("collected", Ds(i));
|
|
5004
|
+
const a = Re() - s;
|
|
4864
5005
|
let o = $;
|
|
4865
5006
|
a > 48 ? o = $ * 4 : a > 32 ? o = $ * 3 : a > 16 && (o = $ * 2), this.start(e, {
|
|
4866
5007
|
onError: t,
|
|
@@ -4877,8 +5018,8 @@ class vs {
|
|
|
4877
5018
|
return this.requesterAllStatistics.request(t);
|
|
4878
5019
|
};
|
|
4879
5020
|
}
|
|
4880
|
-
const
|
|
4881
|
-
class
|
|
5021
|
+
const Fs = 500;
|
|
5022
|
+
class ks {
|
|
4882
5023
|
statsPeerConnection;
|
|
4883
5024
|
availableStats;
|
|
4884
5025
|
previousAvailableStats;
|
|
@@ -4888,7 +5029,7 @@ class Ms {
|
|
|
4888
5029
|
callManager: e,
|
|
4889
5030
|
apiManager: t
|
|
4890
5031
|
}) {
|
|
4891
|
-
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new
|
|
5032
|
+
this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Us(), this.subscribe();
|
|
4892
5033
|
}
|
|
4893
5034
|
get events() {
|
|
4894
5035
|
return this.statsPeerConnection.events;
|
|
@@ -4938,7 +5079,7 @@ class Ms {
|
|
|
4938
5079
|
return this.previousInboundRtp?.packetsReceived;
|
|
4939
5080
|
}
|
|
4940
5081
|
get isReceivingPackets() {
|
|
4941
|
-
const e = this.packetsReceived !== void 0 && this.packetsReceived >=
|
|
5082
|
+
const e = this.packetsReceived !== void 0 && this.packetsReceived >= Fs, t = this.packetsReceived !== this.previousPacketsReceived;
|
|
4942
5083
|
return e && t;
|
|
4943
5084
|
}
|
|
4944
5085
|
on(e, t) {
|
|
@@ -4978,33 +5119,33 @@ class Ms {
|
|
|
4978
5119
|
});
|
|
4979
5120
|
}
|
|
4980
5121
|
}
|
|
4981
|
-
const
|
|
5122
|
+
const Bs = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), $s = (n) => {
|
|
4982
5123
|
const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
|
|
4983
|
-
return
|
|
4984
|
-
},
|
|
5124
|
+
return Bs(s, i);
|
|
5125
|
+
}, Gs = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
|
|
4985
5126
|
const i = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), a = i === -1 ? Number.MAX_VALUE : i, o = r === -1 ? Number.MAX_VALUE : r;
|
|
4986
5127
|
return a - o;
|
|
4987
|
-
}),
|
|
5128
|
+
}), qs = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Vs = (n, {
|
|
4988
5129
|
preferredMimeTypesVideoCodecs: e,
|
|
4989
5130
|
excludeMimeTypesVideoCodecs: t
|
|
4990
5131
|
}) => {
|
|
4991
5132
|
try {
|
|
4992
5133
|
if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
|
|
4993
|
-
const s =
|
|
5134
|
+
const s = $s("video"), i = qs(s, t), r = Gs(i, e);
|
|
4994
5135
|
n.setCodecPreferences(r);
|
|
4995
5136
|
}
|
|
4996
5137
|
} catch (s) {
|
|
4997
5138
|
d("setCodecPreferences error", s);
|
|
4998
5139
|
}
|
|
4999
|
-
},
|
|
5000
|
-
class
|
|
5140
|
+
}, xs = (n) => [...n.keys()].map((e) => n.get(e)), Hs = (n, e) => xs(n).find((t) => t?.type === e), Ws = async (n) => n.getStats().then((e) => Hs(e, "codec")?.mimeType);
|
|
5141
|
+
class Qs {
|
|
5001
5142
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
5002
5143
|
async getCodecFromSender(e) {
|
|
5003
|
-
return await
|
|
5144
|
+
return await Ws(e) ?? "";
|
|
5004
5145
|
}
|
|
5005
5146
|
}
|
|
5006
|
-
class
|
|
5007
|
-
stackPromises =
|
|
5147
|
+
class Ys {
|
|
5148
|
+
stackPromises = fe({
|
|
5008
5149
|
noRunIsNotActual: !0
|
|
5009
5150
|
});
|
|
5010
5151
|
/**
|
|
@@ -5028,30 +5169,30 @@ class Fs {
|
|
|
5028
5169
|
});
|
|
5029
5170
|
}
|
|
5030
5171
|
}
|
|
5031
|
-
class
|
|
5172
|
+
class zs {
|
|
5032
5173
|
taskQueue;
|
|
5033
5174
|
onSetParameters;
|
|
5034
5175
|
constructor(e) {
|
|
5035
|
-
this.onSetParameters = e, this.taskQueue = new
|
|
5176
|
+
this.onSetParameters = e, this.taskQueue = new Ys();
|
|
5036
5177
|
}
|
|
5037
5178
|
async setEncodingsToSender(e, t) {
|
|
5038
|
-
return this.taskQueue.add(async () =>
|
|
5179
|
+
return this.taskQueue.add(async () => Le(e, t, this.onSetParameters));
|
|
5039
5180
|
}
|
|
5040
5181
|
stop() {
|
|
5041
5182
|
this.taskQueue.stop();
|
|
5042
5183
|
}
|
|
5043
5184
|
}
|
|
5044
|
-
const
|
|
5045
|
-
const t =
|
|
5046
|
-
return
|
|
5047
|
-
},
|
|
5185
|
+
const Xe = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Js = 1e6, y = (n) => n * Js, Ze = y(0.06), et = y(4), js = (n) => n <= 64 ? Ze : n <= 128 ? y(0.12) : n <= 256 ? y(0.25) : n <= 384 ? y(0.32) : n <= 426 ? y(0.38) : n <= 640 ? y(0.5) : n <= 848 ? y(0.7) : n <= 1280 ? y(1) : n <= 1920 ? y(2) : et, Ks = "av1", Xs = (n) => Xe(n, Ks), Zs = 0.6, le = (n, e) => Xs(e) ? n * Zs : n, ei = (n) => le(Ze, n), ti = (n) => le(et, n), Ie = (n, e) => {
|
|
5186
|
+
const t = js(n);
|
|
5187
|
+
return le(t, e);
|
|
5188
|
+
}, se = 1, ni = ({
|
|
5048
5189
|
videoTrack: n,
|
|
5049
5190
|
targetSize: e
|
|
5050
5191
|
}) => {
|
|
5051
|
-
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ?
|
|
5052
|
-
return Math.max(r, a,
|
|
5192
|
+
const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? se : s / e.width, a = i === void 0 ? se : i / e.height;
|
|
5193
|
+
return Math.max(r, a, se);
|
|
5053
5194
|
};
|
|
5054
|
-
class
|
|
5195
|
+
class si {
|
|
5055
5196
|
ignoreForCodec;
|
|
5056
5197
|
senderFinder;
|
|
5057
5198
|
codecProvider;
|
|
@@ -5084,7 +5225,7 @@ class Qs {
|
|
|
5084
5225
|
if (!i?.track)
|
|
5085
5226
|
return { ...this.resultNoChanged, sender: i };
|
|
5086
5227
|
const r = await this.codecProvider.getCodecFromSender(i);
|
|
5087
|
-
if (
|
|
5228
|
+
if (Xe(r, this.ignoreForCodec))
|
|
5088
5229
|
return { ...this.resultNoChanged, sender: i };
|
|
5089
5230
|
const { mainCam: a, resolutionMainCam: o } = t ?? {};
|
|
5090
5231
|
return this.processSender(
|
|
@@ -5126,7 +5267,7 @@ class Qs {
|
|
|
5126
5267
|
async downgradeResolutionSender(e) {
|
|
5127
5268
|
const { sender: t, codec: s } = e, i = {
|
|
5128
5269
|
scaleResolutionDownBy: 200,
|
|
5129
|
-
maxBitrate:
|
|
5270
|
+
maxBitrate: ei(s)
|
|
5130
5271
|
};
|
|
5131
5272
|
return this.parametersSetter.setEncodingsToSender(t, i);
|
|
5132
5273
|
}
|
|
@@ -5136,7 +5277,7 @@ class Qs {
|
|
|
5136
5277
|
* @returns Promise с результатом
|
|
5137
5278
|
*/
|
|
5138
5279
|
async setBitrateByTrackResolution(e) {
|
|
5139
|
-
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ?
|
|
5280
|
+
const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? ti(i) : Ie(a, i);
|
|
5140
5281
|
return this.parametersSetter.setEncodingsToSender(t, {
|
|
5141
5282
|
scaleResolutionDownBy: 1,
|
|
5142
5283
|
maxBitrate: o
|
|
@@ -5152,24 +5293,24 @@ class Qs {
|
|
|
5152
5293
|
const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
|
|
5153
5294
|
width: Number(s),
|
|
5154
5295
|
height: Number(i)
|
|
5155
|
-
}, l =
|
|
5296
|
+
}, l = ni({
|
|
5156
5297
|
videoTrack: a,
|
|
5157
5298
|
targetSize: c
|
|
5158
|
-
}), T =
|
|
5299
|
+
}), T = Ie(c.width, o), g = {
|
|
5159
5300
|
scaleResolutionDownBy: l,
|
|
5160
5301
|
maxBitrate: T
|
|
5161
5302
|
};
|
|
5162
5303
|
return this.parametersSetter.setEncodingsToSender(r, g);
|
|
5163
5304
|
}
|
|
5164
5305
|
}
|
|
5165
|
-
const
|
|
5166
|
-
class
|
|
5306
|
+
const ii = (n) => n.find((e) => e.track?.kind === "video");
|
|
5307
|
+
class ri {
|
|
5167
5308
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
5168
5309
|
findVideoSender(e) {
|
|
5169
|
-
return
|
|
5310
|
+
return ii(e);
|
|
5170
5311
|
}
|
|
5171
5312
|
}
|
|
5172
|
-
class
|
|
5313
|
+
class ai {
|
|
5173
5314
|
currentSender;
|
|
5174
5315
|
originalReplaceTrack;
|
|
5175
5316
|
lastWidth;
|
|
@@ -5182,7 +5323,7 @@ class Js {
|
|
|
5182
5323
|
pollIntervalMs: e = 1e3,
|
|
5183
5324
|
maxPollIntervalMs: t
|
|
5184
5325
|
}) {
|
|
5185
|
-
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new
|
|
5326
|
+
this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ve();
|
|
5186
5327
|
}
|
|
5187
5328
|
/**
|
|
5188
5329
|
* Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
|
|
@@ -5233,7 +5374,7 @@ class Js {
|
|
|
5233
5374
|
this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
|
|
5234
5375
|
}
|
|
5235
5376
|
}
|
|
5236
|
-
class
|
|
5377
|
+
class oi {
|
|
5237
5378
|
apiManager;
|
|
5238
5379
|
currentHandler;
|
|
5239
5380
|
constructor(e) {
|
|
@@ -5253,7 +5394,7 @@ class js {
|
|
|
5253
5394
|
this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
|
|
5254
5395
|
}
|
|
5255
5396
|
}
|
|
5256
|
-
class
|
|
5397
|
+
class ci {
|
|
5257
5398
|
eventHandler;
|
|
5258
5399
|
senderBalancer;
|
|
5259
5400
|
parametersSetterWithQueue;
|
|
@@ -5265,16 +5406,16 @@ class Xs {
|
|
|
5265
5406
|
onSetParameters: i,
|
|
5266
5407
|
pollIntervalMs: r
|
|
5267
5408
|
} = {}) {
|
|
5268
|
-
this.getConnection = t, this.eventHandler = new
|
|
5409
|
+
this.getConnection = t, this.eventHandler = new oi(e), this.parametersSetterWithQueue = new zs(i), this.senderBalancer = new si(
|
|
5269
5410
|
{
|
|
5270
|
-
senderFinder: new
|
|
5271
|
-
codecProvider: new
|
|
5411
|
+
senderFinder: new ri(),
|
|
5412
|
+
codecProvider: new Qs(),
|
|
5272
5413
|
parametersSetter: this.parametersSetterWithQueue
|
|
5273
5414
|
},
|
|
5274
5415
|
{
|
|
5275
5416
|
ignoreForCodec: s
|
|
5276
5417
|
}
|
|
5277
|
-
), this.trackMonitor = new
|
|
5418
|
+
), this.trackMonitor = new ai({ pollIntervalMs: r });
|
|
5278
5419
|
}
|
|
5279
5420
|
/**
|
|
5280
5421
|
* Подписывается на события управления главной камерой
|
|
@@ -5319,13 +5460,13 @@ class Xs {
|
|
|
5319
5460
|
});
|
|
5320
5461
|
};
|
|
5321
5462
|
}
|
|
5322
|
-
const
|
|
5463
|
+
const tt = [
|
|
5323
5464
|
"balancing-scheduled",
|
|
5324
5465
|
"balancing-started",
|
|
5325
5466
|
"balancing-stopped",
|
|
5326
5467
|
"parameters-updated"
|
|
5327
|
-
],
|
|
5328
|
-
class
|
|
5468
|
+
], di = () => new M(tt);
|
|
5469
|
+
class hi {
|
|
5329
5470
|
isBalancingActive = !1;
|
|
5330
5471
|
events;
|
|
5331
5472
|
callManager;
|
|
@@ -5333,7 +5474,7 @@ class Zs {
|
|
|
5333
5474
|
videoSendingBalancer;
|
|
5334
5475
|
startBalancingTimer;
|
|
5335
5476
|
constructor(e, t, s = {}) {
|
|
5336
|
-
this.events =
|
|
5477
|
+
this.events = di(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new ci(
|
|
5337
5478
|
t,
|
|
5338
5479
|
() => e.connection,
|
|
5339
5480
|
{
|
|
@@ -5403,13 +5544,13 @@ class Zs {
|
|
|
5403
5544
|
this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
|
|
5404
5545
|
}
|
|
5405
5546
|
}
|
|
5406
|
-
const
|
|
5407
|
-
class
|
|
5547
|
+
const nt = "no-inbound-frames", st = [nt], li = () => new M(st);
|
|
5548
|
+
class ui {
|
|
5408
5549
|
events;
|
|
5409
5550
|
statsManager;
|
|
5410
5551
|
callManager;
|
|
5411
5552
|
constructor(e, t) {
|
|
5412
|
-
this.statsManager = e, this.callManager = t, this.events =
|
|
5553
|
+
this.statsManager = e, this.callManager = t, this.events = li(), this.subscribe();
|
|
5413
5554
|
}
|
|
5414
5555
|
get mainVideoTrack() {
|
|
5415
5556
|
return this.callManager.getMainRemoteStream()?.getVideoTracks()[0];
|
|
@@ -5422,20 +5563,20 @@ class ti {
|
|
|
5422
5563
|
return this.events.on(e, t);
|
|
5423
5564
|
}
|
|
5424
5565
|
handleStatsCollected = () => {
|
|
5425
|
-
this.hasNoIncomingFrames() && this.events.trigger(
|
|
5566
|
+
this.hasNoIncomingFrames() && this.events.trigger(nt, {});
|
|
5426
5567
|
};
|
|
5427
5568
|
hasNoIncomingFrames = () => this.statsManager.isInvalidInboundFrames && this.isMutedMainVideoTrack;
|
|
5428
5569
|
subscribe() {
|
|
5429
5570
|
this.statsManager.on("collected", this.handleStatsCollected);
|
|
5430
5571
|
}
|
|
5431
5572
|
}
|
|
5432
|
-
const
|
|
5433
|
-
class
|
|
5573
|
+
const gi = 3e3;
|
|
5574
|
+
class Ti {
|
|
5434
5575
|
renegotiateRequester;
|
|
5435
5576
|
renegotiateThrottled;
|
|
5436
5577
|
callManager;
|
|
5437
|
-
constructor(e, t =
|
|
5438
|
-
this.callManager = e, this.renegotiateRequester = new X(e.renegotiate.bind(e)), this.renegotiateThrottled =
|
|
5578
|
+
constructor(e, t = gi) {
|
|
5579
|
+
this.callManager = e, this.renegotiateRequester = new X(e.renegotiate.bind(e)), this.renegotiateThrottled = Et.throttle(
|
|
5439
5580
|
this.requestRenegotiate.bind(this),
|
|
5440
5581
|
t
|
|
5441
5582
|
), this.subscribe();
|
|
@@ -5463,24 +5604,24 @@ class si {
|
|
|
5463
5604
|
d("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
|
|
5464
5605
|
}
|
|
5465
5606
|
}
|
|
5466
|
-
const
|
|
5607
|
+
const Ei = 1e6, Si = Qe.map((n) => `auto-connect:${n}`), mi = Ve.map((n) => `connection:${n}`), pi = ke.map((n) => `call:${n}`), Ci = be.map((n) => `api:${n}`), Ri = Ye.map((n) => `incoming-call:${n}`), Ni = Ge.map((n) => `presentation:${n}`), Ai = je.map((n) => `stats:${n}`), Ii = tt.map((n) => `video-balancer:${n}`), vi = st.map((n) => `main-stream-health:${n}`), fi = Je.map((n) => `session:${n}`), Mi = [
|
|
5467
5608
|
"disconnected-from-out-of-call",
|
|
5468
5609
|
"connected-with-configuration-from-out-of-call",
|
|
5469
5610
|
"stopped-presentation-by-server-command"
|
|
5470
|
-
],
|
|
5471
|
-
...
|
|
5472
|
-
...
|
|
5473
|
-
...
|
|
5474
|
-
...
|
|
5475
|
-
...
|
|
5476
|
-
...
|
|
5477
|
-
...
|
|
5478
|
-
...
|
|
5479
|
-
...
|
|
5480
|
-
...
|
|
5481
|
-
...
|
|
5482
|
-
],
|
|
5483
|
-
class
|
|
5611
|
+
], _i = [
|
|
5612
|
+
...Si,
|
|
5613
|
+
...mi,
|
|
5614
|
+
...pi,
|
|
5615
|
+
...Ci,
|
|
5616
|
+
...Ri,
|
|
5617
|
+
...Ni,
|
|
5618
|
+
...Ai,
|
|
5619
|
+
...Ii,
|
|
5620
|
+
...vi,
|
|
5621
|
+
...fi,
|
|
5622
|
+
...Mi
|
|
5623
|
+
], bi = () => new M(_i);
|
|
5624
|
+
class xi {
|
|
5484
5625
|
events;
|
|
5485
5626
|
connectionManager;
|
|
5486
5627
|
connectionQueueManager;
|
|
@@ -5494,6 +5635,7 @@ class Di {
|
|
|
5494
5635
|
videoSendingBalancerManager;
|
|
5495
5636
|
sessionManager;
|
|
5496
5637
|
mainStreamHealthMonitor;
|
|
5638
|
+
peerToPeerManager;
|
|
5497
5639
|
mainStreamRecovery;
|
|
5498
5640
|
preferredMimeTypesVideoCodecs;
|
|
5499
5641
|
excludeMimeTypesVideoCodecs;
|
|
@@ -5503,26 +5645,26 @@ class Di {
|
|
|
5503
5645
|
videoBalancerOptions: i,
|
|
5504
5646
|
autoConnectorOptions: r
|
|
5505
5647
|
} = {}) {
|
|
5506
|
-
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events =
|
|
5648
|
+
this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = bi(), this.apiManager = new ft(), this.connectionManager = new Jn({ JsSIP: e }), this.connectionQueueManager = new jn({
|
|
5507
5649
|
connectionManager: this.connectionManager
|
|
5508
|
-
}), this.contentedStreamManager = new
|
|
5650
|
+
}), this.contentedStreamManager = new Es(), this.callManager = new vn(this.contentedStreamManager), this.incomingCallManager = new As(this.connectionManager), this.presentationManager = new Pn({
|
|
5509
5651
|
callManager: this.callManager,
|
|
5510
|
-
maxBitrate:
|
|
5511
|
-
}), this.statsManager = new
|
|
5652
|
+
maxBitrate: Ei
|
|
5653
|
+
}), this.statsManager = new ks({
|
|
5512
5654
|
callManager: this.callManager,
|
|
5513
5655
|
apiManager: this.apiManager
|
|
5514
|
-
}), this.autoConnectorManager = new
|
|
5656
|
+
}), this.autoConnectorManager = new hs(
|
|
5515
5657
|
{
|
|
5516
5658
|
connectionQueueManager: this.connectionQueueManager,
|
|
5517
5659
|
connectionManager: this.connectionManager,
|
|
5518
5660
|
callManager: this.callManager
|
|
5519
5661
|
},
|
|
5520
5662
|
r
|
|
5521
|
-
), this.videoSendingBalancerManager = new
|
|
5663
|
+
), this.videoSendingBalancerManager = new hi(
|
|
5522
5664
|
this.callManager,
|
|
5523
5665
|
this.apiManager,
|
|
5524
5666
|
i
|
|
5525
|
-
), this.mainStreamHealthMonitor = new
|
|
5667
|
+
), this.mainStreamHealthMonitor = new ui(this.statsManager, this.callManager), this.mainStreamRecovery = new Ti(this.callManager), this.sessionManager = new Ms({
|
|
5526
5668
|
connectionManager: this.connectionManager,
|
|
5527
5669
|
callManager: this.callManager,
|
|
5528
5670
|
incomingCallManager: this.incomingCallManager,
|
|
@@ -5530,6 +5672,10 @@ class Di {
|
|
|
5530
5672
|
}), this.callManager.subscribeToApiEvents(this.apiManager), this.contentedStreamManager.subscribeToApiEvents(this.apiManager), this.apiManager.subscribe({
|
|
5531
5673
|
connectionManager: this.connectionManager,
|
|
5532
5674
|
callManager: this.callManager
|
|
5675
|
+
}), this.peerToPeerManager = new Is(), this.peerToPeerManager.subscribe({
|
|
5676
|
+
connectionManager: this.connectionManager,
|
|
5677
|
+
callManager: this.callManager,
|
|
5678
|
+
apiManager: this.apiManager
|
|
5533
5679
|
}), this.subscribe();
|
|
5534
5680
|
}
|
|
5535
5681
|
get requestedConnection() {
|
|
@@ -5568,6 +5714,9 @@ class Di {
|
|
|
5568
5714
|
get isAvailableIncomingCall() {
|
|
5569
5715
|
return this.incomingCallManager.isAvailableIncomingCall;
|
|
5570
5716
|
}
|
|
5717
|
+
get isDirectP2PRoom() {
|
|
5718
|
+
return this.callManager.isDirectP2PRoom;
|
|
5719
|
+
}
|
|
5571
5720
|
on(e, t) {
|
|
5572
5721
|
return this.events.on(e, t);
|
|
5573
5722
|
}
|
|
@@ -5626,35 +5775,34 @@ class Di {
|
|
|
5626
5775
|
setRecvQuality = async (e) => this.callManager.setRecvQuality(e);
|
|
5627
5776
|
replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
|
|
5628
5777
|
async startPresentation(e, t = {}) {
|
|
5629
|
-
const {
|
|
5778
|
+
const { callLimit: s, onAddedTransceiver: i, ...r } = t;
|
|
5630
5779
|
return this.presentationManager.startPresentation(
|
|
5631
5780
|
async () => {
|
|
5632
|
-
await (
|
|
5781
|
+
await (this.isDirectP2PRoom ? this.apiManager.sendAvailableContentedStream() : this.apiManager.askPermissionToStartPresentation());
|
|
5633
5782
|
},
|
|
5634
5783
|
e,
|
|
5635
5784
|
{
|
|
5636
|
-
...
|
|
5637
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
5785
|
+
...r,
|
|
5786
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(i)
|
|
5638
5787
|
},
|
|
5639
|
-
|
|
5788
|
+
s === void 0 ? void 0 : { callLimit: s }
|
|
5640
5789
|
);
|
|
5641
5790
|
}
|
|
5642
|
-
async stopPresentation(
|
|
5643
|
-
const { isP2P: t } = e;
|
|
5791
|
+
async stopPresentation() {
|
|
5644
5792
|
return this.presentationManager.stopPresentation(async () => {
|
|
5645
|
-
await (
|
|
5793
|
+
await (this.isDirectP2PRoom ? this.apiManager.sendNotAvailableContentedStream() : this.apiManager.sendStoppedPresentation());
|
|
5646
5794
|
});
|
|
5647
5795
|
}
|
|
5648
5796
|
async updatePresentation(e, t = {}) {
|
|
5649
|
-
const {
|
|
5797
|
+
const { onAddedTransceiver: s, ...i } = t;
|
|
5650
5798
|
return this.presentationManager.updatePresentation(
|
|
5651
5799
|
async () => {
|
|
5652
|
-
await (
|
|
5800
|
+
await (this.isDirectP2PRoom ? this.apiManager.sendAvailableContentedStream() : this.apiManager.askPermissionToStartPresentation());
|
|
5653
5801
|
},
|
|
5654
5802
|
e,
|
|
5655
5803
|
{
|
|
5656
|
-
...
|
|
5657
|
-
onAddedTransceiver: this.resolveHandleAddTransceiver(
|
|
5804
|
+
...i,
|
|
5805
|
+
onAddedTransceiver: this.resolveHandleAddTransceiver(s)
|
|
5658
5806
|
}
|
|
5659
5807
|
);
|
|
5660
5808
|
}
|
|
@@ -5708,13 +5856,20 @@ class Di {
|
|
|
5708
5856
|
this.callManager.setCallRoleSpectator({ audioId: e, sendOffer: this.sendOffer }), this.mayBeStopPresentationAndNotify();
|
|
5709
5857
|
}), this.apiManager.on("presentation:must-stop", () => {
|
|
5710
5858
|
this.mayBeStopPresentationAndNotify();
|
|
5859
|
+
}), this.apiManager.on("failed-send-room-direct-p2p", ({ error: e }) => {
|
|
5860
|
+
const t = new rt();
|
|
5861
|
+
t.body = e instanceof Error ? e.message : String(e);
|
|
5862
|
+
const s = at.causes.INTERNAL_ERROR;
|
|
5863
|
+
this.callManager.failed(t, s).catch((i) => {
|
|
5864
|
+
d("Failed to end call after failed:", i);
|
|
5865
|
+
});
|
|
5711
5866
|
});
|
|
5712
5867
|
}
|
|
5713
5868
|
sendOffer = async (e, t) => {
|
|
5714
5869
|
const i = this.connectionManager.getConnectionConfiguration()?.sipServerUrl;
|
|
5715
5870
|
if (i === void 0)
|
|
5716
5871
|
throw new Error("No sipServerUrl for sendOffer");
|
|
5717
|
-
return
|
|
5872
|
+
return Pt({
|
|
5718
5873
|
serverUrl: i,
|
|
5719
5874
|
offer: t,
|
|
5720
5875
|
token: e.token,
|
|
@@ -5724,7 +5879,7 @@ class Di {
|
|
|
5724
5879
|
});
|
|
5725
5880
|
};
|
|
5726
5881
|
setCodecPreferences(e) {
|
|
5727
|
-
|
|
5882
|
+
Vs(e, {
|
|
5728
5883
|
preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
|
|
5729
5884
|
excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
|
|
5730
5885
|
});
|
|
@@ -5749,27 +5904,28 @@ class Di {
|
|
|
5749
5904
|
};
|
|
5750
5905
|
}
|
|
5751
5906
|
export {
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5907
|
+
xt as D,
|
|
5908
|
+
Be as E,
|
|
5909
|
+
Xt as O,
|
|
5910
|
+
_t as P,
|
|
5911
|
+
xi as S,
|
|
5912
|
+
Pe as a,
|
|
5913
|
+
Le as b,
|
|
5914
|
+
ie as c,
|
|
5915
|
+
re as d,
|
|
5916
|
+
$n as e,
|
|
5917
|
+
ms as f,
|
|
5918
|
+
Qn as g,
|
|
5919
|
+
Oe as h,
|
|
5920
|
+
_e as i,
|
|
5921
|
+
Mn as j,
|
|
5922
|
+
C as k,
|
|
5768
5923
|
d as l,
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5924
|
+
Us as m,
|
|
5925
|
+
qi as n,
|
|
5926
|
+
Gi as o,
|
|
5927
|
+
Y as p,
|
|
5928
|
+
Ws as q,
|
|
5929
|
+
Vi as r,
|
|
5930
|
+
Pt as s
|
|
5775
5931
|
};
|